bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_statics.cxx
blob564ab791056777bb4c600cb7c96da2ab0fcbaf58
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::Property;
51 namespace pq_sdbc_driver
54 struct DefColumnMetaData
56 const sal_Char * columnName;
57 const sal_Char * tableName;
58 const sal_Char * schemaTableName;
59 const sal_Char * typeName;
60 sal_Int32 type;
61 sal_Int32 precision;
62 sal_Int32 scale;
63 bool isCurrency;
64 bool isNullable;
65 bool isAutoIncrement;
68 struct BaseTypeDef { const char * typeName; sal_Int32 value; };
70 struct PropertyDef
72 PropertyDef( const OUString &str, const Type &t )
73 : name( str ) , type( t ) {}
74 OUString name;
75 css::uno::Type type;
78 struct PropertyDefEx : public PropertyDef
80 PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
81 : PropertyDef( str, t ) , attribute( a )
83 sal_Int32 attribute;
86 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
87 PropertyDef const *props, int count , sal_Int16 attr )
89 Sequence< Property > seq( count );
90 for( int i = 0 ; i < count ; i ++ )
92 seq[i] = Property( props[i].name, i, props[i].type, attr );
94 return new cppu::OPropertyArrayHelper( seq, true );
97 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
98 PropertyDefEx const *props, int count )
100 Sequence< Property > seq( count );
101 for( int i = 0 ; i < count ; i ++ )
103 seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
105 return new cppu::OPropertyArrayHelper( seq, true );
108 Statics & getStatics()
110 static Statics* p = []() {
111 static Statics statics ;
112 statics.SYSTEM_TABLE = "SYSTEM TABLE";
113 statics.TABLE = "TABLE";
114 statics.VIEW = "VIEW";
115 statics.UNKNOWN = "UNKNOWN";
116 statics.YES = "YES";
117 statics.NO = "NO";
118 statics.NO_NULLS = "NO_NULLS";
119 statics.NULABLE = "NULABLE";
120 statics.NULLABLE_UNKNOWN = "NULLABLE_UNKNOWN";
122 statics.TYPE = "Type";
123 statics.TYPE_NAME = "TypeName";
124 statics.NAME = "Name";
125 statics.SCHEMA_NAME = "SchemaName";
126 statics.CATALOG_NAME = "CatalogName";
127 statics.DESCRIPTION = "Description";
128 statics.PRIVILEGES = "Privileges";
130 statics.DEFAULT_VALUE = "DefaultValue";
131 statics.IS_AUTO_INCREMENT = "IsAutoIncrement";
132 statics.IS_CURRENCY = "IsCurrency";
133 statics.IS_NULLABLE = "IsNullable";
134 statics.IS_ROW_VERSISON = "IsRowVersion";
135 statics.PRECISION = "Precision";
136 statics.SCALE = "Scale";
138 statics.cPERCENT = "%";
139 statics.BEGIN = "BEGIN";
140 statics.COMMIT = "COMMIT";
141 statics.ROLLBACK = "ROLLBACK";
143 statics.KEY = "Key";
144 statics.REFERENCED_TABLE = "ReferencedTable";
145 statics.UPDATE_RULE = "UpdateRule";
146 statics.DELETE_RULE = "DeleteRule";
147 statics.PRIVATE_COLUMNS = "PrivateColumns";
148 statics.PRIVATE_FOREIGN_COLUMNS = "PrivateForeignColumns";
150 statics.KEY_COLUMN = "KeyColumn";
151 statics.RELATED_COLUMN = "RelatedColumn";
152 statics.PASSWORD = "Password";
153 statics.USER = "User";
155 statics.CURSOR_NAME = "CursorName";
156 statics.ESCAPE_PROCESSING = "EscapeProcessing";
157 statics.FETCH_DIRECTION = "FetchDirection";
158 statics.FETCH_SIZE = "FetchSize";
159 statics.IS_BOOKMARKABLE = "IsBookmarkable";
160 statics.RESULT_SET_CONCURRENCY = "ResultSetConcurrency";
161 statics.RESULT_SET_TYPE = "ResultSetType";
163 statics.COMMAND = "Command";
164 statics.CHECK_OPTION = "CheckOption";
166 statics.TRUE = "t";
167 statics.FALSE = "f";
168 statics.IS_PRIMARY_KEY_INDEX = "IsPrimaryKeyIndex";
169 statics.IS_CLUSTERED = "IsClustered";
170 statics.IS_UNIQUE = "IsUnique";
171 statics.IS_ASCENDING = "IsAscending";
172 statics.PRIVATE_COLUMN_INDEXES = "PrivateColumnIndexes";
173 statics.HELP_TEXT = "HelpText";
175 statics.CATALOG = "Catalog";
177 Type tString = cppu::UnoType<OUString>::get();
178 Type tInt = cppu::UnoType<sal_Int32>::get();
179 Type tBool = cppu::UnoType<bool>::get();
180 Type tStringSequence = cppu::UnoType<css::uno::Sequence< OUString >>::get();
182 // Table props set
183 ImplementationStatics &ist = statics.refl.table;
184 ist.implName = "org.openoffice.comp.pq.sdbcx.Table";
185 ist.serviceNames = Sequence< OUString > ( 1 );
186 ist.serviceNames[0] = "com.sun.star.sdbcx.Table";
187 PropertyDef tableDef[] =
189 PropertyDef( statics.CATALOG_NAME , tString ),
190 PropertyDef( statics.DESCRIPTION , tString ),
191 PropertyDef( statics.NAME , tString ),
192 PropertyDef( statics.PRIVILEGES , tInt ),
193 PropertyDef( statics.SCHEMA_NAME , tString ),
194 PropertyDef( statics.TYPE , tString )
196 ist.pProps = createPropertyArrayHelper(
197 tableDef, SAL_N_ELEMENTS(tableDef), READONLY );
199 statics.refl.tableDescriptor.implName =
200 "org.openoffice.comp.pq.sdbcx.TableDescriptor";
201 statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
202 statics.refl.tableDescriptor.serviceNames[0] =
203 "com.sun.star.sdbcx.TableDescriptor";
204 PropertyDef tableDescDef[] =
206 PropertyDef( statics.CATALOG_NAME , tString ),
207 PropertyDef( statics.DESCRIPTION , tString ),
208 PropertyDef( statics.NAME , tString ),
209 PropertyDef( statics.PRIVILEGES , tInt ),
210 PropertyDef( statics.SCHEMA_NAME , tString )
212 statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
213 tableDescDef, SAL_N_ELEMENTS(tableDescDef), 0 );
215 // Column props set
216 statics.refl.column.implName = "org.openoffice.comp.pq.sdbcx.Column";
217 statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
218 statics.refl.column.serviceNames[0] = "com.sun.star.sdbcx.Column";
219 PropertyDefEx columnDef[] =
221 PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
222 PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
223 PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
224 // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
225 PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
226 PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
227 PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
228 PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
229 PropertyDefEx( statics.NAME , tString,READONLY ),
230 PropertyDefEx( statics.PRECISION , tInt, READONLY ),
231 PropertyDefEx( statics.SCALE , tInt ,READONLY),
232 PropertyDefEx( statics.TYPE , tInt ,READONLY),
233 PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
235 statics.refl.column.pProps = createPropertyArrayHelper(
236 columnDef, SAL_N_ELEMENTS(columnDef) );
238 statics.refl.columnDescriptor.implName =
239 "org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
240 statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
241 statics.refl.columnDescriptor.serviceNames[0] =
242 "com.sun.star.sdbcx.ColumnDescriptor";
243 PropertyDef columnDescDef[] =
245 PropertyDef( statics.CATALOG_NAME , tString ),
246 PropertyDef( statics.DEFAULT_VALUE, tString ),
247 PropertyDef( statics.DESCRIPTION , tString ),
248 // PropertyDef( statics.HELP_TEXT , tString ),
249 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
250 PropertyDef( statics.IS_CURRENCY, tBool ),
251 PropertyDef( statics.IS_NULLABLE, tInt ),
252 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
253 PropertyDef( statics.NAME , tString ),
254 PropertyDef( statics.PRECISION , tInt ),
255 PropertyDef( statics.SCALE , tInt ),
256 PropertyDef( statics.TYPE , tInt ),
257 PropertyDef( statics.TYPE_NAME , tString )
260 statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
261 columnDescDef, SAL_N_ELEMENTS(columnDescDef), 0 );
263 // Key properties
264 statics.refl.key.implName = "org.openoffice.comp.pq.sdbcx.Key";
265 statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
266 statics.refl.key.serviceNames[0] = "com.sun.star.sdbcx.Key";
267 PropertyDef keyDef[] =
269 PropertyDef( statics.DELETE_RULE, tInt ),
270 PropertyDef( statics.NAME, tString ),
271 PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
272 PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
273 PropertyDef( statics.REFERENCED_TABLE, tString ),
274 PropertyDef( statics.TYPE, tInt ),
275 PropertyDef( statics.UPDATE_RULE, tInt )
277 statics.refl.key.pProps = createPropertyArrayHelper(
278 keyDef, SAL_N_ELEMENTS(keyDef), READONLY );
281 // Key properties
282 statics.refl.keyDescriptor.implName =
283 "org.openoffice.comp.pq.sdbcx.KeyDescriptor";
284 statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
285 statics.refl.keyDescriptor.serviceNames[0] =
286 "com.sun.star.sdbcx.KeyDescriptor";
287 PropertyDef keyDescDef[] =
289 PropertyDef( statics.DELETE_RULE, tInt ),
290 PropertyDef( statics.NAME, tString ),
291 PropertyDef( statics.REFERENCED_TABLE, tString ),
292 PropertyDef( statics.TYPE, tInt ),
293 PropertyDef( statics.UPDATE_RULE, tInt )
295 statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
296 keyDescDef, SAL_N_ELEMENTS(keyDescDef), 0 );
299 // KeyColumn props set
300 statics.refl.keycolumn.implName = "org.openoffice.comp.pq.sdbcx.KeyColumn";
301 statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
302 statics.refl.keycolumn.serviceNames[0] = "com.sun.star.sdbcx.KeyColumn";
303 PropertyDef keycolumnDef[] =
305 PropertyDef( statics.CATALOG_NAME , tString ),
306 PropertyDef( statics.DEFAULT_VALUE, tString ),
307 PropertyDef( statics.DESCRIPTION , tString ),
308 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
309 PropertyDef( statics.IS_CURRENCY, tBool ),
310 PropertyDef( statics.IS_NULLABLE, tInt ),
311 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
312 PropertyDef( statics.NAME , tString ),
313 PropertyDef( statics.PRECISION , tInt ),
314 PropertyDef( statics.RELATED_COLUMN, tString ),
315 PropertyDef( statics.SCALE , tInt ),
316 PropertyDef( statics.TYPE , tInt ),
317 PropertyDef( statics.TYPE_NAME , tString )
319 statics.refl.keycolumn.pProps = createPropertyArrayHelper(
320 keycolumnDef, SAL_N_ELEMENTS(keycolumnDef), READONLY );
322 // KeyColumn props set
323 statics.refl.keycolumnDescriptor.implName =
324 "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor";
325 statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
326 statics.refl.keycolumnDescriptor.serviceNames[0] =
327 "com.sun.star.sdbcx.KeyColumnDescriptor";
328 PropertyDef keycolumnDescDef[] =
330 PropertyDef( statics.NAME , tString ),
331 PropertyDef( statics.RELATED_COLUMN, tString )
333 statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
334 keycolumnDescDef, SAL_N_ELEMENTS(keycolumnDescDef), 0 );
336 // view props set
337 statics.refl.view.implName = "org.openoffice.comp.pq.sdbcx.View";
338 statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
339 statics.refl.view.serviceNames[0] = "com.sun.star.sdbcx.View";
340 PropertyDef viewDef[] =
342 PropertyDef( statics.CATALOG_NAME , tString ),
343 PropertyDef( statics.CHECK_OPTION , tInt ),
344 PropertyDef( statics.COMMAND , tString ),
345 PropertyDef( statics.NAME , tString ),
346 PropertyDef( statics.SCHEMA_NAME , tString )
348 statics.refl.view.pProps = createPropertyArrayHelper(
349 viewDef, SAL_N_ELEMENTS(viewDef), READONLY );
351 // view props set
352 statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
353 statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
354 statics.refl.viewDescriptor.serviceNames[0] = "com.sun.star.sdbcx.ViewDescriptor";
355 statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
356 viewDef, SAL_N_ELEMENTS(viewDef), 0 ); // reuse view, as it is identical
357 // user props set
358 statics.refl.user.implName = "org.openoffice.comp.pq.sdbcx.User";
359 statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
360 statics.refl.user.serviceNames[0] = "com.sun.star.sdbcx.User";
361 PropertyDef userDefRO[] =
363 PropertyDef( statics.NAME , tString )
365 statics.refl.user.pProps = createPropertyArrayHelper(
366 userDefRO, SAL_N_ELEMENTS(userDefRO), READONLY );
368 // user props set
369 statics.refl.userDescriptor.implName =
370 "org.openoffice.comp.pq.sdbcx.UserDescriptor";
371 statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
372 statics.refl.userDescriptor.serviceNames[0] =
373 "com.sun.star.sdbcx.UserDescriptor";
374 PropertyDef userDefWR[] =
376 PropertyDef( statics.NAME , tString ),
377 PropertyDef( statics.PASSWORD , tString )
379 statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
380 userDefWR, SAL_N_ELEMENTS(userDefWR), 0 );
382 // index props set
383 statics.refl.index.implName = "org.openoffice.comp.pq.sdbcx.Index";
384 statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
385 statics.refl.index.serviceNames[0] = "com.sun.star.sdbcx.Index";
386 PropertyDef indexDef[] =
388 PropertyDef( statics.CATALOG , tString ),
389 PropertyDef( statics.IS_CLUSTERED, tBool ),
390 PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
391 PropertyDef( statics.IS_UNIQUE, tBool ),
392 PropertyDef( statics.NAME , tString ),
393 PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
395 statics.refl.index.pProps = createPropertyArrayHelper(
396 indexDef, SAL_N_ELEMENTS(indexDef), READONLY );
398 // index props set
399 statics.refl.indexDescriptor.implName =
400 "org.openoffice.comp.pq.sdbcx.IndexDescriptor";
401 statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
402 statics.refl.indexDescriptor.serviceNames[0] =
403 "com.sun.star.sdbcx.IndexDescriptor";
404 statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
405 indexDef, SAL_N_ELEMENTS(indexDef), 0 );
407 // indexColumn props set
408 statics.refl.indexColumn.implName = "org.openoffice.comp.pq.sdbcx.IndexColumn";
409 statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
410 statics.refl.indexColumn.serviceNames[0] = "com.sun.star.sdbcx.IndexColumn";
411 PropertyDef indexColumnDef[] =
413 PropertyDef( statics.CATALOG_NAME , tString ),
414 PropertyDef( statics.DEFAULT_VALUE, tString ),
415 PropertyDef( statics.DESCRIPTION , tString ),
416 PropertyDef( statics.IS_ASCENDING, tBool ),
417 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
418 PropertyDef( statics.IS_CURRENCY, tBool ),
419 PropertyDef( statics.IS_NULLABLE, tInt ),
420 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
421 PropertyDef( statics.NAME , tString ),
422 PropertyDef( statics.PRECISION , tInt ),
423 PropertyDef( statics.SCALE , tInt ),
424 PropertyDef( statics.TYPE , tInt ),
425 PropertyDef( statics.TYPE_NAME , tString )
427 statics.refl.indexColumn.pProps = createPropertyArrayHelper(
428 indexColumnDef, SAL_N_ELEMENTS(indexColumnDef), READONLY );
430 // indexColumn props set
431 statics.refl.indexColumnDescriptor.implName =
432 "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor";
433 statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
434 statics.refl.indexColumnDescriptor.serviceNames[0] =
435 "com.sun.star.sdbcx.IndexColumnDescriptor";
436 PropertyDef indexColumnDescDef[] =
438 PropertyDef( statics.IS_ASCENDING, tBool ),
439 PropertyDef( statics.NAME , tString )
441 statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
442 indexColumnDescDef, SAL_N_ELEMENTS(indexColumnDescDef), 0 );
444 // resultset
445 statics.refl.resultSet.implName = "org.openoffice.comp.pq.ResultSet";
446 statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
447 statics.refl.resultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet";
448 statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
449 PropertyDef resultSet[] =
451 PropertyDef( statics.CURSOR_NAME , tString ),
452 PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
453 PropertyDef( statics.FETCH_DIRECTION , tInt ),
454 PropertyDef( statics.FETCH_SIZE , tInt ),
455 PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
456 PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
457 PropertyDef( statics.RESULT_SET_TYPE , tInt )
459 statics.refl.resultSet.pProps = createPropertyArrayHelper(
460 resultSet, SAL_N_ELEMENTS(resultSet), 0 );
462 // updateableResultset
463 statics.refl.updateableResultSet.implName = "org.openoffice.comp.pq.UpdateableResultSet";
464 statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
465 statics.refl.updateableResultSet.serviceNames[0] = "com.sun.star.sdbc.ResultSet";
466 statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
467 statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
468 resultSet, SAL_N_ELEMENTS(resultSet), 0 );
470 // databasemetadata
471 statics.tablesRowNames = std::vector< OUString > ( 5 );
472 statics.tablesRowNames[TABLE_INDEX_CATALOG] = "TABLE_CAT";
473 statics.tablesRowNames[TABLE_INDEX_SCHEMA] = "TABLE_SCHEM";
474 statics.tablesRowNames[TABLE_INDEX_NAME] = "TABLE_NAME";
475 statics.tablesRowNames[TABLE_INDEX_TYPE] = "TABLE_TYPE";
476 statics.tablesRowNames[TABLE_INDEX_REMARKS] = "REMARKS";
478 statics.primaryKeyNames = std::vector< OUString > ( 6 );
479 statics.primaryKeyNames[0] = "TABLE_CAT";
480 statics.primaryKeyNames[1] = "TABLE_SCHEM";
481 statics.primaryKeyNames[2] = "TABLE_NAME";
482 statics.primaryKeyNames[3] = "COLUMN_NAME";
483 statics.primaryKeyNames[4] = "KEY_SEQ";
484 statics.primaryKeyNames[5] = "PK_NAME";
486 statics.SELECT = "SELECT";
487 statics.UPDATE = "UPDATE";
488 statics.INSERT = "INSERT";
489 statics.DELETE = "DELETE";
490 statics.RULE = "RULE";
491 statics.REFERENCES = "REFERENCES";
492 statics.TRIGGER = "TRIGGER";
493 statics.EXECUTE = "EXECUTE";
494 statics.USAGE = "USAGE";
495 statics.CREATE = "CREATE";
496 statics.TEMPORARY = "TEMPORARY";
497 statics.INDEX = "Index";
498 statics.INDEX_COLUMN = "IndexColumn";
500 statics.schemaNames = std::vector< OUString > ( 1 );
501 statics.schemaNames[0] = "TABLE_SCHEM";
503 statics.tableTypeData = std::vector< std::vector< Any > >( 2 );
505 statics.tableTypeData[0] = std::vector< Any > ( 1 );
506 statics.tableTypeData[0][0] <<= statics.TABLE;
508 // statics.tableTypeData[2] = Sequence< Any > ( 1 );
509 // statics.tableTypeData[2][0] <<= statics.VIEW;
511 statics.tableTypeData[1] = std::vector< Any > ( 1 );
512 statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
514 statics.tableTypeNames = std::vector< OUString > ( 1 );
515 statics.tableTypeNames[0] = "TABLE_TYPE";
517 statics.columnRowNames =
519 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
520 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
521 "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
522 "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
523 "ORDINAL_POSITION", "IS_NULLABLE"
526 statics.typeinfoColumnNames =
528 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
529 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
530 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
531 "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
532 "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
533 "NUM_PREC_RADIX"
536 statics.indexinfoColumnNames =
538 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
539 "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
540 "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
541 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION"
544 statics.resultSetArrayColumnNames = { "INDEX" , "VALUE" };
546 // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type?
547 BaseTypeDef baseTypeDefs[] =
549 { "bool" , css::sdbc::DataType::BOOLEAN },
550 { "bytea", css::sdbc::DataType::VARBINARY },
551 { "char" , css::sdbc::DataType::CHAR },
553 { "int8" , css::sdbc::DataType::BIGINT },
554 { "serial8" , css::sdbc::DataType::BIGINT },
557 { "int2" , css::sdbc::DataType::SMALLINT },
559 { "int4" , css::sdbc::DataType::INTEGER },
560 // { "regproc" , css::sdbc::DataType::INTEGER },
561 // { "oid" , css::sdbc::DataType::INTEGER },
562 // { "xid" , css::sdbc::DataType::INTEGER },
563 // { "cid" , css::sdbc::DataType::INTEGER },
564 // { "serial", css::sdbc::DataType::INTEGER },
565 // { "serial4", css::sdbc::DataType::INTEGER },
567 { "text", css::sdbc::DataType::LONGVARCHAR },
568 { "bpchar", css::sdbc::DataType::CHAR },
569 { "varchar", css::sdbc::DataType::VARCHAR },
571 { "float4", css::sdbc::DataType::REAL },
572 { "float8", css::sdbc::DataType::DOUBLE },
574 { "numeric", css::sdbc::DataType::NUMERIC },
575 { "decimal", css::sdbc::DataType::DECIMAL },
577 { "date", css::sdbc::DataType::DATE },
578 { "time", css::sdbc::DataType::TIME },
579 { "timestamp", css::sdbc::DataType::TIMESTAMP },
581 // { "_bool" , css::sdbc::DataType::ARRAY },
582 // { "_bytea", css::sdbc::DataType::ARRAY },
583 // { "_char" , css::sdbc::DataType::ARRAY },
585 // { "_int8" , css::sdbc::DataType::ARRAY },
586 // { "_serial8" , css::sdbc::DataType::ARRAY },
589 // { "_int2" , css::sdbc::DataType::ARRAY },
591 // { "_int4" , css::sdbc::DataType::ARRAY },
592 // { "_regproc" , css::sdbc::DataType::ARRAY },
593 // { "_oid" , css::sdbc::DataType::ARRAY },
594 // { "_xid" , css::sdbc::DataType::ARRAY },
595 // { "_cid" , css::sdbc::DataType::ARRAY },
597 // { "_text", css::sdbc::DataType::ARRAY },
598 // { "_bpchar", css::sdbc::DataType::ARRAY },
599 // { "_varchar", css::sdbc::DataType::ARRAY },
601 // { "_float4", css::sdbc::DataType::ARRAY },
602 // { "_float8", css::sdbc::DataType::ARRAY },
604 // { "_numeric", css::sdbc::DataType::ARRAY },
605 // { "_decimal", css::sdbc::DataType::ARRAY },
607 // { "_date", css::sdbc::DataType::ARRAY }, // switch to date later
608 // { "_time", css::sdbc::DataType::ARRAY }, // switch to time later
610 { nullptr, 0 }
612 int i;
613 for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
615 statics.baseTypeMap[
616 OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
617 baseTypeDefs[i].value;
620 // This is the metadata for the columns of the recordset returned
621 // by css::sdbc::XDatabaseMetaData::getTypeInfo(),
622 // that is what is returned by getTypeInfo().getMetaData()
623 DefColumnMetaData defTypeInfoMetaData[] =
625 { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR, 0,50,false,false,false }, // 0
626 { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT, 0,50,false,false,false }, // 1
627 { "PRECISION", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER, 0,50,false,false,false }, // 2
628 { "LITERAL_PREFIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR, 0,50,false,false,false }, // 3
629 { "LITERAL_SUFFIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR, 0,50,false,false,false }, // 4
630 { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR, 0,50,false,false,false }, // 5
631 { "NULLABLE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER, 0,50,false,false,false }, // 6
632 { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN, 0,50,false,false,false }, // 7
633 { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT, 0,50,false,false,false }, // 8
634 { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN, 0,50,false,false,false }, // 9
635 { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN, 0,50,false,false,false }, // 10
636 { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN, 0,50,false,false,false }, // 11
637 { "LOCAL_TYPE_NAME", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR, 0,50,false,false,false }, // 12
638 { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT, 0,50,false,false,false}, // 13
639 { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT, 0,50,false,false,false }, // 14
640 { "SQL_DATA_TYPE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER, 0,50,false,false,false }, // 15
641 { "SQL_DATETIME_SUB", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER, 0,50,false,false,false}, // 16
642 { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER, 0,50,false,false,false }, // 17
643 {nullptr,nullptr,nullptr,nullptr,0,0,0,false,false,false}
646 for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
648 statics.typeInfoMetaData.push_back(
649 ColumnMetaData(
650 OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
651 OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
652 OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
653 OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
654 defTypeInfoMetaData[i].type,
655 defTypeInfoMetaData[i].precision,
656 defTypeInfoMetaData[i].scale,
657 defTypeInfoMetaData[i].isCurrency,
658 defTypeInfoMetaData[i].isNullable,
659 defTypeInfoMetaData[i].isAutoIncrement ) );
662 return &statics;
663 }();
664 return *p;
670 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */