22#include <com/sun/star/beans/PropertyAttribute.hpp>
23#include <com/sun/star/sdbcx/Privilege.hpp>
51 virtual OUString getDropForeignKey()
const override {
return " DROP FOREIGN KEY "; }
54 OMySQLKeysHelper(
OTableHelper* _pTable, ::osl::Mutex& _rMutex,
55 const ::std::vector<OUString>& _rVector)
63OMySQLTable::OMySQLTable(
sdbcx::OCollection* _pTables,
const Reference<XConnection>& _xConnection)
67 m_nPrivileges = Privilege::DROP | Privilege::REFERENCE | Privilege::ALTER | Privilege::CREATE
68 | Privilege::READ | Privilege::DELETE | Privilege::UPDATE | Privilege::INSERT
74 const OUString& Name,
const OUString&
Type,
const OUString& Description,
75 const OUString& SchemaName,
const OUString& CatalogName,
76 sal_Int32 _nPrivileges)
78 , m_nPrivileges(_nPrivileges)
111 return new OMySQLKeysHelper(
this,
m_aMutex, _rNames);
121 const Reference<XPropertySet>& descriptor)
126 ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
133 throw NoSuchElementException(colName, *
this);
138 Reference<XPropertySet> xProp;
141 sal_Int32 nOldType = 0, nNewType = 0, nOldPrec = 0, nNewPrec = 0, nOldScale = 0,
153 sal_Int32 nOldNullable = 0, nNewNullable = 0;
160 >>= bOldAutoIncrement;
163 bool bColumnNameChanged =
false;
164 OUString sOldDesc, sNewDesc;
168 if (nOldType != nNewType || nOldPrec != nNewPrec || nOldScale != nNewScale
169 || nNewNullable != nOldNullable || bOldAutoIncrement !=
bAutoIncrement
170 || sOldDesc != sNewDesc)
180 static const char s_sAutoIncrement[] =
"auto_increment";
183 if (sTypeName.indexOf(s_sAutoIncrement) == -1)
185 sTypeName += OUString::Concat(
" ") + s_sAutoIncrement;
192 if (!sTypeName.isEmpty())
194 sal_Int32
nIndex = sTypeName.indexOf(s_sAutoIncrement);
197 sTypeName = sTypeName.copy(0,
nIndex);
205 bColumnNameChanged =
true;
209 OUString sNewDefault, sOldDefault;
214 if (!sOldDefault.isEmpty())
217 if (!sNewDefault.isEmpty() && sOldDefault != sNewDefault)
220 else if (!sNewDefault.isEmpty())
224 OUString sNewColumnName;
226 if (!sNewColumnName.equalsIgnoreAsciiCase(colName) && !bColumnNameChanged)
249 const Reference<XPropertySet>& _xDescriptor)
256 ::comphelper::copyProperties(_xDescriptor, pColumn);
271 +
" SET DEFAULT '" + _sNewDefault +
"'";
287 OUString sSql(
"ALTER TABLE ");
291 ::dbtools::EComposeRule::InTableDefinitions));
299 OUString sSQL = _rStatement;
300 if (sSQL.endsWith(
","))
301 sSQL = sSQL.replaceAt(sSQL.getLength() - 1, 1,
u")");
303 Reference<XStatement> xStmt =
getConnection()->createStatement();
306 xStmt->execute(sSQL);
307 ::comphelper::disposeComponent(xStmt);
OptionalString sComposedName
::cppu::IPropertyArrayHelper * getArrayHelper(sal_Int32 nId)
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
void setParent(OTableHelper *_pTable)
set the parent of the columns.
css::uno::Reference< css::sdbc::XConnection > const & getConnection() const
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData() const override
virtual void construct() override
virtual sdbcx::OCollection * createKeys(const ::std::vector< OUString > &_rNames) override
creates the key collection for the table
virtual OUString getTypeCreatePattern() const override
OMySQLTable(sdbcx::OCollection *_pTables, const css::uno::Reference< css::sdbc::XConnection > &_xConnection)
void alterColumnType(sal_Int32 nNewType, const OUString &_rColName, const css::uno::Reference< css::beans::XPropertySet > &_xDescriptor)
virtual void SAL_CALL alterColumnByName(const OUString &colName, const css::uno::Reference< css::beans::XPropertySet > &descriptor) override
void dropDefaultValue(const OUString &_sNewDefault)
virtual sdbcx::OCollection * createColumns(const ::std::vector< OUString > &_rNames) override
creates the column collection for the table
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
void alterDefaultValue(std::u16string_view _sNewDefault, const OUString &_rColName)
virtual sdbcx::OCollection * createIndexes(const ::std::vector< OUString > &_rNames) override
creates the index collection for the table
void executeStatement(const OUString &_rStatement)
executes the statement.
OUString getAlterTableColumnPart() const
returns the ALTER TABLE XXX statement
virtual OUString getRenameStart() const override
Returns always "RENAME TABLE " even for views.
virtual ::cppu::IPropertyArrayHelper * createArrayHelper(sal_Int32 nId) const override
used to implement the creation of the array helper which is shared amongst all instances of the class...
static OUString adjustSQL(const OUString &_sSql)
convert the sql statement to fit MySQL notation
::cppu::IPropertyArrayHelper * doCreateArrayHelper() const
helper for derived classes to implement OPropertyArrayUsageHelper::createArrayHelper
std::unique_ptr< OCollection > m_xColumns
virtual void construct() override
mutable::osl::Mutex m_aMutex
void checkDisposed(bool _bThrow)
#define PROPERTY_ID_DESCRIPTION
#define PROPERTY_ID_PRIVILEGES
#define PROPERTY_ID_ISNULLABLE
#define PROPERTY_ID_PRECISION
#define PROPERTY_ID_ISAUTOINCREMENT
#define PROPERTY_ID_TYPENAME
#define PROPERTY_ID_DEFAULTVALUE
#define PROPERTY_ID_SCALE