metadata.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /*
  2. * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2.0, as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is also distributed with certain software (including
  9. * but not limited to OpenSSL) that is licensed under separate terms,
  10. * as designated in a particular file or component or in included license
  11. * documentation. The authors of MySQL hereby grant you an
  12. * additional permission to link the program and your derivative works
  13. * with the separately licensed software that they have included with
  14. * MySQL.
  15. *
  16. * Without limiting anything contained in the foregoing, this file,
  17. * which is part of MySQL Connector/C++, is also subject to the
  18. * Universal FOSS Exception, version 1.0, a copy of which can be found at
  19. * http://oss.oracle.com/licenses/universal-foss-exception.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. * See the GNU General Public License, version 2.0, for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #ifndef _SQL_METADATA_H_
  31. #define _SQL_METADATA_H_
  32. #include <string>
  33. #include <list>
  34. #include "datatype.h"
  35. #include "sqlstring.h"
  36. namespace sql
  37. {
  38. class ResultSet;
  39. class Connection;
  40. class DatabaseMetaData
  41. {
  42. protected:
  43. virtual ~DatabaseMetaData() {}
  44. public:
  45. enum
  46. {
  47. attributeNoNulls = 0,
  48. attributeNullable,
  49. attributeNullableUnknown
  50. };
  51. enum
  52. {
  53. bestRowTemporary = 0,
  54. bestRowTransaction,
  55. bestRowSession
  56. };
  57. enum
  58. {
  59. bestRowUnknown = 0,
  60. bestRowNotPseudo,
  61. bestRowPseudo
  62. };
  63. enum
  64. {
  65. columnNoNulls = 0,
  66. columnNullable,
  67. columnNullableUnknown
  68. };
  69. enum
  70. {
  71. importedKeyCascade = 0,
  72. importedKeyInitiallyDeferred,
  73. importedKeyInitiallyImmediate,
  74. importedKeyNoAction,
  75. importedKeyNotDeferrable,
  76. importedKeyRestrict,
  77. importedKeySetDefault,
  78. importedKeySetNull
  79. };
  80. enum
  81. {
  82. procedureColumnIn = 0,
  83. procedureColumnInOut,
  84. procedureColumnOut,
  85. procedureColumnResult,
  86. procedureColumnReturn,
  87. procedureColumnUnknown,
  88. procedureNoNulls,
  89. procedureNoResult,
  90. procedureNullable,
  91. procedureNullableUnknown,
  92. procedureResultUnknown,
  93. procedureReturnsResult
  94. };
  95. enum
  96. {
  97. sqlStateSQL99 = 0,
  98. sqlStateXOpen
  99. };
  100. enum
  101. {
  102. tableIndexClustered = 0,
  103. tableIndexHashed,
  104. tableIndexOther,
  105. tableIndexStatistic
  106. };
  107. enum
  108. {
  109. versionColumnUnknown = 0,
  110. versionColumnNotPseudo = 1,
  111. versionColumnPseudo = 2
  112. };
  113. enum
  114. {
  115. typeNoNulls = 0,
  116. typeNullable = 1,
  117. typeNullableUnknown = 2
  118. };
  119. enum
  120. {
  121. typePredNone = 0,
  122. typePredChar = 1,
  123. typePredBasic= 2,
  124. typeSearchable = 3
  125. };
  126. virtual bool allProceduresAreCallable() = 0;
  127. virtual bool allTablesAreSelectable() = 0;
  128. virtual bool dataDefinitionCausesTransactionCommit() = 0;
  129. virtual bool dataDefinitionIgnoredInTransactions() = 0;
  130. virtual bool deletesAreDetected(int type) = 0;
  131. virtual bool doesMaxRowSizeIncludeBlobs() = 0;
  132. virtual ResultSet * getAttributes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, const sql::SQLString& attributeNamePattern) = 0;
  133. virtual ResultSet * getBestRowIdentifier(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, int scope, bool nullable) = 0;
  134. virtual ResultSet * getCatalogs() = 0;
  135. virtual const sql::SQLString& getCatalogSeparator() = 0;
  136. virtual const sql::SQLString& getCatalogTerm() = 0;
  137. virtual ResultSet * getColumnPrivileges(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, const sql::SQLString& columnNamePattern) = 0;
  138. virtual ResultSet * getColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, const sql::SQLString& columnNamePattern) = 0;
  139. virtual Connection * getConnection() = 0;
  140. virtual ResultSet * getCrossReference(const sql::SQLString& primaryCatalog, const sql::SQLString& primarySchema, const sql::SQLString& primaryTable, const sql::SQLString& foreignCatalog, const sql::SQLString& foreignSchema, const sql::SQLString& foreignTable) = 0;
  141. virtual unsigned int getDatabaseMajorVersion() = 0;
  142. virtual unsigned int getDatabaseMinorVersion() = 0;
  143. virtual unsigned int getDatabasePatchVersion() = 0;
  144. virtual const sql::SQLString& getDatabaseProductName() = 0;
  145. virtual SQLString getDatabaseProductVersion() = 0;
  146. virtual int getDefaultTransactionIsolation() = 0;
  147. virtual unsigned int getDriverMajorVersion() = 0;
  148. virtual unsigned int getDriverMinorVersion() = 0;
  149. virtual unsigned int getDriverPatchVersion() = 0;
  150. virtual const sql::SQLString& getDriverName() = 0;
  151. virtual const sql::SQLString& getDriverVersion() = 0;
  152. virtual ResultSet * getExportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
  153. virtual const sql::SQLString& getExtraNameCharacters() = 0;
  154. virtual const sql::SQLString& getIdentifierQuoteString() = 0;
  155. virtual ResultSet * getImportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
  156. virtual ResultSet * getIndexInfo(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, bool unique, bool approximate) = 0;
  157. virtual unsigned int getCDBCMajorVersion() = 0;
  158. virtual unsigned int getCDBCMinorVersion() = 0;
  159. virtual unsigned int getMaxBinaryLiteralLength() = 0;
  160. virtual unsigned int getMaxCatalogNameLength() = 0;
  161. virtual unsigned int getMaxCharLiteralLength() = 0;
  162. virtual unsigned int getMaxColumnNameLength() = 0;
  163. virtual unsigned int getMaxColumnsInGroupBy() = 0;
  164. virtual unsigned int getMaxColumnsInIndex() = 0;
  165. virtual unsigned int getMaxColumnsInOrderBy() = 0;
  166. virtual unsigned int getMaxColumnsInSelect() = 0;
  167. virtual unsigned int getMaxColumnsInTable() = 0;
  168. virtual unsigned int getMaxConnections() = 0;
  169. virtual unsigned int getMaxCursorNameLength() = 0;
  170. virtual unsigned int getMaxIndexLength() = 0;
  171. virtual unsigned int getMaxProcedureNameLength() = 0;
  172. virtual unsigned int getMaxRowSize() = 0;
  173. virtual unsigned int getMaxSchemaNameLength() = 0;
  174. virtual unsigned int getMaxStatementLength() = 0;
  175. virtual unsigned int getMaxStatements() = 0;
  176. virtual unsigned int getMaxTableNameLength() = 0;
  177. virtual unsigned int getMaxTablesInSelect() = 0;
  178. virtual unsigned int getMaxUserNameLength() = 0;
  179. virtual const sql::SQLString& getNumericFunctions() = 0;
  180. virtual ResultSet * getPrimaryKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
  181. virtual ResultSet * getProcedureColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern, const sql::SQLString& columnNamePattern) = 0;
  182. virtual ResultSet * getProcedures(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern) = 0;
  183. virtual const sql::SQLString& getProcedureTerm() = 0;
  184. virtual int getResultSetHoldability() = 0;
  185. virtual ResultSet * getSchemas() = 0;
  186. virtual const sql::SQLString& getSchemaTerm() = 0;
  187. virtual ResultSet * getSchemaCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
  188. virtual ResultSet * getSchemaCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern) = 0;
  189. virtual const sql::SQLString& getSearchStringEscape() = 0;
  190. virtual const sql::SQLString& getSQLKeywords() = 0;
  191. virtual int getSQLStateType() = 0;
  192. virtual const sql::SQLString& getStringFunctions() = 0;
  193. virtual ResultSet * getSuperTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
  194. virtual ResultSet * getSuperTypes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern) = 0;
  195. virtual const sql::SQLString& getSystemFunctions() = 0;
  196. virtual ResultSet * getTablePrivileges(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
  197. virtual ResultSet * getTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, std::list<sql::SQLString> &types) = 0;
  198. virtual ResultSet * getTableTypes() = 0;
  199. virtual ResultSet * getTableCollation(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
  200. virtual ResultSet * getTableCharset(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0;
  201. virtual const sql::SQLString& getTimeDateFunctions() = 0;
  202. virtual ResultSet * getTypeInfo() = 0;
  203. virtual ResultSet * getUDTs(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, std::list<int> &types) = 0;
  204. virtual SQLString getURL() = 0;
  205. virtual SQLString getUserName() = 0;
  206. virtual ResultSet * getVersionColumns(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0;
  207. virtual bool insertsAreDetected(int type) = 0;
  208. virtual bool isCatalogAtStart() = 0;
  209. virtual bool isReadOnly() = 0;
  210. virtual bool locatorsUpdateCopy() = 0;
  211. virtual bool nullPlusNonNullIsNull() = 0;
  212. virtual bool nullsAreSortedAtEnd() = 0;
  213. virtual bool nullsAreSortedAtStart() = 0;
  214. virtual bool nullsAreSortedHigh() = 0;
  215. virtual bool nullsAreSortedLow() = 0;
  216. virtual bool othersDeletesAreVisible(int type) = 0;
  217. virtual bool othersInsertsAreVisible(int type) = 0;
  218. virtual bool othersUpdatesAreVisible(int type) = 0;
  219. virtual bool ownDeletesAreVisible(int type) = 0;
  220. virtual bool ownInsertsAreVisible(int type) = 0;
  221. virtual bool ownUpdatesAreVisible(int type) = 0;
  222. virtual bool storesLowerCaseIdentifiers() = 0;
  223. virtual bool storesLowerCaseQuotedIdentifiers() = 0;
  224. virtual bool storesMixedCaseIdentifiers() = 0;
  225. virtual bool storesMixedCaseQuotedIdentifiers() = 0;
  226. virtual bool storesUpperCaseIdentifiers() = 0;
  227. virtual bool storesUpperCaseQuotedIdentifiers() = 0;
  228. virtual bool supportsAlterTableWithAddColumn() = 0;
  229. virtual bool supportsAlterTableWithDropColumn() = 0;
  230. virtual bool supportsANSI92EntryLevelSQL() = 0;
  231. virtual bool supportsANSI92FullSQL() = 0;
  232. virtual bool supportsANSI92IntermediateSQL() = 0;
  233. virtual bool supportsBatchUpdates() = 0;
  234. virtual bool supportsCatalogsInDataManipulation() = 0;
  235. virtual bool supportsCatalogsInIndexDefinitions() = 0;
  236. virtual bool supportsCatalogsInPrivilegeDefinitions() = 0;
  237. virtual bool supportsCatalogsInProcedureCalls() = 0;
  238. virtual bool supportsCatalogsInTableDefinitions() = 0;
  239. virtual bool supportsColumnAliasing() = 0;
  240. virtual bool supportsConvert() = 0;
  241. virtual bool supportsConvert(int fromType, int toType) = 0;
  242. virtual bool supportsCoreSQLGrammar() = 0;
  243. virtual bool supportsCorrelatedSubqueries() = 0;
  244. virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0;
  245. virtual bool supportsDataManipulationTransactionsOnly() = 0;
  246. virtual bool supportsDifferentTableCorrelationNames() = 0;
  247. virtual bool supportsExpressionsInOrderBy() = 0;
  248. virtual bool supportsExtendedSQLGrammar() = 0;
  249. virtual bool supportsFullOuterJoins() = 0;
  250. virtual bool supportsGetGeneratedKeys() = 0;
  251. virtual bool supportsGroupBy() = 0;
  252. virtual bool supportsGroupByBeyondSelect() = 0;
  253. virtual bool supportsGroupByUnrelated() = 0;
  254. virtual bool supportsIntegrityEnhancementFacility() = 0;
  255. virtual bool supportsLikeEscapeClause() = 0;
  256. virtual bool supportsLimitedOuterJoins() = 0;
  257. virtual bool supportsMinimumSQLGrammar() = 0;
  258. virtual bool supportsMixedCaseIdentifiers() = 0;
  259. virtual bool supportsMixedCaseQuotedIdentifiers() = 0;
  260. virtual bool supportsMultipleOpenResults() = 0;
  261. virtual bool supportsMultipleResultSets() = 0;
  262. virtual bool supportsMultipleTransactions() = 0;
  263. virtual bool supportsNamedParameters() = 0;
  264. virtual bool supportsNonNullableColumns() = 0;
  265. virtual bool supportsOpenCursorsAcrossCommit() = 0;
  266. virtual bool supportsOpenCursorsAcrossRollback() = 0;
  267. virtual bool supportsOpenStatementsAcrossCommit() = 0;
  268. virtual bool supportsOpenStatementsAcrossRollback() = 0;
  269. virtual bool supportsOrderByUnrelated() = 0;
  270. virtual bool supportsOuterJoins() = 0;
  271. virtual bool supportsPositionedDelete() = 0;
  272. virtual bool supportsPositionedUpdate() = 0;
  273. virtual bool supportsResultSetConcurrency(int type, int concurrency) = 0;
  274. virtual bool supportsResultSetHoldability(int holdability) = 0;
  275. virtual bool supportsResultSetType(int type) = 0;
  276. virtual bool supportsSavepoints() = 0;
  277. virtual bool supportsSchemasInDataManipulation() = 0;
  278. virtual bool supportsSchemasInIndexDefinitions() = 0;
  279. virtual bool supportsSchemasInPrivilegeDefinitions() = 0;
  280. virtual bool supportsSchemasInProcedureCalls() = 0;
  281. virtual bool supportsSchemasInTableDefinitions() = 0;
  282. virtual bool supportsSelectForUpdate() = 0;
  283. virtual bool supportsStatementPooling() = 0;
  284. virtual bool supportsStoredProcedures() = 0;
  285. virtual bool supportsSubqueriesInComparisons() = 0;
  286. virtual bool supportsSubqueriesInExists() = 0;
  287. virtual bool supportsSubqueriesInIns() = 0;
  288. virtual bool supportsSubqueriesInQuantifieds() = 0;
  289. virtual bool supportsTableCorrelationNames() = 0;
  290. virtual bool supportsTransactionIsolationLevel(int level) = 0;
  291. virtual bool supportsTransactions() = 0;
  292. virtual bool supportsTypeConversion() = 0; /* SDBC */
  293. virtual bool supportsUnion() = 0;
  294. virtual bool supportsUnionAll() = 0;
  295. virtual bool updatesAreDetected(int type) = 0;
  296. virtual bool usesLocalFilePerTable() = 0;
  297. virtual bool usesLocalFiles() = 0;
  298. virtual ResultSet *getSchemata(const sql::SQLString& catalogName = "") = 0;
  299. virtual ResultSet *getSchemaObjects(const sql::SQLString& catalogName = "",
  300. const sql::SQLString& schemaName = "",
  301. const sql::SQLString& objectType = "",
  302. bool includingDdl = true,
  303. const sql::SQLString& objectName = "",
  304. const sql::SQLString& contextTableName = "") = 0;
  305. virtual ResultSet *getSchemaObjectTypes() = 0;
  306. };
  307. } /* namespace sql */
  308. #endif /* _SQL_METADATA_H_ */