Line data Source code
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 :
10 : #include "MDatabaseMetaData.hxx"
11 : #include "FDatabaseMetaDataResultSet.hxx"
12 : #include <com/sun/star/sdbc/DataType.hpp>
13 : #include <com/sun/star/sdbc/ResultSetType.hpp>
14 : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
15 : #include <com/sun/star/sdbc/TransactionIsolation.hpp>
16 : #include <connectivity/FValue.hxx>
17 : #include <com/sun/star/sdbc/ColumnValue.hpp>
18 : #include <com/sun/star/sdbc/ColumnSearch.hpp>
19 : #include "resource/common_res.hrc"
20 : #include <vector>
21 :
22 : #include "MDatabaseMetaDataHelper.hxx"
23 : #include "MorkParser.hxx"
24 : #include <connectivity/dbtools.hxx>
25 :
26 : using namespace dbtools;
27 : using namespace connectivity::mork;
28 : using namespace connectivity;
29 :
30 : using namespace com::sun::star::uno;
31 : using namespace com::sun::star::lang;
32 : using namespace com::sun::star::beans;
33 : using namespace com::sun::star::sdbc;
34 : using namespace com::sun::star::sdbcx;
35 :
36 :
37 : namespace connectivity
38 : {
39 : namespace mork
40 : {
41 : static sal_Int32 const s_nCOLUMN_SIZE = 256;
42 : static sal_Int32 const s_nDECIMAL_DIGITS = 0;
43 : static sal_Int32 const s_nNULLABLE = 1;
44 : static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
45 : }
46 : }
47 :
48 6 : ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
49 6 : : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
50 6 : ,m_pConnection(_pCon)
51 : {
52 : OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
53 6 : m_pMetaDataHelper = new MDatabaseMetaDataHelper();
54 6 : }
55 :
56 18 : ODatabaseMetaData::~ODatabaseMetaData()
57 : {
58 6 : delete m_pMetaDataHelper;
59 12 : }
60 :
61 :
62 152 : ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
63 : const OUString& tableNamePattern,
64 : const OUString& columnNamePattern ) throw(SQLException)
65 : {
66 : SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getColumnRows()" );
67 : SAL_INFO("connectivity.mork", "tableNamePattern: " << tableNamePattern);
68 : SAL_INFO("connectivity.mork", "columnNamePattern: " << columnNamePattern);
69 :
70 152 : static ODatabaseMetaDataResultSet::ORows aRows;
71 152 : ODatabaseMetaDataResultSet::ORow aRow(19);
72 152 : aRows.clear();
73 :
74 304 : ::osl::MutexGuard aGuard( m_aMutex );
75 304 : ::std::vector< OUString > tables;
76 152 : if (!m_pMetaDataHelper->getTableStrings(m_pConnection, tables))
77 : {
78 0 : ::connectivity::SharedResources aResources;
79 : // TODO:
80 : // get better message here?
81 0 : const OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
82 0 : ::dbtools::throwGenericSQLException(sMessage ,*this);
83 : }
84 :
85 : // ****************************************************
86 : // Some entries in a row never change, so set them now
87 : // ****************************************************
88 :
89 : // Catalog
90 152 : aRow[1] = new ORowSetValueDecorator(OUString(""));
91 : // Schema
92 152 : aRow[2] = new ORowSetValueDecorator(OUString(""));
93 : // DATA_TYPE
94 152 : aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
95 : // TYPE_NAME, not used
96 152 : aRow[6] = new ORowSetValueDecorator(OUString("VARCHAR"));
97 : // COLUMN_SIZE
98 152 : aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
99 : // BUFFER_LENGTH, not used
100 152 : aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
101 : // DECIMAL_DIGITS.
102 152 : aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
103 : // NUM_PREC_RADIX
104 152 : aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
105 : // NULLABLE
106 152 : aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
107 : // REMARKS
108 152 : aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
109 : // COULUMN_DEF, not used
110 152 : aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
111 : // SQL_DATA_TYPE, not used
112 152 : aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
113 : // SQL_DATETIME_SUB, not used
114 152 : aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
115 : // CHAR_OCTET_LENGTH, refer to [5]
116 152 : aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
117 : // IS_NULLABLE
118 152 : aRow[18] = new ORowSetValueDecorator(OUString("YES"));
119 :
120 : // Iterate over all tables
121 760 : for(size_t j = 0; j < tables.size(); j++ ) {
122 608 : if(match(tableNamePattern, tables[j],'\0')) {
123 : // TABLE_NAME
124 152 : aRow[3] = new ORowSetValueDecorator( tables[j] );
125 :
126 152 : const OColumnAlias& colNames = m_pConnection->getColumnAlias();
127 :
128 : SAL_INFO("connectivity.mork", "\tTableName = : " << tables[j]);
129 : // Iterate over all collumns in the table.
130 17328 : for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
131 11552 : compare != colNames.end();
132 : ++compare
133 : )
134 : {
135 5624 : if ( match( columnNamePattern, compare->first, '\0' ) )
136 : {
137 : SAL_INFO("connectivity.mork", "\t\tColumnNam : " << compare->first);
138 :
139 : // COLUMN_NAME
140 296 : aRow[4] = new ORowSetValueDecorator( compare->first );
141 : // ORDINAL_POSITION
142 296 : aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
143 296 : aRows.push_back(aRow);
144 : }
145 : }
146 : }
147 : }
148 304 : return( aRows );
149 : }
150 :
151 4 : OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
152 : {
153 4 : return OUString();
154 : }
155 :
156 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException, std::exception)
157 : {
158 0 : sal_Int32 nValue = 65535; // 0 means no limit
159 0 : return nValue;
160 : }
161 :
162 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException, std::exception)
163 : {
164 0 : sal_Int32 nValue = 0; // 0 means no limit
165 0 : return nValue;
166 : }
167 :
168 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException, std::exception)
169 : {
170 0 : sal_Int32 nValue = 0; // 0 means no limit
171 0 : return nValue;
172 : }
173 :
174 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException, std::exception)
175 : {
176 0 : sal_Int32 nValue = 254; // 0 means no limit
177 0 : return nValue;
178 : }
179 :
180 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException, std::exception)
181 : {
182 0 : sal_Int32 nValue = 20; // 0 means no limit
183 0 : return nValue;
184 : }
185 :
186 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException, std::exception)
187 : {
188 0 : sal_Int32 nValue = 0; // 0 means no limit
189 0 : return nValue;
190 : }
191 :
192 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException, std::exception)
193 : {
194 0 : sal_Int32 nValue = 0; // 0 means no limit
195 0 : return nValue;
196 : }
197 :
198 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException, std::exception)
199 : {
200 0 : sal_Int32 nValue = 0; // 0 means no limit
201 0 : return nValue;
202 : }
203 :
204 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException, std::exception)
205 : {
206 0 : sal_Int32 nValue = 0; // 0 means no limit
207 0 : return nValue;
208 : }
209 :
210 0 : sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
211 : {
212 0 : return 0;
213 : }
214 :
215 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException, std::exception)
216 : {
217 0 : sal_Int32 nValue = 0; // 0 means no limit
218 0 : return nValue;
219 : }
220 :
221 4 : sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
222 : {
223 : // We only support a single table
224 4 : return 1;
225 : }
226 :
227 :
228 0 : sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException, std::exception)
229 : {
230 0 : return sal_False;
231 : }
232 :
233 0 : sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
234 : {
235 0 : return sal_False;
236 : }
237 :
238 0 : sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
239 : {
240 0 : return sal_False;
241 : }
242 :
243 0 : bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
244 : {
245 0 : return false;
246 : }
247 :
248 0 : sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
249 : {
250 0 : return sal_False;
251 : }
252 :
253 0 : sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
254 : {
255 0 : return sal_False;
256 : }
257 :
258 0 : sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
259 : {
260 0 : return sal_False;
261 : }
262 :
263 0 : bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
264 : {
265 0 : return false;
266 : }
267 :
268 0 : bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
269 : {
270 0 : return false;
271 : }
272 :
273 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException, std::exception)
274 : {
275 0 : sal_Int32 nValue = 0; // 0 means no limit
276 0 : return nValue;
277 : }
278 :
279 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException, std::exception)
280 : {
281 0 : return sal_False;
282 : }
283 :
284 0 : OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException, std::exception)
285 : {
286 0 : OUString aVal;
287 0 : return aVal;
288 : }
289 :
290 4 : OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
291 : {
292 : // normally this is "
293 4 : return OUString( "\"");
294 : }
295 :
296 0 : OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException, std::exception)
297 : {
298 0 : OUString aVal;
299 0 : return aVal;
300 : }
301 :
302 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException, std::exception)
303 : {
304 0 : return sal_True;
305 : }
306 :
307 0 : bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
308 : {
309 0 : return true;
310 : }
311 :
312 0 : sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException, std::exception)
313 : {
314 0 : return sal_True;
315 : }
316 :
317 0 : sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException, std::exception)
318 : {
319 0 : return sal_True;
320 : }
321 :
322 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException, std::exception)
323 : {
324 : //We support create table
325 0 : return sal_False;
326 : }
327 :
328 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException, std::exception)
329 : {
330 0 : return sal_False;
331 : }
332 :
333 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException, std::exception)
334 : {
335 0 : return sal_False;
336 : }
337 :
338 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException, std::exception)
339 : {
340 0 : return sal_False;
341 : }
342 :
343 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException, std::exception)
344 : {
345 0 : return sal_False;
346 : }
347 :
348 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException, std::exception)
349 : {
350 0 : return sal_False;
351 : }
352 :
353 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException, std::exception)
354 : {
355 0 : return sal_False;
356 : }
357 :
358 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException, std::exception)
359 : {
360 0 : return sal_False;
361 : }
362 :
363 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException, std::exception)
364 : {
365 0 : return sal_False;
366 : }
367 :
368 4 : bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
369 : {
370 4 : return false;
371 : }
372 :
373 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException, std::exception)
374 : {
375 0 : return sal_False;
376 : }
377 :
378 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException, std::exception)
379 : {
380 0 : return sal_True; // should be supported at least
381 : }
382 :
383 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException, std::exception)
384 : {
385 0 : return sal_False;
386 : }
387 :
388 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException, std::exception)
389 : {
390 0 : return sal_False;
391 : }
392 :
393 0 : bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
394 : {
395 0 : return false;
396 : }
397 :
398 0 : bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
399 : {
400 0 : return false;
401 : }
402 :
403 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException, std::exception)
404 : {
405 0 : return sal_False;
406 : }
407 :
408 4 : bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
409 : {
410 4 : return false;
411 : }
412 :
413 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException, std::exception)
414 : {
415 0 : return sal_False;
416 : }
417 :
418 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException, std::exception)
419 : {
420 0 : return 0;// 0 means no limit
421 : }
422 :
423 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException, std::exception)
424 : {
425 0 : sal_Int32 nValue = 0; // 0 means no limit
426 0 : return nValue;
427 : }
428 :
429 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException, std::exception)
430 : {
431 0 : sal_Int32 nValue = 0; // 0 means no limit
432 0 : return nValue;
433 : }
434 :
435 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException, std::exception)
436 : {
437 0 : return sal_False;
438 : }
439 :
440 0 : sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException, std::exception)
441 : {
442 0 : return sal_False;
443 : }
444 :
445 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException, std::exception)
446 : {
447 0 : return sal_False;
448 : }
449 :
450 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException, std::exception)
451 : {
452 0 : return sal_False;
453 : }
454 :
455 0 : sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException, std::exception)
456 : {
457 : // We allow you to select from any table.
458 0 : return sal_True;
459 : }
460 :
461 0 : sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException, std::exception)
462 : {
463 : //we support insert/update/delete now
464 : //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
465 : //entry to the popup menu. We should avoid them.
466 0 : return sal_True;
467 : }
468 :
469 0 : sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException, std::exception)
470 : {
471 0 : return sal_False;
472 : }
473 :
474 0 : sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException, std::exception)
475 : {
476 0 : return sal_False;
477 : }
478 :
479 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException, std::exception)
480 : {
481 0 : return sal_False;
482 : }
483 :
484 0 : sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException, std::exception)
485 : {
486 0 : return sal_False;
487 : }
488 :
489 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException, std::exception)
490 : {
491 : // Support added for this.
492 0 : return sal_True;
493 : }
494 :
495 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException, std::exception)
496 : {
497 0 : return sal_False;
498 : }
499 :
500 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException, std::exception)
501 : {
502 0 : return sal_False;
503 : }
504 :
505 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException, std::exception)
506 : {
507 0 : return sal_False;
508 : }
509 :
510 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException, std::exception)
511 : {
512 0 : return sal_False;
513 : }
514 :
515 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException, std::exception)
516 : {
517 0 : return sal_False;
518 : }
519 :
520 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException, std::exception)
521 : {
522 0 : return sal_False;
523 : }
524 :
525 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException, std::exception)
526 : {
527 0 : return sal_False;
528 : }
529 :
530 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException, std::exception)
531 : {
532 0 : return sal_False;
533 : }
534 :
535 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException, std::exception)
536 : {
537 0 : return sal_False;
538 : }
539 :
540 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException, std::exception)
541 : {
542 0 : return sal_False;
543 : }
544 :
545 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException, std::exception)
546 : {
547 0 : return sal_False;
548 : }
549 :
550 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException, std::exception)
551 : {
552 0 : return sal_False;
553 : }
554 :
555 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException, std::exception)
556 : {
557 0 : return sal_True;
558 : }
559 :
560 4 : bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
561 : {
562 : // Any case may be used
563 4 : return true;
564 : }
565 :
566 0 : sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException, std::exception)
567 : {
568 0 : return sal_False;
569 : }
570 :
571 0 : sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException, std::exception)
572 : {
573 0 : return sal_True;
574 : }
575 :
576 0 : sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException, std::exception)
577 : {
578 0 : return sal_False;
579 : }
580 :
581 0 : sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException, std::exception)
582 : {
583 0 : return sal_True;
584 : }
585 :
586 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException, std::exception)
587 : {
588 0 : return sal_False;
589 : }
590 :
591 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException, std::exception)
592 : {
593 0 : return sal_False;
594 : }
595 :
596 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException, std::exception)
597 : {
598 0 : return sal_False;
599 : }
600 :
601 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException, std::exception)
602 : {
603 0 : return sal_False;
604 : }
605 :
606 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException, std::exception)
607 : {
608 0 : return sal_False;
609 : }
610 :
611 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException, std::exception)
612 : {
613 0 : return sal_False;
614 : }
615 :
616 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException, std::exception)
617 : {
618 0 : return sal_False;
619 : }
620 :
621 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException, std::exception)
622 : {
623 0 : return sal_False;
624 : }
625 :
626 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException, std::exception)
627 : {
628 0 : return sal_False;
629 : }
630 :
631 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException, std::exception)
632 : {
633 0 : return sal_False;
634 : }
635 :
636 0 : OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException, std::exception)
637 : {
638 0 : ::osl::MutexGuard aGuard( m_aMutex );
639 :
640 0 : return m_pConnection->getURL();
641 : }
642 :
643 0 : OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException, std::exception)
644 : {
645 0 : OUString aValue;
646 0 : return aValue;
647 : }
648 :
649 0 : OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException, std::exception)
650 : {
651 0 : OUString aValue;
652 0 : return aValue;
653 : }
654 :
655 0 : OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException, std::exception)
656 : {
657 0 : OUString aValue = OUString::number(1);
658 0 : return aValue;
659 : }
660 :
661 0 : OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException, std::exception)
662 : {
663 0 : OUString aValue = OUString::number(0);
664 0 : return aValue;
665 : }
666 :
667 0 : OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException, std::exception)
668 : {
669 0 : OUString aValue;
670 0 : return aValue;
671 : }
672 :
673 0 : OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException, std::exception)
674 : {
675 0 : OUString aValue;
676 0 : return aValue;
677 : }
678 :
679 0 : OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException, std::exception)
680 : {
681 0 : OUString aValue;
682 0 : return aValue;
683 : }
684 :
685 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException, std::exception)
686 : {
687 0 : return 1;
688 : }
689 :
690 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException, std::exception)
691 : {
692 0 : return TransactionIsolation::NONE;
693 : }
694 :
695 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException, std::exception)
696 : {
697 0 : return 0;
698 : }
699 :
700 0 : OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException, std::exception)
701 : {
702 0 : OUString aValue;
703 0 : return aValue;
704 : }
705 :
706 0 : OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException, std::exception)
707 : {
708 0 : OUString aValue;
709 0 : return aValue;
710 : }
711 :
712 0 : OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException, std::exception)
713 : {
714 0 : return OUString();
715 : }
716 :
717 0 : OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException, std::exception)
718 : {
719 0 : return OUString();
720 : }
721 :
722 0 : OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException, std::exception)
723 : {
724 0 : return OUString();
725 : }
726 :
727 0 : OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException, std::exception)
728 : {
729 0 : return OUString();
730 : }
731 :
732 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException, std::exception)
733 : {
734 0 : return sal_False;
735 : }
736 :
737 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException, std::exception)
738 : {
739 0 : return sal_False;
740 : }
741 :
742 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException, std::exception)
743 : {
744 0 : return sal_True;
745 : }
746 :
747 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException, std::exception)
748 : {
749 0 : return sal_False;
750 : }
751 :
752 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException, std::exception)
753 : {
754 0 : return sal_False;
755 : }
756 :
757 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException, std::exception)
758 : {
759 0 : sal_Int32 nValue = 0; // 0 means no limit
760 0 : return nValue;
761 : }
762 :
763 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException, std::exception)
764 : {
765 0 : sal_Int32 nValue = 0; // 0 means no limit
766 0 : return nValue;
767 : }
768 :
769 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException, std::exception)
770 : {
771 0 : sal_Int32 nValue = 0; // 0 means no limit
772 0 : return nValue;
773 : }
774 :
775 0 : sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException, std::exception)
776 : {
777 0 : sal_Int32 nValue = 0; // 0 means no limit
778 0 : return nValue;
779 : }
780 :
781 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
782 : {
783 0 : return sal_False;
784 : }
785 :
786 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException, std::exception)
787 : {
788 0 : return sal_False;
789 : }
790 :
791 0 : sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
792 : {
793 0 : return sal_True;
794 : }
795 :
796 0 : sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
797 : {
798 0 : return sal_True;
799 : }
800 :
801 0 : sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
802 : {
803 0 : return sal_True;
804 : }
805 :
806 0 : sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
807 : {
808 0 : return sal_False;
809 : }
810 :
811 0 : sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
812 : {
813 0 : return sal_False;
814 : }
815 :
816 0 : sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
817 : {
818 0 : return sal_False;
819 : }
820 :
821 0 : sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
822 : {
823 0 : return sal_True;
824 : }
825 :
826 0 : sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
827 : {
828 0 : return sal_True;
829 : }
830 :
831 0 : sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException, std::exception)
832 : {
833 0 : return sal_True;
834 : }
835 :
836 0 : sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException, std::exception)
837 : {
838 0 : return sal_False;
839 : }
840 :
841 : // here follow all methods which return a resultset
842 : // the first methods is an example implementation how to use this resultset
843 : // of course you could implement it on your and you should do this because
844 : // the general way is more memory expensive
845 :
846 0 : Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException, std::exception)
847 : {
848 : // there exists no possibility to get table types so we have to check
849 : static const OUString sTableTypes[] =
850 : {
851 : OUString("TABLE"),
852 : OUString("VIEW")
853 : // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
854 :
855 : // OUString("SYSTEM TABLE"),
856 : // OUString("GLOBAL TEMPORARY"),
857 : // OUString("LOCAL TEMPORARY"),
858 : // OUString("ALIAS"),
859 : // OUString("SYNONYM")
860 0 : };
861 0 : ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
862 0 : Reference< XResultSet > xRef = pResult;
863 :
864 : // here we fill the rows which should be visible when ask for data from the resultset returned here
865 0 : const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(OUString);
866 0 : ODatabaseMetaDataResultSet::ORows aRows;
867 0 : for(sal_Int32 i=0;i < nSize;++i)
868 : {
869 0 : ODatabaseMetaDataResultSet::ORow aRow;
870 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
871 0 : aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
872 : // bound row
873 0 : aRows.push_back(aRow);
874 0 : }
875 : // here we set the rows at the resultset
876 0 : pResult->setRows(aRows);
877 0 : return xRef;
878 : }
879 :
880 0 : Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
881 : {
882 : // this returns an empty resultset where the column-names are already set
883 : // in special the metadata of the resultset already returns the right columns
884 0 : ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
885 0 : Reference< XResultSet > xResultSet = pResultSet;
886 0 : static ODatabaseMetaDataResultSet::ORows aRows;
887 :
888 0 : if(aRows.empty())
889 : {
890 0 : ODatabaseMetaDataResultSet::ORow aRow;
891 0 : aRow.reserve(19);
892 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
893 0 : aRow.push_back(new ORowSetValueDecorator(OUString("VARCHAR")));
894 0 : aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
895 0 : aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
896 0 : aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
897 0 : aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
898 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
899 : // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
900 0 : aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
901 0 : aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
902 0 : aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
903 0 : aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
904 0 : aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
905 0 : aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
906 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
907 0 : aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
908 0 : aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
909 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
910 0 : aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
911 0 : aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
912 :
913 0 : aRows.push_back(aRow);
914 :
915 : }
916 0 : pResultSet->setRows(aRows);
917 0 : return xResultSet;
918 : }
919 :
920 152 : Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
921 : const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern,
922 : const OUString& columnNamePattern ) throw(SQLException, RuntimeException, std::exception)
923 : {
924 : // this returns an empty resultset where the column-names are already set
925 : // in special the metadata of the resultset already returns the right columns
926 152 : ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
927 152 : Reference< XResultSet > xResultSet = pResultSet;
928 152 : pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
929 152 : return xResultSet;
930 : }
931 :
932 10 : Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
933 : const Any& /*catalog*/, const OUString& /*schemaPattern*/,
934 : const OUString& tableNamePattern, const Sequence< OUString >& /*types*/ ) throw(SQLException, RuntimeException, std::exception)
935 : {
936 : SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getTables()" );
937 : // this returns an empty resultset where the column-names are already set
938 : // in special the metadata of the resultset already returns the right columns
939 10 : ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
940 10 : Reference< XResultSet > xResultSet = pResultSet;
941 :
942 : // ODatabaseMetaDataResultSet::ORows aRows;
943 : // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
944 : // pResultSet->setRows( aRows );
945 20 : ODatabaseMetaDataResultSet::ORows _rRows;
946 10 : if ( !m_pMetaDataHelper->getTables( m_pConnection, tableNamePattern, _rRows ) ) {
947 0 : ::connectivity::SharedResources aResources;
948 : // TODO:
949 : // get better message here?
950 0 : const OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
951 0 : ::dbtools::throwGenericSQLException(sMessage ,*this);
952 : }
953 10 : pResultSet->setRows( _rRows );
954 :
955 20 : return xResultSet;
956 : }
957 :
958 0 : Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
959 : const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& tableNamePattern ) throw(SQLException, RuntimeException, std::exception)
960 : {
961 : SAL_INFO("connectivity.mork", "=> ODatabaseMetaData::getTablePrivileges()" );
962 0 : ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
963 0 : Reference< XResultSet > xRef = pResult;
964 :
965 0 : ::std::vector< OUString > tables;
966 0 : if ( !m_pMetaDataHelper->getTableStrings( m_pConnection, tables) )
967 : {
968 0 : ::connectivity::SharedResources aResources;
969 : // TODO:
970 : // get better message here?
971 0 : const OUString sMessage = aResources.getResourceString(STR_UNKNOWN_COLUMN_TYPE);
972 0 : ::dbtools::throwGenericSQLException(sMessage ,*this);
973 : }
974 :
975 0 : ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
976 0 : ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
977 0 : aRows.reserve(8);
978 0 : aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
979 0 : aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
980 0 : aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
981 0 : aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
982 0 : aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
983 0 : aRow[7] = new ::connectivity::ORowSetValueDecorator(OUString("NO"));
984 :
985 :
986 : // Iterate over all tables
987 0 : for(size_t j = 0; j < tables.size(); j++ ) {
988 0 : if(match(tableNamePattern, tables[j],'\0'))
989 : {
990 : // TABLE_NAME
991 0 : aRow[2] = new ORowSetValueDecorator( tables[j] );
992 :
993 : SAL_INFO("connectivity.mork", "\tTableName = : " << tables[j]);
994 :
995 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
996 0 : aRows.push_back(aRow);
997 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
998 0 : aRows.push_back(aRow);
999 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
1000 0 : aRows.push_back(aRow);
1001 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
1002 0 : aRows.push_back(aRow);
1003 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
1004 0 : aRows.push_back(aRow);
1005 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
1006 0 : aRows.push_back(aRow);
1007 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
1008 0 : aRows.push_back(aRow);
1009 0 : aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
1010 0 : aRows.push_back(aRow);
1011 : }
1012 : }
1013 0 : pResult->setRows(aRows);
1014 0 : return xRef;
1015 : }
1016 :
1017 0 : Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const OUString& /*schemaPattern*/, const OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException, std::exception)
1018 : {
1019 0 : return NULL;
1020 : }
1021 :
1022 :
1023 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|