summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-07-27 13:34:22 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-07-27 17:48:43 +0200
commit8c54c132cac96bb13ff70d3920c81d126fd7c17d (patch)
tree253b6ca7f80fb6e9c8ea18e958a060f6eff54e53 /dbaccess
parent6837355d51430f66950f8b5b6f0b714ca15de1c5 (diff)
tdf#150089: not all databases know "RESTART WITH"
Regression from: https://cgit.freedesktop.org/libreoffice/core/commit tdf#119962 Fix autoincrement for copied table in 2021 so use the block added in the patch only when detecting "hsql" or "firebird" in the string returned by getDatabaseProductName put in lowercase Change-Id: Ic35a03039e6d06846892d93d5b30186c53f24052 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137499 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> (cherry picked from commit e9d046442c500c82b353d1e2e27b9adc22bf396b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137515 Reviewed-by: Lionel Mamane <lionel@mamane.lu> Tested-by: Jenkins
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx58
1 files changed, 31 insertions, 27 deletions
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 6196cba6678c..f7cf836be721 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -1346,42 +1346,46 @@ void CopyTableWizard::impl_doCopy_nothrow()
// tdf#119962
const Reference< XDatabaseMetaData > xDestMetaData( m_xDestConnection->getMetaData(), UNO_SET_THROW );
- const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, xTable, ::dbtools::EComposeRule::InDataManipulation, true );
+ OUString sDatabaseDest = xDestMetaData->getDatabaseProductName().toAsciiLowerCase();
+ if ( (sDatabaseDest.indexOf("hsql") != -1) || (sDatabaseDest.indexOf("firebird") != -1) )
+ {
+ const OUString sComposedTableName = ::dbtools::composeTableName( xDestMetaData, xTable, ::dbtools::EComposeRule::InDataManipulation, true );
- OUString aSchema,aTable;
- xTable->getPropertyValue("SchemaName") >>= aSchema;
- xTable->getPropertyValue("Name") >>= aTable;
- Any aCatalog = xTable->getPropertyValue("CatalogName");
+ OUString aSchema,aTable;
+ xTable->getPropertyValue("SchemaName") >>= aSchema;
+ xTable->getPropertyValue("Name") >>= aTable;
+ Any aCatalog = xTable->getPropertyValue("CatalogName");
- const Reference< XResultSet > xResultPKCL(xDestMetaData->getPrimaryKeys(aCatalog,aSchema,aTable));
- Reference< XRow > xRowPKCL(xResultPKCL, UNO_QUERY_THROW);
- OUString sPKCL;
- if ( xRowPKCL.is() )
- {
- if (xResultPKCL->next())
+ const Reference< XResultSet > xResultPKCL(xDestMetaData->getPrimaryKeys(aCatalog,aSchema,aTable));
+ Reference< XRow > xRowPKCL(xResultPKCL, UNO_QUERY_THROW);
+ OUString sPKCL;
+ if ( xRowPKCL.is() )
{
- sPKCL = xRowPKCL->getString(4);
+ if (xResultPKCL->next())
+ {
+ sPKCL = xRowPKCL->getString(4);
+ }
}
- }
- if (!sPKCL.isEmpty())
- {
- OUString strSql = "SELECT MAX(\"" + sPKCL + "\") FROM " + sComposedTableName;
+ if (!sPKCL.isEmpty())
+ {
+ OUString strSql = "SELECT MAX(\"" + sPKCL + "\") FROM " + sComposedTableName;
- Reference< XResultSet > xResultMAXNUM(m_xDestConnection->createStatement()->executeQuery(strSql));
- Reference< XRow > xRow(xResultMAXNUM, UNO_QUERY_THROW);
+ Reference< XResultSet > xResultMAXNUM(m_xDestConnection->createStatement()->executeQuery(strSql));
+ Reference< XRow > xRow(xResultMAXNUM, UNO_QUERY_THROW);
- sal_Int64 maxVal = -1L;
- if (xResultMAXNUM->next())
- {
- maxVal = xRow->getLong(1);
- }
+ sal_Int64 maxVal = -1L;
+ if (xResultMAXNUM->next())
+ {
+ maxVal = xRow->getLong(1);
+ }
- if (maxVal > 0L)
- {
- strSql = "ALTER TABLE " + sComposedTableName + " ALTER \"" + sPKCL + "\" RESTART WITH " + OUString::number(maxVal + 1);
+ if (maxVal > 0L)
+ {
+ strSql = "ALTER TABLE " + sComposedTableName + " ALTER \"" + sPKCL + "\" RESTART WITH " + OUString::number(maxVal + 1);
- m_xDestConnection->createStatement()->execute(strSql);
+ m_xDestConnection->createStatement()->execute(strSql);
+ }
}
}
}