![]() |
|
|||
File indexing completed on 2025-08-03 08:22:03
0001 // $Id: MySQLDatabaseMetaData.cxx,v 1.1.1.1 2004/02/18 20:58:02 dave Exp $ 0002 //*-- Author : Valeriy Onuchin 26/02/2001 0003 // 0004 // RDBC driver to MySQL database implemented with MySQL C API. 0005 // 0006 // ++ The code consists of some parts stolen from mm JDBC and 0007 // MyODBC ODBC drivers and other mysql-related open sources. 0008 // 0009 0010 ///////////////////////////////////////////////////////////////////// 0011 // 0012 // Comprehensive information about the database as a whole. 0013 // 0014 // Many of the methods here return lists of information in the form 0015 // of TSQLResultSet objects. You can use the normal TSQLResultSet 0016 // methods such as TSQLResultSet::GetString() and 0017 // TSQLResultSet::GetInt() to retrieve the data from 0018 // these TSQLResultSet s. If a given form of metadata is not available, 0019 // these methods should throw an TSQLException. 0020 // 0021 // Some of these methods take arguments that are string patterns. 0022 // These arguments all have names such as fooPattern. Within a 0023 // pattern string, "%" means match any substring of 0 or more 0024 // characters, and "_" means match any one character. Only metadata 0025 // entries matching the search pattern are returned. If a search 0026 // pattern argument is set to a null ref, that argument's criteria 0027 // will be dropped from the search. 0028 // 0029 // 0030 ///////////////////////////////////////////////////////////////////// 0031 // 0032 // Constants: 0033 // 0034 //___________________________________________________________________ 0035 // kProcedureResultUnknown 0036 // 0037 // A possible value for column PROCEDURE_TYPE in the 0038 // TSQLResultSet object returned by the method GetProcedures(). 0039 // 0040 // Indicates that it is not known whether the procedure 0041 // returns a result. 0042 // 0043 //___________________________________________________________________ 0044 // kProcedureNoResult 0045 // 0046 // A possible value for column PROCEDURE_TYPE in the 0047 // TSQLResultSet object returned by the method GetProcedures(). 0048 // 0049 // Indicates that the procedure does not return a result. 0050 // 0051 //___________________________________________________________________ 0052 // kProcedureReturnsResult 0053 // 0054 // A possible value for column PROCEDURE_TYPE in the 0055 // TSQLResultSet object returned by the method GetProcedures(). 0056 // 0057 // Indicates that the procedure returns a result. 0058 // 0059 //___________________________________________________________________ 0060 // kProcedureColumnUnknown 0061 // 0062 // Indicates that type of the column is unknown. A possible value 0063 // for the column COLUMN_TYPE in the TSQLResultSet returned by 0064 // the method GetProcedureColumns(). 0065 // 0066 //___________________________________________________________________ 0067 // kProcedureColumnIn 0068 // 0069 // Indicates that the column stores IN parameters. A possible 0070 // value for the column COLUMN_TYPE in the TSLQResultSet returned 0071 // by the method GetProcedureColumns(). 0072 // 0073 //___________________________________________________________________ 0074 // kProcedureColumnInOut 0075 // 0076 // Indicates that the column stores INOUT parameters. A possible 0077 // value for the column COLUMN_TYPE in the TSQLResultSet returned 0078 // by the method GetProcedureColumns(). 0079 // 0080 //___________________________________________________________________ 0081 // kProcedureColumnOut 0082 // 0083 // Indicates that the column stores OUT parameters. A possible 0084 // value for the column kCOLUMN_TYPE in the TSQLResultSet 0085 // returned by the method GetProcedureColumns(). 0086 // 0087 //___________________________________________________________________ 0088 // kProcedureColumnReturn 0089 // 0090 // Indicates that the column stores return values. A possible 0091 // value for the column COLUMN_TYPE in the TSQLResultSet returned 0092 // by the method GetProcedureColumns(). 0093 // 0094 //___________________________________________________________________ 0095 // kProcedureColumnResult 0096 // 0097 // Indicates that the column stores results. A possible value 0098 // for the column kCOLUMN_TYPE in the TSQLResultSet returned 0099 // by the method GetProcedureColumns(). 0100 // 0101 //___________________________________________________________________ 0102 // kProcedureNoNulls 0103 // 0104 // Indicates that NULL values are not allowed. A possible value 0105 // for the column NULLABLE in the TSQLResultSet returned by the 0106 // method GetProcedureColumns(). 0107 // 0108 //___________________________________________________________________ 0109 // kProcedureNullable 0110 // 0111 // Indicates that NULL values are allowed. A possible value for 0112 // the column NULLABLE in the TSQLResultSet returned by 0113 // the method GetProcedureColumns(). 0114 // 0115 //___________________________________________________________________ 0116 // kProcedureNullableUnknown 0117 // 0118 // Indicates that whether NULL values are allowed is unknown. 0119 // A possible value for the column NULLABLE in the TSQLResultSet 0120 // returned by the method GetProcedureColumns(). 0121 // 0122 //___________________________________________________________________ 0123 // kColumnNoNulls 0124 // 0125 // Indicates that the column might not allow NULL values. 0126 // A possible value for the column NULLABLE in the TSQLResultSet 0127 // returned by the method GetColumns(). 0128 // 0129 //___________________________________________________________________ 0130 // kColumnNullable 0131 // 0132 // Indicates that the column definitely allows NULL values. 0133 // A possible value for the column NULLABLE in the TSQLResultSet 0134 // returned by the method GetColumns(). 0135 // 0136 //___________________________________________________________________ 0137 // kColumnNullableUnknown 0138 // 0139 // Indicates that the nullability of columns is unknown. 0140 // A possible value for the column NULLABLE in the TSQLResultSet 0141 // returned by the method GetColumns(). 0142 // 0143 //___________________________________________________________________ 0144 // kBestRowTemporary 0145 // 0146 // Indicates that the scope of the best row identifier is very 0147 // temporary, lasting only while the row is being used. 0148 // A possible value for the column SCOPE in the TSQLResultSet 0149 // object returned by the method GetBestRowIdentifier(). 0150 // 0151 //___________________________________________________________________ 0152 // kBestRowTransaction 0153 // 0154 // Indicates that the scope of the best row identifier is the 0155 // remainder of the current transaction. A possible value for 0156 // the column SCOPE in the TSQLResultSet object returned by 0157 // the method GetBestRowIdentifier(). 0158 // 0159 //___________________________________________________________________ 0160 // kBestRowSession 0161 // 0162 // Indicates that the scope of the best row identifier is the 0163 // remainder of the current session. A possible value for the 0164 // column SCOPE in the TSQLResultSet object returned by 0165 // the method GetBestRowIdentifier(). 0166 // 0167 //___________________________________________________________________ 0168 // kBestRowUnknown 0169 // 0170 // Indicates that the best row identifier may or may not be 0171 // a pseudo column. A possible value for the column 0172 // PSEUDO_COLUMN in the TSQLResultSet object returned by 0173 // the method GetBestRowIdentifier(). 0174 // 0175 //___________________________________________________________________ 0176 // kBestRowNotPseudo 0177 // 0178 // Indicates that the best row identifier is NOT a pseudo 0179 // column. A possible value for the column PSEUDO_COLUMN in 0180 // the TSQLResultSet object returned by the method 0181 // GetBestRowIdentifier(). 0182 // 0183 //___________________________________________________________________ 0184 // kBestRowPseudo 0185 // 0186 // Indicates that the best row identifier is a pseudo column. 0187 // A possible value for the column PSEUDO_COLUMN in the 0188 // TSQLResultSet object returned by the method 0189 // GetBestRowIdentifier(). 0190 // 0191 //___________________________________________________________________ 0192 // kVersionColumnUnknown 0193 // 0194 // Indicates that this version column may or may not be a pseudo 0195 // column. A possible value for the column PSEUDO_COLUMN in 0196 // the TSQLResultSet object returned by the method 0197 // GetVersionColumns(). 0198 // 0199 //___________________________________________________________________ 0200 // kVersionColumnNotPseudo 0201 // 0202 // Indicates that this version column is NOT a pseudo column. 0203 // A possible value for the column PSEUDO_COLUMN in the 0204 // TSQLResultSet object returned by the method GetVersionColumns(). 0205 // 0206 //___________________________________________________________________ 0207 // kVersionColumnPseudo 0208 // 0209 // Indicates that this version column is a pseudo column. 0210 // A possible value for the column PSEUDO_COLUMN in the 0211 // TSQLResultSet object returned by the method GetVersionColumns(). 0212 // 0213 //___________________________________________________________________ 0214 // kImportedKeyCascade 0215 // 0216 // A possible value for the columns UPDATE_RULE and 0217 // DELETE_RULE in the TSQLResultSet objects returned by the 0218 // methods GetImportedKeys(), GetExportedKeys(), 0219 // and GetCrossReference(). 0220 // 0221 // For the column UPDATE_RULE, it indicates that when the 0222 // primary key is updated, the foreign key (imported key) 0223 // is changed to agree with it. 0224 // 0225 // For the column DELETE_RULE, it indicates that when the 0226 // primary key is deleted, rows that imported that key 0227 // are deleted. 0228 // 0229 //___________________________________________________________________ 0230 // kImportedKeyRestrict 0231 // 0232 // A possible value for the columns UPDATE_RULE and DELETE_RULE 0233 // in the TSQLResultSet objects returned by the methods 0234 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0235 // 0236 // For the column UPDATE_RULE, it indicates that a primary 0237 // key may not be updated if it has been imported by another 0238 // table as a foreign key. 0239 // 0240 // For the column DELETE_RULE, it indicates that a primary 0241 // key may not be deleted if it has been imported by another 0242 // table as a foreign key. 0243 // 0244 //___________________________________________________________________ 0245 // kImportedKeySetNull 0246 // 0247 // A possible value for the columns UPDATE_RULE and DELETE_RULE 0248 // in the TSQLResultSet objects returned by the methods 0249 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0250 // 0251 // For the columns UPDATE_RULE and DELETE_RULE, it indicates 0252 // that when the primary key is updated or deleted, the 0253 // foreign key (imported key) is changed to NULL. 0254 // 0255 //___________________________________________________________________ 0256 // kImportedKeyNoAction 0257 // 0258 // A possible value for the columns UPDATE_RULE and DELETE_RULE 0259 // in the TSQLResultSet objects returned by the methods 0260 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0261 // 0262 // For the columns UPDATE_RULE and DELETE_RULE, it indicates 0263 // that if the primary key has been imported, it cannot be 0264 // updated or deleted. 0265 // 0266 //___________________________________________________________________ 0267 // kImportedKeySetDefault 0268 // 0269 // A possible value for the columns UPDATE_RULE and DELETE_RULE 0270 // in the TSQLResultSet objects returned by the methods 0271 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0272 // 0273 // For the columns UPDATE_RULE and DELETE_RULE, it indicates 0274 // that if the primary key is updated or deleted, 0275 // the foreign key (imported key) is set to the default value. 0276 // 0277 //___________________________________________________________________ 0278 // kImportedKeyInitiallyDeferred 0279 // 0280 // A possible value for the column DEFERRABILITY in 0281 // the TSQLResultSet objects returned by the methods 0282 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0283 // 0284 // Indicates deferrability. See SQL-92 for a definition. 0285 // 0286 //___________________________________________________________________ 0287 // kImportedKeyInitiallyImmediate 0288 // 0289 // A possible value for the column DEFERRABILITY in 0290 // the TSQLResultSet objects returned by the methods 0291 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0292 // 0293 // Indicates deferrability. See SQL-92 for a definition. 0294 // 0295 //___________________________________________________________________ 0296 // kImportedKeyNotDeferrable 0297 // 0298 // A possible value for the column DEFERRABILITY in 0299 // the TSQLResultSet objects returned by the methods 0300 // GetImportedKeys(), GetExportedKeys(), and GetCrossReference(). 0301 // 0302 // Indicates deferrability. See SQL-92 for a definition. 0303 // 0304 //___________________________________________________________________ 0305 // kTypeNoNulls 0306 // 0307 // A possible value for column NULLABLE in the TSQLResultSet 0308 // object returned by the method GetTypeInfo(). 0309 // 0310 // Indicates that a NULL value is NOT allowed for 0311 // this data type. 0312 // 0313 //___________________________________________________________________ 0314 // kTypeNullable 0315 // 0316 // A possible value for column NULLABLE in the TSQLResultSet 0317 // object returned by the method GetTypeInfo(). 0318 // 0319 // Indicates that a NULL value is allowed for this data type. 0320 // 0321 //___________________________________________________________________ 0322 // kTypeNullableUnknown 0323 // 0324 // A possible value for column NULLABLE in the TSQLResultSet 0325 // object returned by the method GetTypeInfo(). 0326 // 0327 // Indicates that it is not known whether a NULL value 0328 // is allowed for this data type. 0329 // 0330 //___________________________________________________________________ 0331 // kTypePredNone 0332 // 0333 // A possible value for column SEARCHABLE in the TSQLResultSet 0334 // object returned by the method GetTypeInfo(). 0335 // 0336 // Indicates that WHERE search clauses are not supported 0337 // for this type. 0338 // 0339 //___________________________________________________________________ 0340 // kTypePredChar 0341 // 0342 // A possible value for column SEARCHABLE in the TSQLResultSet 0343 // object returned by the method GetTypeInfo(). 0344 // 0345 // Indicates that the only WHERE search clause that can be 0346 // based on this type is WHERE . . .LIKE. 0347 // 0348 //___________________________________________________________________ 0349 // kTypePredBasic 0350 // 0351 // A possible value for column SEARCHABLE in the TSQLResultSet 0352 // object returned by the method GetTypeInfo(). 0353 // 0354 // Indicates that one can base all WHERE search clauses 0355 // except WHERE . . .LIKE on this data type. 0356 // 0357 //___________________________________________________________________ 0358 // kTypeSearchable 0359 // 0360 // A possible value for column SEARCHABLE in the TSQLResultSet 0361 // object returned by the method GetTypeInfo(). 0362 // 0363 // Indicates that all WHERE search clauses can be based 0364 // on this type. 0365 // 0366 //___________________________________________________________________ 0367 // kTableIndexStatistic 0368 // 0369 // A possible value for column TYPE in the TSQLResultSet 0370 // object returned by the method GetIndexInfo(). 0371 // 0372 // Indicates that this column contains table statistics 0373 // that are returned in conjunction with a table's index 0374 // descriptions. 0375 // 0376 //___________________________________________________________________ 0377 // kTableIndexClustered 0378 // 0379 // A possible value for column TYPE in the TSQLResultSet object 0380 // returned by the method GetIndexInfo(). 0381 // 0382 // Indicates that this table index is a clustered index. 0383 // 0384 //___________________________________________________________________ 0385 // kTableIndexHashed 0386 // 0387 // A possible value for column TYPE in the TSQLResultSet object 0388 // returned by the method GetIndexInfo(). 0389 // 0390 // Indicates that this table index is a hashed index. 0391 // 0392 //___________________________________________________________________ 0393 // kTableIndexOther 0394 // 0395 // A possible value for column TYPE in the TSQLResultSet object 0396 // returned by the method GetIndexInfo(). 0397 // 0398 // Indicates that this table index is not a clustered index, 0399 // a hashed index, or table statistics; it is something 0400 // other than these. 0401 // 0402 // See also: 0403 // TSQLTypes TSQLConnection 0404 // 0405 ///////////////////////////////////////////////////////////////////// 0406 0407 #include <RDBC/TSQLDatabaseMetaData.h> 0408 #include <RDBC/TSQLResultSet.h> 0409 #include <RDBC/TSQLConnection.h> 0410 #include <RDBC/configure.h> // 0411 0412 0413 #include "MySQLConnectionPrivate.h" 0414 0415 ClassImpQ(TSQLDatabaseMetaData) 0416 0417 // allowed extra chars ( stolen from MyODBC-2.50.36/info.c ) 0418 UChar_t gAllowedChars[]= { 0419 '\307','\374','\351','\342','\344','\340','\345','\347','\352','\353', 0420 '\350','\357','\356','\354','\304','\305','\311','\346','\306','\364', 0421 '\366','\362','\373','\371','\377','\326','\334','\341','\355','\363', 0422 '\372','\361','\321',0}; 0423 0424 // from <http://mysql.com/doc///L/e/Legal_names.html> && mysql_com.h 0425 const Int_t gNameLength = NAME_LEN; // Field/table name length 0426 const Int_t gMaxDatabaseNameLength = HOSTNAME_LENGTH; 0427 const Int_t gMaxTableNameLength = NAME_LEN; 0428 const Int_t gMaxColumnNameLength = NAME_LEN; 0429 const Int_t gMaxUserNameLength = USERNAME_LENGTH; 0430 const Int_t gMaxAliasNameLength = 64; 0431 const Int_t gMaxIndexLength = 256; 0432 const Int_t gMaxLiteralLength = 0; // == 4294967295 (2^32 - 1) - NET_HEADER_SIZE - COMP_HEADER_SIZE 0433 0434 MySQLResultSetPrivate* gResult = 0; // result set used in methods which return TSQLResultSets 0435 0436 ///////////////////////////////////////////////////////////////////// 0437 //___________________________________________________________________ 0438 TSQLDatabaseMetaData::TSQLDatabaseMetaData(TSQLConnection* connection, 0439 void* imp):TSQL(imp) 0440 { 0441 // constructor 0442 0443 fConnection = connection; 0444 if(!gResult) gResult = = new MySQLResultSetPrivate(); 0445 } 0446 0447 //___________________________________________________________________ 0448 TSQLDatabaseMetaData::~TSQLDatabaseMetaData() 0449 { 0450 // destructor will be called when fConnection is deleted 0451 0452 fConnection = 0; 0453 fImp = 0; 0454 } 0455 0456 //___________________________________________________________________ 0457 Bool_t TSQLDatabaseMetaData::AllProceduresAreCallable() 0458 { 0459 // Can all the procedures returned by GetProcedures be 0460 // called by the current user? 0461 // 0462 // Returns: 0463 // kTRUE if so; kFALSE otherwise 0464 // Throws: 0465 // TSQLException - if a database access error occurs 0466 0467 return kFALSE; 0468 } 0469 0470 //___________________________________________________________________ 0471 Bool_t TSQLDatabaseMetaData::AllTablesAreSelectable() 0472 { 0473 // Can all the tables returned by GetTable() be SELECTed by 0474 // the current user? 0475 // 0476 // Returns: 0477 // kTRUE if so; kFALSE otherwise 0478 // Throws: 0479 // TSQLException - if a database access error occurs 0480 0481 return kFALSE; 0482 } 0483 0484 //___________________________________________________________________ 0485 TString TSQLDatabaseMetaData::GetUserName() 0486 { 0487 // What's our user name as known to the database? 0488 // 0489 // Returns: 0490 // our database user name 0491 // Throws: 0492 // TSQLException - if a database access error occurs 0493 // 0494 // ... more comments based on "ODBC 3.5 Developer's Guide" 0495 // 0496 // Identifies the user name in a particular database 0497 // (this name can be different from the login name) 0498 // 0499 0500 TString str; 0501 TSQLStatement* stmt = fConnection->CreateSatement(); 0502 TSQLResultSet* rs = stmt->ExecuteQuery("select substring_index(USER(),\"@\",1)"); 0503 rs->Next(); 0504 str = rs->GetString(1); 0505 delete stmt; 0506 return str; 0507 } 0508 0509 //___________________________________________________________________ 0510 Bool_t TSQLDatabaseMetaData::IsReadOnly() 0511 { 0512 // Is the database in read-only mode? 0513 // 0514 // Returns: 0515 // kTRUE if so; kFALSE otherwise 0516 // Throws: 0517 // TSQLException - if a database access error occurs 0518 // 0519 // ... more comments based on "ODBC 3.5 Developer's Guide" 0520 // 0521 // This characteristic pertains only to the data source itself; 0522 // it is not a characteristic of the driver that enables access 0523 // to the data source. A driver that is read/write can be used 0524 // with a data source that is read-only. 0525 // 0526 // If a driver is read-only, all its data sources must be read-only 0527 // and must return kTRUE for this method 0528 // 0529 0530 Bool_t return_value = kTRUE; 0531 return return_value; 0532 } 0533 0534 //___________________________________________________________________ 0535 Bool_t TSQLDatabaseMetaData::NullsAreSortedHigh() 0536 { 0537 // Are NULL values sorted high? 0538 // 0539 // Returns: 0540 // kTRUE if so; kFALSE otherwise 0541 // Throws: 0542 // TSQLException - if a database access error occurs 0543 // 0544 // Identifies where NULL values are sorted in a result data set 0545 // 0546 0547 return kFALSE; 0548 } 0549 0550 //___________________________________________________________________ 0551 Bool_t TSQLDatabaseMetaData::NullsAreSortedLow() 0552 { 0553 // Are NULL values sorted low? 0554 // 0555 // Returns: 0556 // kTRUE if so; kFALSE otherwise 0557 // Throws: 0558 // TSQLException - if a database access error occurs 0559 // 0560 // Identifies where NULL values are sorted in a result data set 0561 // 0562 0563 return !NullsAreSortedHigh(); 0564 } 0565 0566 //___________________________________________________________________ 0567 Bool_t TSQLDatabaseMetaData::NullsAreSortedAtStart() 0568 { 0569 // Are NULL values sorted at the start regardless of sort order? 0570 // 0571 // Returns: 0572 // kTRUE if so; kFALSE otherwise 0573 // Throws: 0574 // TSQLException - if a database access error occurs 0575 // 0576 // Identifies where NULL values are sorted in a result data set 0577 // 0578 0579 return kFALSE; 0580 } 0581 0582 //___________________________________________________________________ 0583 Bool_t TSQLDatabaseMetaData::NullsAreSortedAtEnd() 0584 { 0585 // Are NULL values sorted at the end regardless of sort order? 0586 // 0587 // Returns: 0588 // kTRUE if so; kFALSE otherwise 0589 // Throws: 0590 // TSQLException - if a database access error occurs 0591 // 0592 // Identifies where NULL values are sorted in a result data set 0593 // 0594 0595 return kFALSE; 0596 } 0597 0598 //___________________________________________________________________ 0599 TString TSQLDatabaseMetaData::GetDatabaseProductName() 0600 { 0601 // What's the name of this database product? 0602 // 0603 // Returns: 0604 // database product name 0605 // Throws: 0606 // TSQLException - if a database access error occurs 0607 0608 return "MySQL"; 0609 } 0610 0611 //___________________________________________________________________ 0612 TString TSQLDatabaseMetaData::GetDatabaseProductVersion() 0613 { 0614 // What's the version of this database product? 0615 // 0616 // ... more comments based on "ODBC 3.5 Developer's Guide" 0617 // 0618 // This information returned in a string that has format 0619 // mm.vv.rrrr, where mm is the major version number, 0620 // vv is the minor version number, and rrrr is the release 0621 // virsion number. 0622 // 0623 // Returns: 0624 // database version 0625 // Throws: 0626 // TSQLException - if a database access error occurs 0627 0628 MySQLConnectionPrivate* imp = (MySQLConnectionPrivate*)fImp; 0629 return mysql_get_server_info(imp->fMYSQL); 0630 } 0631 0632 //___________________________________________________________________ 0633 TString TSQLDatabaseMetaData::GetDriverName() 0634 { 0635 // What's the name of this ODBC driver? 0636 // 0637 // Returns: 0638 // driver name 0639 // Throws: 0640 // TSQLException - if a database access error occurs 0641 0642 return "VO MySQL Driver"; 0643 } 0644 0645 //___________________________________________________________________ 0646 TString TSQLDatabaseMetaData::GetDriverVersion() 0647 { 0648 // What's the version of this ODBC driver? 0649 // 0650 // ... more comments based on "ODBC 3.5 Developer's Guide" 0651 // 0652 // This information returned in a string that has format 0653 // mm.vv.rrrr, where mm is the major version number, 0654 // vv is the minor version number, and rrrr is the release 0655 // virsion number 0656 // 0657 // Returns: 0658 // driver version 0659 // Throws: 0660 // TSQLException - if a database access error occurs 0661 0662 TString str = RDBC_VERSION; 0663 return str; 0664 } 0665 0666 //___________________________________________________________________ 0667 Int_t TSQLDatabaseMetaData::GetDriverMajorVersion() 0668 { 0669 // What's this driver's major version number? 0670 // 0671 // Returns: 0672 // driver major version 0673 0674 Int_t return_value = 0; 0675 return return_value; 0676 } 0677 0678 //___________________________________________________________________ 0679 Int_t TSQLDatabaseMetaData::GetDriverMinorVersion() 0680 { 0681 // What's this driver's minor version number? 0682 // 0683 // Returns: 0684 // driver minor version number 0685 0686 Int_t return_value = 0; 0687 return return_value; 0688 } 0689 0690 //___________________________________________________________________ 0691 Bool_t TSQLDatabaseMetaData::UsesLocalFiles() 0692 { 0693 // Does the database store tables in a local file? 0694 // 0695 // Returns: 0696 // kTRUE if so; kFALSE otherwise 0697 // Throws: 0698 // TSQLException - if a database access error occurs 0699 // 0700 // ... more comments based on "ODBC 3.5 Developer's Guide" 0701 // 0702 // kFALSE means that driver is a not single-tier driver 0703 // thereore files are not supported 0704 0705 return kFALSE; 0706 } 0707 0708 //___________________________________________________________________ 0709 Bool_t TSQLDatabaseMetaData::UsesLocalFilePerTable() 0710 { 0711 // Does the database use a file for each table? 0712 // 0713 // Returns: 0714 // kTRUE if the database uses a local file for each table 0715 // Throws: 0716 // TSQLException - if a database access error occurs 0717 // 0718 // ... more comments based on "ODBC 3.5 Developer's Guide" 0719 // 0720 // The single-tier driver treats files in a data source as 0721 // tables 0722 // 0723 0724 return kFALSE; 0725 } 0726 0727 //___________________________________________________________________ 0728 Bool_t TSQLDatabaseMetaData::SupportsMixedCaseIdentifiers() 0729 { 0730 // Does the database treat mixed case unquoted SQL identifiers 0731 // as case sensitive and as a result store them in mixed case? 0732 // A SQL-92 complient driver will always return kFALSE. 0733 // 0734 // Returns: 0735 // kTRUE if so; kFALSE otherwise 0736 // Throws: 0737 // TSQLException - if a database access error occurs 0738 0739 return kFALSE; 0740 } 0741 0742 //___________________________________________________________________ 0743 Bool_t TSQLDatabaseMetaData::StoresUpperCaseIdentifiers() 0744 { 0745 // Does the database treat mixed case unquoted SQL identifiers 0746 // as case insensitive and store them in upper case? 0747 // 0748 // Returns: 0749 // kTRUE if so; kFALSE otherwise 0750 // Throws: 0751 // TSQLException - if a database access error occurs 0752 0753 return kFALSE; 0754 } 0755 0756 //___________________________________________________________________ 0757 Bool_t TSQLDatabaseMetaData::StoresLowerCaseIdentifiers() 0758 { 0759 // Does the database treat mixed case unquoted SQL identifiers 0760 // as case insensitive and store them in lower case? 0761 // 0762 // Returns: 0763 // kTRUE if so; kFALSE otherwise 0764 // Throws: 0765 // TSQLException - if a database access error occurs 0766 0767 return kFALSE; 0768 } 0769 0770 //___________________________________________________________________ 0771 Bool_t TSQLDatabaseMetaData::StoresMixedCaseIdentifiers() 0772 { 0773 // Does the database treat mixed case unquoted SQL identifiers 0774 // as case insensitive and store them in mixed case? 0775 // 0776 // Returns: 0777 // kTRUE if so; kFALSE otherwise 0778 // Throws: 0779 // TSQLException - if a database access error occurs 0780 0781 Bool_t return_value = kTRUE; 0782 return return_value; 0783 } 0784 0785 //___________________________________________________________________ 0786 Bool_t TSQLDatabaseMetaData::SupportsMixedCaseQuotedIdentifiers() 0787 { 0788 // Does the database treat mixed case quoted SQL identifiers 0789 // as case sensitive and as a result store them in mixed case? 0790 // A SQL-92 entry level-conformant driver will always 0791 // return kTRUE. 0792 // 0793 // Returns: 0794 // kTRUE if so; kFALSE otherwise 0795 // Throws: 0796 // TSQLException - if a database access error occurs 0797 0798 Bool_t return_value = kTRUE; 0799 return return_value; 0800 } 0801 0802 //___________________________________________________________________ 0803 Bool_t TSQLDatabaseMetaData::StoresUpperCaseQuotedIdentifiers() 0804 { 0805 // Does the database treat mixed case quoted SQL identifiers 0806 // as case insensitive and store them in upper case? 0807 // 0808 // Returns: 0809 // kTRUE if so; kFALSE otherwise 0810 // Throws: 0811 // TSQLException - if a database access error occurs 0812 0813 return kFALSE; 0814 } 0815 0816 //___________________________________________________________________ 0817 Bool_t TSQLDatabaseMetaData::StoresLowerCaseQuotedIdentifiers() 0818 { 0819 // Does the database treat mixed case quoted SQL identifiers 0820 // as case insensitive and store them in lower case? 0821 // 0822 // Returns: 0823 // kTRUE if so; kFALSE otherwise 0824 // Throws: 0825 // TSQLException - if a database access error occurs 0826 0827 return kFALSE; 0828 } 0829 0830 //___________________________________________________________________ 0831 Bool_t TSQLDatabaseMetaData::StoresMixedCaseQuotedIdentifiers() 0832 { 0833 // Does the database treat mixed case quoted SQL identifiers 0834 // as case insensitive and store them in mixed case? 0835 // 0836 // Returns: 0837 // kTRUE if so; kFALSE otherwise 0838 // Throws: 0839 // TSQLException - if a database access error occurs 0840 0841 return kFALSE; 0842 } 0843 0844 //___________________________________________________________________ 0845 TString TSQLDatabaseMetaData::GetIdentifierQuoteString() 0846 { 0847 // What's the string used to quote SQL identifiers? 0848 // This returns a space " " if identifier quoting isn't supported. 0849 // A SQL-92 Full level-conformant driver always uses a double 0850 // quote character ("). 0851 // 0852 // Returns: 0853 // the quoting string 0854 // Throws: 0855 // TSQLException - if a database access error occurs 0856 // 0857 // ... more comments based on "ODBC 3.5 Developer's Guide" 0858 // 0859 // Identifies the character tht is to be used as the starting and 0860 // ending delimeter of a quoted(delimetered) identifier in SQL 0861 // statements. (Identifiers passed in ODBC function parameters 0862 // do not need to be quoted) This character can also be used for 0863 // quoting catalog function parameters when ... 0864 // 0865 // If the data source does not support quoted identifiers, 0866 // a blank string (" ") is returned 0867 // 0868 0869 return using323() ? "`" : " "; 0870 } 0871 0872 //___________________________________________________________________ 0873 TString TSQLDatabaseMetaData::GetSQLKeywords() 0874 { 0875 // Gets a comma-separated list of all a database's SQL keywords 0876 // that are NOT also SQL92 keywords. 0877 // 0878 // Throws: 0879 // TSQLException - if a database access error occurs 0880 // 0881 // See also <http://mysql.com/doc///E/x/Extensions_to_ANSI.html> 0882 0883 // stolen from MyODBC-2.50.36/info.c 0884 TString str = "UNIQUE,ZEROFILL,UNSIGNED,BIGINT,BLOB,TINYBLOB,MEDIMUMBLOB," 0885 "LONGBLOB,MEDIUMINT,PROCEDURE,SHOW,LIMIT,DEFAULT,TABLES," 0886 "REGEXP,RLIKE,KEYS,TINYTEXT,MEDIUMTEXT"; 0887 return str; 0888 } 0889 0890 //___________________________________________________________________ 0891 TString TSQLDatabaseMetaData::GetNumericFunctions() 0892 { 0893 // Gets a comma-separated list of math functions. 0894 // These are the X/Open CLI math function names used in the ODBC 0895 // function escape clause. 0896 // 0897 // Returns: 0898 // the list 0899 // Throws: 0900 // TSQLException - if a database access error occurs 0901 0902 TString str = "ABS,ACOS,ASIN,ATAN,ATAN2,BIT_COUNT,CEILING,COS,COT," 0903 "DEGREES,EXP,FLOOR,LOG,LOG10,MAX,MIN,MOD,PI,POW,POWER," 0904 "RADIANS,RAND,ROUND,SIN,SQRT,TAN,TRUNCATE"; 0905 return str; 0906 } 0907 0908 //___________________________________________________________________ 0909 TString TSQLDatabaseMetaData::GetStringFunctions() 0910 { 0911 // Gets a comma-separated list of string functions. 0912 // These are the X/Open CLI string function names used in the 0913 // ODBC function escape clause. 0914 // 0915 // Returns: 0916 // the list 0917 // Throws: 0918 // TSQLException - if a database access error occurs 0919 0920 TString str = "ASCII,CHAR,CHAR_LENGTH,CHARACTER_LENGTH,CONCAT," 0921 "ELT,FIELD,FIND_IN_SET,INSERT,INSTR,INTERVAL," 0922 "LCASE,LEFT,LENGTH,LOCATE,LOWER,LTRIM,MID,POSITION," 0923 "OCTET_LENGTH,REPEAT,REPLACE,REVERSE,RIGHT,RTRIM," 0924 "SPACE,SOUNDEX,SUBSTRING,SUBSTRING_INDEX,TRIM," 0925 "UCASE,UPPER"; 0926 return str; 0927 } 0928 0929 //___________________________________________________________________ 0930 TString TSQLDatabaseMetaData::GetSystemFunctions() 0931 { 0932 // Gets a comma-separated list of system functions. 0933 // These are the X/Open CLI system function names used in the 0934 // ODBC function escape clause. 0935 // 0936 // Returns: 0937 // the list 0938 // Throws: 0939 // TSQLException - if a database access error occurs 0940 0941 TString str = "DATABASE,USER,SYSTEM_USER,SESSION_USER," 0942 "PASSWORD,ENCRYPT,LAST_INSERT_ID,VERSION"; 0943 return str; 0944 } 0945 0946 //___________________________________________________________________ 0947 TString TSQLDatabaseMetaData::GetTimeDateFunctions() 0948 { 0949 // Gets a comma-separated list of time and date functions. 0950 // 0951 // Returns: 0952 // the list 0953 // Throws: 0954 // TSQLException - if a database access error occurs 0955 0956 TString str = "DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH," 0957 "DAYNAME,MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE," 0958 "SECOND,PERIOD_ADD,PERIOD_DIFF,TO_DAYS,FROM_DAYS," 0959 "DATE_FORMAT,TIME_FORMAT,CURDATE,CURRENT_DATE," 0960 "CURTIME,CURRENT_TIME,NOW,SYSDATE,CURRENT_TIMESTAMP," 0961 "UNIX_TIMESTAMP,FROM_UNIXTIME,SEC_TO_TIME,TIME_TO_SEC"; 0962 0963 return str; 0964 } 0965 0966 //___________________________________________________________________ 0967 TString TSQLDatabaseMetaData::GetSearchStringEscape() 0968 { 0969 // Gets the string that can be used to escape wildcard characters. 0970 // This is the string that can be used to escape '_' or '%' in 0971 // the string pattern style catalog search parameters. 0972 // 0973 // The '_' character represents any single character. 0974 // 0975 // The '%' character represents any sequence of zero or more 0976 // characters. 0977 // 0978 // Returns: 0979 // the string used to escape wildcard characters 0980 // Throws: 0981 // TSQLException - if a database access error occurs 0982 // 0983 // ... more comments based on "ODBC 3.5 Developer's Guide" 0984 // 0985 // If driver does not provide a search-pattern escape character, 0986 // there is no specified limit, or if limit is unknown, an 0987 // empt string (" ") is returned. 0988 0989 return "\\"; 0990 } 0991 0992 //___________________________________________________________________ 0993 TString TSQLDatabaseMetaData::GetExtraNameCharacters() 0994 { 0995 // Gets all the "extra" characters that can be used in unquoted 0996 // identifier names ( those beyond a-z, A-Z, 0-9 and _ ), 0997 // for example, a table, column or index name. 0998 // 0999 // Returns: 1000 // the string containing the extra characters 1001 // Throws: 1002 // TSQLException - if a database access error occurs 1003 1004 return (char*)gAllowedChars; // 1005 } 1006 1007 //___________________________________________________________________ 1008 Bool_t TSQLDatabaseMetaData::SupportsAlterTableWithAddColumn() 1009 { 1010 // Is "ALTER TABLE" with add column supported? 1011 // 1012 // Returns: 1013 // kTRUE if so; kFALSE otherwise 1014 // Throws: 1015 // TSQLException - if a database access error occurs 1016 1017 Bool_t return_value = kTRUE; 1018 return return_value; 1019 } 1020 1021 //___________________________________________________________________ 1022 Bool_t TSQLDatabaseMetaData::SupportsAlterTableWithDropColumn() 1023 { 1024 // Is "ALTER TABLE" with drop column supported? 1025 // 1026 // Returns: 1027 // kTRUE if so; kFALSE otherwise 1028 // Throws: 1029 // TSQLException - if a database access error occurs 1030 1031 Bool_t return_value = kTRUE; 1032 return return_value; 1033 } 1034 1035 //___________________________________________________________________ 1036 Bool_t TSQLDatabaseMetaData::SupportsColumnAliasing() 1037 { 1038 // Is column aliasing supported? 1039 // 1040 // If so, the SQL "AS" clause can be used to provide names 1041 // for computed columns or to provide alias names for columns 1042 // as required. A SQL-92 entry level-conformant driver always 1043 // returns kTRUE. 1044 // 1045 // Returns: 1046 // kTRUE if so; kFALSE otherwise 1047 // Throws: 1048 // TSQLException - if a database access error occurs 1049 1050 Bool_t return_value = kTRUE; 1051 return return_value; 1052 } 1053 1054 //___________________________________________________________________ 1055 Bool_t TSQLDatabaseMetaData::NullPlusNonNullIsNull() 1056 { 1057 // Are concatenations between NULL and non-NULL values NULL? 1058 // A SQL-92 entry level-conformant driver always returns kTRUE. 1059 // 1060 // Returns: 1061 // kTRUE if so; kFALSE otherwise 1062 // Throws: 1063 // TSQLException - if a database access error occurs 1064 1065 Bool_t return_value = kTRUE; 1066 return return_value; 1067 } 1068 1069 //___________________________________________________________________ 1070 Bool_t TSQLDatabaseMetaData::SupportsConvert() 1071 { 1072 // Is the CONVERT function between SQL types supported? 1073 // 1074 // Returns: 1075 // kTRUE if so; kFALSE otherwise 1076 // Throws: 1077 // TSQLException - if a database access error occurs 1078 1079 return kFALSE; 1080 } 1081 1082 //___________________________________________________________________ 1083 Bool_t TSQLDatabaseMetaData::SupportsConvert( Int_t fromType, 1084 Int_t toType ) 1085 { 1086 // Is CONVERT between the given SQL types supported? 1087 // 1088 // Parameters: 1089 // fromType - the type to convert from 1090 // toType - the type to convert to 1091 // 1092 // Returns: 1093 // kTRUE if so; kFALSE otherwise 1094 // Throws: 1095 // TSQLException - if a database access error occurs 1096 // See Also: 1097 // TSQLTypes.h 1098 // 1099 // 1100 // ... more comments based on "ODBC 3.5 Developer's Guide" 1101 // 1102 // Identifiers whether the specified data type conversion 1103 // is supported by the data source and the CONVERT() 1104 // scalar function. For example, to find out if a data 1105 // source supports the conversion of a SQL_INTEGER data 1106 // type to an SQL_BIGINT data type, an application calls 1107 // SupportsConvert(kINTEGER,kBIGINT) 1108 // If the resulting value is kTRUE, the data type conversion 1109 // is supported. 1110 1111 switch (fromType) { 1112 1113 // The char/binary types can be converted to pretty much anything. 1114 case kCHAR: 1115 case kVARCHAR: 1116 case kLONGVARCHAR: 1117 case kBINARY: 1118 case kVARBINARY: 1119 case kLONGVARBINARY: 1120 1121 switch (toType) { 1122 case kDECIMAL: 1123 case kNUMERIC: 1124 case kREAL: 1125 case kTINYINT: 1126 case kSMALLINT: 1127 case kINTEGER: 1128 case kBIGINT: 1129 case kFLOAT: 1130 case kDOUBLE: 1131 case kCHAR: 1132 case kVARCHAR: 1133 case kLONGVARCHAR: 1134 case kBINARY: 1135 case kVARBINARY: 1136 case kLONGVARBINARY: 1137 case kOTHER: 1138 case kDATE: 1139 case kTIME: 1140 case kTIMESTAMP: 1141 return kTRUE; 1142 default: 1143 return kFALSE; 1144 } 1145 1146 // We don't handle the BIT type yet. 1147 case kBIT: 1148 return kFALSE; 1149 1150 // The numeric types. Basically they can convert 1151 // among themselves, and with char/binary types. 1152 1153 case kDECIMAL: 1154 case kNUMERIC: 1155 case kREAL: 1156 case kTINYINT: 1157 case kSMALLINT: 1158 case kINTEGER: 1159 case kBIGINT: 1160 case kFLOAT: 1161 case kDOUBLE: 1162 1163 switch (toType) { 1164 case kDECIMAL: 1165 case kNUMERIC: 1166 case kREAL: 1167 case kTINYINT: 1168 case kSMALLINT: 1169 case kINTEGER: 1170 case kBIGINT: 1171 case kFLOAT: 1172 case kDOUBLE: 1173 case kCHAR: 1174 case kVARCHAR: 1175 case kLONGVARCHAR: 1176 case kBINARY: 1177 case kVARBINARY: 1178 case kLONGVARBINARY: 1179 return kTRUE; 1180 default: 1181 return kFALSE; 1182 } 1183 1184 // MySQL doesn't support a NULL type. 1185 case kNULL: 1186 return kFALSE; 1187 1188 case kOTHER: 1189 1190 switch (toType) { 1191 case kCHAR: 1192 case kVARCHAR: 1193 case kLONGVARCHAR: 1194 case kBINARY: 1195 case kVARBINARY: 1196 case kLONGVARBINARY: 1197 return kTRUE; 1198 default: 1199 return kFALSE; 1200 } 1201 1202 // Dates can be converted to char/binary types. 1203 case kDATE: 1204 1205 switch (toType) { 1206 case kCHAR: 1207 case kVARCHAR: 1208 case kLONGVARCHAR: 1209 case kBINARY: 1210 case kVARBINARY: 1211 case kLONGVARBINARY: 1212 return kTRUE; 1213 default: 1214 return kFALSE; 1215 } 1216 1217 // Time can be converted to char/binary types 1218 case kTIME: 1219 switch (toType) { 1220 case kCHAR: 1221 case kVARCHAR: 1222 case kLONGVARCHAR: 1223 case kBINARY: 1224 case kVARBINARY: 1225 case kLONGVARBINARY: 1226 return kTRUE; 1227 default: 1228 return kFALSE; 1229 } 1230 1231 // Timestamp can be converted to char/binary types 1232 // and date/time types (with loss of precision). 1233 case kTIMESTAMP: 1234 switch (toType) { 1235 case kCHAR: 1236 case kVARCHAR: 1237 case kLONGVARCHAR: 1238 case kBINARY: 1239 case kVARBINARY: 1240 case kLONGVARBINARY: 1241 case kTIME: 1242 case kDATE: 1243 return kTRUE; 1244 default: 1245 return kFALSE; 1246 } 1247 1248 // We shouldn't get here! 1249 default: 1250 return kFALSE; // not sure 1251 } 1252 } 1253 1254 //___________________________________________________________________ 1255 Bool_t TSQLDatabaseMetaData::SupportsTableCorrelationNames() 1256 { 1257 // Are table correlation names supported? 1258 // A SQL-92 entry level-conformant driver always returns kTRUE. 1259 // 1260 // Returns: 1261 // kTRUE if so; kFALSE otherwise 1262 // Throws: 1263 // TSQLException - if a database access error occurs 1264 1265 Bool_t return_value = kTRUE; 1266 return return_value; 1267 } 1268 1269 //___________________________________________________________________ 1270 Bool_t TSQLDatabaseMetaData::SupportsDifferentTableCorrelationNames() 1271 { 1272 // If table correlation names are supported, are they restricted 1273 // to be different from the names of the tables? 1274 // 1275 // Returns: 1276 // kTRUE if so; kFALSE otherwise 1277 // Throws: 1278 // TSQLException - if a database access error occurs 1279 1280 Bool_t return_value = kTRUE; 1281 return return_value; 1282 } 1283 1284 //___________________________________________________________________ 1285 Bool_t TSQLDatabaseMetaData::SupportsExpressionsInOrderBy() 1286 { 1287 // Are expressions in "ORDER BY" lists supported? 1288 // 1289 // Returns: 1290 // kTRUE if so; kFALSE otherwise 1291 // Throws: 1292 // TSQLException - if a database access error occurs 1293 1294 Bool_t return_value = kTRUE; 1295 return return_value; 1296 } 1297 1298 //___________________________________________________________________ 1299 Bool_t TSQLDatabaseMetaData::SupportsOrderByUnrelated() 1300 { 1301 // Can an "ORDER BY" clause use columns not in the 1302 // SELECT statement? 1303 // 1304 // Returns: 1305 // kTRUE if so; kFALSE otherwise 1306 // Throws: 1307 // TSQLException - if a database access error occurs 1308 1309 Bool_t return_value = kTRUE; 1310 return return_value; 1311 } 1312 1313 //___________________________________________________________________ 1314 Bool_t TSQLDatabaseMetaData::SupportsGroupBy() 1315 { 1316 // Is some form of "GROUP BY" clause supported? 1317 // 1318 // Returns: 1319 // kTRUE if so; kFALSE otherwise 1320 // Throws: 1321 // TSQLException - if a database access error occurs 1322 1323 Bool_t return_value = kTRUE 1324 return return_value; 1325 } 1326 1327 //___________________________________________________________________ 1328 Bool_t TSQLDatabaseMetaData::SupportsGroupByUnrelated() 1329 { 1330 // Can a "GROUP BY" clause use columns not in the SELECT? 1331 // 1332 // For example, 1333 // SELECT DEPT,SALARY FROM EMPLOYEE GROUP BY DEPT,AGE 1334 // 1335 // Returns: 1336 // kTRUE if so; kFALSE otherwise 1337 // Throws: 1338 // TSQLException - if a database access error occurs 1339 1340 Bool_t return_value = kTRUE; 1341 return return_value; 1342 } 1343 1344 //___________________________________________________________________ 1345 Bool_t TSQLDatabaseMetaData::SupportsGroupByBeyondSelect() 1346 { 1347 // Can a "GROUP BY" clause add columns not in the SELECT provided 1348 // it specifies all the columns in the SELECT? 1349 // 1350 // For example, 1351 // SELECT DEPT,MAX(SALARY) FROM EMPLOYEE GROUP BY DEPT,AGE 1352 // 1353 // 1354 // Returns: 1355 // kTRUE if so; kFALSE otherwise 1356 // Throws: 1357 // TSQLException - if a database access error occurs 1358 1359 return kFALSE; 1360 } 1361 1362 //___________________________________________________________________ 1363 Bool_t TSQLDatabaseMetaData::SupportsLikeEscapeClause() 1364 { 1365 // Is the escape character in "LIKE" clauses supported? 1366 // A SQL-92 entry level-conformant driver always returns kTRUE. 1367 // 1368 // Returns: 1369 // kTRUE if so; kFALSE otherwise 1370 // Throws: 1371 // TSQLException - if a database access error occurs 1372 // 1373 1374 Bool_t return_value = kTRUE; 1375 return return_value; 1376 } 1377 1378 //___________________________________________________________________ 1379 Bool_t TSQLDatabaseMetaData::SupportsMultipleResultSets() 1380 { 1381 // Are multiple TSQLResultSets from a single execute supported? 1382 // 1383 // Returns: 1384 // kTRUE if so; kFALSE otherwise 1385 // Throws: 1386 // TSQLException - if a database access error occurs 1387 1388 Bool_t return_value = kTRUE; 1389 return return_value; 1390 } 1391 1392 //___________________________________________________________________ 1393 Bool_t TSQLDatabaseMetaData::SupportsMultipleTransactions() 1394 { 1395 // Can we have multiple transactions open at once (on different 1396 // connections)? 1397 // 1398 // Returns: 1399 // kTRUE if so; kFALSE otherwise 1400 // Throws: 1401 // TSQLException - if a database access error occurs 1402 1403 Bool_t return_value = kTRUE; 1404 return return_value; 1405 } 1406 1407 //___________________________________________________________________ 1408 Bool_t TSQLDatabaseMetaData::SupportsNonNullableColumns() 1409 { 1410 // Can columns be defined as non-nullable? 1411 // A SQL-92 entry level-conformant driver always returns kTRUE. 1412 // 1413 // Returns: 1414 // kTRUE if so; kFALSE otherwise 1415 // Throws: 1416 // TSQLException - if a database access error occurs 1417 // 1418 // ... more comments based on "ODBC 3.5 Developer's Guide" 1419 // 1420 // Indicates whether the data source supports the "NOT NULL" 1421 // column constraint in "CREATE TABLE" SQL statements 1422 // 1423 1424 Bool_t return_value = kTRUE; 1425 return return_value; 1426 } 1427 1428 //___________________________________________________________________ 1429 Bool_t TSQLDatabaseMetaData::SupportsMinimumSQLGrammar() 1430 { 1431 // Is the ODBC Minimum SQL grammar supported? 1432 // All SQL-92 entry level-conformant drivers must return kTRUE. 1433 // 1434 // Returns: 1435 // kTRUE if so; kFALSE otherwise 1436 // Throws: 1437 // TSQLException - if a database access error occurs 1438 1439 Bool_t return_value = kTRUE; 1440 return return_value; 1441 } 1442 1443 //___________________________________________________________________ 1444 Bool_t TSQLDatabaseMetaData::SupportsCoreSQLGrammar() 1445 { 1446 // Is the ODBC Core SQL grammar supported? 1447 // 1448 // Returns: 1449 // kTRUE if so; kFALSE otherwise 1450 // Throws: 1451 // TSQLException - if a database access error occurs 1452 1453 Bool_t return_value = kTRUE; 1454 return return_value; 1455 } 1456 1457 //___________________________________________________________________ 1458 Bool_t TSQLDatabaseMetaData::SupportsExtendedSQLGrammar() 1459 { 1460 // Is the Extended SQL grammar supported? 1461 // 1462 // Returns: 1463 // kTRUE if so; kFALSE otherwise 1464 // Throws: 1465 // TSQLException - if a database access error occurs 1466 1467 Bool_t return_value = kTRUE; 1468 return return_value; 1469 } 1470 1471 //___________________________________________________________________ 1472 Bool_t TSQLDatabaseMetaData::SupportsANSI92EntryLevelSQL() 1473 { 1474 // Is the ANSI92 entry level SQL grammar supported? 1475 // All SQL-92 entry level-conformant drivers must return kTRUE. 1476 // 1477 // Returns: 1478 // kTRUE if so; kFALSE otherwise 1479 // Throws: 1480 // TSQLException - if a database access error occurs 1481 1482 Bool_t return_value = kTRUE; // MyODBC says "Lie to make things work" 1483 return return_value; 1484 } 1485 1486 //___________________________________________________________________ 1487 Bool_t TSQLDatabaseMetaData::SupportsANSI92IntermediateSQL() 1488 { 1489 // Is the ANSI92 intermediate SQL grammar supported? 1490 // 1491 // Returns: 1492 // kTRUE if so; kFALSE otherwise 1493 // Throws: 1494 // TSQLException - if a database access error occurs 1495 1496 Bool_t return_value = kTRUE; // MyODBC says "Lie to make things work" 1497 return return_value; 1498 } 1499 1500 //___________________________________________________________________ 1501 Bool_t TSQLDatabaseMetaData::SupportsANSI92FullSQL() 1502 { 1503 // Is the ANSI92 full SQL grammar supported? 1504 // 1505 // Returns: 1506 // kTRUE if so; kFALSE otherwise 1507 // Throws: 1508 // TSQLException - if a database access error occurs 1509 1510 Bool_t return_value = kTRUE; // MyODBC says "Lie to make things work" 1511 return return_value; 1512 } 1513 1514 //___________________________________________________________________ 1515 Bool_t TSQLDatabaseMetaData::SupportsIntegrityEnhancementFacility() 1516 { 1517 // Is the SQL Integrity Enhancement Facility supported? 1518 // 1519 // Returns: 1520 // kTRUE if so; kFALSE otherwise 1521 // Throws: 1522 // TSQLException - if a database access error occurs 1523 1524 return kFALSE; 1525 } 1526 1527 //___________________________________________________________________ 1528 Bool_t TSQLDatabaseMetaData::SupportsOuterJoins() 1529 { 1530 // Is some form of outer join supported? 1531 // 1532 // Returns: 1533 // kTRUE if so; kFALSE otherwise 1534 // Throws: 1535 // TSQLException - if a database access error occurs 1536 1537 Bool_t return_value = kTRUE; 1538 return return_value; 1539 } 1540 1541 //___________________________________________________________________ 1542 Bool_t TSQLDatabaseMetaData::SupportsFullOuterJoins() 1543 { 1544 // Are full nested outer joins supported? 1545 // 1546 // Returns: 1547 // kTRUE if so; kFALSE otherwise 1548 // Throws: 1549 // TSQLException - if a database access error occurs 1550 1551 return kFALSE; 1552 } 1553 1554 //___________________________________________________________________ 1555 Bool_t TSQLDatabaseMetaData::SupportsLimitedOuterJoins() 1556 { 1557 // Is there limited support for outer joins? (This will be kTRUE 1558 // if SupportFullOuterJoins is kTRUE.) 1559 // 1560 // Returns: 1561 // kTRUE if so; kFALSE otherwise 1562 // Throws: 1563 // TSQLException - if a database access error occurs 1564 1565 Bool_t return_value = kTRUE; 1566 return return_value; 1567 } 1568 1569 //___________________________________________________________________ 1570 TString TSQLDatabaseMetaData::GetSchemaTerm() 1571 { 1572 // What's the database vendor's preferred term for "schema"? 1573 // 1574 // For example "owner",Authorization ID", or "Schema" 1575 // this string can be in upper, lower , or mixed case. 1576 // 1577 // An SQL-92 entry level-conformant driver returns "schema" 1578 // 1579 // Returns: 1580 // the vendor term 1581 // Throws: 1582 // TSQLException - if a database access error occurs 1583 1584 return "owner"; 1585 } 1586 1587 //___________________________________________________________________ 1588 TString TSQLDatabaseMetaData::GetTableTerm() 1589 { 1590 // What's the database vendor's preferred term for "table" 1591 // 1592 // An SQL-92 entry level-conformant driver returns "schema" 1593 // 1594 // Returns: 1595 // the vendor term 1596 // Throws: 1597 // TSQLException - if a database access error occurs 1598 1599 return "table"; 1600 } 1601 1602 //___________________________________________________________________ 1603 TString TSQLDatabaseMetaData::GetProcedureTerm() 1604 { 1605 // What's the database vendor's preferred term for a 1606 // stored procedure? 1607 // 1608 // For example,"database procedure","stored procedure", 1609 // "procedure","package", or "stored query" 1610 // 1611 // Returns: 1612 // the vendor term 1613 // Throws: 1614 // TSQLException - if a database access error occurs 1615 1616 return "procedure"; 1617 } 1618 1619 //___________________________________________________________________ 1620 TString TSQLDatabaseMetaData::GetCatalogTerm() 1621 { 1622 // What's the database vendor's preferred term for "catalog"? 1623 // 1624 // Can be for example "directory" or "database" 1625 // This string can be in upper, lower , or mixed case. 1626 // I catalogs are not supported by the data source, an empty 1627 // string ("") is returned. 1628 // 1629 // Returns: 1630 // the vendor term 1631 // Throws: 1632 // TSQLException - if a database access error occurs 1633 1634 return "database"; 1635 } 1636 1637 //___________________________________________________________________ 1638 Bool_t TSQLDatabaseMetaData::IsCatalogAtStart() 1639 { 1640 // Does a catalog appear at the start of a qualified table name? 1641 // (Otherwise it appears at the end) 1642 // 1643 // For example MySQL would say kTRUE, 1644 // dBASE driver also returns kTRUE because the directory (catalog) 1645 // name is at the start of the table name, a in \EMPDATA\EMP.DBF 1646 // An ORACLE Server driver returns kFALSE, because the catalog is 1647 // at the end of the table name as in ADMIN.EMP@EMPDATA 1648 // 1649 // Returns: 1650 // kTRUE if it appears at the start 1651 // Throws: 1652 // TSQLException - if a database access error occurs 1653 1654 Bool_t return_value = kTRUE; 1655 return return_value; 1656 } 1657 1658 //___________________________________________________________________ 1659 TString TSQLDatabaseMetaData::GetCatalogSeparator() 1660 { 1661 // What's the separator between catalog and table name? 1662 // 1663 // For example ORACLE would return a "@", while MySQL would say "." 1664 // If catalogs are not supported by the data source, an empty 1665 // string ("") is returned. 1666 // 1667 // An SQL-92 Full level conformant driver returns "." 1668 // 1669 // Returns: 1670 // the separator string 1671 // Throws: 1672 // TSQLException - if a database access error occurs 1673 1674 return "."; 1675 } 1676 1677 //___________________________________________________________________ 1678 Bool_t TSQLDatabaseMetaData::SupportsSchemasInDataManipulation() 1679 { 1680 // Can a schema name be used in a data manipulation statement? 1681 // 1682 // Returns: 1683 // kTRUE if so; kFALSE otherwise 1684 // Throws: 1685 // TSQLException - if a database access error occurs 1686 // 1687 // ... more comments based on "ODBC 3.5 Developer's Guide" 1688 // 1689 // Returns kTRUE if schemas are supported in all Data 1690 // Manipulation Language (DML) statements: 1691 // SELECT,INSERT,UPDATE,DELETE, and , if supported 1692 // SELECT FOR UPDATE and positioned UPDATE and DELETE 1693 // statements. 1694 // 1695 // An SQL-92 entry level-conformant driver returns kTRUE. 1696 1697 Bool_t return_value = kFALSE; 1698 return return_value; 1699 } 1700 1701 //___________________________________________________________________ 1702 Bool_t TSQLDatabaseMetaData::SupportsSchemasInProcedureCalls() 1703 { 1704 // Can a schema name be used in a procedure call statement? 1705 // 1706 // Returns: 1707 // kTRUE if so; kFALSE otherwise 1708 // Throws: 1709 // TSQLException - if a database access error occurs 1710 1711 return kFALSE; 1712 } 1713 1714 //___________________________________________________________________ 1715 Bool_t TSQLDatabaseMetaData::SupportsSchemasInTableDefinitions() 1716 { 1717 // Can a schema name be used in a table definition statement? 1718 // 1719 // Returns: 1720 // kTRUE if so; kFALSE otherwise 1721 // Throws: 1722 // TSQLException - if a database access error occurs 1723 // 1724 // Returns kTRUE if schemas are supported in all table 1725 // definition statements: CREATE TABLE,CREATE VIEW, 1726 // ALTER TABLE, DROP TABLE and DROP VIEW 1727 // 1728 // An SQL-92 entry level-conformant driver returns kTRUE. 1729 1730 return kFALSE; 1731 } 1732 1733 //___________________________________________________________________ 1734 Bool_t TSQLDatabaseMetaData::SupportsSchemasInIndexDefinitions() 1735 { 1736 // Can a schema name be used in an index definition statement? 1737 // 1738 // Returns: 1739 // kTRUE if so; kFALSE otherwise 1740 // Throws: 1741 // TSQLException - if a database access error occurs 1742 // 1743 // Returns kTRUE if schemas are supported in all index 1744 // definition statements: CREATE INDEX and DROP INDEX 1745 1746 return kFALSE; 1747 } 1748 1749 //___________________________________________________________________ 1750 Bool_t TSQLDatabaseMetaData::SupportsSchemasInPrivilegeDefinitions() 1751 { 1752 // Can a schema name be used in a privilege definition statement? 1753 // 1754 // Returns: 1755 // kTRUE if so; kFALSE otherwise 1756 // Throws: 1757 // TSQLException - if a database access error occurs 1758 // 1759 // Returns kTRUE if schemas are supported in all privelege 1760 // definition statements: GRANT and REVOKE 1761 // 1762 // An SQL-92 entry level-conformant driver returns kTRUE. 1763 1764 return kFALSE; 1765 } 1766 1767 //___________________________________________________________________ 1768 Bool_t TSQLDatabaseMetaData::SupportsCatalogsInDataManipulation() 1769 { 1770 // Can a catalog name be used in a data manipulation statement? 1771 // 1772 // Returns: 1773 // kTRUE if so; kFALSE otherwise 1774 // Throws: 1775 // TSQLException - if a database access error occurs 1776 // 1777 // ... more comments based on "ODBC 3.5 Developer's Guide" 1778 // 1779 // Returns kTRUE if catalog names can be used in all Data 1780 // Manipulation Language (DML) statements: 1781 // SELECT,INSERT,UPDATE,DELETE, and , if supported 1782 // SELECT FOR UPDATE and positioned UPDATE and DELETE 1783 // statements. 1784 // 1785 // An SQL-92 Full level-conformant driver returns kTRUE 1786 1787 // Servers before 3.22 could not do this 1788 if (_Conn.getServerMajorVersion() >= 3) { // newer than version 3? 1789 if (_Conn.getServerMajorVersion() == 3) { 1790 if (_Conn.getServerMinorVersion() >= 22) { // minor 22? 1791 return true; 1792 } 1793 else { 1794 return false; // Old version 3 1795 } 1796 } 1797 else { 1798 return true; // newer than version 3.22 1799 } 1800 } 1801 else { 1802 return false; // older than version 3 1803 } 1804 1805 } 1806 1807 //___________________________________________________________________ 1808 Bool_t TSQLDatabaseMetaData::SupportsCatalogsInProcedureCalls() 1809 { 1810 // Can a catalog name be used in a procedure call statement? 1811 // 1812 // Returns: 1813 // kTRUE if so; kFALSE otherwise 1814 // Throws: 1815 // TSQLException - if a database access error occurs 1816 // 1817 // An SQL-92 Full level-conformant driver returns kTRUE 1818 1819 return kFALSE; 1820 } 1821 1822 //___________________________________________________________________ 1823 Bool_t TSQLDatabaseMetaData::SupportsCatalogsInTableDefinitions() 1824 { 1825 // Can a catalog name be used in a table definition statement? 1826 // 1827 // Returns: 1828 // kTRUE if so; kFALSE otherwise 1829 // Throws: 1830 // TSQLException - if a database access error occurs 1831 // 1832 // Returns kTRUE if catalog names can be used in all table 1833 // definition statements: CREATE TABLE,CREATE VIEW, 1834 // ALTER TABLE, DROP TABLE and DROP VIEW 1835 1836 Bool_t return_value = kFALSE; 1837 return return_value; 1838 } 1839 1840 //___________________________________________________________________ 1841 Bool_t TSQLDatabaseMetaData::SupportsCatalogsInIndexDefinitions() 1842 { 1843 // Can a catalog name be used in an index definition statement? 1844 // 1845 // Returns: 1846 // kTRUE if so; kFALSE otherwise 1847 // Throws: 1848 // TSQLException - if a database access error occurs 1849 // 1850 // Returns kTRUE if catalog names can be used in all index 1851 // definition statements: CREATE INDEX and DROP INDEX 1852 // 1853 // An SQL-92 Full level-conformant driver returns kTRUE. 1854 1855 return kFALSE; 1856 } 1857 1858 //___________________________________________________________________ 1859 Bool_t TSQLDatabaseMetaData::SupportsCatalogsInPrivilegeDefinitions() 1860 { 1861 // Can a catalog name be used in a privilege definition statement? 1862 // 1863 // Returns: 1864 // kTRUE if so; kFALSE otherwise 1865 // Throws: 1866 // TSQLException - if a database access error occurs 1867 // 1868 // Returns kTRUE if catalog names can be used in all privelege 1869 // definition statements: GRANT and REVOKE 1870 // 1871 // An SQL-92 Full level-conformant driver returns kTRUE 1872 1873 return kFALSE; 1874 } 1875 1876 //___________________________________________________________________ 1877 Bool_t TSQLDatabaseMetaData::SupportsPositionedDelete() 1878 { 1879 // Is positioned DELETE supported? 1880 // 1881 // Returns: 1882 // kTRUE if so; kFALSE otherwise 1883 // Throws: 1884 // TSQLException - if a database access error occurs 1885 1886 return kFALSE; 1887 } 1888 1889 //___________________________________________________________________ 1890 Bool_t TSQLDatabaseMetaData::SupportsPositionedUpdate() 1891 { 1892 // Is positioned UPDATE supported? 1893 // 1894 // Returns: 1895 // kTRUE if so; kFALSE otherwise 1896 // Throws: 1897 // TSQLException - if a database access error occurs 1898 1899 return kFALSE; 1900 } 1901 1902 //___________________________________________________________________ 1903 Bool_t TSQLDatabaseMetaData::SupportsSelectForUpdate() 1904 { 1905 // Is SELECT for UPDATE supported? 1906 // 1907 // Returns: 1908 // kTRUE if so; kFALSE otherwise 1909 // Throws: 1910 // TSQLException - if a database access error occurs 1911 1912 return kFALSE; 1913 } 1914 1915 //___________________________________________________________________ 1916 Bool_t TSQLDatabaseMetaData::SupportsStoredProcedures() 1917 { 1918 // Are stored procedure calls using the stored procedure escape 1919 // syntax supported? 1920 // 1921 // Returns: 1922 // kTRUE if so; kFALSE otherwise 1923 // Throws: 1924 // TSQLException - if a database access error occurs 1925 1926 return kFALSE; 1927 } 1928 1929 //___________________________________________________________________ 1930 Bool_t TSQLDatabaseMetaData::SupportsSubqueriesInComparisons() 1931 { 1932 // Are subqueries in comparison expressions supported? 1933 // A SQL-92 entry level-conformant driver always returns kTRUE. 1934 // 1935 // Returns: 1936 // kTRUE if so; kFALSE otherwise 1937 // Throws: 1938 // TSQLException - if a database access error occurs 1939 1940 Bool_t return_value = kTRUE; 1941 return return_value; 1942 } 1943 1944 //___________________________________________________________________ 1945 Bool_t TSQLDatabaseMetaData::SupportsSubqueriesInExists() 1946 { 1947 // Are subqueries in EXISTS expressions supported? 1948 // A SQL-92 entry level-conformant driver always returns kTRUE. 1949 // 1950 // Returns: 1951 // kTRUE if so; kFALSE otherwise 1952 // Throws: 1953 // TSQLException - if a database access error occurs 1954 1955 return kFALSE; 1956 } 1957 1958 //___________________________________________________________________ 1959 Bool_t TSQLDatabaseMetaData::SupportsSubqueriesInIns() 1960 { 1961 // Are subqueries in IN statements supported? 1962 // A SQL-92 entry level-conformant driver always returns kTRUE. 1963 // 1964 // Returns: 1965 // kTRUE if so; kFALSE otherwise 1966 // Throws: 1967 // TSQLException - if a database access error occurs 1968 1969 return kFALSE; 1970 } 1971 1972 //___________________________________________________________________ 1973 Bool_t TSQLDatabaseMetaData::SupportsSubqueriesInQuantifieds() 1974 { 1975 // Are subqueries in quantified expressions supported? 1976 // A SQL-92 entry level-conformant driver always returns kTRUE. 1977 // 1978 // Returns: 1979 // kTRUE if so; kFALSE otherwise 1980 // Throws: 1981 // TSQLException - if a database access error occurs 1982 1983 return kFALSE 1984 } 1985 1986 //___________________________________________________________________ 1987 Bool_t TSQLDatabaseMetaData::SupportsCorrelatedSubqueries() 1988 { 1989 // Are correlated subqueries supported? 1990 // A SQL-92 entry level-conformant driver always returns kTRUE. 1991 // 1992 // Returns: 1993 // kTRUE if so; kFALSE otherwise 1994 // Throws: 1995 // TSQLException - if a database access error occurs 1996 1997 return kFALSE 1998 } 1999 2000 //___________________________________________________________________ 2001 Bool_t TSQLDatabaseMetaData::SupportsUnion() 2002 { 2003 // Is SQL UNION supported? 2004 // A SQL-92 entry level-conformant driver always returns kTRUE. 2005 // 2006 // Returns: 2007 // kTRUE if so; kFALSE otherwise 2008 // Throws: 2009 // TSQLException - if a database access error occurs 2010 2011 return kFALSE; 2012 } 2013 2014 //___________________________________________________________________ 2015 Bool_t TSQLDatabaseMetaData::SupportsUnionAll() 2016 { 2017 // Is SQL UNION ALL supported? 2018 // A SQL-92 entry level-conformant driver always returns kTRUE. 2019 // 2020 // Returns: 2021 // kTRUE if so; kFALSE otherwise 2022 // Throws: 2023 // TSQLException - if a database access error occurs 2024 2025 return kFALSE; 2026 } 2027 2028 //___________________________________________________________________ 2029 Bool_t TSQLDatabaseMetaData::SupportsOpenCursorsAcrossCommit() 2030 { 2031 // Can cursors remain open across commits? 2032 // 2033 // Returns kTRUE if the data source and the driver can handle 2034 // open cursors (eg. TSQLResultSets) across a commit, or kFALSE 2035 // if they are invalidated. 2036 // 2037 // Returns: 2038 // kTRUE if cursors always remain open; 2039 // kFALSE if they might not remain open 2040 // Throws: 2041 // TSQLException - if a database access error occurs 2042 // 2043 // ... more comments based on "ODBC 3.5 Developer's Guide" 2044 // 2045 // Returns kTRUE if cursors and access plans for prepared SQL 2046 // statements reamin as they were before the COMMIT operation 2047 // ( see TSQLConnection::Commit() method ) was performed. 2048 // The application can continue to fetch data or it can close 2049 // cursor and re-execute SQL statement without having to 2050 // re-prepare it. 2051 // 2052 2053 return kFALSE; 2054 } 2055 2056 //___________________________________________________________________ 2057 Bool_t TSQLDatabaseMetaData::SupportsOpenCursorsAcrossRollback() 2058 { 2059 // Can cursors remain open across rollbacks? 2060 // 2061 // Returns kTRUE if the data source and the driver can handle 2062 // open cursors (eg. TSQLResultSet s) across a rollback, or kFALSE 2063 // if they are invalidated. 2064 // 2065 // Returns: 2066 // kTRUE if cursors always remain open; 2067 // kFALSE if they might not remain open 2068 // Throws: 2069 // TSQLException - if a database access error occurs 2070 // 2071 // ... more comments based on "ODBC 3.5 Developer's Guide" 2072 // 2073 // Returns kTRUE if cursors and access plans for prepared SQL 2074 // statements reamin as they were before the ROLLBACK operation 2075 // ( see TSQLConnection::Rollback() method ) was performed. 2076 // The application can continue to fetch data or it can close 2077 // cursor and re-execute SQL statement without having to 2078 // re-prepare it. 2079 // 2080 2081 return kFALSE; 2082 } 2083 2084 //___________________________________________________________________ 2085 Bool_t TSQLDatabaseMetaData::SupportsOpenStatementsAcrossCommit() 2086 { 2087 // Can statements remain open across commits? 2088 // 2089 // Returns kTRUE if the data source and the driver can handle 2090 // open statements across a commit, or kFALSE if 2091 // they are invalidated. 2092 // 2093 // Returns: 2094 // kTRUE if statements always remain open; 2095 // kFALSE if they might not remain open 2096 // Throws: 2097 // TSQLException - if a database access error occurs 2098 2099 return kFALSE; 2100 } 2101 2102 //___________________________________________________________________ 2103 Bool_t TSQLDatabaseMetaData::SupportsOpenStatementsAcrossRollback() 2104 { 2105 // Can statements remain open across rollbacks? 2106 // 2107 // Returns kTRUE if the data source and the driver can handle 2108 // open statements across a rollback, or kFALSE if 2109 // they are invalidated. 2110 // 2111 // Returns: 2112 // kTRUE if statements always remain open; 2113 // kFALSE if they might not remain open 2114 // Throws: 2115 // TSQLException - if a database access error occurs 2116 2117 return kFALSE; 2118 } 2119 2120 //___________________________________________________________________ 2121 Int_t TSQLDatabaseMetaData::GetMaxBinaryLiteralLength() 2122 { 2123 // How many hex characters can you have in an inline binary 2124 // literal (number of hexadecimal characters, exluding the 2125 // literal prefix and suffix ) ? For example the binary 2126 // literal 0xFFAA has a length of 4. 2127 // 2128 // Returns: 2129 // max binary literal length in hex characters; a result 2130 // of zero means that thereis no limit or the limit is 2131 // not known 2132 // Throws: 2133 // TSQLException - if a database access error occurs 2134 2135 return gMaxLiteralLength; 2136 } 2137 2138 //___________________________________________________________________ 2139 Int_t TSQLDatabaseMetaData::GetMaxCharLiteralLength() 2140 { 2141 // What's the max length for a character literal 2142 // (number of characters, exluding the literal prefix 2143 // and suffix ) ? 2144 // 2145 // Returns: 2146 // max literal length; a result of zero means that 2147 // there is no limit or the limit is not known 2148 // Throws: 2149 // TSQLException - if a database access error occurs 2150 2151 return gMaxLiteralLength; 2152 } 2153 2154 //___________________________________________________________________ 2155 Int_t TSQLDatabaseMetaData::GetMaxColumnNameLength() 2156 { 2157 // What's the limit on column name length? 2158 // 2159 // Returns: 2160 // max column name length; a result of zero means that 2161 // there is no limit or the limit is not known 2162 // Throws: 2163 // TSQLException - if a database access error occurs 2164 // 2165 // See also <http://mysql.com/doc///L/e/Legal_names.html> 2166 2167 return gMaxColumnNameLength; 2168 } 2169 2170 //___________________________________________________________________ 2171 Int_t TSQLDatabaseMetaData::GetMaxColumnsInGroupBy() 2172 { 2173 // What's the maximum number of columns in a "GROUP BY" clause? 2174 // 2175 // Returns: 2176 // max number of columns; a result of zero means that 2177 // there is no limit or the limit is not known 2178 // Throws: 2179 // TSQLException - if a database access error occurs 2180 2181 return 16; 2182 } 2183 2184 //___________________________________________________________________ 2185 Int_t TSQLDatabaseMetaData::GetMaxColumnsInIndex() 2186 { 2187 // What's the maximum number of columns allowed in an index? 2188 // 2189 // Returns: 2190 // max number of columns; a result of zero means that 2191 // there is no limit or the limit is not known 2192 // Throws: 2193 // TSQLException - if a database access error occurs 2194 // 2195 // See also <http://mysql.com/doc///M/u/Multiple-column_indexes.html> 2196 2197 return 16; 2198 } 2199 2200 //___________________________________________________________________ 2201 Int_t TSQLDatabaseMetaData::GetMaxColumnsInOrderBy() 2202 { 2203 // What's the maximum number of columns in an "ORDER BY" clause? 2204 // 2205 // Returns: 2206 // max number of columns; a result of zero means that 2207 // there is no limit or the limit is not known 2208 // Throws: 2209 // TSQLException - if a database access error occurs 2210 2211 return 16; 2212 } 2213 2214 //___________________________________________________________________ 2215 Int_t TSQLDatabaseMetaData::GetMaxColumnsInSelect() 2216 { 2217 // What's the maximum number of columns in a "SELECT" list? 2218 // 2219 // Returns: 2220 // max number of columns; a result of zero means that 2221 // there is no limit or the limit is not known 2222 // Throws: 2223 // TSQLException - if a database access error occurs 2224 2225 return 256; 2226 } 2227 2228 //___________________________________________________________________ 2229 Int_t TSQLDatabaseMetaData::GetMaxColumnsInTable() 2230 { 2231 // What's the maximum number of columns in a table? 2232 // 2233 // Returns: 2234 // max number of columns; a result of zero means that 2235 // there is no limit or the limit is not known 2236 // Throws: 2237 // TSQLException - if a database access error occurs 2238 2239 return 32; 2240 } 2241 2242 //___________________________________________________________________ 2243 Int_t TSQLDatabaseMetaData::GetMaxConnections() 2244 { 2245 // How many active connections can we have at a time to this 2246 // database? This value can reflect a limitation imposed by 2247 // either the driver or the data source. 2248 // 2249 // Returns: 2250 // max number of active connections; a result of zero 2251 // means that there is no limit or the limit is not known 2252 // Throws: 2253 // TSQLException - if a database access error occurs 2254 2255 return 0; 2256 } 2257 2258 //___________________________________________________________________ 2259 Int_t TSQLDatabaseMetaData::GetMaxCursorNameLength() 2260 { 2261 // What's the maximum cursor name length? 2262 // 2263 // Returns: 2264 // max cursor name length in bytes; a result of zero means 2265 // that there is no limit or the limit is not known 2266 // Throws: 2267 // TSQLException - if a database access error occurs 2268 2269 return gMaxCursorNameLength; 2270 } 2271 2272 //___________________________________________________________________ 2273 Int_t TSQLDatabaseMetaData::GetMaxIndexLength() 2274 { 2275 // What's the maximum length of an index (in bytes)? 2276 // 2277 // Returns: 2278 // max index length in bytes; a result of zero means that 2279 // there is no limit or the limit is not known 2280 // Throws: 2281 // TSQLException - if a database access error occurs 2282 // 2283 // See also, <http://mysql.com/doc///I/n/Indexes.html> 2284 2285 return gMaxIndexLength; 2286 } 2287 2288 //___________________________________________________________________ 2289 Int_t TSQLDatabaseMetaData::GetMaxSchemaNameLength() 2290 { 2291 // What's the maximum length allowed for a schema name? 2292 // 2293 // Returns: 2294 // max name length in bytes; a result of zero means that 2295 // there is no limit or the limit is not known 2296 // Throws: 2297 // TSQLException - if a database access error occurs 2298 2299 return 0; 2300 } 2301 2302 //___________________________________________________________________ 2303 Int_t TSQLDatabaseMetaData::GetMaxProcedureNameLength() 2304 { 2305 // What's the maximum length of a procedure name? 2306 // 2307 // Returns: 2308 // max name length in bytes; a result of zero means that 2309 // there is no limit or the limit is not known 2310 // Throws: 2311 // TSQLException - if a database access error occurs 2312 2313 return 0; 2314 } 2315 2316 //___________________________________________________________________ 2317 Int_t TSQLDatabaseMetaData::GetMaxCatalogNameLength() 2318 { 2319 // What's the maximum length of a catalog name? 2320 // 2321 // Returns: 2322 // max name length in bytes; a result of zero means 2323 // that there is no limit or the limit is not known 2324 // Throws: 2325 // TSQLException - if a database access error occurs 2326 // 2327 // See also, <http://mysql.com/doc///L/e/Legal_names.html> 2328 2329 return gMaxDatabaseNameLength; 2330 } 2331 2332 //___________________________________________________________________ 2333 Int_t TSQLDatabaseMetaData::GetMaxRowSize() 2334 { 2335 // What's the maximum length of a single row? 2336 // 2337 // Returns: 2338 // max row size in bytes; a result of zero means 2339 // that there is no limit or the limit is not known 2340 // Throws: 2341 // TSQLException - if a database access error occurs 2342 2343 return 0; 2344 } 2345 2346 //___________________________________________________________________ 2347 Bool_t TSQLDatabaseMetaData::DoesMaxRowSizeIncludeBlobs() 2348 { 2349 // Did GetMaxRowSize() include LONGVARCHAR and LONGVARBINARY blobs? 2350 // 2351 // Returns: 2352 // kTRUE if so; kFALSE otherwise 2353 // Throws: 2354 // TSQLException - if a database access error occurs 2355 // 2356 2357 return kTRUE; 2358 } 2359 2360 //___________________________________________________________________ 2361 Int_t TSQLDatabaseMetaData::GetMaxStatementLength() 2362 { 2363 // What's the maximum length of a SQL statement? 2364 // 2365 // Returns: 2366 // max length in bytes; a result of zero means that there 2367 // is no limit or the limit is not known 2368 // Throws: 2369 // TSQLException - if a database access error occurs 2370 2371 return MySQLdefs::kMAXBUF - 4; // Max buffer - header 2372 } 2373 2374 //___________________________________________________________________ 2375 Int_t TSQLDatabaseMetaData::GetMaxStatements() 2376 { 2377 // How many active statements can we have open at one time to this 2378 // database? 2379 // 2380 // Returns: 2381 // the maximum number of statements that can be open at 2382 // one time; a result of zero means that there is no limit 2383 // or the limit is not known 2384 // Throws: 2385 // TSQLException - if a database access error occurs 2386 // 2387 // ... more comments based on "ODBC 3.5 Developer's Guide" 2388 // 2389 // Identifies the maximum number of active SQL statements 2390 // the driver can support for a connection. A statement is defined 2391 // as active if it has results pending, with the term results 2392 // meaning ows from a SELECT operation or rows affected by an 2393 // INSERT, UPDATE, or DELETE operation (such as a row count), 2394 // or if it is in a "Need Data" state. This value can reflect a 2395 // limitation imposed by either the driver or the data source 2396 // 2397 2398 return 0; 2399 } 2400 2401 //___________________________________________________________________ 2402 Int_t TSQLDatabaseMetaData::GetMaxTableNameLength() 2403 { 2404 // What's the maximum length of a table name? 2405 // 2406 // Returns: 2407 // max name length in bytes; a result of zero means that 2408 // there is no limit or the limit is not known 2409 // Throws: 2410 // TSQLException - if a database access error occurs 2411 // 2412 // See also, <http://mysql.com/doc///L/e/Legal_names.html> 2413 2414 return gMaxTableNameLength; 2415 } 2416 2417 //___________________________________________________________________ 2418 Int_t TSQLDatabaseMetaData::GetMaxTablesInSelect() 2419 { 2420 // What's the maximum number of tables in a SELECT statement? 2421 // 2422 // Returns: 2423 // the maximum number of tables allowed in a SELECT 2424 // statement; a result of zero means that there is no 2425 // limit or the limit is not known 2426 // Throws: 2427 // TSQLException - if a database access error occurs 2428 // 2429 // ... more comments based on "ODBC 3.5 Developer's Guide" 2430 // 2431 // Identifies the maximum number of tables allowed in the 2432 // FROM clause of a SELECT statement. 2433 // 2434 2435 return 32; // ?? odbc driver returns 32 2436 } 2437 2438 //___________________________________________________________________ 2439 Int_t TSQLDatabaseMetaData::GetMaxUserNameLength() 2440 { 2441 // What's the maximum length of a user name? 2442 // 2443 // Returns: 2444 // max user name length in bytes; a result of zero means 2445 // that there is no limit or the limit is not known 2446 // Throws: 2447 // TSQLException - if a database access error occurs 2448 2449 return gNameLength; 2450 } 2451 2452 //___________________________________________________________________ 2453 Int_t TSQLDatabaseMetaData::GetDefaultTransactionIsolation() 2454 { 2455 // What's the database's default transaction isolation level? 2456 // The values are defined in TSQLConnection. 2457 // 2458 // Returns: 2459 // the default isolation level 2460 // Throws: 2461 // TSQLException - if a database access error occurs 2462 // See Also: 2463 // TSQLConnection 2464 2465 return kTRANSACTION_NONE; 2466 } 2467 2468 //___________________________________________________________________ 2469 Bool_t TSQLDatabaseMetaData::SupportsTransactions() 2470 { 2471 // Are transactions supported? If not, invoking the method commit 2472 // is a noop and the isolation level is TRANSACTION_NONE. 2473 // 2474 // Returns: 2475 // kTRUE if transactions are supported; kFALSE otherwise 2476 // Throws: 2477 // TSQLException - if a database access error occurs 2478 2479 return kFALSE; 2480 } 2481 2482 //___________________________________________________________________ 2483 Bool_t TSQLDatabaseMetaData::SupportsTransactionIsolationLevel( 2484 Int_t level ) 2485 { 2486 // Does this database support the given transaction isolation 2487 // level? 2488 // 2489 // Parameters: 2490 // level - the values are defined in TSQLConnection 2491 // 2492 // Returns: 2493 // kTRUE if so; kFALSE otherwise 2494 // Throws: 2495 // TSQLException - if a database access error occurs 2496 // See Also: 2497 // TSQLConnection 2498 2499 return kFALSE; 2500 } 2501 2502 //___________________________________________________________________ 2503 Bool_t TSQLDatabaseMetaData::SupportsDataDefinitionAndDataManipulationTransactions() 2504 { 2505 // Are both data definition and data manipulation statements 2506 // within a transaction supported? 2507 // 2508 // Returns: 2509 // kTRUE if so; kFALSE otherwise 2510 // Throws: 2511 // TSQLException - if a database access error occurs 2512 2513 return kFALSE; 2514 } 2515 2516 //___________________________________________________________________ 2517 Bool_t TSQLDatabaseMetaData::SupportsDataManipulationTransactionsOnly() 2518 { 2519 // Are only data manipulation statements within a transaction 2520 // supported? 2521 // 2522 // Returns: 2523 // kTRUE if so; kFALSE otherwise 2524 // Throws: 2525 // TSQLException - if a database access error occurs 2526 2527 return kFALSE; 2528 } 2529 2530 //___________________________________________________________________ 2531 Bool_t TSQLDatabaseMetaData::DataDefinitionCausesTransactionCommit() 2532 { 2533 // Does a data definition statement within a transaction force 2534 // the transaction to commit? 2535 // 2536 // Returns: 2537 // kTRUE if so; kFALSE otherwise 2538 // Throws: 2539 // TSQLException - if a database access error occurs 2540 2541 return kFALSE; 2542 } 2543 2544 //___________________________________________________________________ 2545 Bool_t TSQLDatabaseMetaData::DataDefinitionIgnoredInTransactions() 2546 { 2547 // Is a data definition statement within a transaction ignored? 2548 // 2549 // Returns: 2550 // kTRUE if so; kFALSE otherwise 2551 // Throws: 2552 // TSQLException - if a database access error occurs 2553 2554 return kFALSE; 2555 } 2556 2557 //___________________________________________________________________ 2558 TSQLResultSet* TSQLDatabaseMetaData::GetProcedures( 2559 const TString& catalog, 2560 const TString& schemaPattern, 2561 const TString& procedureNamePattern ) 2562 { 2563 // Gets a description of the stored procedures available in 2564 // a catalog. 2565 // 2566 // Only procedure descriptions matching the schema and procedure 2567 // name criteria are returned. They are ordered by PROCEDURE_SCHEM, 2568 // and PROCEDURE_NAME. 2569 // 2570 // Each procedure description has the the following columns: 2571 // 2572 // 1.PROCEDURE_CAT string => procedure catalog (may be null) 2573 // 2574 // 2.PROCEDURE_SCHEM string => procedure schema (may be null) 2575 // 2576 // 3.PROCEDURE_NAME string => procedure name 2577 // 2578 // 4.reserved for future use 2579 // 5.reserved for future use 2580 // 6.reserved for future use 2581 // 2582 // 7.REMARKS string => explanatory comment on the procedure 2583 // 2584 // 8.PROCEDURE_TYPE short => kind of procedure: 2585 // 2586 // kProcedureResultUnknown - May return a result 2587 // kProcedureNoResult - Does not return a result 2588 // kProcedureReturnsResult - Returns a result 2589 // 2590 // Parameters: 2591 // catalog - a catalog name; 2592 // "" - retrieves those without a catalog; 2593 // schemaPattern - a schema name pattern; 2594 // "" - retrieves those without a schema 2595 // procedureNamePattern - a procedure name pattern 2596 // 2597 // Returns: 2598 // TSQLResultSet - each row is a procedure description 2599 // Throws: 2600 // TSQLException - if a database access error occurs 2601 // See Also: 2602 // GetSearchStringEscape() 2603 2604 Throw( new TSQLException("MyODBC doesn't support this yet","08002",4000) ); 2605 return 0; 2606 } 2607 2608 //___________________________________________________________________ 2609 TSQLResultSet* TSQLDatabaseMetaData::GetProcedureColumns( 2610 const TString& catalog, 2611 const TString& schemaPattern, 2612 const TString& procedureNamePattern, 2613 const TString& columnNamePattern ) 2614 { 2615 // Gets a description of a catalog's stored procedure parameters 2616 // and result columns. 2617 // 2618 // Only descriptions matching the schema, procedure and 2619 // parameter name criteria are returned. They are ordered by 2620 // PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return 2621 // value, if any, is first. Next are the parameter descriptions 2622 // in call order. The column descriptions follow in column number 2623 // order. 2624 // 2625 // Each row in the TSQLResultSet is a parameter description or 2626 // column description with the following fields: 2627 // 2628 // 1.PROCEDURE_CAT string => procedure catalog (may be null) 2629 // 2630 // 2.PROCEDURE_SCHEM string => procedure schema (may be null) 2631 // 2632 // 3.PROCEDURE_NAME string => procedure name 2633 // 2634 // 4.COLUMN_NAME string => column/parameter name 2635 // 2636 // 5.COLUMN_TYPE Short => kind of column/parameter: 2637 // 2638 // kProcedureColumnUnknown - nobody knows 2639 // kProcedureColumnIn - IN parameter 2640 // kProcedureColumnInOut - INOUT parameter 2641 // kProcedureColumnOut - OUT parameter 2642 // kProcedureColumnReturn - procedure return value 2643 // kProcedureColumnResult - result column in TSQLResultSet 2644 // 2645 // 6.DATA_TYPE short => SQL type from TSQLTypes 2646 // 2647 // 7.TYPE_NAME string => SQL type name, for a UDT type 2648 // the type name is fully qualified 2649 // 2650 // 8.PRECISION int => precision 2651 // 2652 // 9.LENGTH int => length in bytes of data 2653 // 2654 // 10.SCALE short => scale 2655 // 2656 // 11.RADIX short => radix 2657 // 2658 // 12.NULLABLE short => can it contain NULL? 2659 // 2660 // kProcedureNoNulls - does not allow NULL values 2661 // kProcedureNullable - allows NULL values 2662 // kProcedureNullableUnknown - nullability unknown 2663 // 2664 // 13.REMARKS string => comment describing parameter/column 2665 // 2666 // Note: Some databases may not return the column descriptions 2667 // for a procedure. Additional columns beyond REMARKS 2668 // can be defined by the database. 2669 // 2670 // Parameters: 2671 // catalog - a catalog name; 2672 // "" - retrieves those without a catalog; 2673 // schemaPattern - a schema name pattern; 2674 // "" - retrieves those without a schema 2675 // procedureNamePattern - a procedure name pattern 2676 // columnNamePattern - a column name pattern 2677 // 2678 // Returns: 2679 // TSQLResultSet - each row describes a stored procedure 2680 // parameter or column 2681 // Throws: 2682 // TSQLException - if a database access error occurs 2683 // See Also: 2684 // GetSearchStringEscape() 2685 2686 Throw( new TSQLException("MyODBC doesn't support this yet","08002",4000) ); 2687 return 0; 2688 } 2689 2690 //___________________________________________________________________ 2691 TSQLResultSet* TSQLDatabaseMetaData::GetTables( 2692 const TString& catalog, 2693 const TString& schemaPattern, 2694 const TString& tableNamePattern, 2695 const TString& types ) 2696 { 2697 // Gets a description of tables available in a catalog. 2698 // 2699 // Only table descriptions matching the catalog, schema, 2700 // table name and type criteria are returned. They are ordered 2701 // by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME. 2702 // 2703 // Each table description has the following columns: 2704 // 2705 // 1.TABLE_CAT string => table catalog (may be null) 2706 // 2707 // 2.TABLE_SCHEM string => table schema (may be null) 2708 // 2709 // 3.TABLE_NAME string => table name 2710 // 2711 // 4.TABLE_TYPE string => table type. Typical types are: 2712 // 2713 // "TABLE", "VIEW", "SYSTEM TABLE", 2714 // "GLOBAL TEMPORARY", "LOCAL TEMPORARY", 2715 // "ALIAS", "SYNONYM". 2716 // 2717 // 5.REMARKS string => explanatory comment on the table 2718 // 2719 // Note: Some databases may not return information for all tables. 2720 // 2721 // Parameters: 2722 // catalog - a catalog name; 2723 // "" - retrieves those without a catalog; 2724 // schemaPattern - a schema name pattern; 2725 // "" - retrieves those without a schema 2726 // tableNamePattern - a table name pattern 2727 // types - a list of table types to include; 2728 // null returns all types 2729 // 2730 // Returns: 2731 // TSQLResultSet - each row is a table description 2732 // Throws: 2733 // TSQLException - if a database access error occurs 2734 // See Also: 2735 // GetSearchStringEscape() 2736 2737 static MYSQL_FIELD SQLTABLES_fields[] = { 2738 {"TABLE_CAT","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}, 2739 {"TABLE_SHEM","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}, 2740 {"TABLE_NAME","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,NAME_LEN,0}, 2741 {"TABLE_TYPE","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,5,0}, 2742 {"REMARKS","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,11}}; 2743 2744 const Int_t SQLTABLES_FIELDS = array_elements(SQLTABLES_values); 2745 2746 gResult->Close(); 2747 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 2748 TString db = con->fURL->GetDatabase(); 2749 2750 if( !catalog.IsNull() && schemaPattern.IsNull() && tableNamePattern.IsNull() ) { 2751 gResult->fMYSQL_RES = mysql_list_dbs(con->fMYSQL,catalog); 2752 2753 if(!gResult->fMYSQL_RES) { 2754 Throw( new TSQLException("Could not read database names","S1000",0) ); 2755 return 0; 2756 } 2757 2758 gResult->fMYSQL_RES->fields = SQLTABLES_fields; 2759 gResult->fMYSQL_RES->field_count = SQLTABLES_FIELDS; 2760 gResult->fMYSQL_RES->current_field = 0; 2761 2762 return new TSQLResultSet(0,gResult); 2763 } 2764 2765 if( catalog.IsNull() && schemaPattern == "%" && tableNamePattern.IsNull() ) { 2766 gResult->fMYSQL_RES = (MYSQL_RES*) my_malloc(sizeof(MYSQL_RES),MYF(MY_ZEROFILL)); 2767 gResult->fMYSQL_RES->row_count = 1; 2768 gResult->fMYSQL_RES->fields = SQLTABLES_fields; 2769 gResult->fMYSQL_RES->field_count = SQLTABLES_FIELDS; 2770 gResult->fMYSQL_RES->current_field = 0; 2771 2772 return new TSQLResultSet(0,gResult); 2773 } 2774 2775 if( catalog.IsNull() && schemaPattern.IsNull() && 2776 tableNamePattern.IsNull() && types=="%" ) { 2777 gResult->fMYSQL_RES = (MYSQL_RES*) my_malloc(sizeof(MYSQL_RES),MYF(MY_ZEROFILL)); 2778 gResult->fMYSQL_RES->row_count = 1; 2779 gResult->fMYSQL_RES->fields = SQLTABLES_fields; 2780 gResult->fMYSQL_RES->field_count = SQLTABLES_FIELDS; 2781 gResult->fMYSQL_RES->current_field = 0; 2782 2783 return new TSQLResultSet(0,gResult); 2784 } 2785 2786 // Return empty set if unknown tbale type or if catalog or schemaPattern is used 2787 2788 if( (!types.IsNull() && !types.Contains("TABLE") ) || 2789 (!catalog.IsNull() && catalog != "%" && catalog != db) || 2790 (!schemaPattern.IsNull() && schemaPattern != "%" && catalog != db) ) { 2791 gResult->fMYSQL_RES = (MYSQL_RES*) my_malloc(sizeof(MYSQL_RES),MYF(MY_ZEROFILL)); 2792 gResult->fMYSQL_RES->row_count = 0; 2793 gResult->fMYSQL_RES->fields = SQLTABLES_fields; 2794 gResult->fMYSQL_RES->field_count = SQLTABLES_FIELDS; 2795 gResult->fMYSQL_RES->current_field = 0; 2796 2797 return new TSQLResultSet(0,gResult); 2798 } 2799 2800 // this was a normal request for tables. Return matching tables 2801 2802 gResult->fMYSQL_RES = mysql_list_tables(con->fMYSQL,tableNamePattern); 2803 2804 if(!gResult->fMYSQL_RES) { 2805 Throw( new TSQLException("Could not read table names","S1000",0) ); 2806 return 0; 2807 } 2808 2809 gResult->fMYSQL_RES->fields = SQLTABLES_fields; 2810 gResult->fMYSQL_RES->field_count = SQLTABLES_FIELDS; 2811 gResult->fMYSQL_RES->current_field = 0; 2812 2813 return new TSQLResultSet(0,gResult); 2814 } 2815 2816 //___________________________________________________________________ 2817 TSQLResultSet* TSQLDatabaseMetaData::GetSchemas() 2818 { 2819 // Gets the schema names available in this database. The results 2820 // are ordered by schema name. 2821 // 2822 // The schema column is: 2823 // 1.TABLE_SCHEM string => schema name 2824 // 2825 // Returns: 2826 // TSQLResultSet - each row has a single string column 2827 // that is a schema name 2828 // Throws: 2829 // TSQLException - if a database access error occurs 2830 // 2831 // Note: result the same as GetTables("%","","",""); 2832 2833 static MYSQL_FIELD SCHEMA_fields[] = { 2834 {"TABLE_SHEM","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}}; 2835 2836 gResult->Close(); 2837 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 2838 2839 gResult->fMYSQL_RES = (MYSQL_RES*) my_malloc(sizeof(MYSQL_RES),MYF(MY_ZEROFILL)); 2840 gResult->fMYSQL_RES->row_count = 1; 2841 gResult->fMYSQL_RES->fields = SCHEMA_fields; 2842 gResult->fMYSQL_RES->field_count = 1; 2843 gResult->fMYSQL_RES->current_field = 0; 2844 2845 return new TSQLResultSet(0,gResult); 2846 } 2847 2848 //___________________________________________________________________ 2849 TSQLResultSet* TSQLDatabaseMetaData::GetCatalogs() 2850 { 2851 // Gets the catalog names available in this database. The results 2852 // are ordered by catalog name. 2853 // 2854 // The catalog column is: 2855 // 1.TABLE_CAT string => catalog name 2856 // 2857 // Returns: 2858 // TSQLResultSet - each row has a single string column 2859 // that is a catalog name 2860 // Throws: 2861 // TSQLException - if a database access error occurs 2862 2863 static MYSQL_FIELD CATALOG_fields[] = { 2864 {"TABLE_CAT","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}}; 2865 2866 gResult->Close(); 2867 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 2868 2869 gResult->fMYSQL_RES = mysql_list_dbs(con->fMYSQL,"%"); 2870 2871 if(!gResult->fMYSQL_RES) { 2872 Throw( new TSQLException("Could not read database names","S1000",0) ); 2873 return 0; 2874 } 2875 2876 gResult->fMYSQL_RES->fields = CATALOG_fields; 2877 gResult->fMYSQL_RES->field_count = 1; 2878 gResult->fMYSQL_RES->current_field = 0; 2879 2880 return new TSQLResultSet(0,gResult); 2881 } 2882 2883 //___________________________________________________________________ 2884 TSQLResultSet* TSQLDatabaseMetaData::GetTableTypes() 2885 { 2886 // Gets the table types available in this database. The results 2887 // are ordered by table type. 2888 // 2889 // The table type is: 2890 // 1.TABLE_TYPE string => table type. Typical types are: 2891 // 2892 // "TABLE", "VIEW", "SYSTEM TABLE", 2893 // "GLOBAL TEMPORARY","LOCAL TEMPORARY", 2894 // "ALIAS", "SYNONYM". 2895 // 2896 // Returns: 2897 // TSQLResultSet - each row has a single string column 2898 // that is a table type 2899 // Throws: 2900 // TSQLException - if a database access error occurs 2901 2902 static MYSQL_FIELD TTYPE_fields[] = { 2903 {"TABLE_TYPE","Catalog",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}}; 2904 2905 gResult->Close(); 2906 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 2907 2908 gResult->fMYSQL_RES = (MYSQL_RES*) my_malloc(sizeof(MYSQL_RES),MYF(MY_ZEROFILL)); 2909 gResult->fMYSQL_RES->row_count = 1; 2910 gResult->fMYSQL_RES->fields = TTYPE_fields; 2911 gResult->fMYSQL_RES->field_count = 1; 2912 gResult->fMYSQL_RES->current_field = 0; 2913 2914 return new TSQLResultSet(0,gResult); 2915 } 2916 2917 //___________________________________________________________________ 2918 TSQLResultSet* TSQLDatabaseMetaData::GetColumns( 2919 const TString& catalog, 2920 const TString& schemaPattern, 2921 const TString& tableNamePattern, 2922 const TString& columnNamePattern ) 2923 { 2924 // Gets a description of table columns available in the specified 2925 // catalog. 2926 // 2927 // Only column descriptions matching the catalog, schema, 2928 // table and column name criteria are returned. They are ordered 2929 // by TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION. 2930 // 2931 // Each column description has the following columns: 2932 // 2933 // 1.TABLE_CAT string => table catalog (may be null) 2934 // 2935 // 2.TABLE_SCHEM string => table schema (may be null) 2936 // 2937 // 3.TABLE_NAME string => table name 2938 // 2939 // 4.COLUMN_NAME string => column name 2940 // 2941 // 5.DATA_TYPE short => SQL type from TSQLTypes 2942 // 2943 // 6.TYPE_NAME string => Data source dependent type name, 2944 // for a UDT the type name is fully qualified 2945 // 2946 // 7.COLUMN_SIZE int => column size. For char or date types 2947 // this is the maximum number of characters, 2948 // for numeric or decimal types this is precision. 2949 // 2950 // 8.BUFFER_LENGTH is not used. 2951 // 2952 // 9.DECIMAL_DIGITS int => the number of fractional digits 2953 // 2954 // 10.NUM_PREC_RADIX int => Radix (typically either 10 or 2) 2955 // 2956 // 11.NULLABLE int => is NULL allowed? 2957 // 2958 // kColumnNoNulls - might not allow NULL values 2959 // kColumnNullable - definitely allows NULL values 2960 // kColumnNullableUnknown - nullability unknown 2961 // 2962 // 12.REMARKS string => comment describing column (may be null) 2963 // 2964 // 13.COLUMN_DEF string => default value (may be null) 2965 // 2966 // 14.SQL_DATA_TYPE int => unused 2967 // 2968 // 15.SQL_DATETIME_SUB int => unused 2969 // 2970 // 16.CHAR_OCTET_LENGTH int => for char types the maximum 2971 // number of bytes in the column 2972 // 2973 // 17.ORDINAL_POSITION int => index of column in 2974 // table (starting at 1) 2975 // 2976 // 18.IS_NULLABLE string => "NO" means column definitely 2977 // does not allow NULL values; 2978 // "YES" means the column might allow 2979 // NULL values. 2980 // An empty string means nobody knows. 2981 // 2982 // Parameters: 2983 // catalog - a catalog name; 2984 // "" - retrieves those without a catalog; 2985 // schemaPattern - a schema name pattern; 2986 // "" - retrieves those without a schema 2987 // tableNamePattern - a table name pattern 2988 // columnNamePattern - a column name pattern 2989 // 2990 // Returns: 2991 // TSQLResultSet - each row is a column description 2992 // Throws: 2993 // TSQLException - if a database access error occurs 2994 // See Also: 2995 // GetSearchStringEscape() 2996 2997 gResult->Close(); 2998 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 2999 3000 return new TSQLResultSet(0,gResult); 3001 } 3002 3003 //___________________________________________________________________ 3004 TSQLResultSet* TSQLDatabaseMetaData::GetColumnPrivileges( 3005 const TString& catalog, 3006 const TString& schema, 3007 const TString& table, 3008 const TString& columnNamePattern ) 3009 { 3010 // Gets a description of the access rights for a table's columns. 3011 // 3012 // Only privileges matching the column name criteria are 3013 // returned. They are ordered by COLUMN_NAME and PRIVILEGE. 3014 // 3015 // Each privilige description has the following columns: 3016 // 3017 // 1.TABLE_CAT string => table catalog (may be null) 3018 // 3019 // 2.TABLE_SCHEM string => table schema (may be null) 3020 // 3021 // 3.TABLE_NAME string => table name 3022 // 3023 // 4.COLUMN_NAME string => column name 3024 // 3025 // 5.GRANTOR => grantor of access (may be null) 3026 // 3027 // 6.GRANTEE string => grantee of access 3028 // 3029 // 7.PRIVILEGE string => name of access (SELECT, INSERT, 3030 // UPDATE, REFRENCES, ...) 3031 // 3032 // 8.IS_GRANTABLE string => "YES" if grantee is permitted 3033 // to grant to others; 3034 // "NO" if not; 3035 // null if unknown 3036 // 3037 // Parameters: 3038 // catalog - a catalog name; 3039 // "" - retrieves those without a catalog; 3040 // schema - a schema name; 3041 // "" - retrieves those without a schema 3042 // table - a table name 3043 // columnNamePattern - a column name pattern 3044 // 3045 // Returns: 3046 // TSQLResultSet - each row is a column privilege 3047 // description 3048 // Throws: 3049 // TSQLException - if a database access error occurs 3050 // See Also: 3051 // GetSearchStringEscape() 3052 3053 gResult->Close(); 3054 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3055 3056 Throw( new TSQLException("MyODBC doesn't support this yet","08002",4000) ); 3057 return 0; 3058 } 3059 3060 //___________________________________________________________________ 3061 TSQLResultSet* TSQLDatabaseMetaData::GetTablePrivileges( 3062 const TString& catalog, 3063 const TString& schemaPattern, 3064 const TString& tableNamePattern ) 3065 { 3066 // Gets a description of the access rights for each table 3067 // available in a catalog. Note that a table privilege applies 3068 // to one or more columns in the table. It would be wrong to 3069 // assume that this priviledge applies to all columns (this may 3070 // be true for some systems but is not true for all.) 3071 // 3072 // Only privileges matching the schema and table name criteria 3073 // are returned. They are ordered by TABLE_SCHEM, TABLE_NAME, 3074 // and PRIVILEGE. 3075 // 3076 // Each privilige description has the following columns: 3077 // 3078 // 1.TABLE_CAT string => table catalog (may be null) 3079 // 3080 // 2.TABLE_SCHEM string => table schema (may be null) 3081 // 3082 // 3.TABLE_NAME string => table name 3083 // 3084 // 4.GRANTOR => grantor of access (may be null) 3085 // 3086 // 5.GRANTEE string => grantee of access 3087 // 3088 // 6.PRIVILEGE string => name of access (SELECT, INSERT, 3089 // UPDATE, REFRENCES, ...) 3090 // 3091 // 7.IS_GRANTABLE string => "YES" - if grantee is permitted 3092 // to grant to others; 3093 // "NO" - if not; 3094 // null - if unknown 3095 // 3096 // Parameters: 3097 // catalog - a catalog name; 3098 // "" - retrieves those without a catalog; 3099 // schemaPattern - a schema name pattern; 3100 // "" - retrieves those without a schema 3101 // tableNamePattern - a table name pattern 3102 // 3103 // Returns: 3104 // TSQLResultSet - each row is a table privilege 3105 // description 3106 // Throws: 3107 // TSQLException - if a database access error occurs 3108 // See Also: 3109 // GetSearchStringEscape() 3110 3111 gResult->Close(); 3112 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3113 3114 Throw( new TSQLException("MyODBC doesn't support this yet","08002",4000) ); 3115 return 0; 3116 } 3117 3118 //___________________________________________________________________ 3119 TSQLResultSet* TSQLDatabaseMetaData::GetBestRowIdentifier( 3120 const TString& catalog, 3121 const TString& schema, 3122 const TString& table, 3123 Int_t scope, 3124 Bool_t nullable ) 3125 { 3126 // Gets a description of a table's optimal set of columns that 3127 // uniquely identifies a row. They are ordered by SCOPE. 3128 // 3129 // Each column description has the following columns: 3130 // 3131 // 1.SCOPE short => actual scope of result 3132 // 3133 // kBestRowTemporary - very temporary, while using row 3134 // kBestRowTransaction - valid for remainder of current 3135 // transaction 3136 // kBestRowSession - valid for remainder of current session 3137 // 3138 // 2.COLUMN_NAME string => column name 3139 // 3140 // 3.DATA_TYPE short => SQL data type from TSQLTypes 3141 // 3142 // 4.TYPE_NAME string => Data source dependent type name, 3143 // for a UDT the type name is fully 3144 // qualified 3145 // 3146 // 5.COLUMN_SIZE int => precision 3147 // 3148 // 6.BUFFER_LENGTH int => not used 3149 // 3150 // 7.DECIMAL_DIGITS short => scale 3151 // 3152 // 8.PSEUDO_COLUMN short => is this a pseudo column like 3153 // an Oracle ROWID 3154 // 3155 // kBestRowUnknown - may or may not be pseudo column 3156 // kBestRowNotPseudo - is NOT a pseudo column 3157 // kBestRowPseudo - is a pseudo column 3158 // 3159 // Parameters: 3160 // catalog - a catalog name; 3161 // "" - retrieves those without a catalog; 3162 // schema - a schema name; 3163 // "" - retrieves those without a schema 3164 // table - a table name 3165 // scope - the scope of interest; use same values as SCOPE 3166 // nullable - include columns that are nullable? 3167 // 3168 // Returns: 3169 // TSQLResultSet - each row is a column description 3170 // Throws: 3171 // TSQLException - if a database access error occurs 3172 3173 gResult->Close(); 3174 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3175 3176 return new TSQLResultSet(0,gResult); 3177 } 3178 3179 //___________________________________________________________________ 3180 TSQLResultSet* TSQLDatabaseMetaData::GetVersionColumns( 3181 const TString& catalog, 3182 const TString& schema, 3183 const TString& table ) 3184 { 3185 // Gets a description of a table's columns that are automatically 3186 // updated when any value in a row is updated. They are unordered. 3187 // 3188 // Each column description has the following columns: 3189 // 3190 // 1.SCOPE short => is not used 3191 // 3192 // 2.COLUMN_NAME string => column name 3193 // 3194 // 3.DATA_TYPE short => SQL data type from TSQLTypes 3195 // 3196 // 4.TYPE_NAME string => Data source dependent type name 3197 // 3198 // 5.COLUMN_SIZE int => precision 3199 // 3200 // 6.BUFFER_LENGTH int => length of column value in bytes 3201 // 3202 // 7.DECIMAL_DIGITS short => scale 3203 // 3204 // 8.PSEUDO_COLUMN short => is this a pseudo column like 3205 // an Oracle ROWID 3206 // 3207 // kVersionColumnUnknown - may or may not be pseudo column 3208 // kVersionColumnNotPseudo - is NOT a pseudo column 3209 // kVersionColumnPseudo - is a pseudo column 3210 // 3211 // Parameters: 3212 // catalog - a catalog name; 3213 // "" - retrieves those without a catalog; 3214 // schema - a schema name; 3215 // "" retrieves those without a schema 3216 // table - a table name 3217 // 3218 // Returns: 3219 // TSQLResultSet - each row is a column description 3220 // Throws: 3221 // TSQLException - if a database access error occurs 3222 3223 gResult->Close(); 3224 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3225 3226 Throw( new TSQLException("MyODBC doesn't support this yet","08002",4000) ); 3227 return 0; 3228 } 3229 3230 //___________________________________________________________________ 3231 TSQLResultSet* TSQLDatabaseMetaData::GetPrimaryKeys( 3232 const TString& catalog, 3233 const TString& schema, 3234 const TString& table ) 3235 { 3236 // Gets a description of a table's primary key columns. 3237 // They are ordered by COLUMN_NAME. 3238 // 3239 // Each primary key column description has the following columns: 3240 // 3241 // 1.TABLE_CAT string => table catalog (may be null) 3242 // 3243 // 2.TABLE_SCHEM string => table schema (may be null) 3244 // 3245 // 3.TABLE_NAME string => table name 3246 // 3247 // 4.COLUMN_NAME string => column name 3248 // 3249 // 5.KEY_SEQ short => sequence number within primary key 3250 // 3251 // 6.PK_NAME string => primary key name (may be null) 3252 // 3253 // Parameters: 3254 // catalog - a catalog name; 3255 // "" - retrieves those without a catalog; 3256 // schema - a schema name; 3257 // "" - retrieves those without a schema 3258 // table - a table name 3259 // 3260 // Returns: 3261 // TSQLResultSet - each row is a primary key column 3262 // description 3263 // Throws: 3264 // TSQLException - if a database access error occurs 3265 3266 gResult->Close(); 3267 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3268 3269 return new TSQLResultSet(0,gResult); 3270 } 3271 3272 //___________________________________________________________________ 3273 TSQLResultSet* TSQLDatabaseMetaData::GetImportedKeys( 3274 const TString& catalog, 3275 const TString& schema, 3276 const TString& table ) 3277 { 3278 // Gets a description of the primary key columns that are 3279 // referenced by a table's foreign key columns (the primary keys 3280 // imported by a table). They are ordered by PKTABLE_CAT, 3281 // PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ. 3282 // 3283 // Each primary key column description has the following columns: 3284 // 3285 // 1.PKTABLE_CAT string => primary key table catalog being 3286 // imported (may be null) 3287 // 3288 // 2.PKTABLE_SCHEM string => primary key table schema being 3289 // imported (may be null) 3290 // 3291 // 3.PKTABLE_NAME string => primary key table name being 3292 // imported 3293 // 3294 // 4.PKCOLUMN_NAME string => primary key column name being 3295 // imported 3296 // 3297 // 5.FKTABLE_CAT string => foreign key table catalog 3298 // (may be null) 3299 // 3300 // 6.FKTABLE_SCHEM string => foreign key table schema 3301 // (may be null) 3302 // 3303 // 7.FKTABLE_NAME string => foreign key table name 3304 // 3305 // 8.FKCOLUMN_NAME string => foreign key column name 3306 // 3307 // 9.KEY_SEQ short => sequence number within foreign key 3308 // 3309 // 10.UPDATE_RULE short => What happens to foreign key when 3310 // primary is updated: 3311 // 3312 // kImportedNoAction - do not allow update of primary key 3313 // if it has been imported 3314 // kImportedKeyCascade - change imported key to agree 3315 // with primary key update 3316 // kImportedKeySetNull - change imported key to NULL if 3317 // its primary key has been updated 3318 // kImportedKeySetDefault - change imported key to default 3319 // values if its primary key has 3320 // been updated 3321 // kImportedKeyRestrict - same as kImportedKeyNoAction 3322 // 3323 // 11.DELETE_RULE short => What happens to the foreign key 3324 // when primary is deleted: 3325 // 3326 // kImportedKeyNoAction - do not allow delete of primary 3327 // key if it has been imported 3328 // kImportedKeyCascade - delete rows that import a 3329 // deleted key 3330 // kImportedKeySetNull - change imported key to NULL 3331 // if its primary key has been deleted 3332 // kImportedKeyRestrict - same as kImportedKeyNoAction 3333 // kImportedKeySetDefault - change imported key to default 3334 // if its primary key has been deleted 3335 // 3336 // 12.FK_NAME string => foreign key name (may be null) 3337 // 3338 // 13.PK_NAME string => primary key name (may be null) 3339 // 3340 // 14.DEFERRABILITY short => can the evaluation of foreign key 3341 // constraints be deferred until commit 3342 // 3343 // kImportedKeyInitiallyDeferred - see SQL92 for definition 3344 // kImportedKeyInitiallyImmediate - see SQL92 for definition 3345 // kImportedKeyNotDeferrable - see SQL92 for definition 3346 // 3347 // Parameters: 3348 // catalog - a catalog name; 3349 // "" - retrieves those without a catalog; 3350 // schema - a schema name; 3351 // "" - retrieves those without a schema 3352 // table - a table name 3353 // 3354 // Returns: 3355 // TSQLResultSet - each row is a primary key column description 3356 // Throws: 3357 // TSQLException - if a database access error occurs 3358 // See Also: 3359 // GetExportedKeys(const TString&, 3360 // const TString&, 3361 // const TString&) 3362 3363 return GetCrossReference("","","",catalog,schema,table); 3364 } 3365 3366 //___________________________________________________________________ 3367 TSQLResultSet* TSQLDatabaseMetaData::GetExportedKeys( 3368 const TString& catalog, 3369 const TString& schema, 3370 const TString& table ) 3371 { 3372 // Gets a description of the foreign key columns that reference 3373 // a table's primary key columns (the foreign keys exported by 3374 // a table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, 3375 // FKTABLE_NAME, and KEY_SEQ. 3376 // 3377 // Each foreign key column description has the following columns: 3378 // 3379 // 1.PKTABLE_CAT string => primary key table catalog (may be null) 3380 // 3381 // 2.PKTABLE_SCHEM string => primary key table schema (may be null) 3382 // 3383 // 3.PKTABLE_NAME string => primary key table name 3384 // 3385 // 4.PKCOLUMN_NAME string => primary key column name 3386 // 3387 // 5.FKTABLE_CAT string => foreign key table catalog (may be 3388 // null) being exported (may be null) 3389 // 3390 // 6.FKTABLE_SCHEM string => foreign key table schema (may be 3391 // null) being exported (may be null) 3392 // 7.FKTABLE_NAME string => foreign key table name being exported 3393 // 3394 // 8.FKCOLUMN_NAME string => foreign key column name being exported 3395 // 3396 // 9.KEY_SEQ short => sequence number within foreign key 3397 // 3398 // 10.UPDATE_RULE short => What happens to foreign key when 3399 // primary is updated: 3400 // 3401 // kImportedNoAction - do not allow update of primary 3402 // key if it has been imported 3403 // kImportedKeyCascade - change imported key to agree 3404 // with primary key update 3405 // kImportedKeySetNull - change imported key to NULL 3406 // if its primary key has been updated 3407 // kImportedKeySetDefault - change imported key to default 3408 // values if its primary key has been 3409 // updated 3410 // kImportedKeyRestrict - same as kImportedKeyNoAction 3411 // 3412 // 11.DELETE_RULE short => What happens to the foreign key 3413 // when primary is deleted: 3414 // 3415 // kImportedKeyNoAction - do not allow delete of primary 3416 // key if it has been imported 3417 // kImportedKeyCascade - delete rows that import a 3418 // deleted key 3419 // kImportedKeySetNull - change imported key to NULL if 3420 // its primary key has been deleted 3421 // kImportedKeyRestrict - same as kImportedKeyNoAction 3422 // kImportedKeySetDefault - change imported key to default 3423 // if its primary key has been 3424 // deleted 3425 // 3426 // 12.FK_NAME string => foreign key name (may be null) 3427 // 3428 // 13.PK_NAME string => primary key name (may be null) 3429 // 3430 // 14.DEFERRABILITY short => can the evaluation of foreign key 3431 // constraints be deferred until commit 3432 // 3433 // kImportedKeyInitiallyDeferred - see SQL92 for definition 3434 // kImportedKeyInitiallyImmediate - see SQL92 for definition 3435 // kImportedKeyNotDeferrable - see SQL92 for definition 3436 // 3437 // Parameters: 3438 // catalog - a catalog name; 3439 // "" - retrieves those without a catalog; 3440 // schema - a schema name; 3441 // "" - retrieves those without a schema 3442 // table - a table name 3443 // 3444 // Returns: 3445 // TSQLResultSet - each row is a foreign key column 3446 // description 3447 // Throws: 3448 // TSQLException - if a database access error occurs 3449 // See Also: 3450 // GetImportedKeys( const TString&, 3451 // const TString&, 3452 // const TString& ) 3453 3454 gResult->Close(); 3455 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3456 3457 return GetCrossReference(catalog,schema,table,"","",""); 3458 } 3459 3460 //___________________________________________________________________ 3461 TSQLResultSet* TSQLDatabaseMetaData::GetCrossReference( 3462 const TString& primaryCatalog, 3463 const TString& primarySchema, 3464 const TString& primaryTable, 3465 const TString& foreignCatalog, 3466 const TString& foreignSchema, 3467 const TString& foreignTable ) 3468 { 3469 // Gets a description of the foreign key columns in the foreign 3470 // key table that reference the primary key columns of the primary 3471 // key table (describe how one table imports another's key.) 3472 // This should normally return a single foreign key/primary key 3473 // pair (most tables only import a foreign key from a table once.) 3474 // They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, 3475 // and KEY_SEQ. 3476 // 3477 // Each foreign key column description has the following columns: 3478 // 3479 // 1.PKTABLE_CAT string => primary key table catalog (may be null) 3480 // 3481 // 2.PKTABLE_SCHEM string => primary key table schema (may be null) 3482 // 3483 // 3.PKTABLE_NAME string => primary key table name 3484 // 3485 // 4.PKCOLUMN_NAME string => primary key column name 3486 // 3487 // 5.FKTABLE_CAT string => foreign key table catalog (may be null) 3488 // being exported (may be null) 3489 // 3490 // 6.FKTABLE_SCHEM string => foreign key table schema (may be null) 3491 // being exported (may be null) 3492 // 3493 // 7.FKTABLE_NAME string => foreign key table name being exported 3494 // 3495 // 8.FKCOLUMN_NAME string => foreign key column name 3496 // being exported 3497 // 3498 // 9.KEY_SEQ short => sequence number within foreign key 3499 // 3500 // 10.UPDATE_RULE short => What happens to foreign key when 3501 // primary is updated: 3502 // 3503 // kImportedNoAction - do not allow update of primary key 3504 // if it has been imported 3505 // kImportedKeyCascade - change imported key to agree 3506 // with primary key update 3507 // kImportedKeySetNull - change imported key to NULL 3508 // if its primary key has been updated 3509 // kImportedKeySetDefault - change imported key to 3510 // default values if its primary key 3511 // has been updated 3512 // kImportedKeyRestrict - same as kImportedKeyNoAction 3513 // 3514 // 11.DELETE_RULE short => What happens to the foreign key 3515 // when primary is deleted 3516 // 3517 // kImportedKeyNoAction - do not allow delete of primary 3518 // key if it has been imported 3519 // kImportedKeyCascade - delete rows that import 3520 // a deleted key 3521 // kImportedKeySetNull - change imported key to NULL if 3522 // its primary key has been deleted 3523 // kImportedKeyRestrict - same as kImportedKeyNoAction 3524 // kImportedKeySetDefault - change imported key to 3525 // default if its primary key has 3526 // been deleted 3527 // 3528 // 12.FK_NAME string => foreign key name (may be null) 3529 // 3530 // 13.PK_NAME string => primary key name (may be null) 3531 // 3532 // 14.DEFERRABILITY short => can the evaluation of foreign 3533 // key constraints be deferred until 3534 // commit 3535 // 3536 // kImportedKeyInitiallyDeferred - see SQL92 for definition 3537 // kImportedKeyInitiallyImmediate - see SQL92 for definition 3538 // kImportedKeyNotDeferrable - see SQL92 for definition 3539 // 3540 // Parameters: 3541 // primaryCatalog - a catalog name; 3542 // "" - retrieves those without a catalog; 3543 // primarySchema - a schema name; 3544 // "" - retrieves those without a schema 3545 // primaryTable - the table name that exports the key 3546 // foreignCatalog - a catalog name; 3547 // "" - retrieves those without a catalog; 3548 // foreignSchema - a schema name; 3549 // "" - retrieves those without a schema 3550 // foreignTable - the table name that imports the key 3551 // 3552 // Returns: 3553 // TSQLResultSet - each row is a foreign key column 3554 // description 3555 // Throws: 3556 // TSQLException - if a database access error occurs 3557 // See Also: 3558 // GetImportedKeys( const TString&, 3559 // const TString&, 3560 // const TString& ) 3561 3562 gResult->Close(); 3563 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3564 3565 } 3566 3567 //___________________________________________________________________ 3568 TSQLResultSet* TSQLDatabaseMetaData::GetTypeInfo() 3569 { 3570 // Gets a description of all the standard SQL types supported 3571 // by this database. They are ordered by DATA_TYPE and then by 3572 // how closely the data type maps to the corresponding SQL type. 3573 // 3574 // Each type description has the following columns: 3575 // 3576 // 1.TYPE_NAME string => Type name 3577 // 3578 // 2.DATA_TYPE short => SQL data type from TSQLTypes 3579 // 3580 // 3.PRECISION int => maximum precision 3581 // 3582 // 4.LITERAL_PREFIX string => prefix used to quote a 3583 // literal (may be null) 3584 // 3585 // 5.LITERAL_SUFFIX string => suffix used to quote a 3586 // literal (may be null) 3587 // 3588 // 6.CREATE_PARAMS string => parameters used in creating 3589 // the type (may be null) 3590 // 3591 // 7.NULLABLE short => can you use NULL for this type? 3592 // 3593 // kTypeNoNulls - does not allow NULL values 3594 // kTypeNullable - allows NULL values 3595 // kTypeNullableUnknown - nullability unknown 3596 // 3597 // 8.CASE_SENSITIVE boolean=> is it case sensitive? 3598 // 3599 // 9.SEARCHABLE short => can you use "WHERE" based on 3600 // this type: 3601 // 3602 // kTypePredNone - No support 3603 // kTypePredChar - Only supported with WHERE .. LIKE 3604 // kTypePredBasic - Supported except for WHERE .. LIKE 3605 // kTypeSearchable - Supported for all WHERE .. 3606 // 3607 // 10.UNSIGNED_ATTRIBUTE => is it unsigned? 3608 // 3609 // 11.FIXED_PREC_SCALE => can it be a money value? 3610 // 3611 // 12.AUTO_INCREMENT => can it be used for an auto-increment 3612 // value? 3613 // 3614 // 13.LOCAL_TYPE_NAME string => localized version of type 3615 // name (may be null) 3616 // 3617 // 14.MINIMUM_SCALE short => minimum scale supported 3618 // 3619 // 15.MAXIMUM_SCALE short => maximum scale supported 3620 // 3621 // 16.SQL_DATA_TYPE int => unused 3622 // 3623 // 17.SQL_DATETIME_SUB int => unused 3624 // 3625 // 18.NUM_PREC_RADIX int => usually 2 or 10 3626 // 3627 // Returns: 3628 // TSQLResultSet - each row is a SQL type description 3629 // Throws: 3630 // TSQLException - if a database access error occurs 3631 3632 gResult->Close(); 3633 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3634 3635 return new TSQLResultSet(0,gResult); 3636 } 3637 3638 //___________________________________________________________________ 3639 TSQLResultSet* TSQLDatabaseMetaData::GetIndexInfo( 3640 const TString& catalog, 3641 const TString& schema, 3642 const TString& table, 3643 Bool_t unique, 3644 Bool_t approximate ) 3645 { 3646 // Gets a description of a table's indices and statistics. 3647 // They are ordered by NON_UNIQUE, TYPE, INDEX_NAME, 3648 // and ORDINAL_POSITION. 3649 // 3650 // Each index column description has the following columns: 3651 // 3652 // 1.TABLE_CAT string => table catalog (may be null) 3653 // 3654 // 2.TABLE_SCHEM string => table schema (may be null) 3655 // 3656 // 3.TABLE_NAME string => table name 3657 // 3658 // 4.NON_UNIQUE => Can index values be non-unique? 3659 // kFALSE when TYPE is kTableIndexStatistic 3660 // 3661 // 5.INDEX_QUALIFIER string => index catalog (may be null); 3662 // null when TYPE is kTableIndexStatistic 3663 // 3664 // 6.INDEX_NAME string => index name; null when TYPE 3665 // is kTableIndexStatistic 3666 // 3667 // 7.TYPE short => index type: 3668 // 3669 // kTableIndexStatistic - this identifies table 3670 // statistics that are returned 3671 // in conjuction with a table's 3672 // index descriptions 3673 // 3674 // kTableIndexClustered - this is a clustered index 3675 // kTableIndexHashed - this is a hashed index 3676 // kTableIndexOther - this is some other style of index 3677 // 3678 // 8.ORDINAL_POSITION short => column sequence number within 3679 // index; zero when TYPE is 3680 // kTableIndexStatistic 3681 // 3682 // 9.COLUMN_NAME string => column name; null when TYPE is 3683 // kTableIndexStatistic 3684 // 3685 // 10.ASC_OR_DESC string => column sort sequence, 3686 // 3687 // "A" => ascending, 3688 // "D" => descending, may be null if 3689 // sort sequence is not supported; 3690 // null => when TYPE is kTableIndexStatistic 3691 // 3692 // 11.CARDINALITY int => When TYPE is kTableIndexStatistic, 3693 // then this is the number of rows in 3694 // the table; otherwise, it is the number 3695 // of unique values in the index. 3696 // 3697 // 12.PAGES int => When TYPE is kTableIndexStatisic then 3698 // this is the number of pages used for 3699 // the table, otherwise it is the number 3700 // of pages used for the current index. 3701 // 3702 // 13.FILTER_CONDITION string => Filter condition, if any 3703 // (may be null) 3704 // 3705 // Parameters: 3706 // catalog - a catalog name; 3707 // "" - retrieves those without a catalog; 3708 // schema - a schema name; 3709 // "" - retrieves those without a schema 3710 // table - a table name 3711 // unique - when kTRUE, return only indices for unique 3712 // values; when kFALSE, return indices 3713 // regardless of whether unique or not 3714 // approximate - when kTRUE, result is allowed to reflect 3715 // approximate or out of data values; 3716 // when kFALSE, results are requested to 3717 // be accurate 3718 // 3719 // Returns: 3720 // TSQLResultSet - each row is an index column description 3721 // Throws: 3722 // TSQLException - if a database access error occurs 3723 3724 gResult->Close(); 3725 MySQLConnectionPrivate* con = (MySQLConnectionPrivate*)fConnection->fImp; 3726 3727 static MYSQL_FIELD SQLSTAT_fields[] = { 3728 {"TABLE_CAT","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}, 3729 {"TABLE_SCHEM","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}, 3730 {"TABLE_NAME","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,NAME_LEN,NOT_NULL_FLAG}, 3731 {"NON_UNIQUE","MySQL_Stat",NULL,FIELD_TYPE_SHORT,1,1,NOT_NULL_FLAG}, 3732 {"NDEX_QUALIFIER","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,0}, 3733 {"INDEX_NAME","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,NAME_LEN}, 3734 {"TYPE","MySQL_Stat",NULL,FIELD_TYPE_SHORT,1,1,NOT_NULL_FLAG}, 3735 {"ORDINAL_POSITION","MySQL_Stat",NULL,FIELD_TYPE_SHORT,1,2,NOT_NULL_FLAG}, 3736 {"COLUMN_NAME","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,NAME_LEN,NAME_LEN,NOT_NULL_FLAG}, 3737 {"ASC_OR_DESC","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,1,1}, 3738 {"CARDINALITY","MySQL_Stat",NULL,FIELD_TYPE_LONG,11,11}, 3739 {"PAGES","MySQL_Stat",NULL,FIELD_TYPE_LONG,9,9}, 3740 {"FILTER_CONDITION","MySQL_Stat",NULL,FIELD_TYPE_VAR_STRING,10,10}, 3741 }; 3742 3743 const Int_t SQLSTAT_FIELDS=array_elements(SQLSTAT_fields); 3744 3745 return new TSQLResultSet(0,gResult); 3746 } 3747 3748 //___________________________________________________________________ 3749 Bool_t TSQLDatabaseMetaData::SupportsResultSetType( Int_t type ) 3750 { 3751 // Does the database support the given result set type? 3752 // 3753 // Parameters: 3754 // type - defined in TSQLResultSet::kTYPE_XXX 3755 // 3756 // Returns: 3757 // kTRUE if so; kFALSE otherwise 3758 // Throws: 3759 // TSQLException - if a database access error occurs 3760 // See Also: 3761 // TSQLResultSet 3762 3763 return ( (type==kTYPE_SCROLL_INSENSITIVE) || (type==kTYPE_FORWARD_ONLY) ); 3764 } 3765 3766 //___________________________________________________________________ 3767 Bool_t TSQLDatabaseMetaData::SupportsResultSetConcurrency( Int_t type, 3768 Int_t concurrency ) 3769 { 3770 // Does the database support the concurrency type in combination 3771 // with the given result set type? 3772 // 3773 // Parameters: 3774 // type - defined in TSQLResultSet 3775 // concurrency - type defined in TSQLResultSet 3776 // 3777 // Returns: 3778 // kTRUE if so; kFALSE otherwise 3779 // Throws: 3780 // TSQLException - if a database access error occurs 3781 // See Also: 3782 // TSQLConnection TSQLResultSet 3783 3784 return (type == kTYPE_SCROLL_SENSITIVE && 3785 concurrency == kCONCUR_READ_ONLY); 3786 } 3787 3788 //___________________________________________________________________ 3789 Bool_t TSQLDatabaseMetaData::OwnUpdatesAreVisible( Int_t type ) 3790 { 3791 // Indicates whether a result set's own updates are visible. 3792 // 3793 // Parameters: 3794 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3795 // 3796 // Returns: 3797 // kTRUE if updates are visible for the result set type; 3798 // kFALSE otherwise 3799 // Throws: 3800 // TSQLException - if a database access error occurs 3801 // 3802 // see also TSQLResultSet 3803 3804 Bool_t return_value = kFALSE; 3805 return return_value; 3806 } 3807 3808 //___________________________________________________________________ 3809 Bool_t TSQLDatabaseMetaData::OwnDeletesAreVisible( Int_t type ) 3810 { 3811 // Indicates whether a result set's own deletes are visible. 3812 // 3813 // Parameters: 3814 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3815 // 3816 // Returns: 3817 // kTRUE if deletes are visible for the result set type; 3818 // kFALSE otherwise 3819 // Throws: 3820 // TSQLException - if a database access error occurs 3821 // 3822 // see also TSQLResultSet 3823 3824 return kFALSE; 3825 } 3826 3827 //___________________________________________________________________ 3828 Bool_t TSQLDatabaseMetaData::OwnInsertsAreVisible( Int_t type ) 3829 { 3830 // Indicates whether a result set's own inserts are visible. 3831 // 3832 // Parameters: 3833 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3834 // 3835 // Returns: 3836 // kTRUE if inserts are visible for the result set type; 3837 // kFALSE otherwise 3838 // Throws: 3839 // TSQLException - if a database access error occurs 3840 // 3841 // see also TSQLResultSet 3842 3843 return kFALSE; 3844 } 3845 3846 //___________________________________________________________________ 3847 Bool_t TSQLDatabaseMetaData::OthersUpdatesAreVisible( Int_t type ) 3848 { 3849 // Indicates whether updates made by others are visible. 3850 // 3851 // Parameters: 3852 // resultset type, i.e. TSQLResultSet::kTYPE_XXX. 3853 // 3854 // Returns: 3855 // kTRUE if updates made by others are visible for 3856 // the result set type; kFALSE otherwise 3857 // Throws: 3858 // TSQLException - if a database access error occurs 3859 3860 return kFALSE; 3861 } 3862 3863 //___________________________________________________________________ 3864 Bool_t TSQLDatabaseMetaData::OthersDeletesAreVisible( Int_t type ) 3865 { 3866 // Indicates whether deletes made by others are visible. 3867 // 3868 // Parameters: 3869 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3870 // 3871 // Returns: 3872 // kTRUE if deletes made by others are visible for the 3873 // result set type; kFALSE otherwise 3874 // Throws: 3875 // TSQLException - if a database access error occurs 3876 3877 return kFALSE; 3878 } 3879 3880 //___________________________________________________________________ 3881 Bool_t TSQLDatabaseMetaData::OthersInsertsAreVisible( Int_t type ) 3882 { 3883 // Indicates whether inserts made by others are visible. 3884 // 3885 // Parameters: 3886 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3887 // 3888 // Returns: 3889 // kTRUE if updates are visible for the result set type 3890 // Throws: 3891 // TSQLException - if a database access error occurs 3892 3893 return kFALSE; 3894 } 3895 3896 //___________________________________________________________________ 3897 Bool_t TSQLDatabaseMetaData::UpdatesAreDetected( Int_t type ) 3898 { 3899 // Indicates whether or not a visible row update can be detected 3900 // by calling the method TSQLResultSet::RowUpdated(). 3901 // 3902 // Parameters: 3903 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3904 // 3905 // Returns: 3906 // kTRUE if changes are detected by the result set type; 3907 // kFALSE otherwise 3908 // Throws: 3909 // TSQLException - if a database access error occurs 3910 3911 return kFALSE; 3912 } 3913 3914 //___________________________________________________________________ 3915 Bool_t TSQLDatabaseMetaData::DeletesAreDetected( Int_t type ) 3916 { 3917 // Indicates whether or not a visible row delete 3918 // can be detected by calling TSQLResultSet::RowDeleted(). 3919 // If DeletesAreDetected() returns kFALSE, then deleted rows are 3920 // removed from the result set. 3921 // 3922 // Parameters: 3923 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3924 // 3925 // Returns: 3926 // kTRUE if changes are detected by the resultset type 3927 // Throws: 3928 // TSQLException - if a database access error occurs 3929 3930 return kFALSE; 3931 } 3932 3933 //___________________________________________________________________ 3934 Bool_t TSQLDatabaseMetaData::InsertsAreDetected( Int_t type ) 3935 { 3936 // Indicates whether or not a visible row insert 3937 // can be detected by calling TSQLResultSet::RowInserted(). 3938 // 3939 // Parameters: 3940 // resultset type, i.e. TSQLResultSet::kTYPE_XXX 3941 // 3942 // Returns: 3943 // kTRUE if changes are detected by the resultset type 3944 // Throws: 3945 // TSQLException - if a database access error occurs 3946 3947 return kFALSE; 3948 } 3949 3950 //___________________________________________________________________ 3951 Bool_t TSQLDatabaseMetaData::SupportsBatchUpdates() 3952 { 3953 // Indicates whether the driver supports batch updates. 3954 // 3955 // Returns: 3956 // kTRUE if the driver supports batch updates; 3957 // kFALSE otherwise 3958 3959 return kFALSE; 3960 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |