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,
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 using com::sun::star::uno::Sequence
;
43 using com::sun::star::uno::Any
;
44 using com::sun::star::uno::Type
;
46 using com::sun::star::beans::PropertyAttribute::READONLY
;
47 using com::sun::star::beans::Property
;
49 namespace pq_sdbc_driver
54 struct DefColumnMetaData
56 const char * columnName
;
57 const char * tableName
;
58 const char * schemaTableName
;
59 const char * typeName
;
68 struct BaseTypeDef
{ const char * typeName
; sal_Int32 value
; };
72 PropertyDef( const OUString
&str
, const Type
&t
)
73 : name( str
) , type( t
) {}
78 struct PropertyDefEx
: public PropertyDef
80 PropertyDefEx( const OUString
& str
, const Type
&t
, sal_Int32 a
)
81 : PropertyDef( str
, t
) , attribute( a
)
88 static cppu::IPropertyArrayHelper
* createPropertyArrayHelper(
89 PropertyDef
const *props
, int count
, sal_Int16 attr
)
91 Sequence
< Property
> seq( count
);
92 for( int i
= 0 ; i
< count
; i
++ )
94 seq
[i
] = Property( props
[i
].name
, i
, props
[i
].type
, attr
);
96 return new cppu::OPropertyArrayHelper( seq
, true );
99 static cppu::IPropertyArrayHelper
* createPropertyArrayHelper(
100 PropertyDefEx
const *props
, int count
)
102 Sequence
< Property
> seq( count
);
103 for( int i
= 0 ; i
< count
; i
++ )
105 seq
[i
] = Property( props
[i
].name
, i
, props
[i
].type
, props
[i
].attribute
);
107 return new cppu::OPropertyArrayHelper( seq
, true );
110 Statics
& getStatics()
112 static Statics
* p
= []() {
113 static Statics statics
;
114 statics
.SYSTEM_TABLE
= "SYSTEM TABLE";
115 statics
.TABLE
= "TABLE";
116 statics
.VIEW
= "VIEW";
117 statics
.UNKNOWN
= "UNKNOWN";
120 statics
.NO_NULLS
= "NO_NULLS";
121 statics
.NULABLE
= "NULABLE";
122 statics
.NULLABLE_UNKNOWN
= "NULLABLE_UNKNOWN";
124 statics
.TYPE
= "Type";
125 statics
.TYPE_NAME
= "TypeName";
126 statics
.NAME
= "Name";
127 statics
.SCHEMA_NAME
= "SchemaName";
128 statics
.CATALOG_NAME
= "CatalogName";
129 statics
.DESCRIPTION
= "Description";
130 statics
.PRIVILEGES
= "Privileges";
132 statics
.DEFAULT_VALUE
= "DefaultValue";
133 statics
.IS_AUTO_INCREMENT
= "IsAutoIncrement";
134 statics
.IS_CURRENCY
= "IsCurrency";
135 statics
.IS_NULLABLE
= "IsNullable";
136 statics
.IS_ROW_VERSISON
= "IsRowVersion";
137 statics
.PRECISION
= "Precision";
138 statics
.SCALE
= "Scale";
140 statics
.cPERCENT
= "%";
141 statics
.BEGIN
= "BEGIN";
142 statics
.COMMIT
= "COMMIT";
143 statics
.ROLLBACK
= "ROLLBACK";
146 statics
.REFERENCED_TABLE
= "ReferencedTable";
147 statics
.UPDATE_RULE
= "UpdateRule";
148 statics
.DELETE_RULE
= "DeleteRule";
149 statics
.PRIVATE_COLUMNS
= "PrivateColumns";
150 statics
.PRIVATE_FOREIGN_COLUMNS
= "PrivateForeignColumns";
152 statics
.KEY_COLUMN
= "KeyColumn";
153 statics
.RELATED_COLUMN
= "RelatedColumn";
154 statics
.PASSWORD
= "Password";
155 statics
.USER
= "User";
157 statics
.CURSOR_NAME
= "CursorName";
158 statics
.ESCAPE_PROCESSING
= "EscapeProcessing";
159 statics
.FETCH_DIRECTION
= "FetchDirection";
160 statics
.FETCH_SIZE
= "FetchSize";
161 statics
.IS_BOOKMARKABLE
= "IsBookmarkable";
162 statics
.RESULT_SET_CONCURRENCY
= "ResultSetConcurrency";
163 statics
.RESULT_SET_TYPE
= "ResultSetType";
165 statics
.COMMAND
= "Command";
166 statics
.CHECK_OPTION
= "CheckOption";
170 statics
.IS_PRIMARY_KEY_INDEX
= "IsPrimaryKeyIndex";
171 statics
.IS_CLUSTERED
= "IsClustered";
172 statics
.IS_UNIQUE
= "IsUnique";
173 statics
.IS_ASCENDING
= "IsAscending";
174 statics
.PRIVATE_COLUMN_INDEXES
= "PrivateColumnIndexes";
175 statics
.HELP_TEXT
= "HelpText";
177 statics
.CATALOG
= "Catalog";
179 Type tString
= cppu::UnoType
<OUString
>::get();
180 Type tInt
= cppu::UnoType
<sal_Int32
>::get();
181 Type tBool
= cppu::UnoType
<bool>::get();
182 Type tStringSequence
= cppu::UnoType
<css::uno::Sequence
< OUString
>>::get();
185 ImplementationStatics
&ist
= statics
.refl
.table
;
186 ist
.implName
= "org.openoffice.comp.pq.sdbcx.Table";
187 ist
.serviceNames
= Sequence
< OUString
> ( 1 );
188 ist
.serviceNames
[0] = "com.sun.star.sdbcx.Table";
189 PropertyDef tableDef
[] =
191 PropertyDef( statics
.CATALOG_NAME
, tString
),
192 PropertyDef( statics
.DESCRIPTION
, tString
),
193 PropertyDef( statics
.NAME
, tString
),
194 PropertyDef( statics
.PRIVILEGES
, tInt
),
195 PropertyDef( statics
.SCHEMA_NAME
, tString
),
196 PropertyDef( statics
.TYPE
, tString
)
198 ist
.pProps
= createPropertyArrayHelper(
199 tableDef
, SAL_N_ELEMENTS(tableDef
), READONLY
);
201 statics
.refl
.tableDescriptor
.implName
=
202 "org.openoffice.comp.pq.sdbcx.TableDescriptor";
203 statics
.refl
.tableDescriptor
.serviceNames
= Sequence
< OUString
> (1);
204 statics
.refl
.tableDescriptor
.serviceNames
[0] =
205 "com.sun.star.sdbcx.TableDescriptor";
206 PropertyDef tableDescDef
[] =
208 PropertyDef( statics
.CATALOG_NAME
, tString
),
209 PropertyDef( statics
.DESCRIPTION
, tString
),
210 PropertyDef( statics
.NAME
, tString
),
211 PropertyDef( statics
.PRIVILEGES
, tInt
),
212 PropertyDef( statics
.SCHEMA_NAME
, tString
)
214 statics
.refl
.tableDescriptor
.pProps
= createPropertyArrayHelper(
215 tableDescDef
, SAL_N_ELEMENTS(tableDescDef
), 0 );
218 statics
.refl
.column
.implName
= "org.openoffice.comp.pq.sdbcx.Column";
219 statics
.refl
.column
.serviceNames
= Sequence
< OUString
> ( 1 );
220 statics
.refl
.column
.serviceNames
[0] = "com.sun.star.sdbcx.Column";
221 PropertyDefEx columnDef
[] =
223 PropertyDefEx( statics
.CATALOG_NAME
, tString
, READONLY
),
224 PropertyDefEx( statics
.DEFAULT_VALUE
, tString
, READONLY
),
225 PropertyDefEx( statics
.DESCRIPTION
, tString
, READONLY
),
226 // PropertyDefEx( statics.HELP_TEXT , tString, BOUND ),
227 PropertyDefEx( statics
.IS_AUTO_INCREMENT
, tBool
, READONLY
),
228 PropertyDefEx( statics
.IS_CURRENCY
, tBool
, READONLY
),
229 PropertyDefEx( statics
.IS_NULLABLE
, tInt
, READONLY
),
230 PropertyDefEx( statics
.IS_ROW_VERSISON
, tBool
,READONLY
),
231 PropertyDefEx( statics
.NAME
, tString
,READONLY
),
232 PropertyDefEx( statics
.PRECISION
, tInt
, READONLY
),
233 PropertyDefEx( statics
.SCALE
, tInt
,READONLY
),
234 PropertyDefEx( statics
.TYPE
, tInt
,READONLY
),
235 PropertyDefEx( statics
.TYPE_NAME
, tString
,READONLY
)
237 statics
.refl
.column
.pProps
= createPropertyArrayHelper(
238 columnDef
, SAL_N_ELEMENTS(columnDef
) );
240 statics
.refl
.columnDescriptor
.implName
=
241 "org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
242 statics
.refl
.columnDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
243 statics
.refl
.columnDescriptor
.serviceNames
[0] =
244 "com.sun.star.sdbcx.ColumnDescriptor";
245 PropertyDef columnDescDef
[] =
247 PropertyDef( statics
.CATALOG_NAME
, tString
),
248 PropertyDef( statics
.DEFAULT_VALUE
, tString
),
249 PropertyDef( statics
.DESCRIPTION
, tString
),
250 // PropertyDef( statics.HELP_TEXT , tString ),
251 PropertyDef( statics
.IS_AUTO_INCREMENT
, tBool
),
252 PropertyDef( statics
.IS_CURRENCY
, tBool
),
253 PropertyDef( statics
.IS_NULLABLE
, tInt
),
254 PropertyDef( statics
.IS_ROW_VERSISON
, tBool
),
255 PropertyDef( statics
.NAME
, tString
),
256 PropertyDef( statics
.PRECISION
, tInt
),
257 PropertyDef( statics
.SCALE
, tInt
),
258 PropertyDef( statics
.TYPE
, tInt
),
259 PropertyDef( statics
.TYPE_NAME
, tString
)
262 statics
.refl
.columnDescriptor
.pProps
= createPropertyArrayHelper(
263 columnDescDef
, SAL_N_ELEMENTS(columnDescDef
), 0 );
266 statics
.refl
.key
.implName
= "org.openoffice.comp.pq.sdbcx.Key";
267 statics
.refl
.key
.serviceNames
= Sequence
< OUString
> ( 1 );
268 statics
.refl
.key
.serviceNames
[0] = "com.sun.star.sdbcx.Key";
269 PropertyDef keyDef
[] =
271 PropertyDef( statics
.DELETE_RULE
, tInt
),
272 PropertyDef( statics
.NAME
, tString
),
273 PropertyDef( statics
.PRIVATE_COLUMNS
, tStringSequence
),
274 PropertyDef( statics
.PRIVATE_FOREIGN_COLUMNS
, tStringSequence
),
275 PropertyDef( statics
.REFERENCED_TABLE
, tString
),
276 PropertyDef( statics
.TYPE
, tInt
),
277 PropertyDef( statics
.UPDATE_RULE
, tInt
)
279 statics
.refl
.key
.pProps
= createPropertyArrayHelper(
280 keyDef
, SAL_N_ELEMENTS(keyDef
), READONLY
);
284 statics
.refl
.keyDescriptor
.implName
=
285 "org.openoffice.comp.pq.sdbcx.KeyDescriptor";
286 statics
.refl
.keyDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
287 statics
.refl
.keyDescriptor
.serviceNames
[0] =
288 "com.sun.star.sdbcx.KeyDescriptor";
289 PropertyDef keyDescDef
[] =
291 PropertyDef( statics
.DELETE_RULE
, tInt
),
292 PropertyDef( statics
.NAME
, tString
),
293 PropertyDef( statics
.REFERENCED_TABLE
, tString
),
294 PropertyDef( statics
.TYPE
, tInt
),
295 PropertyDef( statics
.UPDATE_RULE
, tInt
)
297 statics
.refl
.keyDescriptor
.pProps
= createPropertyArrayHelper(
298 keyDescDef
, SAL_N_ELEMENTS(keyDescDef
), 0 );
301 // KeyColumn props set
302 statics
.refl
.keycolumn
.implName
= "org.openoffice.comp.pq.sdbcx.KeyColumn";
303 statics
.refl
.keycolumn
.serviceNames
= Sequence
< OUString
> ( 1 );
304 statics
.refl
.keycolumn
.serviceNames
[0] = "com.sun.star.sdbcx.KeyColumn";
305 PropertyDef keycolumnDef
[] =
307 PropertyDef( statics
.CATALOG_NAME
, tString
),
308 PropertyDef( statics
.DEFAULT_VALUE
, tString
),
309 PropertyDef( statics
.DESCRIPTION
, tString
),
310 PropertyDef( statics
.IS_AUTO_INCREMENT
, tBool
),
311 PropertyDef( statics
.IS_CURRENCY
, tBool
),
312 PropertyDef( statics
.IS_NULLABLE
, tInt
),
313 PropertyDef( statics
.IS_ROW_VERSISON
, tBool
),
314 PropertyDef( statics
.NAME
, tString
),
315 PropertyDef( statics
.PRECISION
, tInt
),
316 PropertyDef( statics
.RELATED_COLUMN
, tString
),
317 PropertyDef( statics
.SCALE
, tInt
),
318 PropertyDef( statics
.TYPE
, tInt
),
319 PropertyDef( statics
.TYPE_NAME
, tString
)
321 statics
.refl
.keycolumn
.pProps
= createPropertyArrayHelper(
322 keycolumnDef
, SAL_N_ELEMENTS(keycolumnDef
), READONLY
);
324 // KeyColumn props set
325 statics
.refl
.keycolumnDescriptor
.implName
=
326 "org.openoffice.comp.pq.sdbcx.KeyColumnDescriptor";
327 statics
.refl
.keycolumnDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
328 statics
.refl
.keycolumnDescriptor
.serviceNames
[0] =
329 "com.sun.star.sdbcx.KeyColumnDescriptor";
330 PropertyDef keycolumnDescDef
[] =
332 PropertyDef( statics
.NAME
, tString
),
333 PropertyDef( statics
.RELATED_COLUMN
, tString
)
335 statics
.refl
.keycolumnDescriptor
.pProps
= createPropertyArrayHelper(
336 keycolumnDescDef
, SAL_N_ELEMENTS(keycolumnDescDef
), 0 );
339 statics
.refl
.view
.implName
= "org.openoffice.comp.pq.sdbcx.View";
340 statics
.refl
.view
.serviceNames
= Sequence
< OUString
> ( 1 );
341 statics
.refl
.view
.serviceNames
[0] = "com.sun.star.sdbcx.View";
342 PropertyDef viewDef
[] =
344 PropertyDef( statics
.CATALOG_NAME
, tString
),
345 PropertyDef( statics
.CHECK_OPTION
, tInt
),
346 PropertyDef( statics
.COMMAND
, tString
),
347 PropertyDef( statics
.NAME
, tString
),
348 PropertyDef( statics
.SCHEMA_NAME
, tString
)
350 statics
.refl
.view
.pProps
= createPropertyArrayHelper(
351 viewDef
, SAL_N_ELEMENTS(viewDef
), READONLY
);
354 statics
.refl
.viewDescriptor
.implName
= "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
355 statics
.refl
.viewDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
356 statics
.refl
.viewDescriptor
.serviceNames
[0] = "com.sun.star.sdbcx.ViewDescriptor";
357 statics
.refl
.viewDescriptor
.pProps
= createPropertyArrayHelper(
358 viewDef
, SAL_N_ELEMENTS(viewDef
), 0 ); // reuse view, as it is identical
360 statics
.refl
.user
.implName
= "org.openoffice.comp.pq.sdbcx.User";
361 statics
.refl
.user
.serviceNames
= Sequence
< OUString
> ( 1 );
362 statics
.refl
.user
.serviceNames
[0] = "com.sun.star.sdbcx.User";
363 PropertyDef userDefRO
[] =
365 PropertyDef( statics
.NAME
, tString
)
367 statics
.refl
.user
.pProps
= createPropertyArrayHelper(
368 userDefRO
, SAL_N_ELEMENTS(userDefRO
), READONLY
);
371 statics
.refl
.userDescriptor
.implName
=
372 "org.openoffice.comp.pq.sdbcx.UserDescriptor";
373 statics
.refl
.userDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
374 statics
.refl
.userDescriptor
.serviceNames
[0] =
375 "com.sun.star.sdbcx.UserDescriptor";
376 PropertyDef userDefWR
[] =
378 PropertyDef( statics
.NAME
, tString
),
379 PropertyDef( statics
.PASSWORD
, tString
)
381 statics
.refl
.userDescriptor
.pProps
= createPropertyArrayHelper(
382 userDefWR
, SAL_N_ELEMENTS(userDefWR
), 0 );
385 statics
.refl
.index
.implName
= "org.openoffice.comp.pq.sdbcx.Index";
386 statics
.refl
.index
.serviceNames
= Sequence
< OUString
> ( 1 );
387 statics
.refl
.index
.serviceNames
[0] = "com.sun.star.sdbcx.Index";
388 PropertyDef indexDef
[] =
390 PropertyDef( statics
.CATALOG
, tString
),
391 PropertyDef( statics
.IS_CLUSTERED
, tBool
),
392 PropertyDef( statics
.IS_PRIMARY_KEY_INDEX
, tBool
),
393 PropertyDef( statics
.IS_UNIQUE
, tBool
),
394 PropertyDef( statics
.NAME
, tString
),
395 PropertyDef( statics
.PRIVATE_COLUMN_INDEXES
, tStringSequence
)
397 statics
.refl
.index
.pProps
= createPropertyArrayHelper(
398 indexDef
, SAL_N_ELEMENTS(indexDef
), READONLY
);
401 statics
.refl
.indexDescriptor
.implName
=
402 "org.openoffice.comp.pq.sdbcx.IndexDescriptor";
403 statics
.refl
.indexDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
404 statics
.refl
.indexDescriptor
.serviceNames
[0] =
405 "com.sun.star.sdbcx.IndexDescriptor";
406 statics
.refl
.indexDescriptor
.pProps
= createPropertyArrayHelper(
407 indexDef
, SAL_N_ELEMENTS(indexDef
), 0 );
409 // indexColumn props set
410 statics
.refl
.indexColumn
.implName
= "org.openoffice.comp.pq.sdbcx.IndexColumn";
411 statics
.refl
.indexColumn
.serviceNames
= Sequence
< OUString
> ( 1 );
412 statics
.refl
.indexColumn
.serviceNames
[0] = "com.sun.star.sdbcx.IndexColumn";
413 PropertyDef indexColumnDef
[] =
415 PropertyDef( statics
.CATALOG_NAME
, tString
),
416 PropertyDef( statics
.DEFAULT_VALUE
, tString
),
417 PropertyDef( statics
.DESCRIPTION
, tString
),
418 PropertyDef( statics
.IS_ASCENDING
, tBool
),
419 PropertyDef( statics
.IS_AUTO_INCREMENT
, tBool
),
420 PropertyDef( statics
.IS_CURRENCY
, tBool
),
421 PropertyDef( statics
.IS_NULLABLE
, tInt
),
422 PropertyDef( statics
.IS_ROW_VERSISON
, tBool
),
423 PropertyDef( statics
.NAME
, tString
),
424 PropertyDef( statics
.PRECISION
, tInt
),
425 PropertyDef( statics
.SCALE
, tInt
),
426 PropertyDef( statics
.TYPE
, tInt
),
427 PropertyDef( statics
.TYPE_NAME
, tString
)
429 statics
.refl
.indexColumn
.pProps
= createPropertyArrayHelper(
430 indexColumnDef
, SAL_N_ELEMENTS(indexColumnDef
), READONLY
);
432 // indexColumn props set
433 statics
.refl
.indexColumnDescriptor
.implName
=
434 "org.openoffice.comp.pq.sdbcx.IndexColumnDescriptor";
435 statics
.refl
.indexColumnDescriptor
.serviceNames
= Sequence
< OUString
> ( 1 );
436 statics
.refl
.indexColumnDescriptor
.serviceNames
[0] =
437 "com.sun.star.sdbcx.IndexColumnDescriptor";
438 PropertyDef indexColumnDescDef
[] =
440 PropertyDef( statics
.IS_ASCENDING
, tBool
),
441 PropertyDef( statics
.NAME
, tString
)
443 statics
.refl
.indexColumnDescriptor
.pProps
= createPropertyArrayHelper(
444 indexColumnDescDef
, SAL_N_ELEMENTS(indexColumnDescDef
), 0 );
447 statics
.refl
.resultSet
.implName
= "org.openoffice.comp.pq.ResultSet";
448 statics
.refl
.resultSet
.serviceNames
= Sequence
< OUString
> ( 1 );
449 statics
.refl
.resultSet
.serviceNames
[0] = "com.sun.star.sdbc.ResultSet";
450 statics
.refl
.resultSet
.types
= UpdateableResultSet::getStaticTypes( false /* updateable */ );
451 PropertyDef resultSet
[] =
453 PropertyDef( statics
.CURSOR_NAME
, tString
),
454 PropertyDef( statics
.ESCAPE_PROCESSING
, tBool
),
455 PropertyDef( statics
.FETCH_DIRECTION
, tInt
),
456 PropertyDef( statics
.FETCH_SIZE
, tInt
),
457 PropertyDef( statics
.IS_BOOKMARKABLE
, tBool
),
458 PropertyDef( statics
.RESULT_SET_CONCURRENCY
, tInt
),
459 PropertyDef( statics
.RESULT_SET_TYPE
, tInt
)
461 statics
.refl
.resultSet
.pProps
= createPropertyArrayHelper(
462 resultSet
, SAL_N_ELEMENTS(resultSet
), 0 );
464 // updateableResultset
465 statics
.refl
.updateableResultSet
.implName
= "org.openoffice.comp.pq.UpdateableResultSet";
466 statics
.refl
.updateableResultSet
.serviceNames
= Sequence
< OUString
> ( 1 );
467 statics
.refl
.updateableResultSet
.serviceNames
[0] = "com.sun.star.sdbc.ResultSet";
468 statics
.refl
.updateableResultSet
.types
= UpdateableResultSet::getStaticTypes( true /* updateable */ );
469 statics
.refl
.updateableResultSet
.pProps
= createPropertyArrayHelper(
470 resultSet
, SAL_N_ELEMENTS(resultSet
), 0 );
473 statics
.tablesRowNames
= std::vector
< OUString
> ( 5 );
474 statics
.tablesRowNames
[TABLE_INDEX_CATALOG
] = "TABLE_CAT";
475 statics
.tablesRowNames
[TABLE_INDEX_SCHEMA
] = "TABLE_SCHEM";
476 statics
.tablesRowNames
[TABLE_INDEX_NAME
] = "TABLE_NAME";
477 statics
.tablesRowNames
[TABLE_INDEX_TYPE
] = "TABLE_TYPE";
478 statics
.tablesRowNames
[TABLE_INDEX_REMARKS
] = "REMARKS";
480 statics
.primaryKeyNames
= std::vector
< OUString
> ( 6 );
481 statics
.primaryKeyNames
[0] = "TABLE_CAT";
482 statics
.primaryKeyNames
[1] = "TABLE_SCHEM";
483 statics
.primaryKeyNames
[2] = "TABLE_NAME";
484 statics
.primaryKeyNames
[3] = "COLUMN_NAME";
485 statics
.primaryKeyNames
[4] = "KEY_SEQ";
486 statics
.primaryKeyNames
[5] = "PK_NAME";
488 statics
.SELECT
= "SELECT";
489 statics
.UPDATE
= "UPDATE";
490 statics
.INSERT
= "INSERT";
491 statics
.DELETE
= "DELETE";
492 statics
.RULE
= "RULE";
493 statics
.REFERENCES
= "REFERENCES";
494 statics
.TRIGGER
= "TRIGGER";
495 statics
.EXECUTE
= "EXECUTE";
496 statics
.USAGE
= "USAGE";
497 statics
.CREATE
= "CREATE";
498 statics
.TEMPORARY
= "TEMPORARY";
499 statics
.INDEX
= "Index";
500 statics
.INDEX_COLUMN
= "IndexColumn";
502 statics
.schemaNames
= std::vector
< OUString
> ( 1 );
503 statics
.schemaNames
[0] = "TABLE_SCHEM";
505 statics
.tableTypeData
= std::vector
< std::vector
< Any
> >( 2 );
507 statics
.tableTypeData
[0] = std::vector
< Any
> ( 1 );
508 statics
.tableTypeData
[0][0] <<= statics
.TABLE
;
510 // statics.tableTypeData[2] = Sequence< Any > ( 1 );
511 // statics.tableTypeData[2][0] <<= statics.VIEW;
513 statics
.tableTypeData
[1] = std::vector
< Any
> ( 1 );
514 statics
.tableTypeData
[1][0] <<= statics
.SYSTEM_TABLE
;
516 statics
.tableTypeNames
= std::vector
< OUString
> ( 1 );
517 statics
.tableTypeNames
[0] = "TABLE_TYPE";
519 statics
.columnRowNames
=
521 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME",
522 "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH",
523 "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
524 "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH",
525 "ORDINAL_POSITION", "IS_NULLABLE"
528 statics
.typeinfoColumnNames
=
530 "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX",
531 "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE",
532 "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE",
533 "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE",
534 "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB",
538 statics
.indexinfoColumnNames
=
540 "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME",
541 "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME",
542 "TYPE", "ORDINAL_POSITION", "COLUMN_NAME",
543 "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION"
546 statics
.resultSetArrayColumnNames
= { "INDEX" , "VALUE" };
548 // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type?
549 BaseTypeDef baseTypeDefs
[] =
551 { "bool" , css::sdbc::DataType::BOOLEAN
},
552 { "bytea", css::sdbc::DataType::VARBINARY
},
553 { "char" , css::sdbc::DataType::CHAR
},
555 { "int8" , css::sdbc::DataType::BIGINT
},
556 { "serial8" , css::sdbc::DataType::BIGINT
},
559 { "int2" , css::sdbc::DataType::SMALLINT
},
561 { "int4" , css::sdbc::DataType::INTEGER
},
562 // { "regproc" , css::sdbc::DataType::INTEGER },
563 // { "oid" , css::sdbc::DataType::INTEGER },
564 // { "xid" , css::sdbc::DataType::INTEGER },
565 // { "cid" , css::sdbc::DataType::INTEGER },
566 // { "serial", css::sdbc::DataType::INTEGER },
567 // { "serial4", css::sdbc::DataType::INTEGER },
569 { "text", css::sdbc::DataType::LONGVARCHAR
},
570 { "bpchar", css::sdbc::DataType::CHAR
},
571 { "varchar", css::sdbc::DataType::VARCHAR
},
573 { "float4", css::sdbc::DataType::REAL
},
574 { "float8", css::sdbc::DataType::DOUBLE
},
576 { "numeric", css::sdbc::DataType::NUMERIC
},
577 { "decimal", css::sdbc::DataType::DECIMAL
},
579 { "date", css::sdbc::DataType::DATE
},
580 { "time", css::sdbc::DataType::TIME
},
581 { "timestamp", css::sdbc::DataType::TIMESTAMP
},
583 // { "_bool" , css::sdbc::DataType::ARRAY },
584 // { "_bytea", css::sdbc::DataType::ARRAY },
585 // { "_char" , css::sdbc::DataType::ARRAY },
587 // { "_int8" , css::sdbc::DataType::ARRAY },
588 // { "_serial8" , css::sdbc::DataType::ARRAY },
591 // { "_int2" , css::sdbc::DataType::ARRAY },
593 // { "_int4" , css::sdbc::DataType::ARRAY },
594 // { "_regproc" , css::sdbc::DataType::ARRAY },
595 // { "_oid" , css::sdbc::DataType::ARRAY },
596 // { "_xid" , css::sdbc::DataType::ARRAY },
597 // { "_cid" , css::sdbc::DataType::ARRAY },
599 // { "_text", css::sdbc::DataType::ARRAY },
600 // { "_bpchar", css::sdbc::DataType::ARRAY },
601 // { "_varchar", css::sdbc::DataType::ARRAY },
603 // { "_float4", css::sdbc::DataType::ARRAY },
604 // { "_float8", css::sdbc::DataType::ARRAY },
606 // { "_numeric", css::sdbc::DataType::ARRAY },
607 // { "_decimal", css::sdbc::DataType::ARRAY },
609 // { "_date", css::sdbc::DataType::ARRAY }, // switch to date later
610 // { "_time", css::sdbc::DataType::ARRAY }, // switch to time later
615 for( i
= 0 ; baseTypeDefs
[i
].typeName
; i
++ )
618 OUString::createFromAscii( baseTypeDefs
[i
].typeName
) ] =
619 baseTypeDefs
[i
].value
;
622 // This is the metadata for the columns of the recordset returned
623 // by css::sdbc::XDatabaseMetaData::getTypeInfo(),
624 // that is what is returned by getTypeInfo().getMetaData()
625 DefColumnMetaData defTypeInfoMetaData
[] =
627 { "TYPE_NAME", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR
, 0,50,false,false,false }, // 0
628 { "DATA_TYPE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT
, 0,50,false,false,false }, // 1
629 { "PRECISION", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER
, 0,50,false,false,false }, // 2
630 { "LITERAL_PREFIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR
, 0,50,false,false,false }, // 3
631 { "LITERAL_SUFFIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR
, 0,50,false,false,false }, // 4
632 { "CREATE_PARAMS", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR
, 0,50,false,false,false }, // 5
633 { "NULLABLE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER
, 0,50,false,false,false }, // 6
634 { "CASE_SENSITIVE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN
, 0,50,false,false,false }, // 7
635 { "SEARCHABLE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT
, 0,50,false,false,false }, // 8
636 { "UNSIGNED_ATTRIBUTE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN
, 0,50,false,false,false }, // 9
637 { "FIXED_PREC_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN
, 0,50,false,false,false }, // 10
638 { "AUTO_INCREMENT", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::BOOLEAN
, 0,50,false,false,false }, // 11
639 { "LOCAL_TYPE_NAME", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::VARCHAR
, 0,50,false,false,false }, // 12
640 { "MINIMUM_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT
, 0,50,false,false,false}, // 13
641 { "MAXIMUM_SCALE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::SMALLINT
, 0,50,false,false,false }, // 14
642 { "SQL_DATA_TYPE", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER
, 0,50,false,false,false }, // 15
643 { "SQL_DATETIME_SUB", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER
, 0,50,false,false,false}, // 16
644 { "NUM_PREC_RADIX", "TYPEINFO", "pg_catalog", "", css::sdbc::DataType::INTEGER
, 0,50,false,false,false }, // 17
645 {nullptr,nullptr,nullptr,nullptr,0,0,0,false,false,false}
648 for( i
= 0 ; defTypeInfoMetaData
[i
].columnName
; i
++ )
650 statics
.typeInfoMetaData
.push_back(
652 OUString::createFromAscii( defTypeInfoMetaData
[i
].columnName
),
653 OUString::createFromAscii( defTypeInfoMetaData
[i
].tableName
),
654 OUString::createFromAscii( defTypeInfoMetaData
[i
].schemaTableName
),
655 OUString::createFromAscii( defTypeInfoMetaData
[i
].typeName
),
656 defTypeInfoMetaData
[i
].type
,
657 defTypeInfoMetaData
[i
].precision
,
658 defTypeInfoMetaData
[i
].scale
,
659 defTypeInfoMetaData
[i
].isCurrency
,
660 defTypeInfoMetaData
[i
].isNullable
,
661 defTypeInfoMetaData
[i
].isAutoIncrement
) );
672 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */