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 * 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
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 <rtl/ustrbuf.hxx>
59 #include <rtl/strbuf.hxx>
61 #include <com/sun/star/sdbc/XRow.hpp>
62 #include <com/sun/star/sdbc/XParameters.hpp>
63 #include <com/sun/star/sdbc/DataType.hpp>
64 #include <com/sun/star/sdbc/ColumnValue.hpp>
66 #include <cppuhelper/implbase1.hxx>
68 #include "pq_xcolumns.hxx"
69 #include "pq_xcolumn.hxx"
70 #include "pq_statics.hxx"
71 #include "pq_tools.hxx"
73 using osl::MutexGuard
;
76 using rtl::OUStringBuffer
;
77 using rtl::OUStringToOString
;
79 using com::sun::star::beans::XPropertySet
;
80 using com::sun::star::beans::XPropertyChangeListener
;
81 using com::sun::star::beans::PropertyChangeEvent
;
83 using com::sun::star::uno::Any
;
84 using com::sun::star::uno::makeAny
;
85 using com::sun::star::uno::UNO_QUERY
;
86 using com::sun::star::uno::Type
;
87 using com::sun::star::uno::XInterface
;
88 using com::sun::star::uno::Reference
;
89 using com::sun::star::uno::Sequence
;
90 using com::sun::star::uno::RuntimeException
;
92 using com::sun::star::container::NoSuchElementException
;
93 using com::sun::star::lang::WrappedTargetException
;
95 using com::sun::star::sdbc::XRow
;
96 using com::sun::star::sdbc::XCloseable
;
97 using com::sun::star::sdbc::XStatement
;
98 using com::sun::star::sdbc::XResultSet
;
99 using com::sun::star::sdbc::XParameters
;
100 using com::sun::star::sdbc::XPreparedStatement
;
101 using com::sun::star::sdbc::XDatabaseMetaData
;
102 using com::sun::star::sdbc::SQLException
;
104 namespace pq_sdbc_driver
106 #define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
108 static Any
isCurrency( const rtl::OUString
& typeName
)
110 sal_Bool b
= typeName
.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("money"));
111 return Any( &b
, getBooleanCppuType() );
114 // static sal_Bool isAutoIncrement8( const rtl::OUString & typeName )
116 // return typeName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("serial8")) ||
117 // typeName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("bigserial"));
120 static Any
isAutoIncrement( const rtl::OUString
& defaultValue
)
122 sal_Bool ret
= sal_False
;
124 ret
= defaultValue
.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "nextval(" ) );
125 // printf( "%s %d\n",
126 // OUStringToOString(defaultValue, RTL_TEXTENCODING_ASCII_US).getStr(),
129 // static const char * const serials[] =
131 // "serial", "serial4", "serial8", "bigserial", 0
133 // s sal_Bool b = sal_False;
134 // for( int i = 0; !b && serials[i] ; i ++ )
136 // b = b || typeName.equalsIgnoreAsciiCaseAscii( serials[i] );
138 return Any ( &ret
, getBooleanCppuType() );
142 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
143 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
144 ConnectionSettings
*pSettings
,
145 const rtl::OUString
&schemaName
,
146 const rtl::OUString
&tableName
)
147 : Container( refMutex
, origin
, pSettings
, ASCII_STR( "COLUMN" ) ),
148 m_schemaName( schemaName
),
149 m_tableName( tableName
)
155 rtl::OUString
columnMetaData2SDBCX(
156 ReflectionBase
*pBase
, const com::sun::star::uno::Reference
< com::sun::star::sdbc::XRow
> &xRow
)
158 Statics
& st
= getStatics();
160 // 1. TABLE_CAT string => table catalog (may be NULL)
162 // 2. TABLE_SCHEM string => table schema (may be NULL)
163 // => pg_namespace.nspname
164 // 3. TABLE_NAME string => table name
165 // => pg_class.relname
166 // 4. COLUMN_NAME string => column name
167 // => pg_attribure.attname
168 // 5. DATA_TYPE short => SQL type from java.sql.Types
169 // => pg_type.typname => sdbc.DataType
170 // 6. TYPE_NAME string => Data source dependent type name, for a UDT the
171 // type name is fully qualified
172 // => pg_type.typname
173 // 7. COLUMN_SIZE long => column size. For char or date types this is
174 // the maximum number of characters, for numeric
175 // or decimal types this is precision.
176 // => pg_type.typlen ( TODO: What is about variable size ? )
177 // 8. BUFFER_LENGTH is not used.
179 // 9. DECIMAL_DIGITS long => the number of fractional digits
180 // => don't know ! TODO !
181 // 10. NUM_PREC_RADIX long => Radix (typically either 10 or 2)
183 // 11. NULLABLE long => is NULL allowed?
184 // NO_NULLS - might not allow NULL values
185 // NULABLE - definitely allows NULL values
186 // NULLABLE_UNKNOWN - nullability unknown
187 // => pg_attribute.attnotnull
188 // 12. REMARKS string => comment describing column (may be NULL )
189 // => Don't know, there does not seem to exist something like
191 // 13. COLUMN_DEF string => default value (may be NULL)
192 // => pg_type.typdefault
193 // 14. SQL_DATA_TYPE long => unused
195 // 15. SQL_DATETIME_SUB long => unused
197 // 16. CHAR_OCTET_LENGTH long => for char types the maximum number of
198 // bytes in the column
200 // 17. ORDINAL_POSITION int => index of column in table (starting at 1)
201 // pg_attribute.attnum
202 // 18. IS_NULLABLE string => "NO" means column definitely does not allow
203 // NULL values; "YES" means the column might
204 // allow NULL values. An empty string means
206 // => pg_attribute.attnotnull
208 static const int COLUMN_NAME
= 4;
209 static const int DATA_TYPE
= 5;
210 static const int TYPE_NAME
= 6;
211 static const int COLUMN_SIZE
= 7;
212 static const int DECIMAL_DIGITS
= 9;
213 static const int IS_NULLABLE
= 11;
214 static const int DESCRIPTION
= 12;
215 static const int DEFAULT_VALUE
= 13;
217 OUString name
= xRow
->getString( COLUMN_NAME
);
218 OUString typeName
= xRow
->getString( TYPE_NAME
);
220 pBase
->setPropertyValue_NoBroadcast_public(
221 st
.NAME
, makeAny( name
) );
223 pBase
->setPropertyValue_NoBroadcast_public(
224 st
.TYPE
, makeAny( xRow
->getInt( DATA_TYPE
) ) );
226 pBase
->setPropertyValue_NoBroadcast_public(
227 st
.TYPE_NAME
, makeAny( typeName
) );
229 pBase
->setPropertyValue_NoBroadcast_public(
230 st
.PRECISION
, makeAny( xRow
->getInt( COLUMN_SIZE
) ) );
232 pBase
->setPropertyValue_NoBroadcast_public(
233 st
.SCALE
, makeAny( xRow
->getInt( DECIMAL_DIGITS
) ) );
235 pBase
->setPropertyValue_NoBroadcast_public(
236 st
.IS_NULLABLE
, makeAny( xRow
->getInt( IS_NULLABLE
) ) );
238 pBase
->setPropertyValue_NoBroadcast_public(
239 st
.DEFAULT_VALUE
, makeAny( xRow
->getString( DEFAULT_VALUE
) ) );
241 // pBase->setPropertyValue_NoBroadcast_public(
242 // st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
244 // if( pBase->getPropertySetInfo()->hasPropertyByName( st.HELP_TEXT ) )
245 // pBase->setPropertyValue_NoBroadcast_public(
246 // st.HELP_TEXT, makeAny( xRow->getString( DESCRIPTION ) ) );
247 // else // for key columns, etc. ...
248 pBase
->setPropertyValue_NoBroadcast_public(
249 st
.DESCRIPTION
, makeAny( xRow
->getString( DESCRIPTION
) ) );
252 // maybe a better criterium than the type name can be found in future
253 pBase
->setPropertyValue_NoBroadcast_public(
254 st
.IS_AUTO_INCREMENT
, isAutoIncrement(xRow
->getString( DEFAULT_VALUE
)) );
256 pBase
->setPropertyValue_NoBroadcast_public(
257 st
.IS_CURRENCY
, isCurrency( typeName
));
262 // class CommentChanger : public cppu::WeakImplHelper1< XPropertyChangeListener >
264 // ::rtl::Reference< RefCountedMutex > m_refMutex;
265 // ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
266 // ConnectionSettings *m_pSettings;
267 // rtl::OUString m_schema;
268 // rtl::OUString m_table;
269 // rtl::OUString m_column;
273 // const ::rtl::Reference< RefCountedMutex > & refMutex,
274 // const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
275 // ConnectionSettings *pSettings,
276 // const rtl::OUString & schema,
277 // const rtl::OUString & table,
278 // const rtl::OUString & column ) :
279 // m_refMutex( refMutex ),
280 // m_connection( connection ),
281 // m_pSettings( pSettings ),
282 // m_schema ( schema ),
283 // m_table ( table ),
284 // m_column ( column )
289 // virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
291 // osl::MutexGuard guard( m_refMutex->mutex );
292 // m_connection.clear();
295 // virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
297 // osl::MutexGuard guard( m_refMutex->mutex );
298 // OUStringBuffer buf( 128 );
300 // evt.NewValue >>= comment;
301 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
302 // bufferQuoteQualifiedIdentifier( buf, m_schema, m_table , m_column );
303 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
304 // bufferQuoteConstant( buf, comment,m_pSettings->encoding);
306 // printf( "changing comment of column %s to %s\n",
307 // OUStringToOString( m_column, RTL_TEXTENCODING_ASCII_US ).getStr(),
308 // OUStringToOString( comment, RTL_TEXTENCODING_ASCII_US ).getStr() );
310 // m_connection->createStatement()->executeUpdate( buf.makeStringAndClear() );
314 void Columns::refresh()
315 throw (::com::sun::star::uno::RuntimeException
)
319 if( isLog( m_pSettings
, LogLevel::INFO
) )
321 rtl::OStringBuffer buf
;
322 buf
.append( "sdbcx.Columns get refreshed for table " );
323 buf
.append( OUStringToOString( m_schemaName
, m_pSettings
->encoding
) );
325 buf
.append( OUStringToOString( m_tableName
, m_pSettings
->encoding
) );
326 log( m_pSettings
, LogLevel::INFO
, buf
.makeStringAndClear().getStr() );
328 osl::MutexGuard
guard( m_refMutex
->mutex
);
330 Statics
&st
= getStatics();
331 Reference
< XDatabaseMetaData
> meta
= m_origin
->getMetaData();
333 Reference
< XResultSet
> rs
=
334 meta
->getColumns( Any(), m_schemaName
, m_tableName
, st
.cPERCENT
);
336 DisposeGuard
disposeIt( rs
);
337 Reference
< XRow
> xRow( rs
, UNO_QUERY
);
341 m_values
= Sequence
< com::sun::star::uno::Any
> ();
346 new Column( m_refMutex
, m_origin
, m_pSettings
);
347 Reference
< com::sun::star::beans::XPropertySet
> prop
= pColumn
;
349 OUString name
= columnMetaData2SDBCX( pColumn
, xRow
);
350 // pColumn->addPropertyChangeListener(
352 // new CommentChanger(
361 const int currentColumnIndex
= columnIndex
++;
362 assert(currentColumnIndex
== m_values
.getLength());
363 m_values
.realloc( columnIndex
);
364 m_values
[currentColumnIndex
] = makeAny( prop
);
365 map
[ name
] = currentColumnIndex
;
368 m_name2index
.swap( map
);
370 catch ( com::sun::star::sdbc::SQLException
& e
)
372 throw RuntimeException( e
.Message
, e
.Context
);
374 fire( RefreshedBroadcaster( *this ) );
378 void alterColumnByDescriptor(
379 const OUString
& schemaName
,
380 const OUString
& tableName
,
381 ConnectionSettings
*settings
,
382 const Reference
< XStatement
> &stmt
,
383 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> & past
,
384 const com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySet
> & future
)
386 Statics
& st
= getStatics();
388 // if( past->getPropertyValue( st.TABLE_NAME ) != future->getPropertyValue( st.TABLE_NAME ) ||
389 // past->getPropertyValue( st.SCHEMA_NAME ) != future->getPropertyValue( st.SCHEMA_NAME ))
391 // OUStringBuffer buf(128);
392 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Can't move column " ) );
393 // buf.append( extractStringProperty( past, st.COLUMN_NAME ) );
394 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " from table " ) );
395 // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
396 // buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " to table " ) );
397 // buf.append( extractStringProperty( past, st.TABLE_NAME ) );
398 // throw SQLException( buf.makeStringAndClear(), Reference< XInterface > () );
401 // OUString tableName = extractStringProperty( past, st.TABLE_NAME );
402 // OUString schemaName = extractStringProperty( past, st.SCHEMA_NAME );
403 OUString pastColumnName
= extractStringProperty( past
, st
.NAME
);
404 OUString futureColumnName
= extractStringProperty( future
, st
.NAME
);
405 OUString pastTypeName
= sqltype2string( past
);
406 OUString futureTypeName
= sqltype2string( future
);
408 TransactionGuard
transaction( stmt
);
410 OUStringBuffer
buf( 128 );
411 if( ! pastColumnName
.getLength())
413 // create a new column
414 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
415 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, settings
);
416 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ADD COLUMN" ) );
417 bufferQuoteIdentifier( buf
, futureColumnName
, settings
);
418 buf
.append( futureTypeName
);
419 transaction
.executeUpdate( buf
.makeStringAndClear() );
423 if( pastTypeName
!= futureTypeName
)
425 throw RuntimeException(
426 ASCII_STR( "Can't modify column types, drop the column and create a new one" ),
427 Reference
< XInterface
> () );
430 if( pastColumnName
!= futureColumnName
)
432 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
433 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, settings
);
434 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "RENAME COLUMN" ) );
435 bufferQuoteIdentifier( buf
, pastColumnName
, settings
);
436 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TO" ) );
437 bufferQuoteIdentifier( buf
, futureColumnName
, settings
);
438 transaction
.executeUpdate( buf
.makeStringAndClear() );
442 OUString futureDefaultValue
= extractStringProperty( future
, st
.DEFAULT_VALUE
);
443 OUString pastDefaultValue
= extractStringProperty( past
, st
.DEFAULT_VALUE
);
444 if( futureDefaultValue
!= pastDefaultValue
)
446 buf
= OUStringBuffer( 128 );
447 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
448 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, settings
);
449 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
450 bufferQuoteIdentifier( buf
, futureColumnName
, settings
);
451 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET DEFAULT " ) );
452 // LEM TODO: check out
453 // default value is not quoted, caller needs to quote himself (otherwise
454 // how to pass e.g. nextval('something' ) ????
455 buf
.append( futureDefaultValue
);
456 // bufferQuoteConstant( buf, defaultValue, encoding );
457 transaction
.executeUpdate( buf
.makeStringAndClear() );
460 sal_Int32 futureNullable
= extractIntProperty( future
, st
.IS_NULLABLE
);
461 sal_Int32 pastNullable
= extractIntProperty( past
, st
.IS_NULLABLE
);
462 if( futureNullable
!= pastNullable
)
464 buf
= OUStringBuffer( 128 );
465 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
466 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, settings
);
467 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER COLUMN" ) );
468 bufferQuoteIdentifier( buf
, futureColumnName
, settings
);
469 if( futureNullable
== com::sun::star::sdbc::ColumnValue::NO_NULLS
)
471 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET" ) );
475 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP" ) );
477 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL" ) );
478 transaction
.executeUpdate( buf
.makeStringAndClear() );
481 // OUString futureComment = extractStringProperty( future, st.HELP_TEXT );
482 // OUString pastComment = extractStringProperty( past, st.HELP_TEXT );
483 // printf( "past Comment %s, futureComment %s\n",
484 // OUStringToOString( pastComment, RTL_TEXTENCODING_ASCII_US ).getStr(),
485 // OUStringToOString( futureComment, RTL_TEXTENCODING_ASCII_US ).getStr() );
486 OUString futureComment
= extractStringProperty( future
, st
.DESCRIPTION
);
487 OUString pastComment
= extractStringProperty( past
, st
.DESCRIPTION
);
489 if( futureComment
!= pastComment
)
491 buf
= OUStringBuffer( 128 );
492 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
493 bufferQuoteQualifiedIdentifier( buf
, schemaName
, tableName
, futureColumnName
, settings
);
494 buf
.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
495 bufferQuoteConstant( buf
, futureComment
, settings
);
496 transaction
.executeUpdate( buf
.makeStringAndClear() );
498 transaction
.commit();
501 void Columns::appendByDescriptor(
502 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& future
)
503 throw (::com::sun::star::sdbc::SQLException
,
504 ::com::sun::star::container::ElementExistException
,
505 ::com::sun::star::uno::RuntimeException
)
507 osl::MutexGuard
guard( m_refMutex
->mutex
);
508 Statics
& st
= getStatics();
509 Reference
< XPropertySet
> past
= createDataDescriptor();
510 past
->setPropertyValue( st
.IS_NULLABLE
, makeAny( com::sun::star::sdbc::ColumnValue::NULLABLE
) );
511 alterColumnByDescriptor(
512 m_schemaName
, m_tableName
, m_pSettings
, m_origin
->createStatement() , past
, future
);
517 // void Columns::dropByName( const ::rtl::OUString& elementName )
518 // throw (::com::sun::star::sdbc::SQLException,
519 // ::com::sun::star::container::NoSuchElementException,
520 // ::com::sun::star::uno::RuntimeException)
522 // String2IntMap::const_iterator ii = m_name2index.find( elementName );
523 // if( ii == m_name2index.end() )
525 // OUStringBuffer buf( 128 );
526 // buf.appendAscii( "Column " );
527 // buf.append( elementName );
528 // buf.appendAscii( " is unknown in table " );
529 // buf.append( m_schemaName );
530 // buf.appendAscii( "." );
531 // buf.append( m_tableName );
532 // buf.appendAscii( ", so it can't be dropped" );
533 // throw com::sun::star::container::NoSuchElementException(
534 // buf.makeStringAndClear(), *this );
536 // dropByIndex( ii->second );
539 void Columns::dropByIndex( sal_Int32 index
)
540 throw (::com::sun::star::sdbc::SQLException
,
541 ::com::sun::star::lang::IndexOutOfBoundsException
,
542 ::com::sun::star::uno::RuntimeException
)
544 osl::MutexGuard
guard( m_refMutex
->mutex
);
545 if( index
< 0 || index
>= m_values
.getLength() )
547 OUStringBuffer
buf( 128 );
548 buf
.appendAscii( "COLUMNS: Index out of range (allowed 0 to " );
549 buf
.append((sal_Int32
)(m_values
.getLength() -1) );
550 buf
.appendAscii( ", got " );
552 buf
.appendAscii( ")" );
553 throw com::sun::star::lang::IndexOutOfBoundsException(
554 buf
.makeStringAndClear(), *this );
557 Reference
< XPropertySet
> set
;
558 m_values
[index
] >>= set
;
559 Statics
&st
= getStatics();
561 set
->getPropertyValue( st
.NAME
) >>= name
;
563 OUStringBuffer
update( 128 );
564 update
.appendAscii( "ALTER TABLE ONLY");
565 bufferQuoteQualifiedIdentifier( update
, m_schemaName
, m_tableName
, m_pSettings
);
566 update
.appendAscii( "DROP COLUMN" );
567 bufferQuoteIdentifier( update
, name
, m_pSettings
);
568 Reference
< XStatement
> stmt
= m_origin
->createStatement( );
569 DisposeGuard
disposeIt( stmt
);
570 stmt
->executeUpdate( update
.makeStringAndClear() );
572 Container::dropByIndex( index
);
576 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> Columns::createDataDescriptor()
577 throw (::com::sun::star::uno::RuntimeException
)
579 return new ColumnDescriptor( m_refMutex
, m_origin
, m_pSettings
);
582 Reference
< com::sun::star::container::XNameAccess
> Columns::create(
583 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
584 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
585 ConnectionSettings
*pSettings
,
586 const rtl::OUString
&schemaName
,
587 const rtl::OUString
&tableName
,
590 *ppColumns
= new Columns(
591 refMutex
, origin
, pSettings
, schemaName
, tableName
);
592 Reference
< com::sun::star::container::XNameAccess
> ret
= *ppColumns
;
593 (*ppColumns
)->refresh();
599 //_____________________________________________________________________________________
600 ColumnDescriptors::ColumnDescriptors(
601 const ::rtl::Reference
< RefCountedMutex
> & refMutex
,
602 const ::com::sun::star::uno::Reference
< com::sun::star::sdbc::XConnection
> & origin
,
603 ConnectionSettings
*pSettings
)
604 : Container( refMutex
, origin
, pSettings
, ASCII_STR( "COLUMN-DESCRIPTOR" ) )
608 Reference
< ::com::sun::star::beans::XPropertySet
> ColumnDescriptors::createDataDescriptor()
609 throw (::com::sun::star::uno::RuntimeException
)
611 return new ColumnDescriptor( m_refMutex
, m_origin
, m_pSettings
);