39#include <rtl/ustrbuf.hxx>
40#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
42#include <com/sun/star/sdbc/SQLException.hpp>
43#include <com/sun/star/sdbc/XRow.hpp>
44#include <com/sun/star/sdbc/XParameters.hpp>
59using com::sun::star::uno::Any;
60using com::sun::star::uno::UNO_QUERY;
64using com::sun::star::container::XEnumerationAccess;
65using com::sun::star::container::XEnumeration;
68using com::sun::star::sdbcx::XColumnsSupplier;
70using com::sun::star::sdbc::XRow;
71using com::sun::star::sdbc::XResultSet;
72using com::sun::star::sdbc::XParameters;
73using com::sun::star::sdbc::XPreparedStatement;
79 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
80 const css::uno::Reference< css::sdbc::XConnection > & origin,
85 m_schemaName(
std::move( schemaName )),
99 osl::MutexGuard guard(
m_xMutex->GetMutex() );
114 "FROM pg_index INNER JOIN pg_class ON indrelid = pg_class.oid "
115 "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
116 "INNER JOIN pg_class as class2 ON pg_index.indexrelid = class2.oid "
117 "WHERE nspname = ? AND pg_class.relname = ?" );
132 static const sal_Int32 C_INDEXNAME = 3;
133 static const sal_Int32 C_IS_CLUSTERED = 4;
134 static const sal_Int32 C_IS_UNIQUE = 5;
135 static const sal_Int32 C_IS_PRIMARY = 6;
136 static const sal_Int32 C_COLUMNS = 7;
137 OUString currentIndexName = row->getString( C_INDEXNAME );
142 bool isUnique = row->getBoolean( C_IS_UNIQUE );
143 bool isPrimary = row->getBoolean( C_IS_PRIMARY );
144 bool isClusterd = row->getBoolean( C_IS_CLUSTERED );
146 pIndex->setPropertyValue_NoBroadcast_public(
148 pIndex->setPropertyValue_NoBroadcast_public(
150 pIndex->setPropertyValue_NoBroadcast_public(
152 pIndex->setPropertyValue_NoBroadcast_public(
153 st.
NAME,
Any( currentIndexName ) );
155 std::vector< sal_Int32 > seq =
parseIntArray( row->getString( C_COLUMNS ) );
157 auto columnNamesRange = asNonConstRange(columnNames);
158 for(
size_t columns = 0 ; columns < seq.size() ; columns ++ )
160 columnNamesRange[columns] = column2NameMap[ seq[columns] ];
163 pIndex->setPropertyValue_NoBroadcast_public(
174 catch ( css::sdbc::SQLException & e )
177 throw css::lang::WrappedTargetRuntimeException( e.Message,
186 const css::uno::Reference< css::beans::XPropertySet >& descriptor )
193 OUStringBuffer buf( 128 );
195 buf.append(
"CREATE " );
197 buf.append(
"UNIQUE " );
198 buf.append(
"INDEX " );
200 buf.append(
" ON " );
213 while( xEnum.is() && xEnum->hasMoreElements() )
230 m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
238 osl::MutexGuard guard(
m_xMutex->GetMutex() );
241 throw css::lang::IndexOutOfBoundsException(
242 "Indexes: Index out of range (allowed 0 to "
243 + OUString::number(
m_values.size() -1 )
244 +
", got " + OUString::number(
index )
253 OUStringBuffer buf( 128 );
254 buf.append(
"DROP INDEX " );
256 m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
268 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
269 const css::uno::Reference< css::sdbc::XConnection > & origin,
271 const OUString & schemaName,
282 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
283 const css::uno::Reference< css::sdbc::XConnection > & origin,
289 const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
290 const css::uno::Reference< css::sdbc::XConnection > & origin,
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 css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() 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)
IndexDescriptors(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings)
virtual ~Indexes() override
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL createDataDescriptor() override
Indexes(const ::rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::sdbc::XConnection > &origin, ConnectionSettings *pSettings, OUString schemaName, OUString tableName)
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, const OUString &schemaName, const OUString &tableName)
virtual void SAL_CALL appendByDescriptor(const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
#define SAL_INFO(area, stream)
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 bufferQuoteQualifiedIdentifier(OUStringBuffer &buf, std::u16string_view schema, std::u16string_view table, ConnectionSettings *settings)
std::unordered_map< OUString, sal_Int32 > String2IntMap
std::vector< sal_Int32 > parseIntArray(const OUString &str)
OUString extractStringProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
void bufferQuoteIdentifier(OUStringBuffer &buf, std::u16string_view toQuote, ConnectionSettings *settings)
std::unordered_map< sal_Int32, OUString > Int2StringMap
bool extractBoolProperty(const Reference< XPropertySet > &descriptor, const OUString &name)
void fillAttnum2attnameMap(Int2StringMap &map, const Reference< css::sdbc::XConnection > &conn, const OUString &schema, const OUString &table)
std::map< OUString, rtl::Reference< Entity > > map
OUString PRIVATE_COLUMN_INDEXES
OUString IS_PRIMARY_KEY_INDEX