Skip to content

Commit f5dc0d0

Browse files
committed
FbFunctionPrivileges
1 parent 5cdbf97 commit f5dc0d0

4 files changed

Lines changed: 2103 additions & 1998 deletions

File tree

Provider/src/FirebirdSql.Data.FirebirdClient.Tests/FbSchemaTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ public async Task ForeignKeyColumns()
9696
}
9797
}
9898

99+
[Test]
100+
public async Task FunctionPrivileges()
101+
{
102+
await Connection.GetSchemaAsync("FunctionPrivileges");
103+
}
104+
99105
[Test]
100106
public async Task Functions()
101107
{
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* The contents of this file are subject to the Initial
3+
* Developer's Public License Version 1.0 (the "License");
4+
* you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
* https://github.com/FirebirdSQL/NETProvider/blob/master/license.txt.
7+
*
8+
* Software distributed under the License is distributed on
9+
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
10+
* express or implied. See the License for the specific
11+
* language governing rights and limitations under the License.
12+
*
13+
* All Rights Reserved.
14+
*/
15+
16+
//$Authors = Jiri Cincura (jiri@cincura.net)
17+
18+
using System;
19+
using System.Data;
20+
using System.Globalization;
21+
using System.Text;
22+
23+
namespace FirebirdSql.Data.Schema
24+
{
25+
internal class FbFunctionPrivileges : FbSchema
26+
{
27+
#region Protected Methods
28+
29+
protected override StringBuilder GetCommandText(string[] restrictions)
30+
{
31+
var sql = new StringBuilder();
32+
var where = new StringBuilder();
33+
34+
sql.Append(
35+
@"SELECT
36+
null AS FUNCTION_CATALOG,
37+
null AS FUNCTION_SCHEMA,
38+
rdb$relation_name AS FUNCTION_NAME,
39+
rdb$user AS GRANTEE,
40+
rdb$grantor AS GRANTOR,
41+
rdb$privilege AS PRIVILEGE,
42+
rdb$grant_option AS WITH_GRANT
43+
FROM rdb$user_privileges");
44+
45+
where.Append("rdb$object_type = 15");
46+
47+
if (restrictions != null)
48+
{
49+
var index = 0;
50+
51+
/* FUNCTION_CATALOG */
52+
if (restrictions.Length >= 1 && restrictions[0] != null)
53+
{
54+
}
55+
56+
/* FUNCTION_SCHEMA */
57+
if (restrictions.Length >= 2 && restrictions[1] != null)
58+
{
59+
}
60+
61+
/* FUNCTION_NAME */
62+
if (restrictions.Length >= 3 && restrictions[2] != null)
63+
{
64+
where.AppendFormat(" AND rdb$relation_name = @p{0}", index++);
65+
}
66+
67+
/* GRANTOR */
68+
if (restrictions.Length >= 5 && restrictions[4] != null)
69+
{
70+
where.AppendFormat(" AND rdb$grantor = @p{0}", index++);
71+
}
72+
73+
/* GRANTEE */
74+
if (restrictions.Length >= 4 && restrictions[3] != null)
75+
{
76+
where.AppendFormat(" AND rdb$user = @p{0}", index++);
77+
}
78+
}
79+
80+
if (where.Length > 0)
81+
{
82+
sql.AppendFormat(" WHERE {0} ", where.ToString());
83+
}
84+
85+
sql.Append(" ORDER BY FUNCTION_NAME");
86+
87+
return sql;
88+
}
89+
90+
#endregion
91+
}
92+
}

0 commit comments

Comments
 (0)