Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_statics.cxx
blob0d349a896289831622ed1a25276372bdcf425069
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
31 * This Source Code Form is subject to the terms of the Mozilla Public
32 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
35 ************************************************************************/
37 #include "pq_statics.hxx"
38 #include "pq_updateableresultset.hxx"
39 #include <com/sun/star/sdbc/DataType.hpp>
40 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <string.h>
44 using com::sun::star::uno::Sequence;
45 using com::sun::star::uno::Any;
46 using com::sun::star::uno::Type;
48 using com::sun::star::beans::PropertyAttribute::READONLY;
49 using com::sun::star::beans::PropertyAttribute::BOUND;
50 using com::sun::star::beans::Property;
52 namespace pq_sdbc_driver
55 struct DefColumnMetaData
57 const sal_Char * columnName;
58 const sal_Char * tableName;
59 const sal_Char * schemaTableName;
60 const sal_Char * typeName;
61 sal_Int32 type;
62 sal_Int32 precision;
63 sal_Int32 scale;
64 bool isCurrency;
65 bool isNullable;
66 bool isAutoIncrement;
67 bool isReadOnly;
68 bool isSigned;
71 struct BaseTypeDef { const char * typeName; sal_Int32 value; };
73 static Sequence< OUString > createStringSequence( const char * names[] )
75 int length = 0;
76 while (names[length])
77 ++length;
79 Sequence< OUString > seq( length );
80 for( int i = 0; i < length; i ++ )
82 seq[i] = OUString( names[i] , strlen( names[i] ), RTL_TEXTENCODING_ASCII_US );
84 return seq;
87 struct PropertyDef
89 PropertyDef( const OUString &str, const Type &t )
90 : name( str ) , type( t ) {}
91 OUString name;
92 com::sun::star::uno::Type type;
95 struct PropertyDefEx : public PropertyDef
97 PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
98 : PropertyDef( str, t ) , attribute( a )
100 sal_Int32 attribute;
103 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
104 PropertyDef *props, int count , sal_Int16 attr )
106 Sequence< Property > seq( count );
107 for( int i = 0 ; i < count ; i ++ )
109 seq[i] = Property( props[i].name, i, props[i].type, attr );
111 return new cppu::OPropertyArrayHelper( seq, sal_True );
114 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
115 PropertyDefEx *props, int count )
117 Sequence< Property > seq( count );
118 for( int i = 0 ; i < count ; i ++ )
120 seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
122 return new cppu::OPropertyArrayHelper( seq, sal_True );
125 Statics & getStatics()
127 static Statics * p;
128 if( ! p )
130 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
131 if( ! p )
133 static Statics statics ;
134 statics.SYSTEM_TABLE = "SYSTEM TABLE";
135 statics.TABLE = "TABLE";
136 statics.VIEW = "VIEW";
137 statics.UNKNOWN = "UNKNOWN";
138 statics.YES = "YES";
139 statics.NO = "NO";
140 statics.NO_NULLS = "NO_NULLS";
141 statics.NULABLE = "NULABLE";
142 statics.NULLABLE_UNKNOWN = "NULLABLE_UNKNOWN";
143 statics.cPERCENT = "%";
145 statics.TYPE = "Type";
146 statics.TYPE_NAME = "TypeName";
147 statics.NAME = "Name";
148 statics.SCHEMA_NAME = "SchemaName";
149 statics.CATALOG_NAME = "CatalogName";
150 statics.DESCRIPTION = "Description";
151 statics.PRIVILEGES = "Privileges";
153 statics.DEFAULT_VALUE = "DefaultValue";
154 statics.IS_AUTO_INCREMENT = "IsAutoIncrement";
155 statics.IS_CURRENCY = "IsCurrency";
156 statics.IS_NULLABLE = "IsNullable";
157 statics.IS_ROW_VERSISON = "IsRowVersion";
158 statics.PRECISION = "Precision";
159 statics.SCALE = "Scale";
161 statics.cPERCENT = "%";
162 statics.BEGIN = "BEGIN";
163 statics.COMMIT = "COMMIT";
164 statics.ROLLBACK = "ROLLBACK";
166 statics.KEY = "Key";
167 statics.REFERENCED_TABLE = "ReferencedTable";
168 statics.UPDATE_RULE = "UpdateRule";
169 statics.DELETE_RULE = "DeleteRule";
170 statics.PRIVATE_COLUMNS = "PrivateColumns";
171 statics.PRIVATE_FOREIGN_COLUMNS = "PrivateForeignColumns";
173 statics.KEY_COLUMN = "KeyColumn";
174 statics.RELATED_COLUMN = "RelatedColumn";
175 statics.PASSWORD = "Password";
176 statics.USER = "User";
178 statics.CURSOR_NAME = "CursorName";
179 statics.ESCAPE_PROCESSING = "EscapeProcessing";
180 statics.FETCH_DIRECTION = "FetchDirection";
181 statics.FETCH_SIZE = "FetchSize";
182 statics.IS_BOOKMARKABLE = "IsBookmarkable";
183 statics.RESULT_SET_CONCURRENCY = "ResultSetConcurrency";
184 statics.RESULT_SET_TYPE = "ResultSetType";
186 statics.COMMAND = "Command";
187 statics.CHECK_OPTION = "CheckOption";
189 statics.TRUE = "t";
190 statics.FALSE = "f";
191 statics.IS_PRIMARY_KEY_INDEX = "IsPrimaryKeyIndex";
192 statics.IS_CLUSTERED = "IsClustered";
193 statics.IS_UNIQUE = "IsUnique";
194 statics.IS_ASCENDING = "IsAscending";
195 statics.PRIVATE_COLUMN_INDEXES = "PrivateColumnIndexes";
196 statics.HELP_TEXT = "HelpText";
198 statics.CATALOG = "Catalog";
200 Type tString = cppu::UnoType<OUString>::get();
201 Type tInt = cppu::UnoType<sal_Int32>::get();
202 Type tBool = getBooleanCppuType();
203 Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< OUString > *) 0);
205 // Table props set
206 ImplementationStatics &ist = statics.refl.table;
207 ist.implName = "org.openoffice.comp.pq.sdbcx.Table";
208 ist.serviceNames = Sequence< OUString > ( 1 );
209 ist.serviceNames[0] = "com.sun.star.sdbcx.Table";
210 PropertyDef tableDef[] =
212 PropertyDef( statics.CATALOG_NAME , tString ),
213 PropertyDef( statics.DESCRIPTION , tString ),
214 PropertyDef( statics.NAME , tString ),
215 PropertyDef( statics.PRIVILEGES , tInt ),
216 PropertyDef( statics.SCHEMA_NAME , tString ),
217 PropertyDef( statics.TYPE , tString )
219 ist.pProps = createPropertyArrayHelper(
220 tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
222 statics.refl.tableDescriptor.implName =
223 "org.openoffice.comp.pq.sdbcx.TableDescriptor";
224 statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
225 statics.refl.tableDescriptor.serviceNames[0] =
226 "com.sun.star.sdbcx.TableDescriptor";
227 PropertyDef tableDescDef[] =
229 PropertyDef( statics.CATALOG_NAME , tString ),
230 PropertyDef( statics.DESCRIPTION , tString ),
231 PropertyDef( statics.NAME , tString ),
232 PropertyDef( statics.PRIVILEGES , tInt ),
233 PropertyDef( statics.SCHEMA_NAME , tString )
235 statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
236 tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 );
238 // Column props set
239 statics.refl.column.implName = "org.openoffice.comp.pq.sdbcx.Column";
240 statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
241 statics.refl.column.serviceNames[0] = "com.sun.star.sdbcx.Column";
242 PropertyDefEx columnDef[] =
244 PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
245 PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
246 PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
247 // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
248 PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
249 PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
250 PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
251 PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
252 PropertyDefEx( statics.NAME , tString,READONLY ),
253 PropertyDefEx( statics.PRECISION , tInt, READONLY ),
254 PropertyDefEx( statics.SCALE , tInt ,READONLY),
255 PropertyDefEx( statics.TYPE , tInt ,READONLY),
256 PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
258 statics.refl.column.pProps = createPropertyArrayHelper(
259 columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
261 statics.refl.columnDescriptor.implName =
262 "org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
263 statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
264 statics.refl.columnDescriptor.serviceNames[0] =
265 "com.sun.star.sdbcx.ColumnDescriptor";
266 PropertyDef columnDescDef[] =
268 PropertyDef( statics.CATALOG_NAME , tString ),
269 PropertyDef( statics.DEFAULT_VALUE, tString ),
270 PropertyDef( statics.DESCRIPTION , tString ),
271 // PropertyDef( statics.HELP_TEXT , tString ),
272 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
273 PropertyDef( statics.IS_CURRENCY, tBool ),
274 PropertyDef( statics.IS_NULLABLE, tInt ),
275 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
276 PropertyDef( statics.NAME , tString ),
277 PropertyDef( statics.PRECISION , tInt ),
278 PropertyDef( statics.SCALE , tInt ),
279 PropertyDef( statics.TYPE , tInt ),
280 PropertyDef( statics.TYPE_NAME , tString )
283 statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
284 columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 );
286 // Key properties
287 statics.refl.key.implName = "org.openoffice.comp.pq.sdbcx.Key";
288 statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
289 statics.refl.key.serviceNames[0] = "com.sun.star.sdbcx.Key";
290 PropertyDef keyDef[] =
292 PropertyDef( statics.DELETE_RULE, tInt ),
293 PropertyDef( statics.NAME, tString ),
294 PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
295 PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
296 PropertyDef( statics.REFERENCED_TABLE, tString ),
297 PropertyDef( statics.TYPE, tInt ),
298 PropertyDef( statics.UPDATE_RULE, tInt )
300 statics.refl.key.pProps = createPropertyArrayHelper(
301 keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
304 // Key properties
305 statics.refl.keyDescriptor.implName =
306 "org.openoffice.comp.pq.sdbcx.KeyDescriptor";
307 statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
308 statics.refl.keyDescriptor.serviceNames[0] =
309 "com.sun.star.sdbcx.KeyDescriptor";
310 PropertyDef keyDescDef[] =
312 PropertyDef( statics.DELETE_RULE, tInt ),
313 PropertyDef( statics.NAME, tString ),
314 PropertyDef( statics.REFERENCED_TABLE, tString ),
315 PropertyDef( statics.TYPE, tInt ),
316 PropertyDef( statics.UPDATE_RULE, tInt )
318 statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
319 keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 );
323 // KeyColumn props set
324 statics.refl.keycolumn.implName = "org.openoffice.comp.pq.sdbcx.KeyColumn";
325 statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
326 statics.refl.keycolumn.serviceNames[0] = "com.sun.star.sdbcx.KeyColumn";
327 PropertyDef keycolumnDef[] =
329 PropertyDef( statics.CATALOG_NAME , tString ),
330 PropertyDef( statics.DEFAULT_VALUE, tString ),
331 PropertyDef( statics.DESCRIPTION , tString ),
332 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
333 PropertyDef( statics.IS_CURRENCY, tBool ),
334 PropertyDef( statics.IS_NULLABLE, tInt ),
335 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
336 PropertyDef( statics.NAME , tString ),
337 PropertyDef( statics.PRECISION , tInt ),
338 PropertyDef( statics.RELATED_COLUMN, tString ),
339 PropertyDef( statics.SCALE , tInt ),
340 PropertyDef( statics.TYPE , tInt ),
341 PropertyDef( statics.TYPE_NAME , tString )
343 statics.refl.keycolumn.pProps = createPropertyArrayHelper(
344 keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
346 // KeyColumn props set
347 statics.refl.keycolumnDescriptor.implName =
348 "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor";
349 statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
350 statics.refl.keycolumnDescriptor.serviceNames[0] =
351 "com.sun.star.sdbcx.KeyColumnDescriptor";
352 PropertyDef keycolumnDescDef[] =
354 PropertyDef( statics.NAME , tString ),
355 PropertyDef( statics.RELATED_COLUMN, tString )
357 statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
358 keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 );
360 // view props set
361 statics.refl.view.implName = "org.openoffice.comp.pq.sdbcx.View";
362 statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
363 statics.refl.view.serviceNames[0] = "com.sun.star.sdbcx.View";
364 PropertyDef viewDef[] =
366 PropertyDef( statics.CATALOG_NAME , tString ),
367 PropertyDef( statics.CHECK_OPTION , tInt ),
368 PropertyDef( statics.COMMAND , tString ),
369 PropertyDef( statics.NAME , tString ),
370 PropertyDef( statics.SCHEMA_NAME , tString )
372 statics.refl.view.pProps = createPropertyArrayHelper(
373 viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
375 // view props set
376 statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
377 statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
378 statics.refl.viewDescriptor.serviceNames[0] = "com.sun.star.sdbcx.ViewDescriptor";
379 statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
380 viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical
381 // user props set
382 statics.refl.user.implName = "org.openoffice.comp.pq.sdbcx.User";
383 statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
384 statics.refl.user.serviceNames[0] = "com.sun.star.sdbcx.User";
385 PropertyDef userDefRO[] =
387 PropertyDef( statics.NAME , tString )
389 statics.refl.user.pProps = createPropertyArrayHelper(
390 userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
392 // user props set
393 statics.refl.userDescriptor.implName =
394 "org.openoffice.comp.pq.sdbcx.UserDescriptor";
395 statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
396 statics.refl.userDescriptor.serviceNames[0] =
397 "com.sun.star.sdbcx.UserDescriptor";
398 PropertyDef userDefWR[] =
400 PropertyDef( statics.NAME , tString ),
401 PropertyDef( statics.PASSWORD , tString )
403 statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
404 userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 );
406 // index props set
407 statics.refl.index.implName = "org.openoffice.comp.pq.sdbcx.Index";
408 statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
409 statics.refl.index.serviceNames[0] = "com.sun.star.sdbcx.Index";
410 PropertyDef indexDef[] =
412 PropertyDef( statics.CATALOG , tString ),
413 PropertyDef( statics.IS_CLUSTERED, tBool ),
414 PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
415 PropertyDef( statics.IS_UNIQUE, tBool ),
416 PropertyDef( statics.NAME , tString ),
417 PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
419 statics.refl.index.pProps = createPropertyArrayHelper(
420 indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
422 // index props set
423 statics.refl.indexDescriptor.implName =
424 "org.openoffice.comp.pq.sdbcx.IndexDescriptor";
425 statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
426 statics.refl.indexDescriptor.serviceNames[0] =
427 "com.sun.star.sdbcx.IndexDescriptor";
428 statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
429 indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 );
431 // indexColumn props set
432 statics.refl.indexColumn.implName = "org.openoffice.comp.pq.sdbcx.IndexColumn";
433 statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
434 statics.refl.indexColumn.serviceNames[0] = "com.sun.star.sdbcx.IndexColumn";
435 PropertyDef indexColumnDef[] =
437 PropertyDef( statics.CATALOG_NAME , tString ),
438 PropertyDef( statics.DEFAULT_VALUE, tString ),
439 PropertyDef( statics.DESCRIPTION , tString ),
440 PropertyDef( statics.IS_ASCENDING, tBool ),
441 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
442 PropertyDef( statics.IS_CURRENCY, tBool ),
443 PropertyDef( statics.IS_NULLABLE, tInt ),
444 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
445 PropertyDef( statics.NAME , tString ),
446 PropertyDef( statics.PRECISION , tInt ),
447 PropertyDef( statics.SCALE , tInt ),
448 PropertyDef( statics.TYPE , tInt ),
449 PropertyDef( statics.TYPE_NAME , tString )
451 statics.refl.indexColumn.pProps = createPropertyArrayHelper(
452 indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
454 // indexColumn props set
455 statics.refl.indexColumnDescriptor.implName =
456 "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor";
457 statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
458 statics.refl.indexColumnDescriptor.serviceNames[0] =
459 "com.sun.star.sdbcx.IndexColumnDescriptor";
460 PropertyDef indexColumnDescDef[] =
462 PropertyDef( statics.IS_ASCENDING, tBool ),
463 PropertyDef( statics.NAME , tString )
465 statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
466 indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 );
468 // resultset
469 statics.refl.resultSet.implName = "org.openoffice.comp.pq.ResultSet";
470 statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
471 statics.refl.resultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet";
472 statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
473 PropertyDef resultSet[] =
475 PropertyDef( statics.CURSOR_NAME , tString ),
476 PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
477 PropertyDef( statics.FETCH_DIRECTION , tInt ),
478 PropertyDef( statics.FETCH_SIZE , tInt ),
479 PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
480 PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
481 PropertyDef( statics.RESULT_SET_TYPE , tInt )
483 statics.refl.resultSet.pProps = createPropertyArrayHelper(
484 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
486 // updateableResultset
487 statics.refl.updateableResultSet.implName = "org.openoffice.comp.pq.UpdateableResultSet";
488 statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
489 statics.refl.updateableResultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet";
490 statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
491 statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
492 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
494 // databasemetadata
495 statics.tablesRowNames = Sequence< OUString > ( 5 );
496 statics.tablesRowNames[TABLE_INDEX_CATALOG] = "TABLE_CAT";
497 statics.tablesRowNames[TABLE_INDEX_SCHEMA] = "TABLE_SCHEM";
498 statics.tablesRowNames[TABLE_INDEX_NAME] = "TABLE_NAME";
499 statics.tablesRowNames[TABLE_INDEX_TYPE] = "TABLE_TYPE";
500 statics.tablesRowNames[TABLE_INDEX_REMARKS] = "REMARKS";
502 statics.primaryKeyNames = Sequence< OUString > ( 6 );
503 statics.primaryKeyNames[0] = "TABLE_CAT";
504 statics.primaryKeyNames[1] = "TABLE_SCHEM";
505 statics.primaryKeyNames[2] = "TABLE_NAME";
506 statics.primaryKeyNames[3] = "COLUMN_NAME";
507 statics.primaryKeyNames[4] = "KEY_SEQ";
508 statics.primaryKeyNames[5] = "PK_NAME";
510 statics.SELECT = "SELECT";
511 statics.UPDATE = "UPDATE";
512 statics.INSERT = "INSERT";
513 statics.DELETE = "DELETE";
514 statics.RULE = "RULE";
515 statics.REFERENCES = "REFERENCES";
516 statics.TRIGGER = "TRIGGER";
517 statics.EXECUTE = "EXECUTE";
518 statics.USAGE = "USAGE";
519 statics.CREATE = "CREATE";
520 statics.TEMPORARY = "TEMPORARY";
521 statics.INDEX = "Index";
522 statics.INDEX_COLUMN = "IndexColumn";
524 statics.schemaNames = Sequence< OUString > ( 1 );
525 statics.schemaNames[0] = "TABLE_SCHEM";
527 statics.tableTypeData = Sequence< Sequence< Any > >( 2 );
529 statics.tableTypeData[0] = Sequence< Any > ( 1 );
530 statics.tableTypeData[0][0] <<= statics.TABLE;
532 // statics.tableTypeData[2] = Sequence< Any > ( 1 );
533 // statics.tableTypeData[2][0] <<= statics.VIEW;
535 statics.tableTypeData[1] = Sequence< Any > ( 1 );
536 statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
538 statics.tableTypeNames = Sequence< OUString > ( 1 );
539 statics.tableTypeNames[0] = "TABLE_TYPE";
541 static const char *tablePrivilegesNames[] =
543 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE",
544 "IS_GRANTABLE" , 0
546 statics.tablePrivilegesNames =
547 createStringSequence( tablePrivilegesNames );
549 static const char * columnNames[] =
551 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
552 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
553 "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
554 "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
555 "ORDINAL_POSITION", "IS_NULLABLE", 0
557 statics.columnRowNames =
558 createStringSequence( columnNames );
560 static const char * typeinfoColumnNames[] =
562 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
563 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
564 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
565 "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
566 "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
567 "NUM_PREC_RADIX", 0
569 statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames );
571 static const char * indexinfoColumnNames[] =
573 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
574 "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
575 "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
576 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0
578 statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames );
580 static const char * importedKeysColumnNames[] =
582 "PKTABLE_CAT" ,
583 "PKTABLE_SCHEM",
584 "PKTABLE_NAME" ,
585 "PKCOLUMN_NAME",
586 "FKTABLE_CAT" ,
587 "FKTABLE_SCHEM",
588 "FKTABLE_NAME" ,
589 "FKCOLUMN_NAME",
590 "KEY_SEQ" ,
591 "UPDATE_RULE",
592 "DELETE_RULE",
593 "FK_NAME" ,
594 "PK_NAME" ,
595 "DEFERRABILITY" ,
598 statics.importedKeysColumnNames =
599 createStringSequence( importedKeysColumnNames );
601 static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 };
602 statics.resultSetArrayColumnNames =
603 createStringSequence( resultSetArrayColumnNames );
605 // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type?
606 BaseTypeDef baseTypeDefs[] =
608 { "bool" , com::sun::star::sdbc::DataType::BIT },
609 { "bytea", com::sun::star::sdbc::DataType::VARBINARY },
610 { "char" , com::sun::star::sdbc::DataType::CHAR },
612 { "int8" , com::sun::star::sdbc::DataType::BIGINT },
613 { "serial8" , com::sun::star::sdbc::DataType::BIGINT },
616 { "int2" , com::sun::star::sdbc::DataType::SMALLINT },
618 { "int4" , com::sun::star::sdbc::DataType::INTEGER },
619 // { "regproc" , com::sun::star::sdbc::DataType::INTEGER },
620 // { "oid" , com::sun::star::sdbc::DataType::INTEGER },
621 // { "xid" , com::sun::star::sdbc::DataType::INTEGER },
622 // { "cid" , com::sun::star::sdbc::DataType::INTEGER },
623 // { "serial", com::sun::star::sdbc::DataType::INTEGER },
624 // { "serial4", com::sun::star::sdbc::DataType::INTEGER },
626 { "text", com::sun::star::sdbc::DataType::VARCHAR },
627 { "bpchar", com::sun::star::sdbc::DataType::CHAR },
628 { "varchar", com::sun::star::sdbc::DataType::VARCHAR },
630 { "float4", com::sun::star::sdbc::DataType::REAL },
631 { "float8", com::sun::star::sdbc::DataType::DOUBLE },
633 { "numeric", com::sun::star::sdbc::DataType::NUMERIC },
634 { "decimal", com::sun::star::sdbc::DataType::DECIMAL },
636 { "date", com::sun::star::sdbc::DataType::DATE },
637 { "time", com::sun::star::sdbc::DataType::TIME },
638 { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP },
640 // { "_bool" , com::sun::star::sdbc::DataType::ARRAY },
641 // { "_bytea", com::sun::star::sdbc::DataType::ARRAY },
642 // { "_char" , com::sun::star::sdbc::DataType::ARRAY },
644 // { "_int8" , com::sun::star::sdbc::DataType::ARRAY },
645 // { "_serial8" , com::sun::star::sdbc::DataType::ARRAY },
648 // { "_int2" , com::sun::star::sdbc::DataType::ARRAY },
650 // { "_int4" , com::sun::star::sdbc::DataType::ARRAY },
651 // { "_regproc" , com::sun::star::sdbc::DataType::ARRAY },
652 // { "_oid" , com::sun::star::sdbc::DataType::ARRAY },
653 // { "_xid" , com::sun::star::sdbc::DataType::ARRAY },
654 // { "_cid" , com::sun::star::sdbc::DataType::ARRAY },
656 // { "_text", com::sun::star::sdbc::DataType::ARRAY },
657 // { "_bpchar", com::sun::star::sdbc::DataType::ARRAY },
658 // { "_varchar", com::sun::star::sdbc::DataType::ARRAY },
660 // { "_float4", com::sun::star::sdbc::DataType::ARRAY },
661 // { "_float8", com::sun::star::sdbc::DataType::ARRAY },
663 // { "_numeric", com::sun::star::sdbc::DataType::ARRAY },
664 // { "_decimal", com::sun::star::sdbc::DataType::ARRAY },
666 // { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later
667 // { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later
669 { 0, 0 }
671 int i;
672 for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
674 statics.baseTypeMap[
675 OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
676 baseTypeDefs[i].value;
679 // This is the metadata for the columns of the recordset returned
680 // by ::com::sun::star::sdbc::XDatabaseMetaData::getTypeInfo(),
681 // that is what is returned by getTypeInfo().getMetaData()
682 DefColumnMetaData defTypeInfoMetaData[] =
684 { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,false,false,false,false, false }, // 0
685 { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,false,false,false,false, true }, // 1
686 { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,false,false,false,false, true }, // 2
687 { "LITERAL_PREFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,false,false,false,false, false }, // 3
688 { "LITERAL_SUFFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,false,false,false,false, false }, // 4
689 { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,false,false,false,false, false }, // 5
690 { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,false,false,false,false, true }, // 6
691 { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,false,false,false,false, false }, // 7
692 { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,false,false,false,false, true }, // 8
693 { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,false,false,false,false, false }, // 9
694 { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,false,false,false,false, false }, // 10
695 { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,false,false,false,false, false }, // 11
696 { "LOCAL_TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,false,false,false,false, false }, // 12
697 { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,false,false,false,false, true}, // 13
698 { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,false,false,false,false, true }, // 14
699 { "SQL_DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,false,false,false,false, true }, // 15
700 { "SQL_DATETIME_SUB", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,false,false,false,false , true}, // 16
701 { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,false,false,false,false, true }, // 17
702 {0,0,0,0,0,0,0,false,false,false,false, false}
705 for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
707 statics.typeInfoMetaData.push_back(
708 ColumnMetaData(
709 OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
710 OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
711 OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
712 OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
713 defTypeInfoMetaData[i].type,
714 defTypeInfoMetaData[i].precision,
715 defTypeInfoMetaData[i].scale,
716 defTypeInfoMetaData[i].isCurrency,
717 defTypeInfoMetaData[i].isNullable,
718 defTypeInfoMetaData[i].isAutoIncrement,
719 defTypeInfoMetaData[i].isReadOnly,
720 defTypeInfoMetaData[i].isSigned ) );
723 p = &statics;
726 return *p;
733 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */