diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index fc1b2ac38d82..46f563d62959 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -1205,7 +1206,18 @@ Reference< XPropertySet > OCopyTableWizard::createTable() if ( sSchema.isEmpty() && xMetaData->supportsSchemasInTableDefinitions() ) { + // query of current schema is quite inconsistent. In case of some + // DBMS's each user has their own schema. sSchema = xMetaData->getUserName(); + // In case of mysql it is not that simple + if(xMetaData->getDatabaseProductName() == "MySQL") + { + Reference< XStatement > xSelect = m_xDestConnection->createStatement(); + Reference< XResultSet > xRs = xSelect->executeQuery("select database()"); + xRs->next(); // first and only result + Reference< XRow > xRow( xRs, UNO_QUERY_THROW ); + sSchema = xRow->getString(1); + } } xTable->setPropertyValue(PROPERTY_CATALOGNAME,makeAny(sCatalog));