19 using System.Globalization;
25 namespace Deveel.Data.Client {
28 this.connection = connection;
34 if (restrictions == null)
35 throw new ArgumentException();
37 if (restrictions.Length > 1)
38 throw new ArgumentException();
40 string schema = restrictions[0];
46 dataTable.Columns.Add(
"TABLE_SCHEMA");
47 dataTable.Columns.Add(
"TABLE_CATALOG");
49 var command = connection.CreateCommand(
" SELECT * \n" +
50 " FROM \"INFORMATION_SCHEMA.TABLES\" \n" +
51 " WHERE \"TABLE_SCHEMA\" LIKE ? \n" +
52 " ORDER BY \"TABLE_SCHEMA\" \n");
54 command.Parameters.Add(schema);
59 row[
"TABLE_SCHEMA"] = reader.
GetString(0);
60 row[
"TABLE_CATALOG"] = reader.
GetString(1);
61 dataTable.Rows.Add(row);
68 if (restrictions == null)
69 throw new ArgumentNullException(
"restrictions");
70 if (restrictions.Length < 3)
71 throw new ArgumentException();
74 string catalog = restrictions[0];
75 string schema = restrictions[1];
76 string table = restrictions[2];
78 string[] types =
new string[restrictions.Length - 3];
79 Array.Copy(restrictions, 3, types, 0, types.Length);
82 dataTable.Columns.Add(
"TABLE_CATALOG");
83 dataTable.Columns.Add(
"TABLE_SCHEMA");
84 dataTable.Columns.Add(
"TABLE_NAME");
85 dataTable.Columns.Add(
"TABLE_TYPE");
86 dataTable.Columns.Add(
"REMARKS");
87 dataTable.Columns.Add(
"TYPE_CATALOG");
88 dataTable.Columns.Add(
"TYPE_SCHEMA");
89 dataTable.Columns.Add(
"TYPE_NAME");
90 dataTable.Columns.Add(
"SELF_REFERENCING_COL_NAME");
91 dataTable.Columns.Add(
"REF_GENERATION");
101 if (types.Length > 0) {
102 StringBuilder buf =
new StringBuilder();
103 buf.Append(
" AND \"TABLE_TYPE\" IN ( ");
104 for (
int i = 0; i < types.Length - 1; ++i) {
107 buf.Append(
"? ) \n");
108 typeSize = types.Length;
109 typePart = buf.ToString();
115 " FROM \"INFORMATION_SCHEMA.TABLES\" \n" +
116 " WHERE \"TABLE_SCHEMA\" LIKE ? \n" +
117 " AND \"TABLE_NAME\" LIKE ? \n" +
119 " ORDER BY \"TABLE_TYPE\", \"TABLE_SCHEMA\", \"TABLE_NAME\" \n");
123 for (
int i = 0; i < typeSize; ++i)
130 while (reader.
Read()) {
132 row[
"TABLE_CATALOG"] = reader.
GetString(0);
133 row[
"TABLE_SCHEMA"] = reader.
GetString(1);
139 dataTable.Rows.Add(row);
147 if (restrictions == null)
148 throw new ArgumentNullException(
"restrictions");
149 if (restrictions.Length < 4)
150 throw new ArgumentException(
"COLUMNS collection requires at least 4 arguments.");
152 string catalog = restrictions[0];
153 string schema = restrictions[1];
154 string table = restrictions[2];
155 string column = restrictions[3];
165 dataTable.Columns.Add(
"TABLE_CATALOG");
166 dataTable.Columns.Add(
"TABLE_SCHEMA");
167 dataTable.Columns.Add(
"TABLE_NAME");
168 dataTable.Columns.Add(
"COLUMN_NAME");
169 dataTable.Columns.Add(
"DATA_TYPE", typeof(
int));
170 dataTable.Columns.Add(
"TYPE_NAME");
171 dataTable.Columns.Add(
"COLUMN_SIZE", typeof(
int));
172 dataTable.Columns.Add(
"BUFFER_LENGTH", typeof(
int));
173 dataTable.Columns.Add(
"DECIMAL_DIGITS", typeof(
int));
174 dataTable.Columns.Add(
"NUM_PREC_RADIX", typeof(
int));
175 dataTable.Columns.Add(
"NULLABLE", typeof(
bool));
176 dataTable.Columns.Add(
"REMARKS");
177 dataTable.Columns.Add(
"COLUMN_DEFAULT");
178 dataTable.Columns.Add(
"SQL_DATA_TYPE");
179 dataTable.Columns.Add(
"SQL_DATETIME_SUB");
180 dataTable.Columns.Add(
"CHAR_OCTET_LENGTH", typeof(
int));
181 dataTable.Columns.Add(
"ORDINAL_POSITION", typeof(
int));
182 dataTable.Columns.Add(
"IS_NULLABLE", typeof (
bool));
185 " FROM INFORMATION_SCHEMA.COLUMNS \n" +
186 " WHERE \"TABLE_SCHEMA\" LIKE ? \n" +
187 " AND \"TABLE_NAME\" LIKE ? \n" +
188 " AND \"COLUMN_NAME\" LIKE ? \n" +
189 "ORDER BY \"TABLE_SCHEMA\", \"TABLE_NAME\", \"ORDINAL_POSITION\"");
196 while (reader.
Read()) {
198 row[
"TABLE_CATALOG"] = reader.
GetString(0);
199 row[
"TABLE_SCHEMA"] = reader.
GetString(1);
201 row[
"COLUMN_NAME"] = reader.
GetString(3);
202 row[
"DATA_TYPE"] = reader.
GetInt32(4);
204 row[
"COLUMN_SIZE"] = reader.
GetInt32(6);
205 row[
"BUFFER_LENGTH"] = reader.
GetInt32(7);
206 row[
"DECIMAL_DIGITS"] = reader.
GetInt32(8);
207 row[
"NUM_PREC_RADIX"] = reader.
GetInt32(9);
210 row[
"COLUMN_DEFAULT"] = reader.
GetString(12);
211 row[
"SQL_DATA_TYPE"] = reader.
GetString(13);
212 row[
"SQL_DATETIME_SUB"] = reader.
GetString(14);
213 row[
"CHAR_OCTET_LENGTH"] = reader.
GetInt32(15);
214 row[
"ORDINAL_POSITION"] = reader.
GetInt32(16);
215 row[
"IS_NULLABLE"] = reader.
GetString(17) ==
"YES";
216 dataTable.Rows.Add(row);
224 if (restrictions == null)
225 throw new ArgumentNullException(
"restrictions");
226 if (restrictions.Length < 3)
227 throw new ArgumentException();
229 string catalog = restrictions[0];
230 string schema = restrictions[1];
231 string table = restrictions[2];
232 string column = restrictions[3];
235 throw new ArgumentException(
"The table name must be specified.");
242 dataTable.Columns.Add(
"TABLE_CATALOG");
243 dataTable.Columns.Add(
"TABLE_SCHEMA");
244 dataTable.Columns.Add(
"TABLE_NAME");
245 dataTable.Columns.Add(
"COLUMN_NAME");
246 dataTable.Columns.Add(
"GRANTOR");
247 dataTable.Columns.Add(
"GRANTEE");
248 dataTable.Columns.Add(
"PRIVILEGE");
249 dataTable.Columns.Add(
"IS_GRANTABLE", typeof(
bool));
251 DeveelDbCommand command = connection.CreateCommand(
" SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES \n" +
252 " WHERE (? IS NULL OR \"TABLE_SCHEMA\" = ? ) \n" +
253 " AND (? IS NOT NULL AND \"TABLE_NAME\" = ? ) \n" +
254 " AND \"COLUMN_NAME\" LIKE ? \n" +
255 " ORDER BY \"COLUMN_NAME\", \"PRIVILEGE\" ");
265 while (reader.
Read()) {
267 row[
"TABLE_CATALOG"] = reader.
GetString(0);
268 row[
"TABLE_SCHEMA"] = reader.
GetString(1);
270 row[
"COLUMN_NAME"] = reader.
GetString(3);
274 row[
"IS_GRANTABLE"] = reader.
GetString(7) ==
"YES";
275 dataTable.Rows.Add(row);
283 if (restrictions == null)
284 throw new ArgumentNullException(
"restrictions");
285 if (restrictions.Length < 3)
286 throw new ArgumentException();
288 string catalog = restrictions[0];
289 string schema = restrictions[1];
290 string table = restrictions[2];
298 dataTable.Columns.Add(
"TABLE_CATALOG");
299 dataTable.Columns.Add(
"TABLE_SCHEMA");
300 dataTable.Columns.Add(
"TABLE_NAME");
301 dataTable.Columns.Add(
"PRIVILEGE");
302 dataTable.Columns.Add(
"GRANTOR");
303 dataTable.Columns.Add(
"GRANTEE");
304 dataTable.Columns.Add(
"IS_GRANTABLE", typeof(
bool));
306 DeveelDbCommand command = connection.CreateCommand(
" SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES \n" +
307 " WHERE \"TABLE_SCHEMA\" LIKE ? \n" +
308 " AND \"TABLE_NAME\" LIKE ? \n" +
309 " ORDER BY \"TABLE_SCHEMA\", \"TABLE_NAME\", \"PRIVILEGE\" ");
316 while (reader.
Read()) {
318 row[
"TABLE_CATALOG"] = reader.
GetString(0);
319 row[
"TABLE_SCHEMA"] = reader.
GetString(1);
324 row[
"IS_GRANTABLE"] = reader.
GetString(6) ==
"YES";
325 dataTable.Rows.Add(row);
333 if (restrictions == null)
334 throw new ArgumentNullException(
"restrictions");
335 if (restrictions.Length < 3)
336 throw new ArgumentException();
338 string catalog = restrictions[0];
339 string schema = restrictions[1];
340 string table = restrictions[2];
343 dataTable.Columns.Add(
"TABLE_CATALOG");
344 dataTable.Columns.Add(
"TABLE_SCHEMA");
345 dataTable.Columns.Add(
"TABLE_NAME");
346 dataTable.Columns.Add(
"COLUMN_NAME");
347 dataTable.Columns.Add(
"KEY_SEQ", typeof(
int));
348 dataTable.Columns.Add(
"PK_NAME");
351 " FROM INFORMATION_SCHEMA.PrimaryKeys \n" +
352 " WHERE ( ? IS NULL OR \"TABLE_SCHEMA\" = ? ) \n" +
353 " AND \"TABLE_NAME\" = ? \n" +
354 " ORDER BY \"COLUMN_NAME\"");
364 row[
"TABLE_CATALOG"] = reader.
GetString(0);
365 row[
"TABLE_SCHEMA"] = reader.
GetString(1);
367 row[
"COLUMN_NAME"] = reader.
GetString(3);
368 row[
"KEY_SEQ"] = reader.
GetInt32(4);
370 dataTable.Rows.Add(row);
377 if (restrictions == null)
378 throw new ArgumentNullException(
"restrictions");
379 if (restrictions.Length < 3)
380 throw new ArgumentException();
382 string catalog = restrictions[0];
383 string schema = restrictions[1];
384 string table = restrictions[2];
387 dataTable.Columns.Add(
"PKTABLE_CATALOG");
388 dataTable.Columns.Add(
"PKTABLE_SCHEMA");
389 dataTable.Columns.Add(
"PKTABLE_NAME");
390 dataTable.Columns.Add(
"PKCOLUMN_NAME");
391 dataTable.Columns.Add(
"FKTABLE_CATALOG");
392 dataTable.Columns.Add(
"FKTABLE_SCHEMA");
393 dataTable.Columns.Add(
"FKTABLE_NAME");
394 dataTable.Columns.Add(
"FKCOLUMN_NAME");
395 dataTable.Columns.Add(
"KEY_SEQ");
396 dataTable.Columns.Add(
"UPDATE_RULE");
397 dataTable.Columns.Add(
"DELETE_RULE");
398 dataTable.Columns.Add(
"FK_NAME");
399 dataTable.Columns.Add(
"PK_NAME");
400 dataTable.Columns.Add(
"DEFERRABILITY");
402 DeveelDbCommand command = connection.CreateCommand(
" SELECT * FROM INFORMATION_SCHEMA.imported_keys \n" +
403 " WHERE ( ? IS NULL OR \"FKTABLE_SCHEMA\" = ? )\n" +
404 " AND \"FKTABLE_NAME\" = ? \n" +
405 " ORDER BY \"FKTABLE_SCHEMA\", \"FKTABLE_NAME\", \"KEY_SEQ\"");
415 while (reader.
Read()) {
416 var row = dataTable.NewRow();
417 row[
"PKTABLE_CATALOG"] = reader.
GetString(0);
418 row[
"PKTABLE_SCHEMA"] = reader.
GetString(1);
419 row[
"PKTABLE_NAME"] = reader.
GetString(2);
420 row[
"PKCOLUMN_NAME"] = reader.
GetString(3);
421 row[
"FKTABLE_CATALOG"] = reader.
GetString(4);
422 row[
"FKTABLE_SCHEMA"] = reader.
GetString(5);
423 row[
"FKTABLE_NAME"] = reader.
GetString(6);
424 row[
"FKCOLUMN_NAME"] = reader.
GetString(7);
425 row[
"KEY_SEQ"] = reader.
GetInt32(8);
426 row[
"UPDATE_RULE"] = reader.
GetString(9);
427 row[
"DELETE_RULE"] = reader.
GetString(10);
430 row[
"DEFERRABILITY"] = reader.
GetInt32(13);
431 dataTable.Rows.Add(row);
440 if (restrictions == null)
441 throw new ArgumentNullException(
"restrictions");
442 if (restrictions.Length < 3)
443 throw new ArgumentException();
445 string catalog = restrictions[0];
446 string schema = restrictions[1];
447 string table = restrictions[2];
450 dataTable.Columns.Add(
"PKTABLE_CATALOG");
451 dataTable.Columns.Add(
"PKTABLE_SCHEMA");
452 dataTable.Columns.Add(
"PKTABLE_NAME");
453 dataTable.Columns.Add(
"PKCOLUMN_NAME");
454 dataTable.Columns.Add(
"FKTABLE_CATALOG");
455 dataTable.Columns.Add(
"FKTABLE_SCHEMA");
456 dataTable.Columns.Add(
"FKTABLE_NAME");
457 dataTable.Columns.Add(
"FKCOLUMN_NAME");
458 dataTable.Columns.Add(
"KEY_SEQ");
459 dataTable.Columns.Add(
"UPDATE_RULE");
460 dataTable.Columns.Add(
"DELETE_RULE");
461 dataTable.Columns.Add(
"FK_NAME");
462 dataTable.Columns.Add(
"PK_NAME");
463 dataTable.Columns.Add(
"DEFERRABILITY");
465 DeveelDbCommand command = connection.CreateCommand(
" SELECT * FROM INFORMATION_SCHEMA.imported_keys \n" +
466 " WHERE ( ? IS NULL OR \"PKTABLE_SCHEMA\" = ? ) \n" +
467 " AND \"PKTABLE_NAME\" = ? \n" +
468 "ORDER BY \"FKTABLE_SCHEMA\", \"FKTABLE_NAME\", \"KEY_SEQ\"");
478 while (reader.
Read()) {
479 var row = dataTable.NewRow();
480 row[
"PKTABLE_CATALOG"] = reader.
GetString(0);
481 row[
"PKTABLE_SCHEMA"] = reader.
GetString(1);
482 row[
"PKTABLE_NAME"] = reader.
GetString(2);
483 row[
"PKCOLUMN_NAME"] = reader.
GetString(3);
484 row[
"FKTABLE_CATALOG"] = reader.
GetString(4);
485 row[
"FKTABLE_SCHEMA"] = reader.
GetString(5);
486 row[
"FKTABLE_NAME"] = reader.
GetString(6);
487 row[
"FKCOLUMN_NAME"] = reader.
GetString(7);
488 row[
"KEY_SEQ"] = reader.
GetInt32(8);
489 row[
"UPDATE_RULE"] = reader.
GetString(9);
490 row[
"DELETE_RULE"] = reader.
GetString(10);
493 row[
"DEFERRABILITY"] = reader.
GetInt32(13);
494 dataTable.Rows.Add(row);
503 object[][] restrictions =
new object[][]
505 new object[] {
"Schemata",
"Schema",
"", 0},
506 new object[] {
"Tables",
"Catalog",
"", 0},
507 new object[] {
"Tables",
"Schema",
"", 1},
508 new object[] {
"Tables",
"Table",
"", 2},
509 new object[] {
"Tables",
"TableType",
"", 3},
510 new object[] {
"Columns",
"Catalog",
"", 0},
511 new object[] {
"Columns",
"Schema",
"", 1},
512 new object[] {
"Columns",
"Table",
"", 2},
513 new object[] {
"Columns",
"Column",
"", 3},
514 new object[] {
"PrimaryKeys",
"Database",
"", 0},
515 new object[] {
"PrimaryKeys",
"Schema",
"", 1},
516 new object[] {
"PrimaryKeys",
"Table",
"", 2},
517 new object[] {
"ExportedKeys",
"Catalog",
"", 0},
518 new object[] {
"ExportedKeys",
"Schema",
"", 1},
519 new object[] {
"ExportedKeys",
"Table",
"", 2},
520 new object[] {
"ImportedKeys",
"Catalog",
"", 0},
521 new object[] {
"ImportedKeys",
"Schema",
"", 1},
522 new object[] {
"ImportedKeys",
"Table",
"", 2},
523 new object[] {
"ColumnPrivileges",
"Catalog",
"", 0},
524 new object[] {
"ColumnPrivileges",
"Schema",
"", 1},
525 new object[] {
"ColumnPrivileges",
"Table",
"", 2},
526 new object[] {
"ColumnPrivileges",
"Column",
"", 3},
527 new object[] {
"TablePrivileges",
"Catalog",
"", 0},
528 new object[] {
"TablePrivileges",
"Schema",
"", 1},
529 new object[] {
"TablePrivileges",
"Table",
"", 2},
530 new object[] {
"UserPrivileges",
"UserName",
"", 0}
534 dt.Columns.Add(
new DataColumn(
"CollectionName", typeof(
string)));
535 dt.Columns.Add(
new DataColumn(
"RestrictionName", typeof(
string)));
536 dt.Columns.Add(
new DataColumn(
"RestrictionDefault", typeof(
string)));
537 dt.Columns.Add(
new DataColumn(
"RestrictionNumber", typeof(
int)));
539 FillTable(dt, restrictions);
545 object[][] collections =
new object[][]
547 new object[] {
"MetaDataCollections", 0, 0},
548 new object[] {
"DataSourceInformation", 0, 0},
549 new object[] {
"DataTypes", 0, 0},
550 new object[] {
"Restrictions", 0, 0},
551 new object[] {
"ReservedWords", 0, 0},
552 new object[] {
"Databases", 1, 1},
553 new object[] {
"Tables", 4, 2},
554 new object[] {
"Columns", 4, 4},
555 new object[] {
"PrimaryKeys", 4, 3},
556 new object[] {
"ExportedKeys", 4, 3},
557 new object[] {
"ImportedKeys", 4, 3},
558 new object[] {
"UserPrivileges", 1, 0}
562 dt.Columns.Add(
"CollectionName", typeof(
string));
563 dt.Columns.Add(
"NumberOfRestrictions", typeof(
int));
564 dt.Columns.Add(
"NumberOfIdentifierParts", typeof(
int));
566 FillTable(dt, collections);
573 dt.Columns.Add(
"CompositeIdentifierSeparatorPattern", typeof(
string));
574 dt.Columns.Add(
"DataSourceProductName", typeof(
string));
575 dt.Columns.Add(
"DataSourceProductVersion", typeof(
string));
576 dt.Columns.Add(
"DataSourceProductVersionNormalized", typeof(
string));
577 dt.Columns.Add(
"GroupByBehavior", typeof(GroupByBehavior));
578 dt.Columns.Add(
"IdentifierPattern", typeof(
string));
579 dt.Columns.Add(
"IdentifierCase", typeof(IdentifierCase));
580 dt.Columns.Add(
"OrderByColumnsInSelect", typeof(
bool));
581 dt.Columns.Add(
"ParameterMarkerFormat", typeof(
string));
582 dt.Columns.Add(
"ParameterMarkerPattern", typeof(
string));
583 dt.Columns.Add(
"ParameterNameMaxLength", typeof(
int));
584 dt.Columns.Add(
"ParameterNamePattern", typeof(
string));
585 dt.Columns.Add(
"QuotedIdentifierPattern", typeof(
string));
586 dt.Columns.Add(
"QuotedIdentifierCase", typeof(IdentifierCase));
587 dt.Columns.Add(
"StatementSeparatorPattern", typeof(
string));
588 dt.Columns.Add(
"StringLiteralPattern", typeof(
string));
589 dt.Columns.Add(
"SupportedJoinOperators", typeof(SupportedJoinOperators));
592 row[
"CompositeIdentifierSeparatorPattern"] =
"\\.";
593 row[
"DataSourceProductName"] =
"DeveelDB";
594 row[
"DataSourceProductVersion"] = connection.ServerVersion;
595 row[
"DataSourceProductVersionNormalized"] = connection.ServerVersion;
596 row[
"GroupByBehavior"] = GroupByBehavior.Unrelated;
597 row[
"IdentifierPattern"] =
598 @"(^\`\p{Lo}\p{Lu}\p{Ll}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Nd}@$#_]*$)|(^\`[^\`\0]|\`\`+\`$)|(^\"" + [^\""\0]|\""\""+\""$)";
599 row[
"IdentifierCase"] = IdentifierCase.Insensitive;
600 row[
"OrderByColumnsInSelect"] =
false;
601 row[
"ParameterMarkerFormat"] =
"{0}";
602 row[
"ParameterMarkerPattern"] =
"(@[A-Za-z0-9_$#]*)";
603 row[
"ParameterNameMaxLength"] = 128;
604 row[
"ParameterNamePattern"] =
@"^[\p{Lo}\p{Lu}\p{Ll}\p{Lm}_@#][\p{Lo}\p{Lu}\p{Ll}\p{Lm}\p{Nd}\uff3f_@#\$]*(?=\s+|$)";
605 row[
"QuotedIdentifierPattern"] =
@"(([^\`]|\`\`)*)";
606 row[
"QuotedIdentifierCase"] = IdentifierCase.Sensitive;
607 row[
"StatementSeparatorPattern"] =
";";
608 row[
"StringLiteralPattern"] =
"'(([^']|'')*)'";
609 row[
"SupportedJoinOperators"] = 15;
618 dataTable.Columns.Add(
"TYPE_NAME", typeof(
string));
619 dataTable.Columns.Add(
"DATA_TYPE", typeof(
int));
620 dataTable.Columns.Add(
"PRECISION", typeof(
int));
621 dataTable.Columns.Add(
"LITERAL_PREFIX", typeof(
string));
622 dataTable.Columns.Add(
"LITERAL_SUFFIX", typeof(
string));
623 dataTable.Columns.Add(
"CREATE_PARAMS", typeof(
string));
624 dataTable.Columns.Add(
"NULLABLE", typeof(
bool));
625 dataTable.Columns.Add(
"CASE_SENSITIVE", typeof(
bool));
626 dataTable.Columns.Add(
"SEARCHABLE", typeof(
bool));
627 dataTable.Columns.Add(
"UNSIGNED_ATTRIBUTE", typeof(
bool));
628 dataTable.Columns.Add(
"FIXED_PREC_SCALE", typeof(
bool));
629 dataTable.Columns.Add(
"AUTO_INCREMENT", typeof(
bool));
630 dataTable.Columns.Add(
"LOCAL_TYPE_NAME");
631 dataTable.Columns.Add(
"MINIMUM_SCALE", typeof(
int));
632 dataTable.Columns.Add(
"MAXIMUM_SCALE", typeof(
int));
633 dataTable.Columns.Add(
"SQL_DATA_TYPE", typeof(
string));
634 dataTable.Columns.Add(
"SQL_DATETIME_SUB", typeof(
string));
635 dataTable.Columns.Add(
"NUM_PREC_RADIX", typeof(
int));
637 DeveelDbCommand command = connection.CreateCommand(
"SELECT * FROM INFORMATION_SCHEMA.DATA_TYPES");
640 while (reader.
Read()) {
644 row[
"DATA_TYPE"] = reader.
GetInt32(1);
645 row[
"PRECISION"] = reader.
GetInt32(2);
646 row[
"LITERAL_PREFIX"] = reader.
GetString(3);
647 row[
"LITERAL_SUFFIX"] = reader.
GetString(4);
648 row[
"CREATE_PARAMS"] = reader.
GetString(5);
652 row[
"UNSIGNED_ATTRIBUTE"] = reader.
GetBoolean(9);
653 row[
"FIXED_PREC_SCALE"] = reader.
GetBoolean(10);
654 row[
"AUTO_INCREMENT"] = reader.
GetBoolean(11);
655 row[
"LOCAL_TYPE_NAME"] = reader.
GetString(12);
656 row[
"MINIMUM_SCALE"] = reader.
GetInt32(13);
657 row[
"MAXIMUM_SCALE"] = reader.
GetInt32(14);
658 row[
"SQL_DATA_TYPE"] = reader.
GetString(15);
659 row[
"SQL_DATETIME_SUB"] = reader.
GetString(16);
660 row[
"NUM_PREC_RADIX"] = reader.
GetInt32(17);
662 dataTable.Rows.Add(row);
670 if (restrictions == null)
671 throw new ArgumentNullException(
"restrictions");
672 if (restrictions.Length < 1)
673 throw new ArgumentException();
675 var userName = restrictions[0];
678 dataTable.Columns.Add(
"TABLE_CATALOG");
679 dataTable.Columns.Add(
"GRANTEE");
680 dataTable.Columns.Add(
"OBJECT_TYPE");
681 dataTable.Columns.Add(
"OBJECT_NAME");
682 dataTable.Columns.Add(
"PRIVS");
683 dataTable.Columns.Add(
"IS_GRANTABLE", typeof(
bool));
684 dataTable.Columns.Add(
"GRANTER");
686 var command = connection.CreateCommand(
"SELECT * FROM INFORMATION_SCHEMA.USER_PRIVILEGES WHERE (? IS NULL OR \"GRANTEE\" = ?)");
687 command.Parameters.Add(userName);
688 command.Parameters.Add(userName);
692 using (var reader = command.ExecuteReader()) {
693 while (reader.Read()) {
694 var row = dataTable.NewRow();
695 row[
"TABLE_CATALOG"] = reader.GetString(0);
696 row[
"GRANTEE"] = reader.GetString(1);
697 row[
"OBJECT_TYPE"] = reader.GetString(2);
698 row[
"OBJECT_NAME"] = reader.GetString(3);
699 row[
"PRIVS"] = reader.GetString(4);
700 row[
"IS_GRANTABLE"] = reader.GetBoolean(5);
701 dataTable.Rows.Add(row);
709 if (connection.State != ConnectionState.Open)
710 throw new DataException(
"GetSchema can only be called on an open connection.");
712 collection = collection.ToUpper(CultureInfo.InvariantCulture);
716 switch (collection) {
718 case "METADATACOLLECTIONS":
719 dt = GetCollections();
721 case "DATASOURCEINFORMATION":
722 dt = GetDataSourceInformation();
728 dt = GetRestrictions();
730 case "RESERVEDWORDS":
735 if (restrictions == null)
736 restrictions =
new string[2];
737 if (connection != null &&
738 connection.Settings.Schema != null &&
739 connection.Settings.Schema.Length > 0 &&
740 restrictions.Length > 1 &&
741 restrictions[1] == null)
742 restrictions[1] = connection.Settings.Schema;
744 switch (collection) {
746 dt = GetSchemata(restrictions);
749 dt = GetTables(restrictions);
752 dt = GetColumns(restrictions);
754 case "TABLEPRIVILEGES":
755 dt = GetTablePrivileges(restrictions);
757 case "COLUMNPRIVILEGES":
758 dt = GetColumnPrivileges(restrictions);
761 dt = GetPrimaryKeys(restrictions);
764 dt = GetExportedKeys(restrictions);
767 dt = GetImportedKeys(restrictions);
769 case "USERPRIVILEGES":
770 dt = GetUserPrivileges(restrictions);
776 throw new DataException(
"Invalid collection name");
782 foreach (
object[] dataItem
in data) {
784 for (
int i = 0; i < dataItem.Length; i++)
785 row[i] = dataItem[i];
new DeveelDbParameterCollection Parameters
new DeveelDbDataReader ExecuteReader(CommandBehavior behavior)
override bool GetBoolean(int ordinal)
override string GetString(int ordinal)
override int GetInt32(int ordinal)
override int Add(object value)