1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <odbc/ODatabaseMetaData.hxx>
21 #include <odbc/OTools.hxx>
22 #include <odbc/ODatabaseMetaDataResultSet.hxx>
23 #include <FDatabaseMetaDataResultSet.hxx>
24 #include <com/sun/star/sdbc/DataType.hpp>
25 #include <com/sun/star/sdbc/ResultSetType.hpp>
26 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
27 #include <com/sun/star/sdbc/TransactionIsolation.hpp>
28 #include <connectivity/odbc.hxx>
29 #include <TPrivilegesResultSet.hxx>
30 #include <connectivity/dbexception.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <sal/log.hxx>
33
34 using namespace connectivity::odbc;
35 using namespace com::sun::star::uno;
36 using namespace com::sun::star::lang;
37 using namespace com::sun::star::beans;
38 using namespace com::sun::star::sdbc;
39
ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection * _pCon)40 ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon)
41 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
42 ,m_aConnectionHandle(_pHandle)
43 ,m_pConnection(_pCon)
44 ,m_bUseCatalog(true)
45 {
46 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
47 if(!m_pConnection->isCatalogUsed())
48 {
49 osl_atomic_increment( &m_refCount );
50 try
51 {
52 m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
53 }
54 catch(SQLException& )
55 { // doesn't matter here
56 }
57 osl_atomic_decrement( &m_refCount );
58 }
59 }
60
~ODatabaseMetaData()61 ODatabaseMetaData::~ODatabaseMetaData()
62 {
63 }
64
impl_getTypeInfo_throw()65 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
66 {
67 Reference< XResultSet > xRef;
68 try
69 {
70 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
71 xRef = pResult;
72 pResult->openTypeInfo();
73 }
74 catch(SQLException&)
75 {
76 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
77 }
78
79 return xRef;
80 }
81
getCatalogs()82 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( )
83 {
84 Reference< XResultSet > xRef;
85 if(!m_bUseCatalog)
86 {
87 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
88 }
89 else
90 {
91 try
92 {
93 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
94 xRef = pResult;
95 pResult->openCatalogs();
96 }
97 catch(SQLException&)
98 {
99 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
100 }
101 }
102
103 return xRef;
104 }
105
impl_getCatalogSeparator_throw()106 OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
107 {
108 OUString aVal;
109 if ( m_bUseCatalog )
110 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_NAME_SEPARATOR,aVal,*this,m_pConnection->getTextEncoding());
111
112 return aVal;
113 }
114
getSchemas()115 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( )
116 {
117 Reference< XResultSet > xRef;
118 try
119 {
120 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
121 xRef = pResult;
122 pResult->openSchemas();
123 }
124 catch(SQLException&)
125 {
126 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eSchemas);
127 }
128 return xRef;
129 }
130
getColumnPrivileges(const Any & catalog,const OUString & schema,const OUString & table,const OUString & columnNamePattern)131 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
132 const Any& catalog, const OUString& schema, const OUString& table,
133 const OUString& columnNamePattern )
134 {
135 Reference< XResultSet > xRef;
136 try
137 {
138 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
139 xRef = pResult;
140 pResult->openColumnPrivileges(m_bUseCatalog ? catalog : Any(),schema,table,columnNamePattern);
141 }
142 catch(SQLException&)
143 {
144 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumnPrivileges);
145 }
146 return xRef;
147 }
148
getColumns(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern,const OUString & columnNamePattern)149 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
150 const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern,
151 const OUString& columnNamePattern )
152 {
153 Reference< XResultSet > xRef;
154 try
155 {
156 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
157 xRef = pResult;
158 pResult->openColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,columnNamePattern);
159 }
160 catch(SQLException&)
161 {
162 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
163 }
164 return xRef;
165 }
166
getTables(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern,const Sequence<OUString> & types)167 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
168 const Any& catalog, const OUString& schemaPattern,
169 const OUString& tableNamePattern, const Sequence< OUString >& types )
170 {
171 Reference< XResultSet > xRef;
172 try
173 {
174 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
175 xRef = pResult;
176 pResult->openTables(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,types);
177 }
178 catch(SQLException&)
179 {
180 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
181 }
182 return xRef;
183 }
184
getProcedureColumns(const Any & catalog,const OUString & schemaPattern,const OUString & procedureNamePattern,const OUString & columnNamePattern)185 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
186 const Any& catalog, const OUString& schemaPattern,
187 const OUString& procedureNamePattern, const OUString& columnNamePattern )
188 {
189 Reference< XResultSet > xRef;
190 try
191 {
192 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
193 xRef = pResult;
194 pResult->openProcedureColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern,columnNamePattern);
195 }
196 catch(SQLException&)
197 {
198 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedureColumns);
199 }
200 return xRef;
201 }
202
getProcedures(const Any & catalog,const OUString & schemaPattern,const OUString & procedureNamePattern)203 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
204 const Any& catalog, const OUString& schemaPattern,
205 const OUString& procedureNamePattern )
206 {
207 Reference< XResultSet > xRef;
208 try
209 {
210 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
211 xRef = pResult;
212 pResult->openProcedures(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern);
213 }
214 catch(SQLException&)
215 {
216 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedures);
217 }
218 return xRef;
219 }
220
getVersionColumns(const Any & catalog,const OUString & schema,const OUString & table)221 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
222 const Any& catalog, const OUString& schema, const OUString& table )
223 {
224 Reference< XResultSet > xRef;
225 bool bSuccess = false;
226 try
227 {
228 if ( !m_pConnection->preventGetVersionColumns() )
229 {
230 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
231 xRef = pResult;
232 pResult->openVersionColumns(m_bUseCatalog ? catalog : Any(),schema,table);
233 bSuccess = true;
234 }
235 }
236 catch(SQLException&)
237 {
238 }
239
240 if ( !bSuccess )
241 {
242 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
243 }
244
245 return xRef;
246 }
247
getMaxBinaryLiteralLength()248 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( )
249 {
250 SQLUINTEGER nValue;
251 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_BINARY_LITERAL_LEN,nValue,*this);
252 return nValue;
253 }
254
getMaxRowSize()255 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( )
256 {
257 SQLUINTEGER nValue;
258 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE,nValue,*this);
259 return nValue;
260 }
261
getMaxCatalogNameLength()262 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( )
263 {
264 SQLUSMALLINT nValue;
265 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CATALOG_NAME_LEN,nValue,*this);
266 return nValue;
267 }
268
getMaxCharLiteralLength()269 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( )
270 {
271 SQLUINTEGER nValue;
272 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CHAR_LITERAL_LEN,nValue,*this);
273 return nValue;
274 }
275
getMaxColumnNameLength()276 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( )
277 {
278 SQLUSMALLINT nValue;
279 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMN_NAME_LEN,nValue,*this);
280 return nValue;
281 }
282
getMaxColumnsInIndex()283 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( )
284 {
285 SQLUSMALLINT nValue;
286 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_INDEX,nValue,*this);
287 return nValue;
288 }
289
getMaxCursorNameLength()290 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( )
291 {
292 SQLUSMALLINT nValue;
293 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CURSOR_NAME_LEN,nValue,*this);
294 return nValue;
295 }
296
getMaxConnections()297 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( )
298 {
299 SQLUSMALLINT nValue;
300 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_DRIVER_CONNECTIONS/*SQL_ACTIVE_CONNECTIONS*/,nValue,*this);
301 return nValue;
302 }
303
getMaxColumnsInTable()304 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( )
305 {
306 SQLUSMALLINT nValue;
307 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_TABLE,nValue,*this);
308 return nValue;
309 }
310
getMaxStatementLength()311 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( )
312 {
313 SQLUINTEGER nValue;
314 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_STATEMENT_LEN,nValue,*this);
315 return nValue;
316 }
317
getMaxTableNameLength()318 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( )
319 {
320 SQLUSMALLINT nValue;
321 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLE_NAME_LEN,nValue,*this);
322 return nValue;
323 }
324
impl_getMaxTablesInSelect_throw()325 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
326 {
327 SQLUSMALLINT nValue;
328 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLES_IN_SELECT,nValue,*this);
329 return nValue;
330 }
331
getExportedKeys(const Any & catalog,const OUString & schema,const OUString & table)332 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
333 const Any& catalog, const OUString& schema, const OUString& table )
334 {
335 Reference< XResultSet > xRef;
336 try
337 {
338 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
339 xRef = pResult;
340 pResult->openExportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
341 }
342 catch(SQLException&)
343 {
344 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eExportedKeys);
345 }
346 return xRef;
347 }
348
getImportedKeys(const Any & catalog,const OUString & schema,const OUString & table)349 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
350 const Any& catalog, const OUString& schema, const OUString& table )
351 {
352 Reference< XResultSet > xRef;
353 try
354 {
355 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
356 xRef = pResult;
357 pResult->openImportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
358 }
359 catch(SQLException&)
360 {
361 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eImportedKeys);
362 }
363 return xRef;
364 }
365
getPrimaryKeys(const Any & catalog,const OUString & schema,const OUString & table)366 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
367 const Any& catalog, const OUString& schema, const OUString& table )
368 {
369 Reference< XResultSet > xRef;
370 try
371 {
372 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
373 xRef = pResult;
374 pResult->openPrimaryKeys(m_bUseCatalog ? catalog : Any(),schema,table);
375 }
376 catch(SQLException&)
377 {
378 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::ePrimaryKeys);
379 }
380 return xRef;
381 }
382
getIndexInfo(const Any & catalog,const OUString & schema,const OUString & table,sal_Bool unique,sal_Bool approximate)383 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
384 const Any& catalog, const OUString& schema, const OUString& table,
385 sal_Bool unique, sal_Bool approximate )
386 {
387 Reference< XResultSet > xRef;
388 try
389 {
390 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
391 xRef = pResult;
392 pResult->openIndexInfo(m_bUseCatalog ? catalog : Any(),schema,table,unique,approximate);
393 }
394 catch(SQLException&)
395 {
396 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo);
397 }
398 return xRef;
399 }
400
getBestRowIdentifier(const Any & catalog,const OUString & schema,const OUString & table,sal_Int32 scope,sal_Bool nullable)401 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
402 const Any& catalog, const OUString& schema, const OUString& table, sal_Int32 scope,
403 sal_Bool nullable )
404 {
405 Reference< XResultSet > xRef;
406 try
407 {
408 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
409 xRef = pResult;
410 pResult->openBestRowIdentifier(m_bUseCatalog ? catalog : Any(),schema,table,scope,nullable);
411 }
412 catch(SQLException&)
413 {
414 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eBestRowIdentifier);
415 }
416 return xRef;
417 }
418
getTablePrivileges(const Any & catalog,const OUString & schemaPattern,const OUString & tableNamePattern)419 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
420 const Any& catalog, const OUString& schemaPattern, const OUString& tableNamePattern )
421 {
422 if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
423 {
424 return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
425 }
426 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
427 Reference< XResultSet > xRef = pResult;
428 pResult->openTablePrivileges(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern);
429 return xRef;
430 }
431
getCrossReference(const Any & primaryCatalog,const OUString & primarySchema,const OUString & primaryTable,const Any & foreignCatalog,const OUString & foreignSchema,const OUString & foreignTable)432 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
433 const Any& primaryCatalog, const OUString& primarySchema,
434 const OUString& primaryTable, const Any& foreignCatalog,
435 const OUString& foreignSchema, const OUString& foreignTable )
436 {
437 Reference< XResultSet > xRef;
438 try
439 {
440 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
441 xRef = pResult;
442 pResult->openForeignKeys(m_bUseCatalog ? primaryCatalog : Any(),primarySchema.toChar() == '%' ? &primarySchema : nullptr,&primaryTable,
443 m_bUseCatalog ? foreignCatalog : Any(), foreignSchema.toChar() == '%' ? &foreignSchema : nullptr,&foreignTable);
444 }
445 catch(SQLException&)
446 {
447 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCrossReference);
448 }
449 return xRef;
450 }
451
doesMaxRowSizeIncludeBlobs()452 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
453 {
454 OUString aVal;
455 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE_INCLUDES_LONG,aVal,*this,m_pConnection->getTextEncoding());
456 return aVal.toChar() == 'Y';
457 }
458
storesLowerCaseQuotedIdentifiers()459 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
460 {
461 SQLUSMALLINT nValue;
462 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
463 return nValue == SQL_IC_LOWER;
464 }
465
storesLowerCaseIdentifiers()466 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( )
467 {
468 SQLUSMALLINT nValue;
469 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
470 return nValue == SQL_IC_LOWER;
471 }
472
impl_storesMixedCaseQuotedIdentifiers_throw()473 bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
474 {
475 SQLUSMALLINT nValue;
476 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
477 return nValue == SQL_IC_MIXED;
478 }
479
storesMixedCaseIdentifiers()480 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( )
481 {
482 SQLUSMALLINT nValue;
483 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
484 return nValue == SQL_IC_MIXED;
485 }
486
storesUpperCaseQuotedIdentifiers()487 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
488 {
489 SQLUSMALLINT nValue;
490 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
491 return nValue == SQL_IC_UPPER;
492 }
493
storesUpperCaseIdentifiers()494 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( )
495 {
496 SQLUSMALLINT nValue;
497 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
498 return nValue == SQL_IC_UPPER;
499 }
500
impl_supportsAlterTableWithAddColumn_throw()501 bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
502 {
503 SQLUINTEGER nValue;
504 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
505 return (nValue & SQL_AT_ADD_COLUMN) == SQL_AT_ADD_COLUMN;
506 }
507
impl_supportsAlterTableWithDropColumn_throw()508 bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
509 {
510 SQLUINTEGER nValue;
511 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
512 return ((nValue & SQL_AT_DROP_COLUMN) == SQL_AT_DROP_COLUMN) ||
513 ((nValue & SQL_AT_DROP_COLUMN_CASCADE) == SQL_AT_DROP_COLUMN_CASCADE) ||
514 ((nValue & SQL_AT_DROP_COLUMN_RESTRICT) == SQL_AT_DROP_COLUMN_RESTRICT);
515 }
516
getMaxIndexLength()517 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( )
518 {
519 SQLUINTEGER nValue;
520 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_INDEX_SIZE,nValue,*this);
521 return nValue;
522 }
523
supportsNonNullableColumns()524 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( )
525 {
526 SQLUSMALLINT nValue;
527 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NON_NULLABLE_COLUMNS,nValue,*this);
528 return nValue == SQL_NNC_NON_NULL;
529 }
530
getCatalogTerm()531 OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( )
532 {
533 OUString aVal;
534 if(m_bUseCatalog)
535 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_TERM,aVal,*this,m_pConnection->getTextEncoding());
536 return aVal;
537 }
538
impl_getIdentifierQuoteString_throw()539 OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
540 {
541 OUString aVal;
542 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_QUOTE_CHAR,aVal,*this,m_pConnection->getTextEncoding());
543 return aVal;
544 }
545
getExtraNameCharacters()546 OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( )
547 {
548 OUString aVal;
549 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SPECIAL_CHARACTERS,aVal,*this,m_pConnection->getTextEncoding());
550 return aVal;
551 }
552
supportsDifferentTableCorrelationNames()553 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
554 {
555 SQLUSMALLINT nValue;
556 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
557 return nValue != SQL_CN_NONE;
558 }
559
impl_isCatalogAtStart_throw()560 bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
561 {
562 SQLUSMALLINT nValue=0;
563 if ( m_bUseCatalog )
564 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_LOCATION,nValue,*this);
565 return nValue == SQL_CL_START;
566 }
567
dataDefinitionIgnoredInTransactions()568 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( )
569 {
570 SQLUSMALLINT nValue;
571 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
572 return nValue == SQL_TC_DDL_IGNORE;
573 }
574
dataDefinitionCausesTransactionCommit()575 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( )
576 {
577 SQLUSMALLINT nValue;
578 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
579 return nValue == SQL_TC_DDL_COMMIT;
580 }
581
supportsDataManipulationTransactionsOnly()582 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( )
583 {
584 SQLUSMALLINT nValue;
585 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
586 return nValue == SQL_TC_DML;
587 }
588
supportsDataDefinitionAndDataManipulationTransactions()589 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
590 {
591 SQLUSMALLINT nValue;
592 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
593 return nValue == SQL_TC_ALL;
594 }
595
supportsPositionedDelete()596 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( )
597 {
598 SQLUINTEGER nValue;
599 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
600 return (nValue & SQL_CA1_POS_DELETE) == SQL_CA1_POS_DELETE;
601 }
602
supportsPositionedUpdate()603 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( )
604 {
605 SQLUINTEGER nValue;
606 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
607 return (nValue & SQL_CA1_POS_UPDATE) == SQL_CA1_POS_UPDATE;
608 }
609
supportsOpenStatementsAcrossRollback()610 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( )
611 {
612 SQLUSMALLINT nValue;
613 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
614 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
615 }
616
supportsOpenStatementsAcrossCommit()617 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( )
618 {
619 SQLUSMALLINT nValue;
620 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
621 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
622 }
623
supportsOpenCursorsAcrossCommit()624 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( )
625 {
626 SQLUSMALLINT nValue;
627 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
628 return nValue == SQL_CB_PRESERVE;
629 }
630
supportsOpenCursorsAcrossRollback()631 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( )
632 {
633 SQLUSMALLINT nValue;
634 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
635 return nValue == SQL_CB_PRESERVE;
636 }
637
supportsTransactionIsolationLevel(sal_Int32 level)638 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level )
639 {
640 SQLUINTEGER nValue;
641 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_ISOLATION_OPTION,nValue,*this);
642 return (nValue & static_cast<SQLUINTEGER>(level)) == static_cast<SQLUINTEGER>(level);
643 }
644
impl_supportsSchemasInDataManipulation_throw()645 bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
646 {
647 SQLUINTEGER nValue;
648 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
649 return (nValue & SQL_SU_DML_STATEMENTS) == SQL_SU_DML_STATEMENTS;
650 }
651
supportsANSI92FullSQL()652 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( )
653 {
654 SQLUINTEGER nValue;
655 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
656 return static_cast<bool>(nValue & SQL_SC_SQL92_FULL);
657 }
658
supportsANSI92EntryLevelSQL()659 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( )
660 {
661 SQLUINTEGER nValue;
662 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
663 return static_cast<bool>(nValue &SQL_SC_SQL92_ENTRY);
664 }
665
supportsIntegrityEnhancementFacility()666 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( )
667 {
668 OUString aStr;
669 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_INTEGRITY,aStr,*this,m_pConnection->getTextEncoding());
670 return aStr.toChar() == 'Y';
671 }
672
supportsSchemasInIndexDefinitions()673 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( )
674 {
675 SQLUINTEGER nValue;
676 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
677 return (nValue & SQL_SU_INDEX_DEFINITION) == SQL_SU_INDEX_DEFINITION;
678 }
679
impl_supportsSchemasInTableDefinitions_throw()680 bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
681 {
682 SQLUINTEGER nValue;
683 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
684 return (nValue & SQL_SU_TABLE_DEFINITION) == SQL_SU_TABLE_DEFINITION;
685 }
686
impl_supportsCatalogsInTableDefinitions_throw()687 bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
688 {
689 SQLUINTEGER nValue=0;
690 if(m_bUseCatalog)
691 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
692 return (nValue & SQL_CU_TABLE_DEFINITION) == SQL_CU_TABLE_DEFINITION;
693 }
694
supportsCatalogsInIndexDefinitions()695 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( )
696 {
697 SQLUINTEGER nValue=0;
698 if(m_bUseCatalog)
699 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
700 return (nValue & SQL_CU_INDEX_DEFINITION) == SQL_CU_INDEX_DEFINITION;
701 }
702
impl_supportsCatalogsInDataManipulation_throw()703 bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
704 {
705 SQLUINTEGER nValue=0;
706 if(m_bUseCatalog)
707 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
708 return (nValue & SQL_CU_DML_STATEMENTS) == SQL_CU_DML_STATEMENTS;
709 }
710
supportsOuterJoins()711 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( )
712 {
713 SQLUINTEGER nValue;
714 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
715 return ((nValue & (SQL_OJ_FULL|SQL_OJ_LEFT|SQL_OJ_RIGHT|SQL_OJ_NESTED|SQL_OJ_NOT_ORDERED|SQL_OJ_ALL_COMPARISON_OPS|SQL_OJ_INNER)) != 0);
716 }
717
getTableTypes()718 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( )
719 {
720 Reference< XResultSet > xRef;
721 try
722 {
723 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
724 xRef = pResult;
725 pResult->openTablesTypes();
726 }
727 catch(SQLException&)
728 {
729 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
730 }
731 return xRef;
732 }
733
impl_getMaxStatements_throw()734 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
735 {
736 SQLUSMALLINT nValue;
737 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CONCURRENT_ACTIVITIES,nValue,*this);
738 return nValue;
739 }
740
getMaxProcedureNameLength()741 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( )
742 {
743 SQLUSMALLINT nValue;
744 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_PROCEDURE_NAME_LEN,nValue,*this);
745 return nValue;
746 }
747
getMaxSchemaNameLength()748 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( )
749 {
750 SQLUSMALLINT nValue;
751 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_SCHEMA_NAME_LEN,nValue,*this);
752 return nValue;
753 }
754
supportsTransactions()755 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( )
756 {
757 SQLUSMALLINT nValue;
758 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
759 return nValue != SQL_TC_NONE;
760 }
761
allProceduresAreCallable()762 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( )
763 {
764 OUString aValue;
765 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
766 return aValue.toChar() == 'Y';
767 }
768
supportsStoredProcedures()769 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( )
770 {
771 OUString aValue;
772 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
773 return aValue.toChar() == 'Y';
774 }
775
supportsSelectForUpdate()776 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( )
777 {
778 SQLUINTEGER nValue;
779 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
780 return (nValue & SQL_CA1_POSITIONED_UPDATE) == SQL_CA1_POSITIONED_UPDATE;
781 }
782
allTablesAreSelectable()783 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( )
784 {
785 OUString aValue;
786 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_TABLES,aValue,*this,m_pConnection->getTextEncoding());
787 return aValue.toChar() == 'Y';
788 }
789
isReadOnly()790 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( )
791 {
792 return m_pConnection->isReadOnly();
793 }
794
usesLocalFiles()795 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( )
796 {
797 SQLUSMALLINT nValue;
798 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
799 return nValue == SQL_FILE_CATALOG;
800 }
801
usesLocalFilePerTable()802 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( )
803 {
804 SQLUSMALLINT nValue;
805 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
806 return nValue == SQL_FILE_TABLE;
807 }
808
supportsTypeConversion()809 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( )
810 {
811 SQLUINTEGER nValue;
812 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FUNCTIONS,nValue,*this);
813 return (nValue & SQL_FN_CVT_CONVERT) == SQL_FN_CVT_CONVERT;
814 }
815
nullPlusNonNullIsNull()816 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( )
817 {
818 SQLUSMALLINT nValue;
819 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONCAT_NULL_BEHAVIOR,nValue,*this);
820 return nValue == SQL_CB_NULL;
821 }
822
supportsColumnAliasing()823 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( )
824 {
825 OUString aValue;
826 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_COLUMN_ALIAS,aValue,*this,m_pConnection->getTextEncoding());
827 return aValue.toChar() == 'Y';
828 }
829
supportsTableCorrelationNames()830 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( )
831 {
832 SQLUSMALLINT nValue;
833 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
834 return nValue != SQL_CN_NONE;
835 }
836
supportsConvert(sal_Int32 fromType,sal_Int32 toType)837 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType )
838 {
839 if(fromType == toType)
840 return true;
841
842 SQLUINTEGER nValue=0;
843 switch(fromType)
844 {
845 case DataType::BIT:
846 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIT,nValue,*this);
847 break;
848 case DataType::TINYINT:
849 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TINYINT,nValue,*this);
850 break;
851 case DataType::SMALLINT:
852 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_SMALLINT,nValue,*this);
853 break;
854 case DataType::INTEGER:
855 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_INTEGER,nValue,*this);
856 break;
857 case DataType::BIGINT:
858 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIGINT,nValue,*this);
859 break;
860 case DataType::FLOAT:
861 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FLOAT,nValue,*this);
862 break;
863 case DataType::REAL:
864 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_REAL,nValue,*this);
865 break;
866 case DataType::DOUBLE:
867 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DOUBLE,nValue,*this);
868 break;
869 case DataType::NUMERIC:
870 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_NUMERIC,nValue,*this);
871 break;
872 case DataType::DECIMAL:
873 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DECIMAL,nValue,*this);
874 break;
875 case DataType::CHAR:
876 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_CHAR,nValue,*this);
877 break;
878 case DataType::VARCHAR:
879 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this);
880 break;
881 case DataType::LONGVARCHAR:
882 case DataType::CLOB:
883 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this);
884 break;
885 case DataType::DATE:
886 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DATE,nValue,*this);
887 break;
888 case DataType::TIME:
889 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIME,nValue,*this);
890 break;
891 case DataType::TIMESTAMP:
892 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIMESTAMP,nValue,*this);
893 break;
894 case DataType::BINARY:
895 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BINARY,nValue,*this);
896 break;
897 case DataType::VARBINARY:
898 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this);
899 break;
900 case DataType::LONGVARBINARY:
901 case DataType::BLOB:
902 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this);
903 break;
904 case DataType::SQLNULL:
905 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
906 break;
907 case DataType::OTHER:
908 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
909 break;
910 case DataType::OBJECT:
911 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
912 break;
913 case DataType::DISTINCT:
914 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
915 break;
916 case DataType::STRUCT:
917 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
918 break;
919 case DataType::ARRAY:
920 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
921 break;
922 case DataType::REF:
923 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
924 break;
925 }
926 bool bConvert = false;
927 switch(toType)
928 {
929 case DataType::BIT:
930 bConvert = (nValue & SQL_CVT_BIT) == SQL_CVT_BIT;
931 break;
932 case DataType::TINYINT:
933 bConvert = (nValue & SQL_CVT_TINYINT) == SQL_CVT_TINYINT;
934 break;
935 case DataType::SMALLINT:
936 bConvert = (nValue & SQL_CVT_SMALLINT) == SQL_CVT_SMALLINT;
937 break;
938 case DataType::INTEGER:
939 bConvert = (nValue & SQL_CVT_INTEGER) == SQL_CVT_INTEGER;
940 break;
941 case DataType::BIGINT:
942 bConvert = (nValue & SQL_CVT_BIGINT) == SQL_CVT_BIGINT;
943 break;
944 case DataType::FLOAT:
945 bConvert = (nValue & SQL_CVT_FLOAT) == SQL_CVT_FLOAT;
946 break;
947 case DataType::REAL:
948 bConvert = (nValue & SQL_CVT_REAL) == SQL_CVT_REAL;
949 break;
950 case DataType::DOUBLE:
951 bConvert = (nValue & SQL_CVT_DOUBLE) == SQL_CVT_DOUBLE;
952 break;
953 case DataType::NUMERIC:
954 bConvert = (nValue & SQL_CVT_NUMERIC) == SQL_CVT_NUMERIC;
955 break;
956 case DataType::DECIMAL:
957 bConvert = (nValue & SQL_CVT_DECIMAL) == SQL_CVT_DECIMAL;
958 break;
959 case DataType::CHAR:
960 bConvert = (nValue & SQL_CVT_CHAR) == SQL_CVT_CHAR;
961 break;
962 case DataType::VARCHAR:
963 bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR;
964 break;
965 case DataType::LONGVARCHAR:
966 case DataType::CLOB:
967 bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR;
968 break;
969 case DataType::DATE:
970 bConvert = (nValue & SQL_CVT_DATE) == SQL_CVT_DATE;
971 break;
972 case DataType::TIME:
973 bConvert = (nValue & SQL_CVT_TIME) == SQL_CVT_TIME;
974 break;
975 case DataType::TIMESTAMP:
976 bConvert = (nValue & SQL_CVT_TIMESTAMP) == SQL_CVT_TIMESTAMP;
977 break;
978 case DataType::BINARY:
979 bConvert = (nValue & SQL_CVT_BINARY) == SQL_CVT_BINARY;
980 break;
981 case DataType::VARBINARY:
982 bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY;
983 break;
984 case DataType::LONGVARBINARY:
985 case DataType::BLOB:
986 bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY;
987 break;
988 }
989
990 return bConvert;
991 }
992
supportsExpressionsInOrderBy()993 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( )
994 {
995 OUString aValue;
996 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_EXPRESSIONS_IN_ORDERBY,aValue,*this,m_pConnection->getTextEncoding());
997 return aValue.toChar() == 'Y';
998 }
999
supportsGroupBy()1000 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( )
1001 {
1002 SQLUSMALLINT nValue;
1003 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1004 return nValue != SQL_GB_NOT_SUPPORTED;
1005 }
1006
supportsGroupByBeyondSelect()1007 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( )
1008 {
1009 SQLUSMALLINT nValue;
1010 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1011 return nValue != SQL_GB_GROUP_BY_CONTAINS_SELECT;
1012 }
1013
supportsGroupByUnrelated()1014 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( )
1015 {
1016 SQLUSMALLINT nValue;
1017 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1018 return nValue == SQL_GB_NO_RELATION;
1019 }
1020
supportsMultipleTransactions()1021 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( )
1022 {
1023 OUString aValue;
1024 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULTIPLE_ACTIVE_TXN,aValue,*this,m_pConnection->getTextEncoding());
1025 return aValue.toChar() == 'Y';
1026 }
1027
supportsMultipleResultSets()1028 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( )
1029 {
1030 OUString aValue;
1031 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULT_RESULT_SETS,aValue,*this,m_pConnection->getTextEncoding());
1032 return aValue.toChar() == 'Y';
1033 }
1034
supportsLikeEscapeClause()1035 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( )
1036 {
1037 OUString aValue;
1038 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_LIKE_ESCAPE_CLAUSE,aValue,*this,m_pConnection->getTextEncoding());
1039 return aValue.toChar() == 'Y';
1040 }
1041
supportsOrderByUnrelated()1042 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( )
1043 {
1044 OUString aValue;
1045 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ORDER_BY_COLUMNS_IN_SELECT,aValue,*this,m_pConnection->getTextEncoding());
1046 return aValue.toChar() == 'N';
1047 }
1048
supportsUnion()1049 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( )
1050 {
1051 SQLUINTEGER nValue;
1052 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1053 return (nValue & SQL_U_UNION) == SQL_U_UNION;
1054 }
1055
supportsUnionAll()1056 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( )
1057 {
1058 SQLUINTEGER nValue;
1059 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1060 return (nValue & SQL_U_UNION_ALL) == SQL_U_UNION_ALL;
1061 }
1062
supportsMixedCaseIdentifiers()1063 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( )
1064 {
1065 SQLUSMALLINT nValue;
1066 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
1067 return nValue == SQL_IC_MIXED;
1068 }
1069
impl_supportsMixedCaseQuotedIdentifiers_throw()1070 bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1071 {
1072 SQLUSMALLINT nValue;
1073 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
1074 return nValue == SQL_IC_MIXED;
1075 }
1076
nullsAreSortedAtEnd()1077 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( )
1078 {
1079 SQLUSMALLINT nValue;
1080 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1081 return nValue == SQL_NC_END;
1082 }
1083
nullsAreSortedAtStart()1084 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( )
1085 {
1086 SQLUSMALLINT nValue;
1087 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1088 return nValue == SQL_NC_START;
1089 }
1090
nullsAreSortedHigh()1091 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( )
1092 {
1093 SQLUSMALLINT nValue;
1094 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1095 return nValue == SQL_NC_HIGH;
1096 }
1097
nullsAreSortedLow()1098 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( )
1099 {
1100 SQLUSMALLINT nValue;
1101 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1102 return nValue == SQL_NC_LOW;
1103 }
1104
supportsSchemasInProcedureCalls()1105 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( )
1106 {
1107 SQLUINTEGER nValue;
1108 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1109 return (nValue & SQL_SU_PROCEDURE_INVOCATION) == SQL_SU_PROCEDURE_INVOCATION;
1110 }
1111
supportsSchemasInPrivilegeDefinitions()1112 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
1113 {
1114 SQLUINTEGER nValue;
1115 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1116 return (nValue & SQL_SU_PRIVILEGE_DEFINITION) == SQL_SU_PRIVILEGE_DEFINITION;
1117 }
1118
supportsCatalogsInProcedureCalls()1119 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( )
1120 {
1121 SQLUINTEGER nValue=0;
1122 if(m_bUseCatalog)
1123 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1124 return (nValue & SQL_CU_PROCEDURE_INVOCATION) == SQL_CU_PROCEDURE_INVOCATION;
1125 }
1126
supportsCatalogsInPrivilegeDefinitions()1127 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
1128 {
1129 SQLUINTEGER nValue=0;
1130 if(m_bUseCatalog)
1131 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1132 return (nValue & SQL_CU_PRIVILEGE_DEFINITION) == SQL_CU_PRIVILEGE_DEFINITION;
1133 }
1134
supportsCorrelatedSubqueries()1135 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( )
1136 {
1137 SQLUINTEGER nValue;
1138 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1139 return (nValue & SQL_SQ_CORRELATED_SUBQUERIES) == SQL_SQ_CORRELATED_SUBQUERIES;
1140 }
1141
supportsSubqueriesInComparisons()1142 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( )
1143 {
1144 SQLUINTEGER nValue;
1145 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1146 return (nValue & SQL_SQ_COMPARISON) == SQL_SQ_COMPARISON;
1147 }
1148
supportsSubqueriesInExists()1149 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( )
1150 {
1151 SQLUINTEGER nValue;
1152 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1153 return (nValue & SQL_SQ_EXISTS) == SQL_SQ_EXISTS;
1154 }
1155
supportsSubqueriesInIns()1156 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( )
1157 {
1158 SQLUINTEGER nValue;
1159 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1160 return (nValue & SQL_SQ_IN) == SQL_SQ_IN;
1161 }
1162
supportsSubqueriesInQuantifieds()1163 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( )
1164 {
1165 SQLUINTEGER nValue;
1166 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1167 return (nValue & SQL_SQ_QUANTIFIED) == SQL_SQ_QUANTIFIED;
1168 }
1169
supportsANSI92IntermediateSQL()1170 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( )
1171 {
1172 SQLUINTEGER nValue;
1173 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
1174 return static_cast<bool>(nValue & SQL_SC_SQL92_INTERMEDIATE);
1175 }
1176
getURLImpl()1177 OUString ODatabaseMetaData::getURLImpl()
1178 {
1179 OUString aValue;
1180 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_NAME,aValue,*this,m_pConnection->getTextEncoding());
1181 return aValue;
1182 }
1183
getURL()1184 OUString SAL_CALL ODatabaseMetaData::getURL( )
1185 {
1186 OUString aValue = m_pConnection->getURL();
1187 if ( aValue.isEmpty() )
1188 {
1189 aValue = "sdbc:odbc:" + getURLImpl();
1190 }
1191 return aValue;
1192 }
1193
getUserName()1194 OUString SAL_CALL ODatabaseMetaData::getUserName( )
1195 {
1196 OUString aValue;
1197 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_USER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1198 return aValue;
1199 }
1200
getDriverName()1201 OUString SAL_CALL ODatabaseMetaData::getDriverName( )
1202 {
1203 OUString aValue;
1204 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1205 return aValue;
1206 }
1207
getDriverVersion()1208 OUString SAL_CALL ODatabaseMetaData::getDriverVersion()
1209 {
1210 OUString aValue;
1211 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_ODBC_VER,aValue,*this,m_pConnection->getTextEncoding());
1212 return aValue;
1213 }
1214
getDatabaseProductVersion()1215 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( )
1216 {
1217 OUString aValue;
1218 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1219 return aValue;
1220 }
1221
getDatabaseProductName()1222 OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( )
1223 {
1224 OUString aValue;
1225 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DBMS_NAME,aValue,*this,m_pConnection->getTextEncoding());
1226 return aValue;
1227 }
1228
getProcedureTerm()1229 OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( )
1230 {
1231 OUString aValue;
1232 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURE_TERM,aValue,*this,m_pConnection->getTextEncoding());
1233 return aValue;
1234 }
1235
getSchemaTerm()1236 OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( )
1237 {
1238 OUString aValue;
1239 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_TERM,aValue,*this,m_pConnection->getTextEncoding());
1240 return aValue;
1241 }
1242
getDriverMajorVersion()1243 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) try
1244 {
1245 OUString aValue;
1246 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1247 return aValue.copy(0,aValue.indexOf('.')).toInt32();
1248 }
1249 catch (const SQLException &)
1250 {
1251 return 0;
1252 }
1253
getDefaultTransactionIsolation()1254 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( )
1255 {
1256 SQLUINTEGER nValue;
1257 sal_Int32 nValueTranslated;
1258 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DEFAULT_TXN_ISOLATION,nValue,*this);
1259 switch(nValue)
1260 {
1261 case SQL_TXN_READ_UNCOMMITTED:
1262 nValueTranslated = css::sdbc::TransactionIsolation::READ_UNCOMMITTED;
1263 break;
1264 case SQL_TXN_READ_COMMITTED:
1265 nValueTranslated = css::sdbc::TransactionIsolation::READ_COMMITTED;
1266 break;
1267 case SQL_TXN_REPEATABLE_READ:
1268 nValueTranslated = css::sdbc::TransactionIsolation::REPEATABLE_READ;
1269 break;
1270 case SQL_TXN_SERIALIZABLE:
1271 nValueTranslated = css::sdbc::TransactionIsolation::SERIALIZABLE;
1272 break;
1273 default:
1274 nValueTranslated = 0;
1275 }
1276 return nValueTranslated;
1277 }
1278
getDriverMinorVersion()1279 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) try
1280 {
1281 OUString aValue;
1282 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1283 return aValue.copy(0,aValue.lastIndexOf('.')).toInt32();
1284 }
1285 catch (const SQLException &)
1286 {
1287 return 0;
1288 }
1289
getSQLKeywords()1290 OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( )
1291 {
1292 OUString aValue;
1293 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_KEYWORDS,aValue,*this,m_pConnection->getTextEncoding());
1294 return aValue;
1295 }
1296
getSearchStringEscape()1297 OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( )
1298 {
1299 OUString aValue;
1300 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SEARCH_PATTERN_ESCAPE,aValue,*this,m_pConnection->getTextEncoding());
1301 return aValue;
1302 }
1303
getStringFunctions()1304 OUString SAL_CALL ODatabaseMetaData::getStringFunctions( )
1305 {
1306 SQLUINTEGER nValue;
1307 OUStringBuffer aValue;
1308 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
1309 if(nValue & SQL_FN_STR_ASCII)
1310 aValue.append("ASCII,");
1311 if(nValue & SQL_FN_STR_BIT_LENGTH)
1312 aValue.append("BIT_LENGTH,");
1313 if(nValue & SQL_FN_STR_CHAR)
1314 aValue.append("CHAR,");
1315 if(nValue & SQL_FN_STR_CHAR_LENGTH)
1316 aValue.append("CHAR_LENGTH,");
1317 if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
1318 aValue.append("CHARACTER_LENGTH,");
1319 if(nValue & SQL_FN_STR_CONCAT)
1320 aValue.append("CONCAT,");
1321 if(nValue & SQL_FN_STR_DIFFERENCE)
1322 aValue.append("DIFFERENCE,");
1323 if(nValue & SQL_FN_STR_INSERT)
1324 aValue.append("INSERT,");
1325 if(nValue & SQL_FN_STR_LCASE)
1326 aValue.append("LCASE,");
1327 if(nValue & SQL_FN_STR_LEFT)
1328 aValue.append("LEFT,");
1329 if(nValue & SQL_FN_STR_LENGTH)
1330 aValue.append("LENGTH,");
1331 if(nValue & SQL_FN_STR_LOCATE)
1332 aValue.append("LOCATE,");
1333 if(nValue & SQL_FN_STR_LOCATE_2)
1334 aValue.append("LOCATE_2,");
1335 if(nValue & SQL_FN_STR_LTRIM)
1336 aValue.append("LTRIM,");
1337 if(nValue & SQL_FN_STR_OCTET_LENGTH)
1338 aValue.append("OCTET_LENGTH,");
1339 if(nValue & SQL_FN_STR_POSITION)
1340 aValue.append("POSITION,");
1341 if(nValue & SQL_FN_STR_REPEAT)
1342 aValue.append("REPEAT,");
1343 if(nValue & SQL_FN_STR_REPLACE)
1344 aValue.append("REPLACE,");
1345 if(nValue & SQL_FN_STR_RIGHT)
1346 aValue.append("RIGHT,");
1347 if(nValue & SQL_FN_STR_RTRIM)
1348 aValue.append("RTRIM,");
1349 if(nValue & SQL_FN_STR_SOUNDEX)
1350 aValue.append("SOUNDEX,");
1351 if(nValue & SQL_FN_STR_SPACE)
1352 aValue.append("SPACE,");
1353 if(nValue & SQL_FN_STR_SUBSTRING)
1354 aValue.append("SUBSTRING,");
1355 if(nValue & SQL_FN_STR_UCASE)
1356 aValue.append("UCASE,");
1357
1358
1359 if ( !aValue.isEmpty() )
1360 aValue.setLength(aValue.getLength()-1);
1361
1362 return aValue.makeStringAndClear();
1363 }
1364
getTimeDateFunctions()1365 OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( )
1366 {
1367 SQLUINTEGER nValue;
1368 OUStringBuffer aValue;
1369 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this);
1370
1371 if(nValue & SQL_FN_TD_CURRENT_DATE)
1372 aValue.append("CURRENT_DATE,");
1373 if(nValue & SQL_FN_TD_CURRENT_TIME)
1374 aValue.append("CURRENT_TIME,");
1375 if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP)
1376 aValue.append("CURRENT_TIMESTAMP,");
1377 if(nValue & SQL_FN_TD_CURDATE)
1378 aValue.append("CURDATE,");
1379 if(nValue & SQL_FN_TD_CURTIME)
1380 aValue.append("CURTIME,");
1381 if(nValue & SQL_FN_TD_DAYNAME)
1382 aValue.append("DAYNAME,");
1383 if(nValue & SQL_FN_TD_DAYOFMONTH)
1384 aValue.append("DAYOFMONTH,");
1385 if(nValue & SQL_FN_TD_DAYOFWEEK)
1386 aValue.append("DAYOFWEEK,");
1387 if(nValue & SQL_FN_TD_DAYOFYEAR)
1388 aValue.append("DAYOFYEAR,");
1389 if(nValue & SQL_FN_TD_EXTRACT)
1390 aValue.append("EXTRACT,");
1391 if(nValue & SQL_FN_TD_HOUR)
1392 aValue.append("HOUR,");
1393 if(nValue & SQL_FN_TD_MINUTE)
1394 aValue.append("MINUTE,");
1395 if(nValue & SQL_FN_TD_MONTH)
1396 aValue.append("MONTH,");
1397 if(nValue & SQL_FN_TD_MONTHNAME)
1398 aValue.append("MONTHNAME,");
1399 if(nValue & SQL_FN_TD_NOW)
1400 aValue.append("NOW,");
1401 if(nValue & SQL_FN_TD_QUARTER)
1402 aValue.append("QUARTER,");
1403 if(nValue & SQL_FN_TD_SECOND)
1404 aValue.append("SECOND,");
1405 if(nValue & SQL_FN_TD_TIMESTAMPADD)
1406 aValue.append("TIMESTAMPADD,");
1407 if(nValue & SQL_FN_TD_TIMESTAMPDIFF)
1408 aValue.append("TIMESTAMPDIFF,");
1409 if(nValue & SQL_FN_TD_WEEK)
1410 aValue.append("WEEK,");
1411 if(nValue & SQL_FN_TD_YEAR)
1412 aValue.append("YEAR,");
1413
1414 if ( !aValue.isEmpty() )
1415 aValue.setLength(aValue.getLength()-1);
1416
1417 return aValue.makeStringAndClear();
1418 }
1419
getSystemFunctions()1420 OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( )
1421 {
1422 SQLUINTEGER nValue;
1423 OUStringBuffer aValue;
1424 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this);
1425
1426 if(nValue & SQL_FN_SYS_DBNAME)
1427 aValue.append("DBNAME,");
1428 if(nValue & SQL_FN_SYS_IFNULL)
1429 aValue.append("IFNULL,");
1430 if(nValue & SQL_FN_SYS_USERNAME)
1431 aValue.append("USERNAME,");
1432
1433 if ( !aValue.isEmpty() )
1434 aValue.setLength(aValue.getLength()-1);
1435
1436 return aValue.makeStringAndClear();
1437 }
1438
getNumericFunctions()1439 OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( )
1440 {
1441 SQLUINTEGER nValue;
1442 OUStringBuffer aValue;
1443 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this);
1444
1445 if(nValue & SQL_FN_NUM_ABS)
1446 aValue.append("ABS,");
1447 if(nValue & SQL_FN_NUM_ACOS)
1448 aValue.append("ACOS,");
1449 if(nValue & SQL_FN_NUM_ASIN)
1450 aValue.append("ASIN,");
1451 if(nValue & SQL_FN_NUM_ATAN)
1452 aValue.append("ATAN,");
1453 if(nValue & SQL_FN_NUM_ATAN2)
1454 aValue.append("ATAN2,");
1455 if(nValue & SQL_FN_NUM_CEILING)
1456 aValue.append("CEILING,");
1457 if(nValue & SQL_FN_NUM_COS)
1458 aValue.append("COS,");
1459 if(nValue & SQL_FN_NUM_COT)
1460 aValue.append("COT,");
1461 if(nValue & SQL_FN_NUM_DEGREES)
1462 aValue.append("DEGREES,");
1463 if(nValue & SQL_FN_NUM_EXP)
1464 aValue.append("EXP,");
1465 if(nValue & SQL_FN_NUM_FLOOR)
1466 aValue.append("FLOOR,");
1467 if(nValue & SQL_FN_NUM_LOG)
1468 aValue.append("LOGF,");
1469 if(nValue & SQL_FN_NUM_LOG10)
1470 aValue.append("LOG10,");
1471 if(nValue & SQL_FN_NUM_MOD)
1472 aValue.append("MOD,");
1473 if(nValue & SQL_FN_NUM_PI)
1474 aValue.append("PI,");
1475 if(nValue & SQL_FN_NUM_POWER)
1476 aValue.append("POWER,");
1477 if(nValue & SQL_FN_NUM_RADIANS)
1478 aValue.append("RADIANS,");
1479 if(nValue & SQL_FN_NUM_RAND)
1480 aValue.append("RAND,");
1481 if(nValue & SQL_FN_NUM_ROUND)
1482 aValue.append("ROUND,");
1483 if(nValue & SQL_FN_NUM_SIGN)
1484 aValue.append("SIGN,");
1485 if(nValue & SQL_FN_NUM_SIN)
1486 aValue.append("SIN,");
1487 if(nValue & SQL_FN_NUM_SQRT)
1488 aValue.append("SQRT,");
1489 if(nValue & SQL_FN_NUM_TAN)
1490 aValue.append("TAN,");
1491 if(nValue & SQL_FN_NUM_TRUNCATE)
1492 aValue.append("TRUNCATE,");
1493
1494 if ( !aValue.isEmpty() )
1495 aValue.setLength(aValue.getLength()-1);
1496
1497 return aValue.makeStringAndClear();
1498 }
1499
supportsExtendedSQLGrammar()1500 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( )
1501 {
1502 SQLUINTEGER nValue;
1503 // SQL_ODBC_SQL_CONFORMANCE is deprecated in ODBC 3.x, but there does not seem te be any equivalent.
1504 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
1505 SAL_WARN_IF(! (nValue == SQL_OSC_MINIMUM || nValue == SQL_OSC_CORE || nValue == SQL_OSC_EXTENDED),
1506 "connectivity.odbc",
1507 "SQL_ODBC_SQL_CONFORMANCE is neither MINIMAL nor CORE nor EXTENDED");
1508 return nValue == SQL_OSC_EXTENDED;
1509 }
1510
supportsCoreSQLGrammar()1511 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( )
1512 {
1513 SQLUINTEGER nValue;
1514 // SQL_ODBC_SQL_CONFORMANCE is deprecated in ODBC 3.x, but there does not seem te be any equivalent.
1515 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
1516 SAL_WARN_IF(! (nValue == SQL_OSC_MINIMUM || nValue == SQL_OSC_CORE || nValue == SQL_OSC_EXTENDED),
1517 "connectivity.odbc",
1518 "SQL_ODBC_SQL_CONFORMANCE is neither MINIMAL nor CORE nor EXTENDED");
1519 return nValue == SQL_OSC_CORE || nValue == SQL_OSC_EXTENDED;
1520 }
1521
supportsMinimumSQLGrammar()1522 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( )
1523 {
1524 SQLUINTEGER nValue;
1525 // SQL_ODBC_SQL_CONFORMANCE is deprecated in ODBC 3.x, but there does not seem te be any equivalent.
1526 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
1527 SAL_WARN_IF(! (nValue == SQL_OSC_MINIMUM || nValue == SQL_OSC_CORE || nValue == SQL_OSC_EXTENDED),
1528 "connectivity.odbc",
1529 "SQL_ODBC_SQL_CONFORMANCE is neither MINIMAL nor CORE nor EXTENDED");
1530 return nValue == SQL_OSC_MINIMUM || nValue == SQL_OSC_CORE || nValue == SQL_OSC_EXTENDED;
1531 }
1532
supportsFullOuterJoins()1533 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( )
1534 {
1535 SQLUINTEGER nValue;
1536 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
1537 return (nValue & SQL_OJ_FULL) == SQL_OJ_FULL;
1538 }
1539
supportsLimitedOuterJoins()1540 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( )
1541 {
1542 return supportsFullOuterJoins( );
1543 }
1544
getMaxColumnsInGroupBy()1545 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( )
1546 {
1547 SQLUSMALLINT nValue;
1548 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_GROUP_BY,nValue,*this);
1549 return nValue;
1550 }
1551
getMaxColumnsInOrderBy()1552 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( )
1553 {
1554 SQLUSMALLINT nValue;
1555 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_ORDER_BY,nValue,*this);
1556 return nValue;
1557 }
1558
getMaxColumnsInSelect()1559 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( )
1560 {
1561 SQLUSMALLINT nValue;
1562 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_SELECT,nValue,*this);
1563 return nValue;
1564 }
1565
getMaxUserNameLength()1566 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( )
1567 {
1568 SQLUSMALLINT nValue;
1569 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_USER_NAME_LEN,nValue,*this);
1570 return nValue;
1571 }
1572
supportsResultSetType(sal_Int32 setType)1573 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType )
1574 {
1575 SQLUINTEGER nValue;
1576 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_SENSITIVITY,nValue,*this);
1577 return (nValue & static_cast<SQLUINTEGER>(setType)) == static_cast<SQLUINTEGER>(setType);
1578 }
1579
supportsResultSetConcurrency(sal_Int32 setType,sal_Int32 concurrency)1580 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency )
1581 {
1582 SQLUINTEGER nValue;
1583 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1584 switch(setType)
1585 {
1586 default:
1587 case ResultSetType::FORWARD_ONLY:
1588 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1589 break;
1590 case ResultSetType::SCROLL_INSENSITIVE:
1591 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1592 break;
1593 case ResultSetType::SCROLL_SENSITIVE:
1594 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1595 break;
1596 }
1597
1598 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1599 bool bRet = false;
1600 switch(concurrency)
1601 {
1602 case ResultSetConcurrency::READ_ONLY:
1603 bRet = (nValue & SQL_CA2_READ_ONLY_CONCURRENCY) == SQL_CA2_READ_ONLY_CONCURRENCY;
1604 break;
1605 case ResultSetConcurrency::UPDATABLE:
1606 bRet = (nValue & SQL_CA2_OPT_VALUES_CONCURRENCY) == SQL_CA2_OPT_VALUES_CONCURRENCY;
1607 break;
1608 }
1609 return bRet;
1610 }
1611
ownUpdatesAreVisible(sal_Int32 setType)1612 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType )
1613 {
1614 SQLUINTEGER nValue;
1615 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1616 switch(setType)
1617 {
1618 default:
1619 case ResultSetType::FORWARD_ONLY:
1620 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1621 break;
1622 case ResultSetType::SCROLL_INSENSITIVE:
1623 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1624 break;
1625 case ResultSetType::SCROLL_SENSITIVE:
1626 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1627 break;
1628 }
1629
1630 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1631 return (nValue & SQL_CA2_SENSITIVITY_UPDATES) == SQL_CA2_SENSITIVITY_UPDATES;
1632 }
1633
ownDeletesAreVisible(sal_Int32 setType)1634 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType )
1635 {
1636 SQLUINTEGER nValue;
1637 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1638 switch(setType)
1639 {
1640 default:
1641 case ResultSetType::FORWARD_ONLY:
1642 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1643 break;
1644 case ResultSetType::SCROLL_INSENSITIVE:
1645 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1646 break;
1647 case ResultSetType::SCROLL_SENSITIVE:
1648 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1649 break;
1650 }
1651
1652 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1653 return (nValue & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS;
1654 }
1655
ownInsertsAreVisible(sal_Int32 setType)1656 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType )
1657 {
1658 SQLUINTEGER nValue;
1659 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1660 switch(setType)
1661 {
1662 default:
1663 case ResultSetType::FORWARD_ONLY:
1664 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1665 break;
1666 case ResultSetType::SCROLL_INSENSITIVE:
1667 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1668 break;
1669 case ResultSetType::SCROLL_SENSITIVE:
1670 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1671 break;
1672 }
1673
1674 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1675 return (nValue & SQL_CA2_SENSITIVITY_ADDITIONS) == SQL_CA2_SENSITIVITY_ADDITIONS;
1676 }
1677
othersUpdatesAreVisible(sal_Int32 setType)1678 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType )
1679 {
1680 return ownUpdatesAreVisible(setType);
1681 }
1682
othersDeletesAreVisible(sal_Int32 setType)1683 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType )
1684 {
1685 return ownDeletesAreVisible(setType);
1686 }
1687
othersInsertsAreVisible(sal_Int32 setType)1688 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType )
1689 {
1690 return ownInsertsAreVisible(setType);
1691 }
1692
updatesAreDetected(sal_Int32)1693 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ )
1694 {
1695 return false;
1696 }
1697
deletesAreDetected(sal_Int32)1698 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ )
1699 {
1700 return false;
1701 }
1702
insertsAreDetected(sal_Int32)1703 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ )
1704 {
1705 return false;
1706 }
1707
supportsBatchUpdates()1708 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( )
1709 {
1710 return false;
1711 }
1712
getUDTs(const Any &,const OUString &,const OUString &,const Sequence<sal_Int32> &)1713 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ )
1714 {
1715 return nullptr;
1716 }
1717
1718
1719 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1720