38#include <rtl/ustrbuf.hxx>
39#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
40#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
41#include <com/sun/star/sdbc/SQLException.hpp>
42#include <com/sun/star/sdbc/XRow.hpp>
43#include <com/sun/star/sdbcx/Privilege.hpp>
44#include <com/sun/star/sdbc/DataType.hpp>
58using com::sun::star::uno::Any;
59using com::sun::star::uno::UNO_QUERY;
63using com::sun::star::container::XEnumerationAccess;
64using com::sun::star::container::XEnumeration;
66using com::sun::star::sdbc::XRow;
67using com::sun::star::sdbc::XStatement;
68using com::sun::star::sdbc::XResultSet;
69using com::sun::star::sdbc::XDatabaseMetaData;
70using com::sun::star::sdbcx::XColumnsSupplier;
71using com::sun::star::sdbcx::XKeysSupplier;
76 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
77 const css::uno::Reference< css::sdbc::XConnection > & origin,
89 osl::MutexGuard guard(
m_xMutex->GetMutex() );
102 sal_Int32 tableIndex = 0;
113 pTable->setPropertyValue_NoBroadcast_public(
115 pTable->setPropertyValue_NoBroadcast_public( st.
NAME ,
Any(
name ) );
116 pTable->setPropertyValue_NoBroadcast_public( st.
SCHEMA_NAME ,
Any( schema ));
117 pTable->setPropertyValue_NoBroadcast_public(
119 pTable->setPropertyValue_NoBroadcast_public(
121 pTable->setPropertyValue_NoBroadcast_public(
123 Any( sal_Int32( css::sdbcx::Privilege::SELECT |
124 css::sdbcx::Privilege::INSERT |
125 css::sdbcx::Privilege::UPDATE |
126 css::sdbcx::Privilege::DELETE |
127 css::sdbcx::Privilege::READ |
128 css::sdbcx::Privilege::CREATE |
129 css::sdbcx::Privilege::ALTER |
130 css::sdbcx::Privilege::REFERENCE |
131 css::sdbcx::Privilege::DROP ) ) );
135 map[ schema +
"." +
name ] = tableIndex;
141 catch (
const css::sdbc::SQLException & e )
144 throw css::lang::WrappedTargetRuntimeException( e.Message,
155 if( !columnSupplier.is() )
166 while( xEnum.is() && xEnum->hasMoreElements() )
187 sal_Int32 dataType = 0;
188 column->getPropertyValue( st.
TYPE ) >>= dataType;
189 if( css::sdbc::DataType::INTEGER == dataType )
191 buf.append(
" serial ");
194 else if( css::sdbc::DataType::BIGINT == dataType )
196 buf.append(
" serial8 " );
206 if( !defaultValue.isEmpty() )
212 buf.append(
" NOT NULL " );
220 if( !keySupplier.is() )
227 while( xEnum.is() && xEnum->hasMoreElements() )
237 const css::uno::Reference< css::beans::XPropertySet >& descriptor )
239 osl::MutexGuard guard(
m_xMutex->GetMutex() );
244 OUString
name,schema;
245 descriptor->getPropertyValue( st.
SCHEMA_NAME ) >>= schema;
246 descriptor->getPropertyValue( st.
NAME ) >>=
name;
250 OUStringBuffer buf( 128 );
251 buf.append(
"CREATE TABLE" );
267 if( !description.isEmpty() )
270 buf.append(
"COMMENT ON TABLE" );
285 while( xEnum.is() && xEnum->hasMoreElements() )
289 if( !description.isEmpty() )
292 buf.append(
"COMMENT ON COLUMN " );
313 osl::MutexGuard guard(
m_xMutex->GetMutex() );
316 throw css::lang::IndexOutOfBoundsException(
317 "TABLES: Index out of range (allowed 0 to " + OUString::number(
m_values.size() -1)
318 +
", got " + OUString::number(
index ) +
")",
325 OUString
name,schema;
334 OUStringBuffer
update( 128 );
339 update.append(
"TABLE " );
343 stmt->executeUpdate(
update.makeStringAndClear() );
356 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
357 const css::uno::Reference< css::sdbc::XConnection > & origin,
361 *ppTables =
new Tables( refMutex, origin, pSettings );
362 (*ppTables)->refresh();
ConnectionSettings * m_pSettings
void fire(const EventBroadcastHelper &helper)
css::uno::Reference< css::sdbc::XConnection > m_origin
::rtl::Reference< comphelper::RefCountedMutex > m_xMutex
String2IntMap m_name2index
virtual void SAL_CALL dropByIndex(sal_Int32 index) override
std::vector< css::uno::Any > m_values
virtual void SAL_CALL refresh() override
virtual void SAL_CALL dropByIndex(sal_Int32 index) override
static css::uno::Reference< css::container::XNameAccess > create(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings, rtl::Reference< Tables > *ppTables)
Tables(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings)
virtual ~Tables() override
virtual void SAL_CALL appendByDescriptor(const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
void executeUpdate(const OUString &sql)
void set(css::uno::UnoInterfaceReference const &value)
class SAL_NO_VTABLE XPropertySet
Any SAL_CALL getCaughtException()
constexpr OUStringLiteral first
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void bufferQuoteConstant(OUStringBuffer &buf, std::u16string_view value, ConnectionSettings *settings)
void bufferQuoteQualifiedIdentifier(OUStringBuffer &buf, std::u16string_view schema, std::u16string_view table, ConnectionSettings *settings)
OUString concatQualified(std::u16string_view a, std::u16string_view b)
const sal_Int32 TABLE_INDEX_SCHEMA
static Any isAutoIncrement(std::u16string_view defaultValue)
const sal_Int32 TABLE_INDEX_TYPE
std::unordered_map< OUString, sal_Int32 > String2IntMap
OUString sqltype2string(const Reference< XPropertySet > &desc)
static void appendKeyList(OUStringBuffer &buf, const Reference< XKeysSupplier > &keySupplier, ConnectionSettings *settings)
OUString extractStringProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
void disposeNoThrow(const css::uno::Reference< css::uno::XInterface > &r)
static void appendColumnList(OUStringBuffer &buf, const Reference< XColumnsSupplier > &columnSupplier, ConnectionSettings *settings)
const sal_Int32 TABLE_INDEX_REMARKS
void bufferQuoteIdentifier(OUStringBuffer &buf, std::u16string_view toQuote, ConnectionSettings *settings)
const sal_Int32 TABLE_INDEX_NAME
const sal_Int32 TABLE_INDEX_CATALOG
void bufferKey2TableConstraint(OUStringBuffer &buf, const Reference< XPropertySet > &key, ConnectionSettings *settings)
bool extractBoolProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
std::map< OUString, rtl::Reference< Entity > > map
rtl::Reference< Views > pViewsImpl
css::uno::Reference< css::container::XNameAccess > views
OUString IS_AUTO_INCREMENT