38#include <rtl/ustrbuf.hxx>
43#include <com/sun/star/sdbc/SQLException.hpp>
56using com::sun::star::container::XNameAccess;
57using com::sun::star::container::XIndexAccess;
60using com::sun::star::uno::UNO_QUERY;
62using com::sun::star::uno::Any;
63using com::sun::star::uno::Type;
67using com::sun::star::sdbc::XStatement;
68using com::sun::star::sdbc::SQLException;
72Table::Table( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
74 ConnectionSettings *pSettings)
87 m_xMutex,
m_conn, m_pSettings );
88 pTable->copyValuesFrom(
this );
95 if( ! m_columns.is() )
97 m_columns = Columns::create(
110 if( ! m_indexes.is() )
136void Table::rename(
const OUString& newName )
138 MutexGuard guard( m_xMutex->GetMutex() );
145 OUString newTableName;
146 OUString newSchemaName;
150 if(
newName.indexOf(
'.' ) >= 0 )
157 newSchemaName = schema;
164 Any a = m_pSettings->pViewsImpl->getByName( fullOldName );
170 setPropertyValue_NoBroadcast_public( st.
SCHEMA_NAME,
Any(newSchemaName) );
175 if( newSchemaName != schema )
180 OUStringBuffer buf(128);
181 buf.append(
"ALTER TABLE" );
183 buf.append(
"SET SCHEMA" );
186 statement->executeUpdate( buf.makeStringAndClear() );
187 setPropertyValue_NoBroadcast_public( st.
SCHEMA_NAME,
Any(newSchemaName) );
189 schema = newSchemaName;
191 catch( css::sdbc::SQLException &e )
193 OUString buf( e.Message +
"(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" );
199 if( newTableName != oldName )
201 OUStringBuffer buf(128);
202 buf.append(
"ALTER TABLE" );
204 buf.append(
"RENAME TO" );
207 statement->executeUpdate( buf.makeStringAndClear() );
211 setPropertyValue_NoBroadcast_public( st.
NAME,
Any(newTableName) );
213 if( m_pSettings->tables.is() )
215 m_pSettings->pTablesImpl->rename( fullOldName, fullNewName );
219void Table::alterColumnByName(
220 const OUString& colName,
230 m_conn->createStatement(),
234 if( colName != newName )
237 m_pColumns->refresh();
241void Table::alterColumnByIndex(
243 const css::uno::Reference< css::beans::XPropertySet >& descriptor )
251 m_conn->createStatement(),
254 m_pColumns->refresh();
265 ReflectionBase::getTypes());
272 return css::uno::Sequence<sal_Int8>();
275Any Table::queryInterface(
const Type & reqType )
277 Any ret = ReflectionBase::queryInterface( reqType );
278 if( ! ret.hasValue() )
279 ret = ::cppu::queryInterface(
281 static_cast< css::sdbcx::XIndexesSupplier *
> (
this ),
282 static_cast< css::sdbcx::XKeysSupplier *
> (
this ),
283 static_cast< css::sdbcx::XColumnsSupplier *
> (
this ),
284 static_cast< css::sdbcx::XRename *
> (
this ),
285 static_cast< css::sdbcx::XAlterTable *
> (
this )
290OUString Table::getName( )
298void Table::setName(
const OUString& aName )
304TableDescriptor::TableDescriptor(
305 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
310 getStatics().refl.tableDescriptor.serviceNames,
365 return css::uno::Sequence<sal_Int8>();
371 if( ! ret.hasValue() )
372 ret = ::cppu::queryInterface(
374 static_cast< css::sdbcx::XIndexesSupplier *
> (
this ),
375 static_cast< css::sdbcx::XKeysSupplier *
> (
this ),
376 static_cast< css::sdbcx::XColumnsSupplier *
> (
this ));
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
static css::uno::Reference< css::container::XNameAccess > create(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings)
static css::uno::Reference< css::container::XNameAccess > create(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings, const OUString &schemaName, const OUString &tableName)
static css::uno::Reference< css::container::XIndexAccess > create(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings)
static css::uno::Reference< css::container::XIndexAccess > create(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings, const OUString &schemaName, const OUString &tableName)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
css::uno::Reference< css::sdbc::XConnection > m_conn
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
std::vector< css::uno::Any > m_values
ConnectionSettings * m_pSettings
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getKeys() override
TableDescriptor(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &connection, ConnectionSettings *pSettings)
css::uno::Reference< css::container::XNameAccess > m_columns
css::uno::Reference< css::container::XNameAccess > m_indexes
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getIndexes() override
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
css::uno::Reference< css::container::XIndexAccess > m_keys
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getColumns() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
Table(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &connection, ConnectionSettings *pSettings)
class SAL_NO_VTABLE XPropertySet
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
void bufferQuoteQualifiedIdentifier(OUStringBuffer &buf, std::u16string_view schema, std::u16string_view table, ConnectionSettings *settings)
OUString concatQualified(std::u16string_view a, std::u16string_view b)
OUString extractStringProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
void splitConcatenatedIdentifier(std::u16string_view source, OUString *first, OUString *second)
void disposeNoThrow(const css::uno::Reference< css::uno::XInterface > &r)
void bufferQuoteIdentifier(OUStringBuffer &buf, std::u16string_view toQuote, ConnectionSettings *settings)
void alterColumnByDescriptor(std::u16string_view schemaName, std::u16string_view tableName, ConnectionSettings *settings, const Reference< XStatement > &stmt, const css::uno::Reference< css::beans::XPropertySet > &past, const css::uno::Reference< css::beans::XPropertySet > &future)
rtl::Reference< Connection > m_conn