23#include <com/sun/star/sdb/tools/XIndexAlteration.hpp>
24#include <com/sun/star/sdbc/XRow.hpp>
25#include <com/sun/star/sdbc/XResultSet.hpp>
26#include <com/sun/star/sdbc/IndexType.hpp>
27#include <com/sun/star/sdbc/SQLException.hpp>
32#include <rtl/ustrbuf.hxx>
45 ::osl::Mutex& _rMutex,
46 const std::vector< OUString> &_rVector
57 if ( !xConnection.is() )
61 OUString
aName,aQualifier;
62 sal_Int32 nLen = _rName.indexOf(
'.');
65 aQualifier = _rName.copy(0,nLen);
66 aName = _rName.copy(nLen+1);
72 OUString aSchema,aTable;
77 Reference< XResultSet > xResult =
m_pTable->
getMetaData()->getIndexInfo(aCatalog,aSchema,aTable,
false,
false);
81 Reference< XRow > xRow(xResult,UNO_QUERY);
82 while( xResult->next() )
84 bool bUnique = !xRow->getBoolean(4);
85 if((aQualifier.isEmpty() || xRow->getString(5) == aQualifier ) && xRow->getString(6) ==
aName)
87 sal_Int32 nClustered = xRow->getShort(7);
88 bool bPrimarKeyIndex =
false;
94 xRow.set(xResult,UNO_QUERY);
96 if ( xRow.is() && xResult->next() )
98 bPrimarKeyIndex = xRow->getString(6) ==
aName;
106 nClustered == IndexType::CLUSTERED);
129 if ( !xConnection.is() )
141 OUStringBuffer aSql(
"CREATE " );
145 aSql.append(
"UNIQUE ");
146 aSql.append(
"INDEX ");
149 OUString aCatalog,aSchema,aTable;
153 if (!_rForName.isEmpty() )
160 Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
161 Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
162 Reference< XPropertySet > xColProp;
164 sal_Int32
nCount = xColumns->getCount();
167 xColProp.set(xColumns->getByIndex(
i),UNO_QUERY);
170 if ( bAddIndexAppendix )
181 aSql[aSql.getLength() - 1] =
')';
185 aSql.append(aComposedName);
187 Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
188 Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
189 Reference< XPropertySet > xColProp;
190 if(xColumns->getCount() != 1)
191 throw SQLException();
193 xColumns->getByIndex(0) >>= xColProp;
202 OUString sSql = aSql.makeStringAndClear();
203 xStmt->execute(sSql);
204 ::comphelper::disposeComponent(xStmt);
224 OUString
aName,aSchema;
225 sal_Int32 nLen = _sElementName.indexOf(
'.');
227 aSchema = _sElementName.copy(0,nLen);
228 aName = _sElementName.copy(nLen+1);
230 OUString aSql(
"DROP INDEX " );
235 aSql += sIndexName +
" ON " + aComposedName;
240 xStmt->execute(aSql);
241 ::comphelper::disposeComponent(xStmt);
virtual void dropObject(sal_Int32 _nPos, const OUString &_sElementName) override
virtual css::uno::Reference< css::beans::XPropertySet > createDescriptor() override
virtual sdbcx::ObjectType createObject(const OUString &_rName) override
virtual sdbcx::ObjectType appendObject(const OUString &_rForName, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
appends an object described by a descriptor, under a given name
virtual void impl_refresh() override
virtual void refreshIndexes() override
css::uno::Reference< css::sdbc::XConnection > const & getConnection() const
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData() const override
css::uno::Reference< css::sdb::tools::XIndexAlteration > const & getIndexService() const
virtual OUString SAL_CALL getName() override
ObjectType cloneDescriptor(const ObjectType &_descriptor)
clones the given descriptor
bool getBOOL(const Any &_rAny)
OUString getString(const Any &_rAny)
css::uno::Reference< css::beans::XPropertySet > ObjectType
bool any2bool(const css::uno::Any &rAny)
#define PROPERTY_ID_ISUNIQUE
#define PROPERTY_ID_CATALOGNAME
#define PROPERTY_ID_ISASCENDING
#define PROPERTY_ID_SCHEMANAME