Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / postgresql / pq_statics.cxx
blob312a9a380741769c9ab458c9e4c742596c9e8ed6
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 * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
33 * The contents of this file are subject to the Mozilla Public License Version
34 * 1.1 (the "License"); you may not use this file except in compliance with
35 * the License or as specified alternatively below. You may obtain a copy of
36 * the License at http://www.mozilla.org/MPL/
38 * Software distributed under the License is distributed on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
40 * for the specific language governing rights and limitations under the
41 * License.
43 * Major Contributor(s):
44 * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
46 * All Rights Reserved.
48 * For minor contributions see the git repository.
50 * Alternatively, the contents of this file may be used under the terms of
51 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
52 * the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
53 * in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
54 * instead of those above.
56 ************************************************************************/
58 #include "pq_statics.hxx"
59 #include "pq_updateableresultset.hxx"
60 #include <com/sun/star/sdbc/DataType.hpp>
61 #include <com/sun/star/beans/PropertyAttribute.hpp>
63 #include <string.h>
65 using rtl::OUString;
66 using com::sun::star::uno::Sequence;
67 using com::sun::star::uno::Any;
68 using com::sun::star::uno::Type;
70 using com::sun::star::beans::PropertyAttribute::READONLY;
71 using com::sun::star::beans::PropertyAttribute::BOUND;
72 using com::sun::star::beans::Property;
74 namespace pq_sdbc_driver
77 struct DefColumnMetaData
79 const sal_Char * columnName;
80 const sal_Char * tableName;
81 const sal_Char * schemaTableName;
82 const sal_Char * typeName;
83 sal_Int32 type;
84 sal_Int32 precision;
85 sal_Int32 scale;
86 sal_Bool isCurrency;
87 sal_Bool isNullable;
88 sal_Bool isAutoIncrement;
89 sal_Bool isReadOnly;
90 sal_Bool isSigned;
93 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
94 struct BaseTypeDef { const char * typeName; sal_Int32 value; };
96 static Sequence< OUString > createStringSequence( const char * name[] )
98 int length;
99 for( length = 0; name[length] ; length ++ );
101 Sequence< OUString > seq( length );
102 for( int i = 0; i < length; i ++ )
104 seq[i] = OUString( name[i] , strlen( name[i] ), RTL_TEXTENCODING_ASCII_US );
106 return seq;
109 struct PropertyDef
111 PropertyDef( const OUString &str, const Type &t )
112 : name( str ) , type( t ) {}
113 ::rtl::OUString name;
114 com::sun::star::uno::Type type;
117 struct PropertyDefEx : public PropertyDef
119 PropertyDefEx( const OUString & str, const Type &t , sal_Int32 a )
120 : PropertyDef( str, t ) , attribute( a )
122 sal_Int32 attribute;
125 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
126 PropertyDef *props, int count , sal_Int16 attr )
128 Sequence< Property > seq( count );
129 for( int i = 0 ; i < count ; i ++ )
131 seq[i] = Property( props[i].name, i, props[i].type, attr );
133 return new cppu::OPropertyArrayHelper( seq, sal_True );
136 static cppu::IPropertyArrayHelper * createPropertyArrayHelper(
137 PropertyDefEx *props, int count )
139 Sequence< Property > seq( count );
140 for( int i = 0 ; i < count ; i ++ )
142 seq[i] = Property( props[i].name, i, props[i].type, props[i].attribute );
144 return new cppu::OPropertyArrayHelper( seq, sal_True );
147 Statics & getStatics()
149 static Statics * p;
150 if( ! p )
152 ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
153 if( ! p )
155 static Statics statics ;
156 statics.SYSTEM_TABLE = ASCII_STR( "SYSTEM TABLE" );
157 statics.TABLE = ASCII_STR( "TABLE" );
158 statics.VIEW = ASCII_STR( "VIEW" );
159 statics.UNKNOWN = ASCII_STR( "UNKNOWN" );
160 statics.YES = ASCII_STR( "YES" );
161 statics.NO = ASCII_STR( "NO" );
162 statics.NO_NULLS = ASCII_STR( "NO_NULLS" );
163 statics.NULABLE = ASCII_STR( "NULABLE" );
164 statics.NULLABLE_UNKNOWN = ASCII_STR( "NULLABLE_UNKNOWN" );
165 statics.cPERCENT = ASCII_STR( "%" );
167 statics.TYPE = ASCII_STR( "Type" );
168 statics.TYPE_NAME = ASCII_STR( "TypeName" );
169 statics.NAME = ASCII_STR( "Name" );
170 statics.SCHEMA_NAME = ASCII_STR( "SchemaName" );
171 statics.CATALOG_NAME = ASCII_STR( "CatalogName" );
172 statics.DESCRIPTION = ASCII_STR( "Description" );
173 statics.PRIVILEGES = ASCII_STR( "Privileges" );
175 statics.DEFAULT_VALUE = ASCII_STR( "DefaultValue" );
176 statics.IS_AUTO_INCREMENT = ASCII_STR( "IsAutoIncrement" );
177 statics.IS_CURRENCY = ASCII_STR( "IsCurrency" );
178 statics.IS_NULLABLE = ASCII_STR( "IsNullable" );
179 statics.IS_ROW_VERSISON = ASCII_STR( "IsRowVersion" );
180 statics.PRECISION = ASCII_STR( "Precision" );
181 statics.SCALE = ASCII_STR( "Scale" );
183 statics.cPERCENT = ASCII_STR( "%" );
184 statics.BEGIN = ASCII_STR( "BEGIN" );
185 statics.COMMIT = ASCII_STR( "COMMIT" );
186 statics.ROLLBACK = ASCII_STR( "ROLLBACK" );
188 statics.KEY = ASCII_STR( "Key" );
189 statics.REFERENCED_TABLE = ASCII_STR( "ReferencedTable" );
190 statics.UPDATE_RULE = ASCII_STR( "UpdateRule" );
191 statics.DELETE_RULE = ASCII_STR( "DeleteRule" );
192 statics.PRIVATE_COLUMNS = ASCII_STR( "PrivateColumns" );
193 statics.PRIVATE_FOREIGN_COLUMNS = ASCII_STR( "PrivateForeignColumns" );
195 statics.KEY_COLUMN = ASCII_STR( "KeyColumn" );
196 statics.RELATED_COLUMN = ASCII_STR( "RelatedColumn" );
197 statics.PASSWORD = ASCII_STR( "Password" );
198 statics.USER = ASCII_STR( "User" );
200 statics.CURSOR_NAME = ASCII_STR( "CursorName" );
201 statics.ESCAPE_PROCESSING = ASCII_STR( "EscapeProcessing" );
202 statics.FETCH_DIRECTION = ASCII_STR( "FetchDirection" );
203 statics.FETCH_SIZE = ASCII_STR( "FetchSize" );
204 statics.IS_BOOKMARKABLE = ASCII_STR( "IsBookmarkable" );
205 statics.RESULT_SET_CONCURRENCY = ASCII_STR( "ResultSetConcurrency" );
206 statics.RESULT_SET_TYPE = ASCII_STR( "ResultSetType" );
208 statics.COMMAND = ASCII_STR( "Command" );
209 statics.CHECK_OPTION = ASCII_STR( "CheckOption" );
211 statics.TRUE = ASCII_STR( "t" );
212 statics.FALSE = ASCII_STR( "f" );
213 statics.IS_PRIMARY_KEY_INDEX = ASCII_STR( "IsPrimaryKeyIndex" );
214 statics.IS_CLUSTERED = ASCII_STR( "IsClustered" );
215 statics.IS_UNIQUE = ASCII_STR( "IsUnique" );
216 statics.IS_ASCENDING = ASCII_STR( "IsAscending" );
217 statics.PRIVATE_COLUMN_INDEXES = ASCII_STR( "PrivateColumnIndexes" );
218 statics.HELP_TEXT = ASCII_STR( "HelpText" );
220 statics.CATALOG = ASCII_STR( "Catalog" );
222 Type tString = getCppuType( (rtl::OUString *) 0 );
223 Type tInt = getCppuType( (sal_Int32 * ) 0 );
224 Type tBool = getBooleanCppuType();
225 Type tStringSequence = getCppuType( (com::sun::star::uno::Sequence< ::rtl::OUString > *) 0);
227 // Table props set
228 ImplementationStatics &ist = statics.refl.table;
229 ist.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Table" );
230 ist.serviceNames = Sequence< OUString > ( 1 );
231 ist.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Table" );
232 PropertyDef tableDef[] =
234 PropertyDef( statics.CATALOG_NAME , tString ),
235 PropertyDef( statics.DESCRIPTION , tString ),
236 PropertyDef( statics.NAME , tString ),
237 PropertyDef( statics.PRIVILEGES , tInt ),
238 PropertyDef( statics.SCHEMA_NAME , tString ),
239 PropertyDef( statics.TYPE , tString )
241 ist.pProps = createPropertyArrayHelper(
242 tableDef, sizeof(tableDef)/sizeof(PropertyDef), READONLY );
244 statics.refl.tableDescriptor.implName =
245 ASCII_STR( "org.openoffice.comp.pq.sdbcx.TableDescriptor" );
246 statics.refl.tableDescriptor.serviceNames = Sequence< OUString > (1);
247 statics.refl.tableDescriptor.serviceNames[0] =
248 ASCII_STR( "com.sun.star.sdbcx.TableDescriptor" );
249 PropertyDef tableDescDef[] =
251 PropertyDef( statics.CATALOG_NAME , tString ),
252 PropertyDef( statics.DESCRIPTION , tString ),
253 PropertyDef( statics.NAME , tString ),
254 PropertyDef( statics.PRIVILEGES , tInt ),
255 PropertyDef( statics.SCHEMA_NAME , tString )
257 statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
258 tableDescDef, sizeof(tableDescDef)/sizeof(PropertyDef), 0 );
260 // Column props set
261 statics.refl.column.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Column" );
262 statics.refl.column.serviceNames = Sequence< OUString > ( 1 );
263 statics.refl.column.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Column" );
264 PropertyDefEx columnDef[] =
266 PropertyDefEx( statics.CATALOG_NAME , tString, READONLY ),
267 PropertyDefEx( statics.DEFAULT_VALUE, tString, READONLY ),
268 PropertyDefEx( statics.DESCRIPTION , tString, READONLY ),
269 // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
270 PropertyDefEx( statics.IS_AUTO_INCREMENT, tBool, READONLY ),
271 PropertyDefEx( statics.IS_CURRENCY, tBool, READONLY ),
272 PropertyDefEx( statics.IS_NULLABLE, tInt, READONLY ),
273 PropertyDefEx( statics.IS_ROW_VERSISON, tBool,READONLY ),
274 PropertyDefEx( statics.NAME , tString,READONLY ),
275 PropertyDefEx( statics.PRECISION , tInt, READONLY ),
276 PropertyDefEx( statics.SCALE , tInt ,READONLY),
277 PropertyDefEx( statics.TYPE , tInt ,READONLY),
278 PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
280 statics.refl.column.pProps = createPropertyArrayHelper(
281 columnDef, sizeof(columnDef)/sizeof(PropertyDefEx) );
283 statics.refl.columnDescriptor.implName =
284 ASCII_STR( "org.openoffice.comp.pq.sdbcx.ColumnDescriptor" );
285 statics.refl.columnDescriptor.serviceNames = Sequence< OUString > ( 1 );
286 statics.refl.columnDescriptor.serviceNames[0] =
287 ASCII_STR( "com.sun.star.sdbcx.ColumnDescriptor" );
288 PropertyDef columnDescDef[] =
290 PropertyDef( statics.CATALOG_NAME , tString ),
291 PropertyDef( statics.DEFAULT_VALUE, tString ),
292 PropertyDef( statics.DESCRIPTION , tString ),
293 // PropertyDef( statics.HELP_TEXT , tString ),
294 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
295 PropertyDef( statics.IS_CURRENCY, tBool ),
296 PropertyDef( statics.IS_NULLABLE, tInt ),
297 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
298 PropertyDef( statics.NAME , tString ),
299 PropertyDef( statics.PRECISION , tInt ),
300 PropertyDef( statics.SCALE , tInt ),
301 PropertyDef( statics.TYPE , tInt ),
302 PropertyDef( statics.TYPE_NAME , tString )
305 statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
306 columnDescDef, sizeof(columnDescDef)/sizeof(PropertyDef), 0 );
308 // Key properties
309 statics.refl.key.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Key" );
310 statics.refl.key.serviceNames = Sequence< OUString > ( 1 );
311 statics.refl.key.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Key" );
312 PropertyDef keyDef[] =
314 PropertyDef( statics.DELETE_RULE, tInt ),
315 PropertyDef( statics.NAME, tString ),
316 PropertyDef( statics.PRIVATE_COLUMNS, tStringSequence ),
317 PropertyDef( statics.PRIVATE_FOREIGN_COLUMNS, tStringSequence ),
318 PropertyDef( statics.REFERENCED_TABLE, tString ),
319 PropertyDef( statics.TYPE, tInt ),
320 PropertyDef( statics.UPDATE_RULE, tInt )
322 statics.refl.key.pProps = createPropertyArrayHelper(
323 keyDef, sizeof(keyDef)/sizeof(PropertyDef), READONLY );
326 // Key properties
327 statics.refl.keyDescriptor.implName =
328 ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyDescriptor" );
329 statics.refl.keyDescriptor.serviceNames = Sequence< OUString > ( 1 );
330 statics.refl.keyDescriptor.serviceNames[0] =
331 ASCII_STR( "com.sun.star.sdbcx.KeyDescriptor" );
332 PropertyDef keyDescDef[] =
334 PropertyDef( statics.DELETE_RULE, tInt ),
335 PropertyDef( statics.NAME, tString ),
336 PropertyDef( statics.REFERENCED_TABLE, tString ),
337 PropertyDef( statics.TYPE, tInt ),
338 PropertyDef( statics.UPDATE_RULE, tInt )
340 statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
341 keyDescDef, sizeof(keyDescDef)/sizeof(PropertyDef), 0 );
345 // KeyColumn props set
346 statics.refl.keycolumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumn" );
347 statics.refl.keycolumn.serviceNames = Sequence< OUString > ( 1 );
348 statics.refl.keycolumn.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.KeyColumn" );
349 PropertyDef keycolumnDef[] =
351 PropertyDef( statics.CATALOG_NAME , tString ),
352 PropertyDef( statics.DEFAULT_VALUE, tString ),
353 PropertyDef( statics.DESCRIPTION , tString ),
354 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
355 PropertyDef( statics.IS_CURRENCY, tBool ),
356 PropertyDef( statics.IS_NULLABLE, tInt ),
357 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
358 PropertyDef( statics.NAME , tString ),
359 PropertyDef( statics.PRECISION , tInt ),
360 PropertyDef( statics.RELATED_COLUMN, tString ),
361 PropertyDef( statics.SCALE , tInt ),
362 PropertyDef( statics.TYPE , tInt ),
363 PropertyDef( statics.TYPE_NAME , tString )
365 statics.refl.keycolumn.pProps = createPropertyArrayHelper(
366 keycolumnDef, sizeof(keycolumnDef)/sizeof(PropertyDef), READONLY );
368 // KeyColumn props set
369 statics.refl.keycolumnDescriptor.implName =
370 ASCII_STR( "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor" );
371 statics.refl.keycolumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
372 statics.refl.keycolumnDescriptor.serviceNames[0] =
373 ASCII_STR( "com.sun.star.sdbcx.KeyColumnDescriptor" );
374 PropertyDef keycolumnDescDef[] =
376 PropertyDef( statics.NAME , tString ),
377 PropertyDef( statics.RELATED_COLUMN, tString )
379 statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
380 keycolumnDescDef, sizeof(keycolumnDescDef)/sizeof(PropertyDef), 0 );
382 // view props set
383 statics.refl.view.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.View");
384 statics.refl.view.serviceNames = Sequence< OUString > ( 1 );
385 statics.refl.view.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.View" );
386 PropertyDef viewDef[] =
388 PropertyDef( statics.CATALOG_NAME , tString ),
389 PropertyDef( statics.CHECK_OPTION , tInt ),
390 PropertyDef( statics.COMMAND , tString ),
391 PropertyDef( statics.NAME , tString ),
392 PropertyDef( statics.SCHEMA_NAME , tString )
394 statics.refl.view.pProps = createPropertyArrayHelper(
395 viewDef, sizeof(viewDef)/sizeof(PropertyDef), READONLY );
397 // view props set
398 statics.refl.viewDescriptor.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.ViewDescriptor");
399 statics.refl.viewDescriptor.serviceNames = Sequence< OUString > ( 1 );
400 statics.refl.viewDescriptor.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.ViewDescriptor" );
401 statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
402 viewDef, sizeof(viewDef)/sizeof(PropertyDef), 0 ); // reuse view, as it is identical
403 // user props set
404 statics.refl.user.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.User");
405 statics.refl.user.serviceNames = Sequence< OUString > ( 1 );
406 statics.refl.user.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.User" );
407 PropertyDef userDefRO[] =
409 PropertyDef( statics.NAME , tString )
411 statics.refl.user.pProps = createPropertyArrayHelper(
412 userDefRO, sizeof(userDefRO)/sizeof(PropertyDef), READONLY );
414 // user props set
415 statics.refl.userDescriptor.implName =
416 ASCII_STR( "org.openoffice.comp.pq.sdbcx.UserDescriptor");
417 statics.refl.userDescriptor.serviceNames = Sequence< OUString > ( 1 );
418 statics.refl.userDescriptor.serviceNames[0] =
419 ASCII_STR( "com.sun.star.sdbcx.UserDescriptor" );
420 PropertyDef userDefWR[] =
422 PropertyDef( statics.NAME , tString ),
423 PropertyDef( statics.PASSWORD , tString )
425 statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
426 userDefWR, sizeof(userDefWR)/sizeof(PropertyDef), 0 );
428 // index props set
429 statics.refl.index.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.Index");
430 statics.refl.index.serviceNames = Sequence< OUString > ( 1 );
431 statics.refl.index.serviceNames[0] = ASCII_STR( "com.sun.star.sdbcx.Index" );
432 PropertyDef indexDef[] =
434 PropertyDef( statics.CATALOG , tString ),
435 PropertyDef( statics.IS_CLUSTERED, tBool ),
436 PropertyDef( statics.IS_PRIMARY_KEY_INDEX, tBool ),
437 PropertyDef( statics.IS_UNIQUE, tBool ),
438 PropertyDef( statics.NAME , tString ),
439 PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
441 statics.refl.index.pProps = createPropertyArrayHelper(
442 indexDef, sizeof(indexDef)/sizeof(PropertyDef), READONLY );
444 // index props set
445 statics.refl.indexDescriptor.implName =
446 ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexDescriptor");
447 statics.refl.indexDescriptor.serviceNames = Sequence< OUString > ( 1 );
448 statics.refl.indexDescriptor.serviceNames[0] =
449 ASCII_STR( "com.sun.star.sdbcx.IndexDescriptor" );
450 statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
451 indexDef, sizeof(indexDef)/sizeof(PropertyDef), 0 );
453 // indexColumn props set
454 statics.refl.indexColumn.implName = ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumn");
455 statics.refl.indexColumn.serviceNames = Sequence< OUString > ( 1 );
456 statics.refl.indexColumn.serviceNames[0] = ASCII_STR("com.sun.star.sdbcx.IndexColumn");
457 PropertyDef indexColumnDef[] =
459 PropertyDef( statics.CATALOG_NAME , tString ),
460 PropertyDef( statics.DEFAULT_VALUE, tString ),
461 PropertyDef( statics.DESCRIPTION , tString ),
462 PropertyDef( statics.IS_ASCENDING, tBool ),
463 PropertyDef( statics.IS_AUTO_INCREMENT, tBool ),
464 PropertyDef( statics.IS_CURRENCY, tBool ),
465 PropertyDef( statics.IS_NULLABLE, tInt ),
466 PropertyDef( statics.IS_ROW_VERSISON, tBool ),
467 PropertyDef( statics.NAME , tString ),
468 PropertyDef( statics.PRECISION , tInt ),
469 PropertyDef( statics.SCALE , tInt ),
470 PropertyDef( statics.TYPE , tInt ),
471 PropertyDef( statics.TYPE_NAME , tString )
473 statics.refl.indexColumn.pProps = createPropertyArrayHelper(
474 indexColumnDef, sizeof(indexColumnDef)/sizeof(PropertyDef), READONLY );
476 // indexColumn props set
477 statics.refl.indexColumnDescriptor.implName =
478 ASCII_STR( "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor");
479 statics.refl.indexColumnDescriptor.serviceNames = Sequence< OUString > ( 1 );
480 statics.refl.indexColumnDescriptor.serviceNames[0] =
481 ASCII_STR("com.sun.star.sdbcx.IndexColumnDescriptor");
482 PropertyDef indexColumnDescDef[] =
484 PropertyDef( statics.IS_ASCENDING, tBool ),
485 PropertyDef( statics.NAME , tString )
487 statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
488 indexColumnDescDef, sizeof(indexColumnDescDef)/sizeof(PropertyDef), 0 );
490 // resultset
491 statics.refl.resultSet.implName = ASCII_STR( "org.openoffice.comp.pq.ResultSet");
492 statics.refl.resultSet.serviceNames = Sequence< OUString > ( 1 );
493 statics.refl.resultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
494 statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
495 PropertyDef resultSet[] =
497 PropertyDef( statics.CURSOR_NAME , tString ),
498 PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
499 PropertyDef( statics.FETCH_DIRECTION , tInt ),
500 PropertyDef( statics.FETCH_SIZE , tInt ),
501 PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
502 PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
503 PropertyDef( statics.RESULT_SET_TYPE , tInt )
505 statics.refl.resultSet.pProps = createPropertyArrayHelper(
506 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
508 // updateableResultset
509 statics.refl.updateableResultSet.implName = ASCII_STR( "org.openoffice.comp.pq.UpdateableResultSet");
510 statics.refl.updateableResultSet.serviceNames = Sequence< OUString > ( 1 );
511 statics.refl.updateableResultSet.serviceNames[0] = ASCII_STR( "com.sun.star.sdbc.ResultSet" );
512 statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
513 statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
514 resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 );
516 // databasemetadata
517 statics.tablesRowNames = Sequence< OUString > ( 5 );
518 statics.tablesRowNames[TABLE_INDEX_CATALOG] = ASCII_STR( "TABLE_CAT" );
519 statics.tablesRowNames[TABLE_INDEX_SCHEMA] = ASCII_STR( "TABLE_SCHEM" );
520 statics.tablesRowNames[TABLE_INDEX_NAME] = ASCII_STR( "TABLE_NAME" );
521 statics.tablesRowNames[TABLE_INDEX_TYPE] = ASCII_STR( "TABLE_TYPE" );
522 statics.tablesRowNames[TABLE_INDEX_REMARKS] = ASCII_STR( "REMARKS" );
524 statics.primaryKeyNames = Sequence< OUString > ( 6 );
525 statics.primaryKeyNames[0] = ASCII_STR( "TABLE_CAT" );
526 statics.primaryKeyNames[1] = ASCII_STR( "TABLE_SCHEM" );
527 statics.primaryKeyNames[2] = ASCII_STR( "TABLE_NAME" );
528 statics.primaryKeyNames[3] = ASCII_STR( "COLUMN_NAME" );
529 statics.primaryKeyNames[4] = ASCII_STR( "KEY_SEQ" );
530 statics.primaryKeyNames[5] = ASCII_STR( "PK_NAME" );
532 statics.SELECT = ASCII_STR( "SELECT" );
533 statics.UPDATE = ASCII_STR( "UPDATE" );
534 statics.INSERT = ASCII_STR( "INSERT" );
535 statics.DELETE = ASCII_STR( "DELETE" );
536 statics.RULE = ASCII_STR( "RULE" );
537 statics.REFERENCES = ASCII_STR( "REFERENCES" );
538 statics.TRIGGER = ASCII_STR( "TRIGGER" );
539 statics.EXECUTE = ASCII_STR( "EXECUTE" );
540 statics.USAGE = ASCII_STR( "USAGE" );
541 statics.CREATE = ASCII_STR( "CREATE" );
542 statics.TEMPORARY = ASCII_STR( "TEMPORARY" );
543 statics.INDEX = ASCII_STR( "Index" );
544 statics.INDEX_COLUMN = ASCII_STR( "IndexColumn" );
546 statics.schemaNames = Sequence< OUString > ( 1 );
547 statics.schemaNames[0] = ASCII_STR( "TABLE_SCHEM" );
549 statics.tableTypeData = Sequence< Sequence< Any > >( 2 );
551 statics.tableTypeData[0] = Sequence< Any > ( 1 );
552 statics.tableTypeData[0][0] <<= statics.TABLE;
554 // statics.tableTypeData[2] = Sequence< Any > ( 1 );
555 // statics.tableTypeData[2][0] <<= statics.VIEW;
557 statics.tableTypeData[1] = Sequence< Any > ( 1 );
558 statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE;
560 statics.tableTypeNames = Sequence< OUString > ( 1 );
561 statics.tableTypeNames[0] = ASCII_STR( "TABLE_TYPE" );
563 static const char *tablePrivilegesNames[] =
565 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE",
566 "IS_GRANTABLE" , 0
568 statics.tablePrivilegesNames =
569 createStringSequence( tablePrivilegesNames );
571 static const char * columnNames[] =
573 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
574 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
575 "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
576 "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
577 "ORDINAL_POSITION", "IS_NULLABLE", 0
579 statics.columnRowNames =
580 createStringSequence( columnNames );
582 static const char * typeinfoColumnNames[] =
584 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
585 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
586 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
587 "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
588 "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
589 "NUM_PREC_RADIX", 0
591 statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames );
593 static const char * indexinfoColumnNames[] =
595 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
596 "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
597 "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
598 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",0
600 statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames );
602 static const char * importedKeysColumnNames[] =
604 "PKTABLE_CAT" ,
605 "PKTABLE_SCHEM",
606 "PKTABLE_NAME" ,
607 "PKCOLUMN_NAME",
608 "FKTABLE_CAT" ,
609 "FKTABLE_SCHEM",
610 "FKTABLE_NAME" ,
611 "FKCOLUMN_NAME",
612 "KEY_SEQ" ,
613 "UPDATE_RULE",
614 "DELETE_RULE",
615 "FK_NAME" ,
616 "PK_NAME" ,
617 "DEFERRABILITY" ,
620 statics.importedKeysColumnNames =
621 createStringSequence( importedKeysColumnNames );
623 static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", 0 };
624 statics.resultSetArrayColumnNames =
625 createStringSequence( resultSetArrayColumnNames );
627 // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type?
628 BaseTypeDef baseTypeDefs[] =
630 { "bool" , com::sun::star::sdbc::DataType::BIT },
631 { "bytea", com::sun::star::sdbc::DataType::VARBINARY },
632 { "char" , com::sun::star::sdbc::DataType::CHAR },
634 { "int8" , com::sun::star::sdbc::DataType::BIGINT },
635 { "serial8" , com::sun::star::sdbc::DataType::BIGINT },
638 { "int2" , com::sun::star::sdbc::DataType::SMALLINT },
640 { "int4" , com::sun::star::sdbc::DataType::INTEGER },
641 // { "regproc" , com::sun::star::sdbc::DataType::INTEGER },
642 // { "oid" , com::sun::star::sdbc::DataType::INTEGER },
643 // { "xid" , com::sun::star::sdbc::DataType::INTEGER },
644 // { "cid" , com::sun::star::sdbc::DataType::INTEGER },
645 // { "serial", com::sun::star::sdbc::DataType::INTEGER },
646 // { "serial4", com::sun::star::sdbc::DataType::INTEGER },
648 { "text", com::sun::star::sdbc::DataType::VARCHAR },
649 { "bpchar", com::sun::star::sdbc::DataType::CHAR },
650 { "varchar", com::sun::star::sdbc::DataType::VARCHAR },
652 { "float4", com::sun::star::sdbc::DataType::REAL },
653 { "float8", com::sun::star::sdbc::DataType::DOUBLE },
655 { "numeric", com::sun::star::sdbc::DataType::NUMERIC },
656 { "decimal", com::sun::star::sdbc::DataType::DECIMAL },
658 { "date", com::sun::star::sdbc::DataType::DATE },
659 { "time", com::sun::star::sdbc::DataType::TIME },
660 { "timestamp", com::sun::star::sdbc::DataType::TIMESTAMP },
662 // { "_bool" , com::sun::star::sdbc::DataType::ARRAY },
663 // { "_bytea", com::sun::star::sdbc::DataType::ARRAY },
664 // { "_char" , com::sun::star::sdbc::DataType::ARRAY },
666 // { "_int8" , com::sun::star::sdbc::DataType::ARRAY },
667 // { "_serial8" , com::sun::star::sdbc::DataType::ARRAY },
670 // { "_int2" , com::sun::star::sdbc::DataType::ARRAY },
672 // { "_int4" , com::sun::star::sdbc::DataType::ARRAY },
673 // { "_regproc" , com::sun::star::sdbc::DataType::ARRAY },
674 // { "_oid" , com::sun::star::sdbc::DataType::ARRAY },
675 // { "_xid" , com::sun::star::sdbc::DataType::ARRAY },
676 // { "_cid" , com::sun::star::sdbc::DataType::ARRAY },
678 // { "_text", com::sun::star::sdbc::DataType::ARRAY },
679 // { "_bpchar", com::sun::star::sdbc::DataType::ARRAY },
680 // { "_varchar", com::sun::star::sdbc::DataType::ARRAY },
682 // { "_float4", com::sun::star::sdbc::DataType::ARRAY },
683 // { "_float8", com::sun::star::sdbc::DataType::ARRAY },
685 // { "_numeric", com::sun::star::sdbc::DataType::ARRAY },
686 // { "_decimal", com::sun::star::sdbc::DataType::ARRAY },
688 // { "_date", com::sun::star::sdbc::DataType::ARRAY }, // switch to date later
689 // { "_time", com::sun::star::sdbc::DataType::ARRAY }, // switch to time later
691 { 0, 0 }
693 int i;
694 for( i = 0 ; baseTypeDefs[i].typeName ; i ++ )
696 statics.baseTypeMap[
697 OUString::createFromAscii( baseTypeDefs[i].typeName) ] =
698 baseTypeDefs[i].value;
701 // This is the metadata for the columns of the recordset returned
702 // by ::com::sun::star::sdbc::XDatabaseMetaData::getTypeInfo(),
703 // that is what is returned by getTypeInfo().getMetaData()
704 DefColumnMetaData defTypeInfoMetaData[] =
706 { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 0
707 { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 1
708 { "PRECISION", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 2
709 { "LITERAL_PREFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 3
710 { "LITERAL_SUFFIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 4
711 { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 5
712 { "NULLABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 6
713 { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 7
714 { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 8
715 { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 9
716 { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 10
717 { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::BIT, 0,50,0,0,0,0, false }, // 11
718 { "LOCAL_TYPE_NAME", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::VARCHAR, 0,50,0,0,0,0, false }, // 12
719 { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true}, // 13
720 { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::SMALLINT, 0,50,0,0,0,0, true }, // 14
721 { "SQL_DATA_TYPE", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 15
722 { "SQL_DATETIME_SUB", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0 , true}, // 16
723 { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", com::sun::star::sdbc::DataType::INTEGER, 0,50,0,0,0,0, true }, // 17
724 {0,0,0,0,0,0,0,0,0,0,0, 0}
727 for( i = 0 ; defTypeInfoMetaData[i].columnName ; i++ )
729 statics.typeInfoMetaData.push_back(
730 ColumnMetaData(
731 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].columnName ),
732 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].tableName ),
733 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].schemaTableName ),
734 rtl::OUString::createFromAscii( defTypeInfoMetaData[i].typeName ),
735 defTypeInfoMetaData[i].type,
736 defTypeInfoMetaData[i].precision,
737 defTypeInfoMetaData[i].scale,
738 defTypeInfoMetaData[i].isCurrency,
739 defTypeInfoMetaData[i].isNullable,
740 defTypeInfoMetaData[i].isAutoIncrement,
741 defTypeInfoMetaData[i].isReadOnly,
742 defTypeInfoMetaData[i].isSigned ) );
745 p = &statics;
748 return *p;