Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / postgresql / pq_statics.cxx
blob03569b24460d56191b5acb8c5d342ddaeba1303f
1 /*************************************************************************
3 * $RCSfile: pq_statics.cxx,v $
5 * $Revision: 1.1.2.6 $
7 * last change: $Author: jbu $ $Date: 2007/02/15 20:04:48 $
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Joerg Budischewski
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Joerg Budischewski
60 ************************************************************************/
62 #include "pq_statics.hxx"
63 #include "pq_updateableresultset.hxx"
64 #include <com/sun/star/sdbc/DataType.hpp>
65 #include <com/sun/star/beans/PropertyAttribute.hpp>
67 #include <string.h>
69 using rtl::OUString;
70 using com::sun::star::uno::Sequence;
71 using com::sun::star::uno::Any;
72 using com::sun::star::uno::Type;
74 using com::sun::star::beans::PropertyAttribute::READONLY;
75 using com::sun::star::beans::PropertyAttribute::BOUND;
76 using com::sun::star::beans::Property;
78 namespace pq_sdbc_driver
81 struct DefColumnMetaData
83 sal_Char * columnName;
84 sal_Char * tableName;
85 sal_Char * schemaTableName;
86 sal_Char * typeName;
87 sal_Int32 type;
88 sal_Int32 precision;
89 sal_Int32 scale;
90 sal_Bool isCurrency;
91 sal_Bool isNullable;
92 sal_Bool isAutoIncrement;
93 sal_Bool isReadOnly;
94 sal_Bool isSigned;
97 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
98 struct BaseTypeDef { const char * typeName; sal_Int32 value; };
100 static Sequence< OUString > createStringSequence( const char * name[] )
102 int length;
103 for( length = 0; name[length] ; length ++ );
105 Sequence< OUString > seq( length );
106 for( int i = 0; i < length; i ++ )
108 seq[i] = OUString( name[i] , strlen( name[i] ), RTL_TEXTENCODING_ASCII_US );
110 return seq;
113 static Sequence< sal_Int8 > generateImplementationId()
115 Sequence< sal_Int8 > seq( 16 );
116 rtl_createUuid( (sal_uInt8*)seq.getArray(), 0 , sal_False );
117 return seq;
120 struct PropertyDef
122 PropertyDef( const OUString &str, const Type &t )
123 : name( str ) , type( t ) {}
124 ::rtl::OUString name;
125 com::sun::star::uno::Type type;
128 struct PropertyDefEx : public PropertyDef
130 PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
131 : PropertyDef( str, t ) , attribute( a )
133 sal_Int32 attribute;
136 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
137 PropertyDef *props, int count , sal_Int16 attr )
139 Sequence< Property > seq( count );
140 for( int i = 0 ; i < count ; i ++ )
142 seq[i] = Property( props[i].name, i, props[i].type, attr );
144 return new cppu::OPropertyArrayHelper( seq, sal_True );
147 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
148 PropertyDefEx *props, int count )
150 Sequence< Property > seq( count );
151 for( int i = 0 ; i < count ; i ++ )
153 seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
155 return new cppu::OPropertyArrayHelper( seq, sal_True );
158 Statics & getStatics()
160 static Statics * p;
161 if( ! p )
163 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
164 if( ! p )
166 static Statics statics ;
167 statics.SYSTEM_TABLE = ASCII_STR( "SYSTEM TABLE" );
168 statics.TABLE = ASCII_STR( "TABLE" );
169 statics.VIEW = ASCII_STR( "VIEW" );
170 statics.UNKNOWN = ASCII_STR( "UNKNOWN" );
171 statics.YES = ASCII_STR( "YES" );
172 statics.NO = ASCII_STR( "NO" );
173 statics.NO_NULLS = ASCII_STR( "NO_NULLS" );
174 statics.NULABLE = ASCII_STR( "NULABLE" );
175 statics.NULLABLE_UNKNOWN = ASCII_STR( "NULLABLE_UNKNOWN" );
176 statics.cPERCENT = ASCII_STR( "%" );
178 statics.TYPE = ASCII_STR( "Type" );
179 statics.TYPE_NAME = ASCII_STR( "TypeName" );
180 statics.NAME = ASCII_STR( "Name" );
181 statics.SCHEMA_NAME = ASCII_STR( "SchemaName" );
182 statics.CATALOG_NAME = ASCII_STR( "CatalogName" );
183 statics.DESCRIPTION = ASCII_STR( "Description" );
184 statics.PRIVILEGES = ASCII_STR( "Privileges" );
186 statics.DEFAULT_VALUE = ASCII_STR( "DefaultValue" );
187 statics.IS_AUTO_INCREMENT = ASCII_STR( "IsAutoIncrement" );
188 statics.IS_CURRENCY = ASCII_STR( "IsCurrency" );
189 statics.IS_NULLABLE = ASCII_STR( "IsNullable" );
190 statics.IS_ROW_VERSISON = ASCII_STR( "IsRowVersion" );
191 statics.PRECISION = ASCII_STR( "Precision" );
192 statics.SCALE = ASCII_STR( "Scale" );
194 statics.cPERCENT = ASCII_STR( "%" );
195 statics.BEGIN = ASCII_STR( "BEGIN" );
196 statics.COMMIT = ASCII_STR( "COMMIT" );
197 statics.ROLLBACK = ASCII_STR( "ROLLBACK" );
199 statics.KEY = ASCII_STR( "Key" );
200 statics.REFERENCED_TABLE = ASCII_STR( "ReferencedTable" );
201 statics.UPDATE_RULE = ASCII_STR( "UpdateRule" );
202 statics.DELETE_RULE = ASCII_STR( "DeleteRule" );
203 statics.PRIVATE_COLUMNS = ASCII_STR( "PrivateColumns" );
204 statics.PRIVATE_FOREIGN_COLUMNS = ASCII_STR( "PrivateForeignColumns" );
206 statics.KEY_COLUMN = ASCII_STR( "KeyColumn" );
207 statics.RELATED_COLUMN = ASCII_STR( "RelatedColumn" );
208 statics.PASSWORD = ASCII_STR( "Password" );
209 statics.USER = ASCII_STR( "User" );
211 statics.CURSOR_NAME = ASCII_STR( "CursorName" );
212 statics.ESCAPE_PROCESSING = ASCII_STR( "EscapeProcessing" );
213 statics.FETCH_DIRECTION = ASCII_STR( "FetchDirection" );
214 statics.FETCH_SIZE = ASCII_STR( "FetchSize" );
215 statics.IS_BOOKMARKABLE = ASCII_STR( "IsBookmarkable" );
216 statics.RESULT_SET_CONCURRENCY = ASCII_STR( "ResultSetConcurrency" );
217 statics.RESULT_SET_TYPE = ASCII_STR( "ResultSetType" );
219 statics.COMMAND = ASCII_STR( "Command" );
220 statics.CHECK_OPTION = ASCII_STR( "CheckOption" );
222 statics.TRUE = ASCII_STR( "t" );
223 statics.FALSE = ASCII_STR( "f" );
224 statics.IS_PRIMARY_KEY_INDEX = ASCII_STR( "IsPrimaryKeyIndex" );
225 statics.IS_CLUSTERED = ASCII_STR( "IsClustered" );
226 statics.IS_UNIQUE = ASCII_STR( "IsUnique" );
227 statics.IS_ASCENDING = ASCII_STR( "IsAscending" );
228 statics.PRIVATE_COLUMN_INDEXES = ASCII_STR( "PrivateColumnIndexes" );
229 statics.HELP_TEXT = ASCII_STR( "HelpText" );
231 statics.CATALOG = ASCII_STR( "Catalog" );
233 Type tString = getCppuType( (rtl::OUString *) 0 );
234 Type tInt = getCppuType( (sal_Int32 * ) 0 );
235 Type tBool = getBooleanCppuType();
236 Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< ::rtl::OUString > *) 0);
238 // Table props set
239 ImplementationStatics &ist = statics.refl.table;
240 ist.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Table" );
241 ist.serviceNames = Sequence< OUString > ( 1 );
242 ist.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Table" );
243 PropertyDef tableDef[] =
245 PropertyDef( statics.CATALOG_NAME , tString ),
246 PropertyDef( statics.DESCRIPTION , tString ),
247 PropertyDef( statics.NAME , tString ),
248 PropertyDef( statics.PRIVILEGES , tInt ),
249 PropertyDef( statics.SCHEMA_NAME , tString ),
250 PropertyDef( statics.TYPE , tString )
252 ist.pProps = createPropertyArrayHelper(
253 tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
255 statics.refl.tableDescriptor.implName =
256 ASCII_STR( "org.openoffice.comp.pq.sdbcx.TableDescriptor" );
257 statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
258 statics.refl.tableDescriptor.serviceNames[0] =
259 ASCII_STR( "com.sun.star.sdbcx.TableDescriptor" );
260 PropertyDef tableDescDef[] =
262 PropertyDef( statics.CATALOG_NAME , tString ),
263 PropertyDef( statics.DESCRIPTION , tString ),
264 PropertyDef( statics.NAME , tString ),
265 PropertyDef( statics.PRIVILEGES , tInt ),
266 PropertyDef( statics.SCHEMA_NAME , tString )
268 statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
269 tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 );
271 // Column props set
272 statics.refl.column.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Column" );
273 statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
274 statics.refl.column.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Column" );
275 PropertyDefEx columnDef[] =
277 PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
278 PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
279 PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
280 // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
281 PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
282 PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
283 PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
284 PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
285 PropertyDefEx( statics.NAME , tString,READONLY ),
286 PropertyDefEx( statics.PRECISION , tInt, READONLY ),
287 PropertyDefEx( statics.SCALE , tInt ,READONLY),
288 PropertyDefEx( statics.TYPE , tInt ,READONLY),
289 PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
291 statics.refl.column.pProps = createPropertyArrayHelper(
292 columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
294 statics.refl.columnDescriptor.implName =
295 ASCII_STR( "org.openoffice.comp.pq.sdbcx.ColumnDescriptor" );
296 statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
297 statics.refl.columnDescriptor.serviceNames[0] =
298 ASCII_STR( "com.sun.star.sdbcx.ColumnDescriptor" );
299 PropertyDef columnDescDef[] =
301 PropertyDef( statics.CATALOG_NAME , tString ),
302 PropertyDef( statics.DEFAULT_VALUE, tString ),
303 PropertyDef( statics.DESCRIPTION , tString ),
304 // PropertyDef( statics.HELP_TEXT , tString ),
305 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
306 PropertyDef( statics.IS_CURRENCY, tBool ),
307 PropertyDef( statics.IS_NULLABLE, tInt ),
308 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
309 PropertyDef( statics.NAME , tString ),
310 PropertyDef( statics.PRECISION , tInt ),
311 PropertyDef( statics.SCALE , tInt ),
312 PropertyDef( statics.TYPE , tInt ),
313 PropertyDef( statics.TYPE_NAME , tString )
316 statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
317 columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 );
319 // Key properties
320 statics.refl.key.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Key" );
321 statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
322 statics.refl.key.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Key" );
323 PropertyDef keyDef[] =
325 PropertyDef( statics.DELETE_RULE, tInt ),
326 PropertyDef( statics.NAME, tString ),
327 PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
328 PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
329 PropertyDef( statics.REFERENCED_TABLE, tString ),
330 PropertyDef( statics.TYPE, tInt ),
331 PropertyDef( statics.UPDATE_RULE, tInt )
333 statics.refl.key.pProps = createPropertyArrayHelper(
334 keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
337 // Key properties
338 statics.refl.keyDescriptor.implName =
339 ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyDescriptor" );
340 statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
341 statics.refl.keyDescriptor.serviceNames[0] =
342 ASCII_STR( "com.sun.star.sdbcx.KeyDescriptor" );
343 PropertyDef keyDescDef[] =
345 PropertyDef( statics.DELETE_RULE, tInt ),
346 PropertyDef( statics.NAME, tString ),
347 PropertyDef( statics.REFERENCED_TABLE, tString ),
348 PropertyDef( statics.TYPE, tInt ),
349 PropertyDef( statics.UPDATE_RULE, tInt )
351 statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
352 keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 );
356 // KeyColumn props set
357 statics.refl.keycolumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumn" );
358 statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
359 statics.refl.keycolumn.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.KeyColumn" );
360 PropertyDef keycolumnDef[] =
362 PropertyDef( statics.CATALOG_NAME , tString ),
363 PropertyDef( statics.DEFAULT_VALUE, tString ),
364 PropertyDef( statics.DESCRIPTION , tString ),
365 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
366 PropertyDef( statics.IS_CURRENCY, tBool ),
367 PropertyDef( statics.IS_NULLABLE, tInt ),
368 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
369 PropertyDef( statics.NAME , tString ),
370 PropertyDef( statics.PRECISION , tInt ),
371 PropertyDef( statics.RELATED_COLUMN, tString ),
372 PropertyDef( statics.SCALE , tInt ),
373 PropertyDef( statics.TYPE , tInt ),
374 PropertyDef( statics.TYPE_NAME , tString )
376 statics.refl.keycolumn.pProps = createPropertyArrayHelper(
377 keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
379 // KeyColumn props set
380 statics.refl.keycolumnDescriptor.implName =
381 ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor" );
382 statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
383 statics.refl.keycolumnDescriptor.serviceNames[0] =
384 ASCII_STR( "com.sun.star.sdbcx.KeyColumnDescriptor" );
385 PropertyDef keycolumnDescDef[] =
387 PropertyDef( statics.NAME , tString ),
388 PropertyDef( statics.RELATED_COLUMN, tString )
390 statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
391 keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 );
393 // view props set
394 statics.refl.view.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.View");
395 statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
396 statics.refl.view.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.View" );
397 PropertyDef viewDef[] =
399 PropertyDef( statics.CATALOG_NAME , tString ),
400 PropertyDef( statics.CHECK_OPTION , tInt ),
401 PropertyDef( statics.COMMAND , tString ),
402 PropertyDef( statics.NAME , tString ),
403 PropertyDef( statics.SCHEMA_NAME , tString )
405 statics.refl.view.pProps = createPropertyArrayHelper(
406 viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
408 // view props set
409 statics.refl.viewDescriptor.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.ViewDescriptor");
410 statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
411 statics.refl.viewDescriptor.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.ViewDescriptor" );
412 statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
413 viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical
414 // user props set
415 statics.refl.user.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.User");
416 statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
417 statics.refl.user.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.User" );
418 PropertyDef userDefRO[] =
420 PropertyDef( statics.NAME , tString )
422 statics.refl.user.pProps = createPropertyArrayHelper(
423 userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
425 // user props set
426 statics.refl.userDescriptor.implName =
427 ASCII_STR( "org.openoffice.comp.pq.sdbcx.UserDescriptor");
428 statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
429 statics.refl.userDescriptor.serviceNames[0] =
430 ASCII_STR( "com.sun.star.sdbcx.UserDescriptor" );
431 PropertyDef userDefWR[] =
433 PropertyDef( statics.NAME , tString ),
434 PropertyDef( statics.PASSWORD , tString )
436 statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
437 userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 );
439 // index props set
440 statics.refl.index.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Index");
441 statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
442 statics.refl.index.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Index" );
443 PropertyDef indexDef[] =
445 PropertyDef( statics.CATALOG , tString ),
446 PropertyDef( statics.IS_CLUSTERED, tBool ),
447 PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
448 PropertyDef( statics.IS_UNIQUE, tBool ),
449 PropertyDef( statics.NAME , tString ),
450 PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
452 statics.refl.index.pProps = createPropertyArrayHelper(
453 indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
455 // index props set
456 statics.refl.indexDescriptor.implName =
457 ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexDescriptor");
458 statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
459 statics.refl.indexDescriptor.serviceNames[0] =
460 ASCII_STR( "com.sun.star.sdbcx.IndexDescriptor" );
461 statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
462 indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 );
464 // indexColumn props set
465 statics.refl.indexColumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumn");
466 statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
467 statics.refl.indexColumn.serviceNames[0] = ASCII_STR("com.sun.star.sdbcx.IndexColumn");
468 PropertyDef indexColumnDef[] =
470 PropertyDef( statics.CATALOG_NAME , tString ),
471 PropertyDef( statics.DEFAULT_VALUE, tString ),
472 PropertyDef( statics.DESCRIPTION , tString ),
473 PropertyDef( statics.IS_ASCENDING, tBool ),
474 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
475 PropertyDef( statics.IS_CURRENCY, tBool ),
476 PropertyDef( statics.IS_NULLABLE, tInt ),
477 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
478 PropertyDef( statics.NAME , tString ),
479 PropertyDef( statics.PRECISION , tInt ),
480 PropertyDef( statics.SCALE , tInt ),
481 PropertyDef( statics.TYPE , tInt ),
482 PropertyDef( statics.TYPE_NAME , tString )
484 statics.refl.indexColumn.pProps = createPropertyArrayHelper(
485 indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
487 // indexColumn props set
488 statics.refl.indexColumnDescriptor.implName =
489 ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor");
490 statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
491 statics.refl.indexColumnDescriptor.serviceNames[0] =
492 ASCII_STR("com.sun.star.sdbcx.IndexColumnDescriptor");
493 PropertyDef indexColumnDescDef[] =
495 PropertyDef( statics.IS_ASCENDING, tBool ),
496 PropertyDef( statics.NAME , tString )
498 statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
499 indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 );
501 // resultset
502 statics.refl.resultSet.implName = ASCII_STR( "org.openoffice.comp.pq.ResultSet");
503 statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
504 statics.refl.resultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
505 statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
506 PropertyDef resultSet[] =
508 PropertyDef( statics.CURSOR_NAME , tString ),
509 PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
510 PropertyDef( statics.FETCH_DIRECTION , tInt ),
511 PropertyDef( statics.FETCH_SIZE , tInt ),
512 PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
513 PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
514 PropertyDef( statics.RESULT_SET_TYPE , tInt )
516 statics.refl.resultSet.pProps = createPropertyArrayHelper(
517 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
519 // updateableResultset
520 statics.refl.updateableResultSet.implName = ASCII_STR( "org.openoffice.comp.pq.UpdateableResultSet");
521 statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
522 statics.refl.updateableResultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
523 statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
524 statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
525 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
527 // databasemetadata
528 statics.tablesRowNames = Sequence< OUString > ( 5 );
529 statics.tablesRowNames[TABLE_INDEX_CATALOG] = ASCII_STR( "TABLE_CAT" );
530 statics.tablesRowNames[TABLE_INDEX_SCHEMA] = ASCII_STR( "TABLE_SCHEM" );
531 statics.tablesRowNames[TABLE_INDEX_NAME] = ASCII_STR( "TABLE_NAME" );
532 statics.tablesRowNames[TABLE_INDEX_TYPE] = ASCII_STR( "TABLE_TYPE" );
533 statics.tablesRowNames[TABLE_INDEX_REMARKS] = ASCII_STR( "REMARKS" );
535 statics.primaryKeyNames = Sequence< OUString > ( 6 );
536 statics.primaryKeyNames[0] = ASCII_STR( "TABLE_CAT" );
537 statics.primaryKeyNames[1] = ASCII_STR( "TABLE_SCHEM" );
538 statics.primaryKeyNames[2] = ASCII_STR( "TABLE_NAME" );
539 statics.primaryKeyNames[3] = ASCII_STR( "COLUMN_NAME" );
540 statics.primaryKeyNames[4] = ASCII_STR( "KEY_SEQ" );
541 statics.primaryKeyNames[5] = ASCII_STR( "PK_NAME" );
543 statics.SELECT = ASCII_STR( "SELECT" );
544 statics.UPDATE = ASCII_STR( "UPDATE" );
545 statics.INSERT = ASCII_STR( "INSERT" );
546 statics.DELETE = ASCII_STR( "DELETE" );
547 statics.RULE = ASCII_STR( "RULE" );
548 statics.REFERENCES = ASCII_STR( "REFERENCES" );
549 statics.TRIGGER = ASCII_STR( "TRIGGER" );
550 statics.EXECUTE = ASCII_STR( "EXECUTE" );
551 statics.USAGE = ASCII_STR( "USAGE" );
552 statics.CREATE = ASCII_STR( "CREATE" );
553 statics.TEMPORARY = ASCII_STR( "TEMPORARY" );
554 statics.INDEX = ASCII_STR( "Index" );
555 statics.INDEX_COLUMN = ASCII_STR( "IndexColumn" );
557 statics.schemaNames = Sequence< OUString > ( 1 );
558 statics.schemaNames[0] = ASCII_STR( "TABLE_SCHEM" );
560 statics.tableTypeData = Sequence< Sequence< Any > >( 2 );
562 statics.tableTypeData[0] = Sequence< Any > ( 1 );
563 statics.tableTypeData[0][0] <<= statics.TABLE;
565 // statics.tableTypeData[2] = Sequence< Any > ( 1 );
566 // statics.tableTypeData[2][0] <<= statics.VIEW;
568 statics.tableTypeData[1] = Sequence< Any > ( 1 );
569 statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
571 statics.tableTypeNames = Sequence< OUString > ( 1 );
572 statics.tableTypeNames[0] = ASCII_STR( "TABLE_TYPE" );
574 static const char *tablePrivilegesNames[] =
576 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE",
577 "IS_GRANTABLE" , 0
579 statics.tablePrivilegesNames =
580 createStringSequence( tablePrivilegesNames );
582 static const char * columnNames[] =
584 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
585 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
586 "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
587 "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
588 "ORDINAL_POSITION", "IS_NULLABLE", 0
590 statics.columnRowNames =
591 createStringSequence( columnNames );
593 static const char * typeinfoColumnNames[] =
595 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
596 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
597 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
598 "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
599 "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
600 "NUM_PREC_RADIX", 0
602 statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames );
604 static const char * indexinfoColumnNames[] =
606 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
607 "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
608 "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
609 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0
611 statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames );
613 static const char * importedKeysColumnNames[] =
615 "PKTABLE_CAT" ,
616 "PKTABLE_SCHEM",
617 "PKTABLE_NAME" ,
618 "PKCOLUMN_NAME",
619 "FKTABLE_CAT" ,
620 "FKTABLE_SCHEM",
621 "FKTABLE_NAME" ,
622 "FKCOLUMN_NAME",
623 "KEY_SEQ" ,
624 "UPDATE_RULE",
625 "DELETE_RULE",
626 "FK_NAME" ,
627 "PK_NAME" ,
628 "DEFERRABILITY" ,
631 statics.importedKeysColumnNames =
632 createStringSequence( importedKeysColumnNames );
634 static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 };
635 statics.resultSetArrayColumnNames =
636 createStringSequence( resultSetArrayColumnNames );
638 BaseTypeDef baseTypeDefs[] =
640 { "bool" , com::sun::star::sdbc::DataType::BIT },
641 { "bytea", com::sun::star::sdbc::DataType::VARBINARY },
642 { "char" , com::sun::star::sdbc::DataType::CHAR },
644 { "int8" , com::sun::star::sdbc::DataType::BIGINT },
645 { "serial8" , com::sun::star::sdbc::DataType::BIGINT },
648 { "int2" , com::sun::star::sdbc::DataType::SMALLINT },
650 { "int4" , com::sun::star::sdbc::DataType::INTEGER },
651 // { "regproc" , com::sun::star::sdbc::DataType::INTEGER },
652 // { "oid" , com::sun::star::sdbc::DataType::INTEGER },
653 // { "xid" , com::sun::star::sdbc::DataType::INTEGER },
654 // { "cid" , com::sun::star::sdbc::DataType::INTEGER },
655 // { "serial", com::sun::star::sdbc::DataType::INTEGER },
656 // { "serial4", com::sun::star::sdbc::DataType::INTEGER },
658 { "text", com::sun::star::sdbc::DataType::VARCHAR },
659 { "bpchar", com::sun::star::sdbc::DataType::CHAR },
660 { "varchar", com::sun::star::sdbc::DataType::VARCHAR },
662 { "float4", com::sun::star::sdbc::DataType::REAL },
663 { "float8", com::sun::star::sdbc::DataType::DOUBLE },
665 { "numeric", com::sun::star::sdbc::DataType::NUMERIC },
666 { "decimal", com::sun::star::sdbc::DataType::DECIMAL },
668 { "date", com::sun::star::sdbc::DataType::DATE }, // switch to date later
669 { "time", com::sun::star::sdbc::DataType::TIME }, // switch to time later
670 { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP }, // switch to time later
672 // { "_bool" , com::sun::star::sdbc::DataType::ARRAY },
673 // { "_bytea", com::sun::star::sdbc::DataType::ARRAY },
674 // { "_char" , com::sun::star::sdbc::DataType::ARRAY },
676 // { "_int8" , com::sun::star::sdbc::DataType::ARRAY },
677 // { "_serial8" , com::sun::star::sdbc::DataType::ARRAY },
680 // { "_int2" , com::sun::star::sdbc::DataType::ARRAY },
682 // { "_int4" , com::sun::star::sdbc::DataType::ARRAY },
683 // { "_regproc" , com::sun::star::sdbc::DataType::ARRAY },
684 // { "_oid" , com::sun::star::sdbc::DataType::ARRAY },
685 // { "_xid" , com::sun::star::sdbc::DataType::ARRAY },
686 // { "_cid" , com::sun::star::sdbc::DataType::ARRAY },
688 // { "_text", com::sun::star::sdbc::DataType::ARRAY },
689 // { "_bpchar", com::sun::star::sdbc::DataType::ARRAY },
690 // { "_varchar", com::sun::star::sdbc::DataType::ARRAY },
692 // { "_float4", com::sun::star::sdbc::DataType::ARRAY },
693 // { "_float8", com::sun::star::sdbc::DataType::ARRAY },
695 // { "_numeric", com::sun::star::sdbc::DataType::ARRAY },
696 // { "_decimal", com::sun::star::sdbc::DataType::ARRAY },
698 // { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later
699 // { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later
701 { 0, 0 }
703 int i;
704 for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
706 statics.baseTypeMap[
707 OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
708 baseTypeDefs[i].value;
711 DefColumnMetaData defTypeInfoMetaData[] =
713 { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 0
714 { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 1
715 { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 2
716 { "foo1", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 3
717 { "foo2", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 4
718 { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0 }, // 5
719 { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 6
720 { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 7
721 { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0 }, // 8
722 { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 9
723 { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 10
724 { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0 }, // 11
725 { "foo3", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 12
726 { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 13
727 { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 14
728 { "foo4", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 15
729 { "foo5", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 16
730 { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 }, // 17
731 {0,0,0,0,0,0,0,0,0,0,0}
734 for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
736 statics.typeInfoMetaData.push_back(
737 ColumnMetaData(
738 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
739 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
740 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
741 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
742 defTypeInfoMetaData[i].type,
743 defTypeInfoMetaData[i].precision,
744 defTypeInfoMetaData[i].scale,
745 defTypeInfoMetaData[i].isCurrency,
746 defTypeInfoMetaData[i].isNullable,
747 defTypeInfoMetaData[i].isAutoIncrement,
748 defTypeInfoMetaData[i].isReadOnly,
749 defTypeInfoMetaData[i].isSigned ) );
752 p = &statics;
755 return *p;