xref: /trunk/main/mysqlc/source/mysqlc_databasemetadata.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef CONNECTIVITY_SDATABASEMETADATA_HXX
23 #define CONNECTIVITY_SDATABASEMETADATA_HXX
24 
25 #include "mysqlc_connection.hxx"
26 
27 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
28 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
29 #endif
30 #ifndef _CPPUHELPER_IMPLBASE1_HXX_
31 #include <cppuhelper/implbase1.hxx>
32 #endif
33 
34 #include <preextstl.h>
35 #include <cppconn/metadata.h>
36 #include <postextstl.h>
37 
38 namespace connectivity
39 {
40     namespace mysqlc
41     {
42         typedef ::com::sun::star::sdbc::SQLException my_SQLException;
43         typedef ::com::sun::star::uno::RuntimeException my_RuntimeException;
44         typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > my_XResultSetRef;
45         using ::com::sun::star::uno::Any;
46         using ::rtl::OUString;
47 
48         //**************************************************************
49         //************ Class: ODatabaseMetaData
50         //**************************************************************
51 
52         typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> ODatabaseMetaData_BASE;
53 
54         class ODatabaseMetaData : public ODatabaseMetaData_BASE
55         {
56             OConnection&    m_rConnection;
57             sal_Bool        m_bUseCatalog;
58         protected:
59             sql::DatabaseMetaData * meta;
60             OUString        identifier_quote_string;
61             bool            identifier_quote_string_set;
62 
63         private:
64             OUString impl_getStringMetaData( const sal_Char* _methodName, const ext_std::string& (sql::DatabaseMetaData::*_Method)() );
65             OUString impl_getStringMetaData( const sal_Char* _methodName, ext_std::string (sql::DatabaseMetaData::*_Method)() );
66             OUString impl_getStringMetaData( const sal_Char* _methodName, const sql::SQLString& (sql::DatabaseMetaData::*_Method)() );
67             OUString impl_getStringMetaData( const sal_Char* _methodName, sql::SQLString (sql::DatabaseMetaData::*_Method)() );
68             sal_Int32 impl_getInt32MetaData( const sal_Char* _methodName, unsigned int (sql::DatabaseMetaData::*_Method)() );
69             sal_Bool impl_getBoolMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)() );
70             sal_Bool impl_getBoolMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)(int), sal_Int32 _arg );
71             sal_Bool impl_getRSTypeMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*_Method)(int), sal_Int32 _resultSetType );
72 
73         public:
getOwnConnection() const74             inline const OConnection& getOwnConnection() const { return m_rConnection; }
75 
76             ODatabaseMetaData(OConnection& _rCon);
77             virtual ~ODatabaseMetaData();
78 
79             // as I mentioned before this interface is really BIG
80             // XDatabaseMetaData
81             sal_Bool SAL_CALL allProceduresAreCallable();
82             sal_Bool SAL_CALL allTablesAreSelectable();
83             OUString SAL_CALL getURL();
84             OUString SAL_CALL getUserName();
85             sal_Bool SAL_CALL isReadOnly();
86             sal_Bool SAL_CALL nullsAreSortedHigh();
87             sal_Bool SAL_CALL nullsAreSortedLow();
88             sal_Bool SAL_CALL nullsAreSortedAtStart();
89             sal_Bool SAL_CALL nullsAreSortedAtEnd();
90             OUString SAL_CALL getDatabaseProductName();
91             OUString SAL_CALL getDatabaseProductVersion();
92             OUString SAL_CALL getDriverName();
93             OUString SAL_CALL getDriverVersion();
94             sal_Int32 SAL_CALL getDriverMajorVersion();
95             sal_Int32 SAL_CALL getDriverMinorVersion();
96             sal_Bool SAL_CALL usesLocalFiles();
97             sal_Bool SAL_CALL usesLocalFilePerTable();
98             sal_Bool SAL_CALL supportsMixedCaseIdentifiers();
99             sal_Bool SAL_CALL storesUpperCaseIdentifiers();
100             sal_Bool SAL_CALL storesLowerCaseIdentifiers();
101             sal_Bool SAL_CALL storesMixedCaseIdentifiers();
102             sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers();
103             sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers();
104             sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers();
105             sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers();
106             OUString SAL_CALL getIdentifierQuoteString();
107             OUString SAL_CALL getSQLKeywords();
108             OUString SAL_CALL getNumericFunctions();
109             OUString SAL_CALL getStringFunctions();
110             OUString SAL_CALL getSystemFunctions();
111             OUString SAL_CALL getTimeDateFunctions();
112             OUString SAL_CALL getSearchStringEscape();
113             OUString SAL_CALL getExtraNameCharacters();
114             sal_Bool SAL_CALL supportsAlterTableWithAddColumn();
115             sal_Bool SAL_CALL supportsAlterTableWithDropColumn();
116             sal_Bool SAL_CALL supportsColumnAliasing();
117             sal_Bool SAL_CALL nullPlusNonNullIsNull();
118             sal_Bool SAL_CALL supportsTypeConversion();
119             sal_Bool SAL_CALL supportsConvert(sal_Int32 fromType, sal_Int32 toType);
120             sal_Bool SAL_CALL supportsTableCorrelationNames();
121             sal_Bool SAL_CALL supportsDifferentTableCorrelationNames();
122             sal_Bool SAL_CALL supportsExpressionsInOrderBy();
123             sal_Bool SAL_CALL supportsOrderByUnrelated();
124             sal_Bool SAL_CALL supportsGroupBy();
125             sal_Bool SAL_CALL supportsGroupByUnrelated();
126             sal_Bool SAL_CALL supportsGroupByBeyondSelect();
127             sal_Bool SAL_CALL supportsLikeEscapeClause();
128             sal_Bool SAL_CALL supportsMultipleResultSets();
129             sal_Bool SAL_CALL supportsMultipleTransactions();
130             sal_Bool SAL_CALL supportsNonNullableColumns();
131             sal_Bool SAL_CALL supportsMinimumSQLGrammar();
132             sal_Bool SAL_CALL supportsCoreSQLGrammar();
133             sal_Bool SAL_CALL supportsExtendedSQLGrammar();
134             sal_Bool SAL_CALL supportsANSI92EntryLevelSQL();
135             sal_Bool SAL_CALL supportsANSI92IntermediateSQL();
136             sal_Bool SAL_CALL supportsANSI92FullSQL();
137             sal_Bool SAL_CALL supportsIntegrityEnhancementFacility();
138             sal_Bool SAL_CALL supportsOuterJoins();
139             sal_Bool SAL_CALL supportsFullOuterJoins();
140             sal_Bool SAL_CALL supportsLimitedOuterJoins();
141             OUString SAL_CALL getSchemaTerm();
142             OUString SAL_CALL getProcedureTerm();
143             OUString SAL_CALL getCatalogTerm();
144             sal_Bool SAL_CALL isCatalogAtStart();
145             OUString SAL_CALL getCatalogSeparator();
146             sal_Bool SAL_CALL supportsSchemasInDataManipulation();
147             sal_Bool SAL_CALL supportsSchemasInProcedureCalls();
148             sal_Bool SAL_CALL supportsSchemasInTableDefinitions();
149             sal_Bool SAL_CALL supportsSchemasInIndexDefinitions();
150             sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions();
151             sal_Bool SAL_CALL supportsCatalogsInDataManipulation();
152             sal_Bool SAL_CALL supportsCatalogsInProcedureCalls();
153             sal_Bool SAL_CALL supportsCatalogsInTableDefinitions();
154             sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions();
155             sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions();
156             sal_Bool SAL_CALL supportsPositionedDelete();
157             sal_Bool SAL_CALL supportsPositionedUpdate();
158             sal_Bool SAL_CALL supportsSelectForUpdate();
159             sal_Bool SAL_CALL supportsStoredProcedures();
160             sal_Bool SAL_CALL supportsSubqueriesInComparisons();
161             sal_Bool SAL_CALL supportsSubqueriesInExists();
162             sal_Bool SAL_CALL supportsSubqueriesInIns();
163             sal_Bool SAL_CALL supportsSubqueriesInQuantifieds();
164             sal_Bool SAL_CALL supportsCorrelatedSubqueries();
165             sal_Bool SAL_CALL supportsUnion();
166             sal_Bool SAL_CALL supportsUnionAll();
167             sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit();
168             sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback();
169             sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit();
170             sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback();
171             sal_Int32 SAL_CALL getMaxBinaryLiteralLength();
172             sal_Int32 SAL_CALL getMaxCharLiteralLength();
173             sal_Int32 SAL_CALL getMaxColumnNameLength();
174             sal_Int32 SAL_CALL getMaxColumnsInGroupBy();
175             sal_Int32 SAL_CALL getMaxColumnsInIndex();
176             sal_Int32 SAL_CALL getMaxColumnsInOrderBy();
177             sal_Int32 SAL_CALL getMaxColumnsInSelect();
178             sal_Int32 SAL_CALL getMaxColumnsInTable();
179             sal_Int32 SAL_CALL getMaxConnections();
180             sal_Int32 SAL_CALL getMaxCursorNameLength();
181             sal_Int32 SAL_CALL getMaxIndexLength();
182             sal_Int32 SAL_CALL getMaxSchemaNameLength();
183             sal_Int32 SAL_CALL getMaxProcedureNameLength();
184             sal_Int32 SAL_CALL getMaxCatalogNameLength();
185             sal_Int32 SAL_CALL getMaxRowSize();
186             sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs();
187             sal_Int32 SAL_CALL getMaxStatementLength();
188             sal_Int32 SAL_CALL getMaxStatements();
189             sal_Int32 SAL_CALL getMaxTableNameLength();
190             sal_Int32 SAL_CALL getMaxTablesInSelect();
191             sal_Int32 SAL_CALL getMaxUserNameLength();
192             sal_Int32 SAL_CALL getDefaultTransactionIsolation();
193             sal_Bool SAL_CALL supportsTransactions();
194             sal_Bool SAL_CALL supportsTransactionIsolationLevel(sal_Int32 level);
195             sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions();
196             sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly();
197             sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit();
198             sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions();
199             my_XResultSetRef SAL_CALL getProcedures(const Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern);
200             my_XResultSetRef SAL_CALL getProcedureColumns(const Any& catalog, const OUString& schemaPattern, const OUString& procedureNamePattern, const OUString& columnNamePattern);
201             my_XResultSetRef SAL_CALL getTables(const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< OUString >& types);
202             my_XResultSetRef SAL_CALL getSchemas();
203             my_XResultSetRef SAL_CALL getCatalogs();
204             my_XResultSetRef SAL_CALL getTableTypes();
205             my_XResultSetRef SAL_CALL getColumns(const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern, const OUString& columnNamePattern);
206             my_XResultSetRef SAL_CALL getColumnPrivileges(const Any& catalog, const OUString& schema, const OUString& table, const OUString& columnNamePattern);
207             my_XResultSetRef SAL_CALL getTablePrivileges(const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern);
208             my_XResultSetRef SAL_CALL getBestRowIdentifier(const Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope, sal_Bool nullable);
209             my_XResultSetRef SAL_CALL getVersionColumns(const Any& catalog, const OUString& schema, const OUString& table);
210             my_XResultSetRef SAL_CALL getPrimaryKeys(const Any& catalog, const OUString& schema, const OUString& table);
211             my_XResultSetRef SAL_CALL getImportedKeys(const Any& catalog, const OUString& schema, const OUString& table);
212             my_XResultSetRef SAL_CALL getExportedKeys(const Any& catalog, const OUString& schema, const OUString& table);
213             my_XResultSetRef SAL_CALL getCrossReference(const Any& primaryCatalog, const OUString& primarySchema, const OUString& primaryTable, const Any& foreignCatalog, const OUString& foreignSchema, const OUString& foreignTable);
214             my_XResultSetRef SAL_CALL getTypeInfo();
215             my_XResultSetRef SAL_CALL getIndexInfo(const Any& catalog, const OUString& schema, const OUString& table, sal_Bool unique, sal_Bool approximate);
216             sal_Bool SAL_CALL supportsResultSetType(sal_Int32 setType);
217             sal_Bool SAL_CALL supportsResultSetConcurrency(sal_Int32 setType, sal_Int32 concurrency);
218             sal_Bool SAL_CALL ownUpdatesAreVisible(sal_Int32 setType);
219             sal_Bool SAL_CALL ownDeletesAreVisible(sal_Int32 setType);
220             sal_Bool SAL_CALL ownInsertsAreVisible(sal_Int32 setType);
221             sal_Bool SAL_CALL othersUpdatesAreVisible(sal_Int32 setType);
222             sal_Bool SAL_CALL othersDeletesAreVisible(sal_Int32 setType);
223             sal_Bool SAL_CALL othersInsertsAreVisible(sal_Int32 setType);
224             sal_Bool SAL_CALL updatesAreDetected(sal_Int32 setType);
225             sal_Bool SAL_CALL deletesAreDetected(sal_Int32 setType);
226             sal_Bool SAL_CALL insertsAreDetected(sal_Int32 setType);
227             sal_Bool SAL_CALL supportsBatchUpdates();
228             my_XResultSetRef SAL_CALL getUDTs(const Any& catalog, const OUString& schemaPattern, const OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types);
229             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection();
230         };
231     }
232 }
233 
234 #endif // CONNECTIVITY_SDATABASEMETADATA_HXX
235