Tag: cws_src680_hsqlcsv User: fs Date: 2008-01-16 21:49:39+0000 Modified: dba/connectivity/source/drivers/hsqldb/HTable.cxx
Log: RESYNC: (1.10-1.12); FILE MERGED File Changes: Directory: /dba/connectivity/source/drivers/hsqldb/ =================================================== File [changed]: HTable.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HTable.cxx?r1=1.10.12.2&r2=1.10.12.3 Delta lines: +46 -25 --------------------- --- HTable.cxx 2006-12-18 11:31:39+0000 1.10.12.2 +++ HTable.cxx 2008-01-16 21:49:37+0000 1.10.12.3 @@ -104,6 +104,7 @@ #ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> #endif +#include <tools/diagnose_ex.h> using namespace ::comphelper; using namespace connectivity::hsqldb; @@ -263,6 +264,23 @@ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bOldAutoIncrement; descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement; + // now we should look if the name of the column changed + ::rtl::OUString sNewColumnName; + descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName; + if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) ) + { + const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( ); + + ::rtl::OUString sSql = getAlterTableColumnPart(); + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN ")); + sSql += ::dbtools::quoteName(sQuote,colName); + + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" RENAME TO ")); + sSql += ::dbtools::quoteName(sQuote,sNewColumnName); + + executeStatement(sSql); + } + if ( nOldType != nNewType || sOldTypeName != sNewTypeName || nOldPrec != nNewPrec @@ -276,7 +294,7 @@ { /// TODO: insert special handling for auto increment "IDENTITY" and primary key } - alterColumnType(nNewType,colName,descriptor); + alterColumnType(nNewType,sNewColumnName,descriptor); } // third: check the default values @@ -288,27 +306,11 @@ { dropDefaultValue(colName); if(sNewDefault.getLength() && sOldDefault != sNewDefault) - alterDefaultValue(sNewDefault,colName); + alterDefaultValue(sNewDefault,sNewColumnName); } else if(!sOldDefault.getLength() && sNewDefault.getLength()) - alterDefaultValue(sNewDefault,colName); - - // now we should look if the name of the column changed - ::rtl::OUString sNewColumnName; - descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName; - if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) ) - { - const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( ); + alterDefaultValue(sNewDefault,sNewColumnName); - ::rtl::OUString sSql = getAlterTableColumnPart(); - sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN ")); - sSql += ::dbtools::quoteName(sQuote,colName); - - sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" RENAME TO ")); - sSql += ::dbtools::quoteName(sQuote,sNewColumnName); - - executeStatement(sSql); - } m_pColumns->refresh(); } else @@ -327,8 +329,22 @@ ::rtl::OUString sSql = getAlterTableColumnPart(); sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN ")); - sSql += ::dbtools::quoteName( getMetaData()->getIdentifierQuoteString(), _rColName ); - sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); +#if OSL_DEBUG_LEVEL > 0 + try + { + ::rtl::OUString sDescriptorName; + OSL_ENSURE( _xDescriptor.is() + && ( _xDescriptor->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sDescriptorName ) + && ( sDescriptorName == _rColName ), + "OHSQLTable::alterColumnType: unexpected column name!" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +#else + (void)_rColName; +#endif OHSQLColumn* pColumn = new OHSQLColumn(sal_True); Reference<XPropertySet> xProp = pColumn; @@ -384,7 +400,12 @@ Reference< XStatement > xStmt = getConnection()->createStatement( ); if ( xStmt.is() ) { - xStmt->execute(sSQL); + try { xStmt->execute(sSQL); } + catch( const Exception& ) + { + ::comphelper::disposeComponent(xStmt); + throw; + } ::comphelper::disposeComponent(xStmt); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
