2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Firebird / DbSchema / FbProcedurePrivileges.cs
1 /*
2  *  Firebird ADO.NET Data provider for .NET and Mono 
3  * 
4  *     The contents of this file are subject to the Initial 
5  *     Developer's Public License Version 1.0 (the "License"); 
6  *     you may not use this file except in compliance with the 
7  *     License. You may obtain a copy of the License at 
8  *     http://www.firebirdsql.org/index.php?op=doc&id=idpl
9  *
10  *     Software distributed under the License is distributed on 
11  *     an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either 
12  *     express or implied.  See the License for the specific 
13  *     language governing rights and limitations under the License.
14  * 
15  *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
16  *  All Rights Reserved.
17  */
18
19 using System;
20 using System.Data;
21 using System.Globalization;
22 using System.Text;
23
24 namespace FirebirdSql.Data.Firebird.DbSchema
25 {
26         internal class FbProcedurePrivilegesSchema : FbDbSchema
27         {
28                 #region Constructors
29
30                 public FbProcedurePrivilegesSchema() : base("ProcedurePrivileges")
31                 {
32                 }
33
34                 #endregion
35
36                 #region Protected Methods
37
38                 protected override StringBuilder GetCommandText(object[] restrictions)
39                 {
40                         StringBuilder sql       = new StringBuilder();
41                         StringBuilder where = new StringBuilder();
42
43                         sql.Append(
44                                 @"SELECT " +
45                     "null AS PROCEDURE_CATALOG, " +
46                     "null AS PROCEDURE_SCHEMA, " +
47                     "rdb$relation_name AS PROCEDURE_NAME, " +
48                     "rdb$user AS GRANTEE, " +
49                                         "rdb$grantor AS GRANTOR, " +
50                                         "rdb$privilege AS PRIVILEGE, " +
51                                         "rdb$grant_option AS WITH_GRANT " +
52                                 "FROM " +
53                                         "rdb$user_privileges");
54
55                         where.Append("rdb$object_type = 5");
56
57                         if (restrictions != null)
58                         {
59                                 int index = 0;
60
61                 /* PROCEDURE_CATALOG */
62                 if (restrictions.Length >= 1 && restrictions[0] != null)
63                 {
64                 }
65
66                 /* PROCEDURE_SCHEMA */
67                 if (restrictions.Length >= 2 && restrictions[1] != null)
68                 {
69                 }
70
71                 /* PROCEDURE_NAME */
72                 if (restrictions.Length >= 3 && restrictions[2] != null)
73                                 {
74                     where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$relation_name = @p{0}", index++);
75                 }
76
77                 /* GRANTOR */
78                 if (restrictions.Length >= 5 && restrictions[4] != null)
79                 {
80                     where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$grantor = @p{0}", index++);
81                 }
82
83                 /* GRANTEE */
84                                 if (restrictions.Length >= 4 && restrictions[3] != null)
85                                 {
86                     where.AppendFormat(CultureInfo.CurrentUICulture, " AND rdb$user = @p{0}", index++);
87                 }
88                         }
89
90                         if (where.Length > 0)
91                         {
92                 sql.AppendFormat(CultureInfo.CurrentUICulture, " WHERE {0} ", where.ToString());
93             }
94
95                         sql.Append(" ORDER BY rdb$relation_name");
96
97                         return sql;
98                 }
99
100                 #endregion
101         }
102 }