summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2018-10-08 11:04:48 +0200
committerAndras Timar <andras.timar@collabora.com>2018-10-25 14:52:44 +0200
commit36defede63afe94e9bc6872eac955757c49452c1 (patch)
tree22808dc57e280b96da66d96190e50dea826236c9
parente840ab22b71898c07a4d44dbeae250f93b7b5983 (diff)
Revert removal of mysql jdbc connector
And also make some minor fixes so it cooperates with the new mysqlc library. Change-Id: I866add99a699150c6550ee7f7ff2ee947e07117c Reviewed-on: https://gerrit.libreoffice.org/61648 Tested-by: Jenkins Reviewed-by: Tamás Bunth <btomi96@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/62318 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--connectivity/Configuration_mysql.mk8
-rw-r--r--connectivity/Configuration_mysqlc.mk20
-rw-r--r--connectivity/Library_mysql.mk32
-rw-r--r--connectivity/Module_connectivity.mk5
-rw-r--r--connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu249
-rw-r--r--connectivity/source/drivers/mysql/YUser.cxx320
-rw-r--r--connectivity/source/drivers/mysql/mysql.component26
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx4
-rw-r--r--dbaccess/source/ui/dlg/generalpage.hxx5
-rw-r--r--mysqlc/Extension_mysql-connector-ooo.mk35
-rw-r--r--mysqlc/source/mysqlc_connection.hxx195
-rw-r--r--mysqlc/source/mysqlc_databasemetadata.cxx1234
-rw-r--r--mysqlc/source/mysqlc_driver.cxx317
-rw-r--r--mysqlc/source/mysqlc_driver.hxx124
-rw-r--r--mysqlc/source/mysqlc_general.cxx352
-rw-r--r--mysqlc/source/mysqlc_statement.hxx196
-rw-r--r--mysqlc/source/mysqlc_subcomponent.hxx201
-rw-r--r--postprocess/CustomTarget_registry.mk5
-rw-r--r--postprocess/Rdb_services.mk1
19 files changed, 665 insertions, 2664 deletions
diff --git a/connectivity/Configuration_mysql.mk b/connectivity/Configuration_mysql.mk
index 5ef54c70a80c..1cb07ca71441 100644
--- a/connectivity/Configuration_mysql.mk
+++ b/connectivity/Configuration_mysql.mk
@@ -7,13 +7,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-$(eval $(call gb_Configuration_Configuration,driver_mysqlc))
+$(eval $(call gb_Configuration_Configuration,driver_mysql))
-$(eval $(call gb_Configuration_add_spool_modules,driver_mysqlc,connectivity/registry/mysqlc,\
- org/openoffice/Office/DataAccess/Drivers-mysqlc.xcu \
+$(eval $(call gb_Configuration_add_spool_modules,driver_mysql,connectivity/registry/mysql,\
+ org/openoffice/Office/DataAccess/Drivers-mysql.xcu \
))
-$(eval $(call gb_Configuration_add_localized_datas,driver_mysqlc,connectivity/registry/mysqlc,\
+$(eval $(call gb_Configuration_add_localized_datas,driver_mysql,connectivity/registry/mysql,\
org/openoffice/Office/DataAccess/Drivers.xcu \
))
diff --git a/connectivity/Configuration_mysqlc.mk b/connectivity/Configuration_mysqlc.mk
new file mode 100644
index 000000000000..5ef54c70a80c
--- /dev/null
+++ b/connectivity/Configuration_mysqlc.mk
@@ -0,0 +1,20 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Configuration_Configuration,driver_mysqlc))
+
+$(eval $(call gb_Configuration_add_spool_modules,driver_mysqlc,connectivity/registry/mysqlc,\
+ org/openoffice/Office/DataAccess/Drivers-mysqlc.xcu \
+))
+
+$(eval $(call gb_Configuration_add_localized_datas,driver_mysqlc,connectivity/registry/mysqlc,\
+ org/openoffice/Office/DataAccess/Drivers.xcu \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Library_mysql.mk b/connectivity/Library_mysql.mk
index f82593c23d2e..ac3c0c2619e8 100644
--- a/connectivity/Library_mysql.mk
+++ b/connectivity/Library_mysql.mk
@@ -1,20 +1,48 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
+#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at http://mozilla.org/MPL/2.0/.
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Library_Library,mysql))
+$(eval $(call gb_Library_set_componentfile,mysql,connectivity/source/drivers/mysql/mysql))
+
+$(eval $(call gb_Library_use_external,mysql,boost_headers))
+
+$(eval $(call gb_Library_use_sdk_api,mysql))
+
+$(eval $(call gb_Library_set_include,mysql,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/connectivity/inc \
+ -I$(SRCDIR)/connectivity/source/inc \
+))
+
+$(eval $(call gb_Library_set_precompiled_header,mysql,$(SRCDIR)/connectivity/inc/pch/precompiled_mysql))
+
$(eval $(call gb_Library_use_libraries,mysql,\
+ cppu \
+ cppuhelper \
sal \
+ salhelper \
+ dbtools \
+ comphelper \
))
$(eval $(call gb_Library_add_exception_objects,mysql,\
- connectivity/source/drivers/mysqlc/mysql_dummy \
+ connectivity/source/drivers/mysql/YDriver \
+ connectivity/source/drivers/mysql/YTables \
+ connectivity/source/drivers/mysql/YTable \
+ connectivity/source/drivers/mysql/YViews \
+ connectivity/source/drivers/mysql/YCatalog \
+ connectivity/source/drivers/mysql/YColumns \
+ connectivity/source/drivers/mysql/YUser \
+ connectivity/source/drivers/mysql/YUsers \
+ connectivity/source/drivers/mysql/Yservices \
))
# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index 250172e936a1..4a579ddcb43b 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -40,6 +40,8 @@ ifneq ($(ENABLE_JAVA),)
$(eval $(call gb_Module_add_targets,connectivity,\
Configuration_hsqldb \
Configuration_jdbc \
+ Configuration_mysql \
+ Library_mysql \
Jar_sdbc_hsqldb \
Library_hsqldb \
Library_jdbc \
@@ -81,9 +83,8 @@ endif
ifeq ($(ENABLE_MARIADBC),TRUE)
$(eval $(call gb_Module_add_targets,connectivity,\
- Configuration_mysql \
+ Configuration_mysqlc \
Library_mysqlc \
- Library_mysql \
))
endif
diff --git a/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu
new file mode 100644
index 000000000000..faf9ddb9fa55
--- /dev/null
+++ b/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed" install:module="mysql">
+ <node oor:name="sdbc:mysql:jdbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (JDBC)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="JavaDriverClass" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>com.mysql.jdbc.Driver</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseJava" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:mysql:odbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (ODBC)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:mysql:mysqlc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (Native)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="LocalSocket" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="NamedPipe" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/mysql/YUser.cxx b/connectivity/source/drivers/mysql/YUser.cxx
new file mode 100644
index 000000000000..bc9c8c55b22e
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YUser.cxx
@@ -0,0 +1,320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <mysql/YUser.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include <TConnection.hxx>
+#include <strings.hrc>
+
+using namespace connectivity;
+using namespace connectivity::mysql;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OMySQLUser::OMySQLUser( const css::uno::Reference< css::sdbc::XConnection >& _xConnection) : connectivity::sdbcx::OUser(true)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+
+OMySQLUser::OMySQLUser( const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
+ const OUString& Name
+ ) : connectivity::sdbcx::OUser(Name,true)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+
+void OMySQLUser::refreshGroups()
+{
+}
+
+OUserExtend::OUserExtend( const css::uno::Reference< css::sdbc::XConnection >& _xConnection) : OMySQLUser(_xConnection)
+{
+ construct();
+}
+
+void OUserExtend::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::cppu::UnoType<OUString>::get());
+}
+
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+
+sal_Int32 SAL_CALL OMySQLUser::getPrivileges( const OUString& objName, sal_Int32 objType )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRights;
+}
+
+void OMySQLUser::findPrivilegesAndGrantPrivileges(const OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
+ Reference<XResultSet> xRes;
+ switch(objType)
+ {
+ case PrivilegeObject::TABLE:
+ case PrivilegeObject::VIEW:
+ {
+ Any aCatalog;
+ if ( !sCatalog.isEmpty() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
+ }
+ break;
+
+ case PrivilegeObject::COLUMN:
+ {
+ Any aCatalog;
+ if ( !sCatalog.isEmpty() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable, "%");
+ }
+ break;
+ }
+
+ if ( xRes.is() )
+ {
+ static const char sYes [] = "YES";
+
+ nRightsWithGrant = nRights = 0;
+
+ Reference<XRow> xCurrentRow(xRes,UNO_QUERY);
+ while( xCurrentRow.is() && xRes->next() )
+ {
+ OUString sGrantee = xCurrentRow->getString(5);
+ OUString sPrivilege = xCurrentRow->getString(6);
+ OUString sGrantable = xCurrentRow->getString(7);
+
+ if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
+ continue;
+
+ if (sPrivilege.equalsIgnoreAsciiCase("SELECT"))
+ {
+ nRights |= Privilege::SELECT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::SELECT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("INSERT"))
+ {
+ nRights |= Privilege::INSERT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::INSERT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("UPDATE"))
+ {
+ nRights |= Privilege::UPDATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::UPDATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("DELETE"))
+ {
+ nRights |= Privilege::DELETE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DELETE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("READ"))
+ {
+ nRights |= Privilege::READ;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::READ;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("CREATE"))
+ {
+ nRights |= Privilege::CREATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::CREATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("ALTER"))
+ {
+ nRights |= Privilege::ALTER;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::ALTER;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("REFERENCES"))
+ {
+ nRights |= Privilege::REFERENCE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::REFERENCE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase("DROP"))
+ {
+ nRights |= Privilege::DROP;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DROP;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+}
+
+sal_Int32 SAL_CALL OMySQLUser::getGrantablePrivileges( const OUString& objName, sal_Int32 objType )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+
+void SAL_CALL OMySQLUser::grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(!sPrivs.isEmpty())
+ {
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ OUString sGrant = "GRANT " + sPrivs +
+ " ON " + ::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation) +
+ " TO " + m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+void SAL_CALL OMySQLUser::revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(!sPrivs.isEmpty())
+ {
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ OUString sGrant = "REVOKE " + sPrivs +
+ " ON " + ::dbtools::quoteTableName(xMeta,objName,::dbtools::EComposeRule::InDataManipulation) +
+ " FROM " + m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+// XUser
+void SAL_CALL OMySQLUser::changePassword( const OUString& /*oldPassword*/, const OUString& newPassword )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ OUString sAlterPwd = "SET PASSWORD FOR " +
+ m_Name + "@\"%\" = PASSWORD('" +
+ newPassword + "')";
+
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+OUString OMySQLUser::getPrivilegeString(sal_Int32 nRights)
+{
+ OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += "INSERT";
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "DELETE";
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "UPDATE";
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "ALTER";
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "SELECT";
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(!sPrivs.isEmpty())
+ sPrivs += ",";
+ sPrivs += "REFERENCES";
+ }
+
+ return sPrivs;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mysql/mysql.component b/connectivity/source/drivers/mysql/mysql.component
new file mode 100644
index 000000000000..9c3e7ad7c6cd
--- /dev/null
+++ b/connectivity/source/drivers/mysql/mysql.component
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ prefix="mysql" xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="org.openoffice.comp.drivers.MySQL.Driver">
+ <service name="com.sun.star.sdbc.Driver"/>
+ <service name="com.sun.star.sdbcx.Driver"/>
+ </implementation>
+</component>
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
index adf5e01bde07..a0ff5233d6cf 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -124,6 +124,10 @@ namespace dbaui
const OUString sURLPrefix = aTypeLoop.getURLPrefix();
if ( !sURLPrefix.isEmpty() )
{
+ // skip mysql connection variations. It is handled in another window.
+ if(sURLPrefix.startsWith("sdbc:mysql:") && !sURLPrefix.startsWith("sdbc:mysql:jdbc:"))
+ continue;
+
OUString sDisplayName = aTypeLoop.getDisplayName();
if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
&& approveDatasourceType( sURLPrefix, sDisplayName ) )
diff --git a/dbaccess/source/ui/dlg/generalpage.hxx b/dbaccess/source/ui/dlg/generalpage.hxx
index e8a3f444806a..c8a597562362 100644
--- a/dbaccess/source/ui/dlg/generalpage.hxx
+++ b/dbaccess/source/ui/dlg/generalpage.hxx
@@ -85,6 +85,11 @@ namespace dbaui
virtual void fillWindows(std::vector< ISaveValueWrapper* >& _rControlList) override;
void onTypeSelected(const OUString& _sURLPrefix);
+
+ /**
+ * Initializes the listbox, which contains entires each representing a
+ * connection to an existing database.
+ */
void initializeTypeList();
void implSetCurrentType( const OUString& _eType );
diff --git a/mysqlc/Extension_mysql-connector-ooo.mk b/mysqlc/Extension_mysql-connector-ooo.mk
deleted file mode 100644
index 6cdf44967c6b..000000000000
--- a/mysqlc/Extension_mysql-connector-ooo.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_Extension_Extension,mysql-connector-ooo,mysqlc/source))
-
-$(eval $(call gb_Extension_use_default_description,mysql-connector-ooo,mysqlc/source/description-en-US.txt))
-$(eval $(call gb_Extension_use_default_license,mysql-connector-ooo))
-
-$(eval $(call gb_Extension_add_library,mysql-connector-ooo,mysqlc))
-
-$(eval $(call gb_Extension_add_file,mysql-connector-ooo,components.rdb,$(call gb_Rdb_get_target,mysqlc)))
-
-$(eval $(call gb_Extension_add_file,mysql-connector-ooo,registry/data/org/openoffice/Office/DataAccess/Drivers.xcu,$(call gb_XcuFile_for_extension,mysqlc/source/registry/data/org/openoffice/Office/DataAccess/Drivers.xcu)))
-
-$(eval $(call gb_Extension_add_files,mysql-connector-ooo,images,\
- $(SRCDIR)/icon-themes/galaxy/desktop/res/extension_32.png \
-))
-
-ifeq ($(SYSTEM_MYSQL_CONNECTOR_CPP),)
-$(eval $(call gb_Extension_add_library,mysql-connector-ooo,mysqlcppconn))
-endif
-
-ifneq ($(BUNDLE_MARIADB_CONNECTOR_C),)
-$(eval $(call gb_Extension_add_files,mysql-connector-ooo,,\
- $(LIBMARIADB_PATH)/$(LIBMARIADB) \
-))
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/mysqlc/source/mysqlc_connection.hxx b/mysqlc/source/mysqlc_connection.hxx
deleted file mode 100644
index 910a5a08d152..000000000000
--- a/mysqlc/source/mysqlc_connection.hxx
+++ /dev/null
@@ -1,195 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
-#define INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
-
-#include <memory>
-#include "mysqlc_subcomponent.hxx"
-#include "mysqlc_types.hxx"
-
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <com/sun/star/sdbc/ColumnSearch.hpp>
-#include <com/sun/star/sdbc/ColumnValue.hpp>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/SQLWarning.hpp>
-#include <com/sun/star/sdbc/XConnection.hpp>
-#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
-#include <com/sun/star/util/XStringSubstitution.hpp>
-
-#include <cppconn/driver.h>
-
-#include <cppuhelper/compbase3.hxx>
-#include <cppuhelper/weakref.hxx>
-#include <rtl/string.hxx>
-#include <rtl/ref.hxx>
-
-#include <mysql.h>
-
-#include <map>
-
-
-namespace sql
-{
- class SQLException;
-}
-
-namespace connectivity
-{
- class OMetaConnection;
- class ODatabaseMetaData;
-
- namespace mysqlc
- {
- using ::com::sun::star::sdbc::SQLWarning;
- using ::com::sun::star::sdbc::SQLException;
- using ::com::sun::star::uno::RuntimeException;
- typedef css::uno::Reference< css::container::XNameAccess > my_XNameAccessRef;
-
- typedef ::cppu::WeakComponentImplHelper3< css::sdbc::XConnection,
- css::sdbc::XWarningsSupplier,
- css::lang::XServiceInfo
- > OMetaConnection_BASE;
- struct ConnectionSettings
- {
- rtl_TextEncoding encoding;
- std::unique_ptr<sql::Connection> cppConnection;
- rtl::OUString schema;
- rtl::OUString connectionURL;
- bool readOnly;
- };
-
- class MysqlCDriver;
-
- typedef OMetaConnection_BASE OConnection_BASE;
-
- typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
-
- class OConnection final : public OBase_Mutex,
- public OConnection_BASE,
- public connectivity::mysqlc::OSubComponent<OConnection, OConnection_BASE>
- {
- private:
- MYSQL m_mysql;
- ConnectionSettings m_settings;
- css::uno::Reference< css::container::XNameAccess > m_typeMap;
- css::uno::Reference< css::util::XStringSubstitution > m_xParameterSubstitution;
-
- // Data attributes
-
- css::uno::WeakReference< css::sdbc::XDatabaseMetaData > m_xMetaData;
-
- OWeakRefArray m_aStatements; // vector containing a list
- // of all the Statement objects
- // for this Connection
-
- rtl::Reference<MysqlCDriver> m_xDriver; // Pointer to the owning driver object
- public:
- MYSQL* getMysqlConnection() { return &m_mysql; }
-
- /// @throws SQLException
- /// @throws RuntimeException
- sal_Int32 getMysqlVersion();
-
- /// @throws SQLException
- void construct(const rtl::OUString& url,const css::uno::Sequence< css::beans::PropertyValue >& info);
-
- OConnection(MysqlCDriver& _rDriver );
- virtual ~OConnection();
-
- rtl_TextEncoding getConnectionEncoding() const { return m_settings.encoding; }
-
-
- // OComponentHelper
- virtual void SAL_CALL disposing() SAL_OVERRIDE;
-
- // XInterface
- virtual void SAL_CALL release() throw() SAL_OVERRIDE;
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
-
- virtual sal_Bool SAL_CALL supportsService(
- rtl::OUString const & ServiceName)
- SAL_OVERRIDE;
-
- virtual css::uno::Sequence<rtl::OUString> SAL_CALL
- getSupportedServiceNames()
- SAL_OVERRIDE;
-
- // XConnection
- css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() SAL_OVERRIDE;
-
- css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const rtl::OUString& sql) SAL_OVERRIDE;
-
- css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const rtl::OUString& sql) SAL_OVERRIDE;
-
- rtl::OUString SAL_CALL nativeSQL(const rtl::OUString& sql) SAL_OVERRIDE;
-
- void SAL_CALL setAutoCommit(sal_Bool autoCommit) SAL_OVERRIDE;
-
- sal_Bool SAL_CALL getAutoCommit() SAL_OVERRIDE;
-
- void SAL_CALL commit() SAL_OVERRIDE;
-
- void SAL_CALL rollback() SAL_OVERRIDE;
-
- sal_Bool SAL_CALL isClosed() SAL_OVERRIDE;
-
- css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() SAL_OVERRIDE;
-
- void SAL_CALL setReadOnly(sal_Bool readOnly) SAL_OVERRIDE;
-
- sal_Bool SAL_CALL isReadOnly() SAL_OVERRIDE;
-
- void SAL_CALL setCatalog(const rtl::OUString& catalog) SAL_OVERRIDE;
-
- rtl::OUString SAL_CALL getCatalog() SAL_OVERRIDE;
-
- void SAL_CALL setTransactionIsolation(sal_Int32 level) SAL_OVERRIDE;
-
- sal_Int32 SAL_CALL getTransactionIsolation() SAL_OVERRIDE;
-
- my_XNameAccessRef SAL_CALL getTypeMap() SAL_OVERRIDE;
-
- void SAL_CALL setTypeMap(const my_XNameAccessRef& typeMap) SAL_OVERRIDE;
- // XCloseable
- void SAL_CALL close() SAL_OVERRIDE;
- // XWarningsSupplier
- css::uno::Any SAL_CALL getWarnings() SAL_OVERRIDE;
- void SAL_CALL clearWarnings() SAL_OVERRIDE;
-
- // TODO: Not used
- //sal_Int32 sdbcColumnType(rtl::OUString typeName);
- const ConnectionSettings& getConnectionSettings() const { return m_settings; }
- rtl::OUString transFormPreparedStatement(const rtl::OUString& _sSQL);
-
- const MysqlCDriver& getDriver() const { return *m_xDriver.get();}
-
- }; /* OConnection */
- // TODO: Not used.
- //inline rtl::OUString getPattern(rtl::OUString p) { return (p.getLength()) ? p : ASC2OU("%"); }
- } /* mysqlc */
-} /* connectivity */
-#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_databasemetadata.cxx b/mysqlc/source/mysqlc_databasemetadata.cxx
deleted file mode 100644
index 0f9e539e6df3..000000000000
--- a/mysqlc/source/mysqlc_databasemetadata.cxx
+++ /dev/null
@@ -1,1234 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#include "mysqlc_databasemetadata.hxx"
-#include <memory>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/ResultSetType.hpp>
-#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
-#include <com/sun/star/sdbc/TransactionIsolation.hpp>
-#include <com/sun/star/sdbc/KeyRule.hpp>
-#include <com/sun/star/sdbc/Deferrability.hpp>
-#include <com/sun/star/sdbc/IndexType.hpp>
-#include <com/sun/star/sdbc/BestRowScope.hpp>
-#include <com/sun/star/sdbc/ColumnType.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-
-#include <rtl/ustrbuf.hxx>
-#include "mysqlc_general.hxx"
-#include "mysqlc_statement.hxx"
-#include "mysqlc_driver.hxx"
-#include "mysqlc_preparedstatement.hxx"
-
-#include <stdio.h>
-
-using namespace connectivity::mysqlc;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::sdbc;
-using mysqlc_sdbc_driver::getStringFromAny;
-
-#include <sal/macros.h>
-
-static std::string wild("%");
-
-
-void lcl_setRows_throw(const Reference< XResultSet >& _xResultSet,sal_Int32 _nType,const std::vector< std::vector< Any > >& _rRows)
-{
- Reference< XInitialization> xIni(_xResultSet,UNO_QUERY);
- Sequence< Any > aArgs(2);
- aArgs[0] <<= _nType;
-
- Sequence< Sequence< Any > > aRows(_rRows.size());
-
- std::vector< std::vector< Any > >::const_iterator aIter = _rRows.begin();
- Sequence< Any > * pRowsIter = aRows.getArray();
- Sequence< Any > * pRowsEnd = pRowsIter + aRows.getLength();
- for (; pRowsIter != pRowsEnd;++pRowsIter,++aIter) {
- if (!aIter->empty()) {
- Sequence<Any> aSeq(&(*aIter->begin()),aIter->size());
- (*pRowsIter) = aSeq;
- }
- }
- aArgs[1] <<= aRows;
- xIni->initialize(aArgs);
-}
-
-ODatabaseMetaData::ODatabaseMetaData(OConnection& _rCon, MYSQL* pMySql)
- :m_rConnection(_rCon)
- ,m_pMySql(pMySql)
- ,identifier_quote_string_set(false)
-{
-}
-
-ODatabaseMetaData::~ODatabaseMetaData()
-{
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator()
-{
- return rtl::OUString();
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength()
-{
- return 16777208L;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize()
-{
- return 2147483647L - 8; // Max buffer size - HEADER
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength()
-{
- return 32;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength()
-{
- return 16777208;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex()
-{
- return 16;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections()
-{
- // TODO
- // SELECT @@max_connections
- return 100;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable()
-{
- return 512;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength()
-{
- // TODO
- // "SHOW VARIABLES LIKE 'max_allowed_packet'"
- return 32767;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect()
-{
- return 256;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers()
-{
- //TODO;
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn()
-{
- return true;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength()
-{
- return 256;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns()
-{
- return true;
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm()
-{
- return rtl::OUString("n/a");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString()
-{
- return rtl::OUString("\"");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters()
-{
- return rtl::OUString("#@");
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel(sal_Int32 /*level*/)
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins()
-{
- return true;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements()
-{
- return 0;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength()
-{
- return 64;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures()
-{
- return m_rConnection.getMysqlVersion() >= 50000;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate()
-{
- return m_rConnection.getMysqlVersion() >= 40000;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert(sal_Int32 /*fromType*/, sal_Int32 /*toType*/)
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion()
-{
- return m_rConnection.getMysqlVersion() >= 40000;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll()
-{
- return m_rConnection.getMysqlVersion() >= 40000;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers()
-{
- // TODO
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart()
-{
- return m_rConnection.getMysqlVersion() > 40001 && m_rConnection.getMysqlVersion() < 40011;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow()
-{
- return !nullsAreSortedHigh();
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls()
-{
- return m_rConnection.getMysqlVersion() >= 32200;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions()
-{
- return m_rConnection.getMysqlVersion() >= 32200;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries()
-{
- return m_rConnection.getMysqlVersion() >= 40100;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons()
-{
- return m_rConnection.getMysqlVersion() >= 40100;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists()
-{
- return m_rConnection.getMysqlVersion() >= 40100;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns()
-{
- return m_rConnection.getMysqlVersion() >= 40100;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds()
-{
- return m_rConnection.getMysqlVersion() >= 40100;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL()
-{
- return false;
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getURL()
-{
- return m_rConnection.getConnectionSettings().connectionURL;
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getUserName()
-{
- // TODO execute "SELECT USER()"
- return rtl::OUString();
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName()
-{
- return rtl::OUString( "MySQL Connector/OO.org" );
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion()
-{
- return rtl::OUString( "0.9.2" );
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion()
-{
- return rtl::OStringToOUString(mysql_get_server_info(m_pMySql),
- m_rConnection.getConnectionEncoding());
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName()
-{
- return rtl::OUString("MySQL");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm()
-{
- return rtl::OUString("procedure");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm()
-{
- return rtl::OUString("database");
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion()
-{
- // TODO
- return MARIADBC_VERSION_MAJOR;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation()
-{
- return m_rConnection.getMysqlVersion() >= 32336 ? TransactionIsolation::READ_COMMITTED :
- TransactionIsolation::NONE;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion()
-{
- // TODO
- return MARIADBC_VERSION_MINOR;
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords()
-{
- return rtl::OUString(
- "ACCESSIBLE, ADD, ALL,"\
- "ALTER, ANALYZE, AND, AS, ASC, ASENSITIVE, BEFORE,"\
- "BETWEEN, BIGINT, BINARY, BLOB, BOTH, BY, CALL,"\
- "CASCADE, CASE, CHANGE, CHAR, CHARACTER, CHECK,"\
- "COLLATE, COLUMN, CONDITION, CONNECTION, CONSTRAINT,"\
- "CONTINUE, CONVERT, CREATE, CROSS, CURRENT_DATE,"\
- "CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, CURSOR,"\
- "DATABASE, DATABASES, DAY_HOUR, DAY_MICROSECOND,"\
- "DAY_MINUTE, DAY_SECOND, DEC, DECIMAL, DECLARE,"\
- "DEFAULT, DELAYED, DELETE, DESC, DESCRIBE,"\
- "DETERMINISTIC, DISTINCT, DISTINCTROW, DIV, DOUBLE,"\
- "DROP, DUAL, EACH, ELSE, ELSEIF, ENCLOSED,"\
- "ESCAPED, EXISTS, EXIT, EXPLAIN, FALSE, FETCH,"\
- "FLOAT, FLOAT4, FLOAT8, FOR, FORCE, FOREIGN, FROM,"\
- "FULLTEXT, GRANT, GROUP, HAVING, HIGH_PRIORITY,"\
- "HOUR_MICROSECOND, HOUR_MINUTE, HOUR_SECOND, IF,"\
- "IGNORE, IN, INDEX, INFILE, INNER, INOUT,"\
- "INSENSITIVE, INSERT, INT, INT1, INT2, INT3, INT4,"\
- "INT8, INTEGER, INTERVAL, INTO, IS, ITERATE, JOIN,"\
- "KEY, KEYS, KILL, LEADING, LEAVE, LEFT, LIKE,"\
- "LOCALTIMESTAMP, LOCK, LONG, LONGBLOB, LONGTEXT,"\
- "LOOP, LOW_PRIORITY, MATCH, MEDIUMBLOB, MEDIUMINT,"\
- "MEDIUMTEXT, MIDDLEINT, MINUTE_MICROSECOND,"\
- "MINUTE_SECOND, MOD, MODIFIES, NATURAL, NOT,"\
- "NO_WRITE_TO_BINLOG, NULL, NUMERIC, ON, OPTIMIZE,"\
- "OPTION, OPTIONALLY, OR, ORDER, OUT, OUTER,"\
- "OUTFILE, PRECISION, PRIMARY, PROCEDURE, PURGE,"\
- "RANGE, READ, READS, READ_ONLY, READ_WRITE, REAL,"\
- "REFERENCES, REGEXP, RELEASE, RENAME, REPEAT,"\
- "REPLACE, REQUIRE, RESTRICT, RETURN, REVOKE, RIGHT,"\
- "RLIKE, SCHEMA, SCHEMAS, SECOND_MICROSECOND, SELECT,"\
- "SENSITIVE, SEPARATOR, SET, SHOW, SMALLINT, SPATIAL,"\
- "SPECIFIC, SQL, SQLEXCEPTION, SQLSTATE, SQLWARNING,"\
- "SQL_BIG_RESULT, SQL_CALC_FOUND_ROWS, SQL_SMALL_RESULT,"\
- "SSL, STARTING, STRAIGHT_JOIN, TABLE, TERMINATED,"\
- "THEN, TINYBLOB, TINYINT, TINYTEXT, TO, TRAILING,"\
- "TRIGGER, TRUE, UNDO, UNION, UNIQUE, UNLOCK,"\
- "UNSIGNED, UPDATE, USAGE, USE, USING, UTC_DATE,"\
- "UTC_TIME, UTC_TIMESTAMP, VALUES, VARBINARY, VARCHAR,"\
- "VARCHARACTER, VARYING, WHEN, WHERE, WHILE, WITH,"\
- "WRITE, X509, XOR, YEAR_MONTH, ZEROFILL" \
- "GENERAL, IGNORE_SERVER_IDS, MASTER_HEARTBEAT_PERIOD," \
- "MAXVALUE, RESIGNAL, SIGNAL, SLOW");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape()
-{
- return rtl::OUString("\\");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions()
-{
- return rtl::OUString(
- "ASCII,BIN,BIT_LENGTH,CHAR,CHARACTER_LENGTH,CHAR_LENGTH,CONCAT,"
- "CONCAT_WS,CONV,ELT,EXPORT_SET,FIELD,FIND_IN_SET,HEX,INSERT,"
- "INSTR,LCASE,LEFT,LENGTH,LOAD_FILE,LOCATE,LOCATE,LOWER,LPAD,"
- "LTRIM,MAKE_SET,MATCH,MID,OCT,OCTET_LENGTH,ORD,POSITION,"
- "QUOTE,REPEAT,REPLACE,REVERSE,RIGHT,RPAD,RTRIM,SOUNDEX,"
- "SPACE,STRCMP,SUBSTRING,SUBSTRING,SUBSTRING,SUBSTRING,"
- "SUBSTRING_INDEX,TRIM,UCASE,UPPER");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions()
-{
- return rtl::OUString(
- "DAYOFWEEK,WEEKDAY,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,"
- "MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,PERIOD_ADD,"
- "PERIOD_DIFF,TO_DAYS,FROM_DAYS,DATE_FORMAT,TIME_FORMAT,"
- "CURDATE,CURRENT_DATE,CURTIME,CURRENT_TIME,NOW,SYSDATE,"
- "CURRENT_TIMESTAMP,UNIX_TIMESTAMP,FROM_UNIXTIME,"
- "SEC_TO_TIME,TIME_TO_SEC");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions()
-{
- return rtl::OUString(
- "DATABASE,USER,SYSTEM_USER,"
- "SESSION_USER,PASSWORD,ENCRYPT,LAST_INSERT_ID,VERSION");
-}
-
-rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions()
-{
- return rtl::OUString("ABS,ACOS,ASIN,ATAN,ATAN2,BIT_COUNT,CEILING,COS,"
- "COT,DEGREES,EXP,FLOOR,LOG,LOG10,MAX,MIN,MOD,PI,POW,"
- "POWER,RADIANS,RAND,ROUND,SIN,SQRT,TAN,TRUNCATE");
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar()
-{
- return true;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins()
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins()
-{
- return true;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy()
-{
- return 64;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect()
-{
- return 256;
-}
-
-sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength()
-{
- return 16;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType(sal_Int32 setType)
-{
- return setType == ResultSetType::SCROLL_SENSITIVE;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency(sal_Int32 /*setType*/, sal_Int32 /*concurrency*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected(sal_Int32 /*setType*/)
-{
- return false;
-}
-
-sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates()
-{
- return true;
-}
-
-Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection()
-{
- return &m_rConnection;
-}
-
-/*
- Here follow all methods which return(a resultset
- the first methods is an example implementation how to use this resultset
- of course you could implement it on your and you should do this because
- the general way is more memory expensive
-*/
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes()
-{
- const char * const table_types[] = {"TABLE", "VIEW"};
- sal_Int32 const requiredVersion[] = {0, 50000};
-
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
-
- for (sal_uInt32 i = 0; i < 2; i++) {
- if (m_rConnection.getMysqlVersion() >= requiredVersion[i]) {
- std::vector< Any > aRow { Any() };
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(table_types[i], encoding)));
- rRows.push_back(aRow);
- }
- }
- lcl_setRows_throw(xResultSet, 5 ,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
-
- std::vector< std::vector< Any > > rRows;
-
- rtl_TextEncoding encoding = m_rConnection.getConnectionEncoding();
- unsigned int i = 0;
- while (mysqlc_types[i].typeName) {
- std::vector< Any > aRow { Any() };
-
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].typeName, encoding)));
- aRow.push_back(makeAny(mysqlc_types[i].dataType));
- aRow.push_back(makeAny(mysqlc_types[i].precision));
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].literalPrefix, encoding)));
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].literalSuffix, encoding)));
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].createParams, encoding)));
- aRow.push_back(makeAny(mysqlc_types[i].nullable));
- aRow.push_back(makeAny(mysqlc_types[i].caseSensitive));
- aRow.push_back(makeAny(mysqlc_types[i].searchable));
- aRow.push_back(makeAny(mysqlc_types[i].isUnsigned));
- aRow.push_back(makeAny(mysqlc_types[i].fixedPrecScale));
- aRow.push_back(makeAny(mysqlc_types[i].autoIncrement));
- aRow.push_back(makeAny(mysqlc_sdbc_driver::convert(mysqlc_types[i].localTypeName, encoding)));
- aRow.push_back(makeAny(mysqlc_types[i].minScale));
- aRow.push_back(makeAny(mysqlc_types[i].maxScale));
- aRow.push_back(makeAny(sal_Int32(0)));
- aRow.push_back(makeAny(sal_Int32(0)));
- aRow.push_back(makeAny(sal_Int32(10)));
-
- rRows.push_back(aRow);
- i++;
- }
-
- lcl_setRows_throw(xResultSet, 14, rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs()
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas()
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
-
- rtl::OUString sSql = m_rConnection.getMysqlVersion() > 49999?
- rtl::OUString{"SELECT SCHEMA_NAME AS TABLE_SCHEM, CATALOG_NAME AS TABLE_CATALOG FROM INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME"}:
- rtl::OUString{"SHOW DATABASES"};
-
- Reference< XStatement > statement = m_rConnection.createStatement();
- Reference< XInterface > executed = statement->executeQuery(sSql);
- Reference< XResultSet > rs( executed, UNO_QUERY_THROW);
- Reference< XResultSetMetaDataSupplier > supp( executed, UNO_QUERY_THROW);
- Reference< XResultSetMetaData > rs_meta = supp->getMetaData();
-
- Reference< XRow > xRow( rs, UNO_QUERY_THROW );
- sal_uInt32 columns = rs_meta->getColumnCount();
- while( rs->next() )
- {
- std::vector< Any > aRow { Any() };
- bool informationSchema = false;
- for (sal_uInt32 i = 1; i <= columns; i++) {
- rtl::OUString columnStringValue = xRow->getString(i);
- if (i == 1) { // TABLE_SCHEM
- informationSchema = (0 == columnStringValue.equalsIgnoreAsciiCase("information_schema"));
- }
- aRow.push_back(makeAny(columnStringValue));
- }
- if (!informationSchema ) {
- rRows.push_back(aRow);
- }
- }
-
- lcl_setRows_throw(xResultSet, 1, rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
- const Any& /*catalog*/,
- const rtl::OUString& schema,
- const rtl::OUString& table,
- const rtl::OUString& columnNamePattern)
-{
- rtl::OUString query("SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS "
- "TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, NULL AS GRANTOR, "
- "GRANTEE, PRIVILEGE_TYPE AS PRIVILEGE, IS_GRANTABLE FROM "
- "INFORMATION_SCHEMA.COLUMN_PRIVILEGES WHERE TABLE_SCHEMA LIKE "
- "'?' AND TABLE_NAME='?' AND COLUMN_NAME LIKE '?' ORDER BY "
- "COLUMN_NAME, PRIVILEGE_TYPE");
-
- query = query.replaceFirst("?", schema);
- query = query.replaceFirst("?", table);
- query = query.replaceFirst("?", columnNamePattern);
-
- Reference<XStatement> statement = m_rConnection.createStatement();
- Reference<XResultSet> rs = statement->executeQuery(query);
- return rs;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
- const Any& /*catalog*/,
- const rtl::OUString& /*schemaPattern*/,
- const rtl::OUString& tableNamePattern,
- const rtl::OUString& columnNamePattern)
-{
- rtl::OUStringBuffer queryBuf("SELECT TABLE_CATALOG AS TABLE_CAT, " // 1
- "TABLE_SCHEMA AS TABLE_SCHEM, " // 2
- "TABLE_NAME, " // 3
- "COLUMN_NAME, " // 4
- "DATA_TYPE, " // 5
- // TYPE_NAME missing
- "CHARACTER_MAXIMUM_LENGTH, " // 6
- "NUMERIC_PRECISION, " // 7
- // buffer length missing
- "NUMERIC_SCALE AS DECIMAL_DIGITS, " // 8
- // NUM_PREC_RADIX missing
- // NULLABLE missing
- "COLUMN_COMMENT AS REMARKS, " // 9
- "COLUMN_DEFAULT AS COLUMN_DEF," // 10
- "CHARACTER_OCTET_LENGTH, " // 11
- "ORDINAL_POSITION, " // 12
- "IS_NULLABLE, " // 13
- "COLUMN_TYPE " // 14
- "FROM INFORMATION_SCHEMA.COLUMNS "
- "WHERE (1 = 1) ");
-
- if (!tableNamePattern.isEmpty())
- {
- rtl::OUString sAppend;
- if (tableNamePattern.match("%"))
- sAppend = "AND TABLE_NAME LIKE '%' ";
- else
- sAppend = "AND TABLE_NAME = '%' ";
- queryBuf.append(sAppend.replaceAll("%", tableNamePattern));
- }
- if (!columnNamePattern.isEmpty())
- {
- rtl::OUString sAppend;
- if (columnNamePattern.match("%"))
- sAppend = "AND COLUMN_NAME LIKE '%' ";
- else
- sAppend = "AND COLUMN_NAME = '%' ";
- queryBuf.append(sAppend.replaceAll("%", columnNamePattern));
- }
-
- rtl::OUString query = queryBuf.makeStringAndClear();
- Reference<XStatement> statement = m_rConnection.createStatement();
- Reference<XResultSet> rs = statement->executeQuery(query.getStr());
- Reference<XRow> xRow( rs, UNO_QUERY_THROW );
-
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance(
- "org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > aRows;
- while( rs->next() )
- {
- std::vector< Any > aRow { Any() }; // 0. element is unused
-
- // catalog name
- aRow.push_back(makeAny(xRow->getString(1)));
- // schema name
- aRow.push_back(makeAny(xRow->getString(2)));
- // table name
- aRow.push_back(makeAny(xRow->getString(3)));
- // column name
- aRow.push_back(makeAny(xRow->getString(4)));
- // data type
- rtl::OUString sDataType = xRow->getString(5);
- aRow.push_back(makeAny(mysqlc_sdbc_driver::mysqlStrToOOOType(sDataType)));
- // type name
- aRow.push_back(makeAny(sDataType)); // TODO
- // column size
- sal_Int32 nColumnSize = 0;
- rtl::OUString sColumnType = xRow->getString(14);
- sal_Int32 nCharMaxLen = xRow->getShort(6);
- bool bIsCharMax = !xRow->wasNull();
- if( sDataType.equalsIgnoreAsciiCase("year") )
- nColumnSize = sColumnType.copy(6, 1).toInt32(); // 'year(' length is 5
- else if(sDataType.equalsIgnoreAsciiCase("date"))
- nColumnSize = 10;
- else if(sDataType.equalsIgnoreAsciiCase("date"))
- nColumnSize = 8;
- else if(sDataType.equalsIgnoreAsciiCase("datetime")
- || sDataType.equalsIgnoreAsciiCase("timestamp"))
- nColumnSize = 19;
- else if(!bIsCharMax)
- nColumnSize = xRow->getShort(7); // numeric precision
- else
- nColumnSize = nCharMaxLen;
- aRow.push_back(makeAny(nColumnSize));
- aRow.push_back( Any() ); // buffer length - unused
- // decimal digits (scale)
- aRow.push_back(makeAny(xRow->getShort(8)));
- // num_prec_radix
- aRow.push_back(makeAny(sal_Int32(10)));
- // nullable
- rtl::OUString sIsNullable = xRow->getString(13);
- if(xRow->wasNull())
- aRow.push_back(makeAny(ColumnValue::NULLABLE_UNKNOWN));
- else if(sIsNullable.equalsIgnoreAsciiCase("YES"))
- aRow.push_back(makeAny(ColumnValue::NULLABLE));
- else
- aRow.push_back(makeAny(ColumnValue::NO_NULLS));
- // remarks
- aRow.push_back(makeAny(xRow->getString(9)));
- // default
- aRow.push_back(makeAny(xRow->getString(10)));
-
- aRow.push_back( Any{} ); // sql_data_type - unused
- aRow.push_back( Any{} ); // sql_datetime_sub - unused
-
- // character octet length
- aRow.push_back(makeAny(xRow->getString(11)));
- // ordinal position
- aRow.push_back(makeAny(xRow->getString(12)));
- // is nullable
- aRow.push_back(makeAny(sIsNullable));
- aRows.push_back(aRow);
- }
- lcl_setRows_throw(xResultSet, 1, aRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
- const Any& /*catalog*/,
- const rtl::OUString& schemaPattern,
- const rtl::OUString& tableNamePattern,
- const Sequence< rtl::OUString >& /*types */)
-{
- rtl::OUString query("SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME,"
- "IF(STRCMP(TABLE_TYPE,'BASE TABLE'), TABLE_TYPE, 'TABLE') AS TABLE_TYPE, TABLE_COMMENT AS REMARKS "
- "FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA LIKE '?' AND TABLE_NAME LIKE '?' "
- "ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME");
-
- // TODO use prepared stmt instead
- // TODO escape schema, table name ?
- query = query.replaceFirst("?", schemaPattern);
- query = query.replaceFirst("?", tableNamePattern);
-
- Reference<XStatement> statement = m_rConnection.createStatement();
- Reference<XResultSet> rs = statement->executeQuery(query);
- return rs;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
- const Any& /* catalog */,
- const rtl::OUString& /* schemaPattern */,
- const rtl::OUString& /* procedureNamePattern */,
- const rtl::OUString& /* columnNamePattern */)
-{
- // Currently there is no information available
- return nullptr;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
- const Any& /*catalog*/,
- const rtl::OUString& /*schemaPattern*/,
- const rtl::OUString& /*procedureNamePattern*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO IMPL
- lcl_setRows_throw(xResultSet, 7,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
- const Any& /* catalog */,
- const rtl::OUString& /* schema */,
- const rtl::OUString& /* table */)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- lcl_setRows_throw(xResultSet, 16,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
- const Any& /*catalog */,
- const rtl::OUString& /*schema */,
- const rtl::OUString& /*table */)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO implement
- lcl_setRows_throw(xResultSet, 8, rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
- const Any& /*catalog*/,
- const rtl::OUString& /*schema*/,
- const rtl::OUString& /*table*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO implement
- lcl_setRows_throw(xResultSet,9,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
- const Any& /*catalog*/,
- const rtl::OUString& schema,
- const rtl::OUString& table)
-{
- rtl::OUString query("SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA "
- "AS TABLE_SCHEM, TABLE_NAME, " "COLUMN_NAME, SEQ_IN_INDEX AS KEY_SEQ,"
- "INDEX_NAME AS PK_NAME FROM INFORMATION_SCHEMA.STATISTICS "
- "WHERE TABLE_SCHEMA LIKE '?' AND TABLE_NAME LIKE '?' AND INDEX_NAME='PRIMARY' "
- "ORDER BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX");
-
- // TODO use prepared stmt instead
- // TODO escape schema, table name ?
- query = query.replaceFirst("?", schema);
- query = query.replaceFirst("?", table);
-
- Reference<XStatement> statement = m_rConnection.createStatement();
- Reference<XResultSet> rs = statement->executeQuery(query);
- return rs;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
- const Any& /*catalog*/,
- const rtl::OUString& /*schema*/,
- const rtl::OUString& /*table*/,
- sal_Bool /*unique*/,
- sal_Bool /*approximate*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO
- lcl_setRows_throw(xResultSet, 11, rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
- const Any& /*catalog*/,
- const rtl::OUString& /*schema*/,
- const rtl::OUString& /*table*/,
- sal_Int32 /*scope*/,
- sal_Bool /*nullable*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO
- lcl_setRows_throw(xResultSet, 15, rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
- const Any& /*catalog*/,
- const rtl::OUString& /*schemaPattern*/,
- const rtl::OUString& /*tableNamePattern*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO
- lcl_setRows_throw(xResultSet,12,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
- const Any& /*primaryCatalog*/,
- const rtl::OUString& /*primarySchema_*/,
- const rtl::OUString& /*primaryTable_*/,
- const Any& /*foreignCatalog*/,
- const rtl::OUString& /*foreignSchema*/,
- const rtl::OUString& /*foreignTable*/)
-{
- Reference< XResultSet > xResultSet(getOwnConnection().getDriver().getFactory()->createInstance("org.openoffice.comp.helper.DatabaseMetaDataResultSet"),UNO_QUERY);
- std::vector< std::vector< Any > > rRows;
- // TODO
- lcl_setRows_throw(xResultSet,13,rRows);
- return xResultSet;
-}
-
-Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs(
- const Any& /* catalog */,
- const rtl::OUString& /* schemaPattern */,
- const rtl::OUString& /* typeNamePattern */,
- const Sequence< sal_Int32 >& /* types */)
-{
- mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getUDTs", *this);
- return nullptr;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_driver.cxx b/mysqlc/source/mysqlc_driver.cxx
deleted file mode 100644
index efbc0777d57c..000000000000
--- a/mysqlc/source/mysqlc_driver.cxx
+++ /dev/null
@@ -1,317 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2008 by Sun Microsystems, Inc.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-************************************************************************/
-#include "mysqlc_driver.hxx"
-#include "mysqlc_connection.hxx"
-#include "mysqlc_general.hxx"
-
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::sdbc;
-using namespace connectivity::mysqlc;
-
-#include <cppuhelper/supportsservice.hxx>
-#include <stdio.h>
-
-#include <cppconn/exception.h>
-#ifdef SYSTEM_MYSQL_CPPCONN
- #include <mysql_driver.h>
-#endif
-
-MysqlCDriver::MysqlCDriver(const Reference< XMultiServiceFactory >& _rxFactory)
- : ODriver_BASE(m_aMutex)
- ,m_xFactory(_rxFactory)
-#ifndef SYSTEM_MYSQL_CPPCONN
- ,m_hCppConnModule( nullptr )
- ,m_bAttemptedLoadCppConn( false )
-#endif
-{
- cppDriver = nullptr;
-}
-
-void MysqlCDriver::disposing()
-{
- ::osl::MutexGuard aGuard(m_aMutex);
-
- // when driver will be destroyed so all our connections have to be destroyed as well
- for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
- {
- Reference< XComponent > xComp(i->get(), UNO_QUERY);
- if (xComp.is()) {
- xComp->dispose();
- }
- }
- m_xConnections.clear();
-
- ODriver_BASE::disposing();
-}
-
-// static ServiceInfo
-rtl::OUString MysqlCDriver::getImplementationName_Static()
-{
- return rtl::OUString( "com.sun.star.comp.sdbc.mysqlc.MysqlCDriver" );
-}
-
-Sequence< rtl::OUString > MysqlCDriver::getSupportedServiceNames_Static()
-{
- // which service is supported
- // for more information @see com.sun.star.sdbc.Driver
- Sequence< rtl::OUString > aSNS(1);
- aSNS[0] = "com.sun.star.sdbc.Driver";
- return aSNS;
-}
-
-rtl::OUString SAL_CALL MysqlCDriver::getImplementationName()
-{
- return getImplementationName_Static();
-}
-
-sal_Bool SAL_CALL MysqlCDriver::supportsService(const rtl::OUString& _rServiceName)
-{
- return cppu::supportsService(this, _rServiceName);
-}
-
-Sequence< rtl::OUString > SAL_CALL MysqlCDriver::getSupportedServiceNames()
-{
- return getSupportedServiceNames_Static();
-}
-
-#ifndef SYSTEM_MYSQL_CPPCONN
-extern "C" { static void SAL_CALL thisModule() {} }
-#endif
-
-void MysqlCDriver::impl_initCppConn_lck_throw()
-{
-#ifdef SYSTEM_MYSQL_CPPCONN
- cppDriver = get_driver_instance();
-#else
-#ifdef BUNDLE_MARIADB
- if ( !m_bAttemptedLoadCConn )
- {
- const rtl::OUString sModuleName(BUNDLE_MARIADB);
- m_hCConnModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
- m_bAttemptedLoadCConn = true;
- }
-
- // attempted to load - was it successful?
- if ( !m_hCConnModule )
- {
- OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not load the " BUNDLE_MARIADB " library!");
- throw SQLException(
- "Unable to load the " BUNDLE_MARIADB " library.",
- *this,
- rtl::OUString( "08001" ), // "unable to connect"
- 0,
- Any()
- );
- }
-#endif
- if ( !m_bAttemptedLoadCppConn )
- {
- const rtl::OUString sModuleName(CPPCONN_LIB);
- m_hCppConnModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
- m_bAttemptedLoadCppConn = true;
- }
-
- // attempted to load - was it successful?
- if ( !m_hCppConnModule )
- {
- OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not load the " CPPCONN_LIB " library!");
- throw SQLException(
- "Unable to load the " CPPCONN_LIB " library.",
- *this,
- rtl::OUString( "08001" ), // "unable to connect"
- 0,
- Any()
- );
- }
-
- // find the factory symbol
- const rtl::OUString sSymbolName = "sql_mysql_get_driver_instance";
- typedef void* (* FGetMySQLDriver)();
-
- const FGetMySQLDriver pFactoryFunction = reinterpret_cast<FGetMySQLDriver>( osl_getFunctionSymbol( m_hCppConnModule, sSymbolName.pData ) );
- if ( !pFactoryFunction )
- {
- OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not find the factory symbol in " CPPCONN_LIB "!");
- throw SQLException(
- CPPCONN_LIB " is invalid: missing the driver factory function.",
- *this,
- rtl::OUString( "08001" ), // "unable to connect"
- 0,
- Any()
- );
- }
-
- cppDriver = static_cast< sql::Driver* >( (*pFactoryFunction)() );
-#endif
- if ( !cppDriver )
- {
- throw SQLException(
- "Unable to obtain the MySQL_Driver instance from Connector/C++.",
- *this,
- rtl::OUString( "08001" ), // "unable to connect"
- 0,
- Any()
- );
- }
-}
-
-Reference< XConnection > SAL_CALL MysqlCDriver::connect(const rtl::OUString& url, const Sequence< PropertyValue >& info)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if (!acceptsURL(url)) {
- return nullptr;
- }
-
- if ( !cppDriver )
- {
- impl_initCppConn_lck_throw();
- if ( !cppDriver )
- throw RuntimeException("MySQLCDriver::connect: internal error.", *this );
- }
-
- Reference< XConnection > xConn;
- // create a new connection with the given properties and append it to our vector
- try {
- OConnection* pCon = new OConnection(*this);
- xConn = pCon;
-
- pCon->construct(url,info);
- m_xConnections.push_back(WeakReferenceHelper(*pCon));
- }
- catch (const sql::SQLException &e)
- {
- mysqlc_sdbc_driver::translateAndThrow(e, *this, getDefaultEncoding());
- }
- return xConn;
-}
-
-sal_Bool SAL_CALL MysqlCDriver::acceptsURL(const rtl::OUString& url)
-{
- return url.startsWith("sdbc:mysqlc:");
-}
-
-Sequence< DriverPropertyInfo > SAL_CALL MysqlCDriver::getPropertyInfo(const rtl::OUString& url, const Sequence< PropertyValue >& /* info */)
-{
- if (acceptsURL(url)) {
- ::std::vector< DriverPropertyInfo > aDriverInfo;
-
- aDriverInfo.push_back(DriverPropertyInfo(
- rtl::OUString("Hostname")
- ,rtl::OUString("Name of host")
- ,true
- ,rtl::OUString("localhost")
- ,Sequence< rtl::OUString >())
- );
- aDriverInfo.push_back(DriverPropertyInfo(
- rtl::OUString("Port")
- ,rtl::OUString("Port")
- ,true
- ,rtl::OUString("3306")
- ,Sequence< rtl::OUString >())
- );
- return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
- }
-
- return Sequence< DriverPropertyInfo >();
-}
-
-sal_Int32 SAL_CALL MysqlCDriver::getMajorVersion()
-{
- return MARIADBC_VERSION_MAJOR;
-}
-
-sal_Int32 SAL_CALL MysqlCDriver::getMinorVersion()
-{
- return MARIADBC_VERSION_MINOR;
-}
-
-namespace connectivity
-{
-namespace mysqlc
-{
-
-Reference< XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
-{
- return(*(new MysqlCDriver(_rxFactory)));
-}
-
-void release(oslInterlockedCount& _refCount,
- ::cppu::OBroadcastHelper& rBHelper,
- Reference< XInterface >& _xInterface,
- css::lang::XComponent* _pObject)
-{
- if (osl_atomic_decrement(&_refCount) == 0) {
- osl_atomic_increment(&_refCount);
-
- if (!rBHelper.bDisposed && !rBHelper.bInDispose) {
- // remember the parent
- Reference< XInterface > xParent;
- {
- ::osl::MutexGuard aGuard(rBHelper.rMutex);
- xParent = _xInterface;
- _xInterface = nullptr;
- }
-
- // First dispose
- _pObject->dispose();
-
- // only the alive ref holds the object
- OSL_ASSERT(_refCount == 1);
-
- // release the parent in the destructor
- if (xParent.is()) {
- ::osl::MutexGuard aGuard(rBHelper.rMutex);
- _xInterface = xParent;
- }
- }
- } else {
- osl_atomic_increment(&_refCount);
- }
-}
-
-void checkDisposed(bool _bThrow)
-{
- if (_bThrow) {
- throw DisposedException();
- }
-}
-
-} /* mysqlc */
-} /* connectivity */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_driver.hxx b/mysqlc/source/mysqlc_driver.hxx
deleted file mode 100644
index 7649fc51539e..000000000000
--- a/mysqlc/source/mysqlc_driver.hxx
+++ /dev/null
@@ -1,124 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2008 by Sun Microsystems, Inc.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-************************************************************************/
-
-#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
-#define INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
-
-#include <config_lgpl.h>
-
-#include "mysqlc_connection.hxx"
-
-#include <com/sun/star/sdbc/XDriver.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
-#include <cppuhelper/compbase2.hxx>
-#include <cppconn/driver.h>
-#include <osl/module.h>
-
-namespace connectivity
-{
- namespace mysqlc
- {
- using ::com::sun::star::sdbc::SQLException;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::uno::Sequence;
- /// @throws Exception
- Reference< css::uno::XInterface > SAL_CALL MysqlCDriver_CreateInstance(const Reference< css::lang::XMultiServiceFactory >& _rxFactory);
-
- typedef ::cppu::WeakComponentImplHelper2< css::sdbc::XDriver,
- css::lang::XServiceInfo > ODriver_BASE;
-
- typedef void* (SAL_CALL * OMysqlCConnection_CreateInstanceFunction)(void* _pDriver);
-
- class MysqlCDriver : public ODriver_BASE
- {
- protected:
- Reference< css::lang::XMultiServiceFactory > m_xFactory;
- ::osl::Mutex m_aMutex; // mutex is need to control member access
- OWeakRefArray m_xConnections; // vector containing a list
- // of all the Connection objects
- // for this Driver
-#ifndef SYSTEM_MYSQL_CPPCONN
-#ifdef BUNDLE_MARIADB
- oslModule m_hCConnModule;
- bool m_bAttemptedLoadCConn;
-#endif
- oslModule m_hCppConnModule;
- bool m_bAttemptedLoadCppConn;
-#endif
-
- sql::Driver * cppDriver;
-
- public:
-
- explicit MysqlCDriver(const Reference< css::lang::XMultiServiceFactory >& _rxFactory);
-
- // OComponentHelper
- void SAL_CALL disposing() SAL_OVERRIDE;
- // XInterface
- /// @throws RuntimeException
- static rtl::OUString getImplementationName_Static();
- /// @throws RuntimeException
- static Sequence< rtl::OUString > getSupportedServiceNames_Static();
-
- // XServiceInfo
- rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
- sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) SAL_OVERRIDE;
- Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() SAL_OVERRIDE;
-
- // XDriver
- Reference< css::sdbc::XConnection > SAL_CALL connect(const rtl::OUString& url, const Sequence< css::beans::PropertyValue >& info) SAL_OVERRIDE;
-
- sal_Bool SAL_CALL acceptsURL(const rtl::OUString& url) SAL_OVERRIDE;
- Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const rtl::OUString& url, const Sequence< css::beans::PropertyValue >& info) SAL_OVERRIDE;
-
- sal_Int32 SAL_CALL getMajorVersion() SAL_OVERRIDE;
- sal_Int32 SAL_CALL getMinorVersion() SAL_OVERRIDE;
-
- const Reference< css::lang::XMultiServiceFactory >& getFactory() const { return m_xFactory; }
-
- static rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; }
-
- private:
- void impl_initCppConn_lck_throw();
- };
- } /* mysqlc */
-} /* connectivity */
-
-#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_general.cxx b/mysqlc/source/mysqlc_general.cxx
deleted file mode 100644
index 8f3d0ed619d2..000000000000
--- a/mysqlc/source/mysqlc_general.cxx
+++ /dev/null
@@ -1,352 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#include "mysqlc_general.hxx"
-#include "mysqlc_resultsetmetadata.hxx"
-
-#include <rtl/ustring.hxx>
-
-using com::sun::star::sdbc::SQLException;
-
-using com::sun::star::uno::Reference;
-using com::sun::star::uno::XInterface;
-using com::sun::star::uno::Any;
-
-using namespace rtl;
-
-namespace mysqlc_sdbc_driver
-{
-
-void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize)
-{
- assert(mem);
- switch(eType)
- {
- case MYSQL_TYPE_LONG:
- case MYSQL_TYPE_INT24:
- *mem = malloc(sizeof(sal_Int32));
- break;
- case MYSQL_TYPE_SHORT:
- *mem = malloc(sizeof(sal_Int16));
- break;
- case MYSQL_TYPE_BIT:
- case MYSQL_TYPE_TINY:
- *mem = malloc(sizeof(sal_Int8));
- break;
- case MYSQL_TYPE_LONGLONG:
- *mem = malloc(sizeof(sal_Int64));
- break;
- case MYSQL_TYPE_FLOAT:
- *mem = malloc(sizeof(float));
- break;
- case MYSQL_TYPE_DOUBLE:
- *mem = malloc(sizeof(double));
- break;
- case MYSQL_TYPE_DATE:
- case MYSQL_TYPE_TIME:
- case MYSQL_TYPE_DATETIME:
- case MYSQL_TYPE_TIMESTAMP:
- case MYSQL_TYPE_YEAR: // FIXME below
- case MYSQL_TYPE_NEWDATE:
- case MYSQL_TYPE_ENUM:
- case MYSQL_TYPE_SET:
- case MYSQL_TYPE_GEOMETRY:
- *mem = malloc(sizeof(MYSQL_TIME));
- break;
- case MYSQL_TYPE_STRING:
- case MYSQL_TYPE_VAR_STRING:
- case MYSQL_TYPE_VARCHAR:
- case MYSQL_TYPE_DECIMAL:
- case MYSQL_TYPE_NEWDECIMAL:
- *mem = malloc(sizeof(char)*nSize);
- break;
- case MYSQL_TYPE_NULL:
- case MYSQL_TYPE_BLOB:
- case MYSQL_TYPE_TINY_BLOB:
- case MYSQL_TYPE_MEDIUM_BLOB:
- case MYSQL_TYPE_LONG_BLOB:
- *mem = nullptr;
- break;
- default:
- SAL_WARN("connectivity","unknown enum_field_type");
- }
-}
-
-/// Use this intead of mysql_real_escape_string, because that one also escapes
-/// single quote ('), which should not be escaped
-rtl::OString escapeSql( const rtl::OString& from )
-{
- rtl::OString sRet = from.replaceAll("\\", "\\\\");
- sRet = sRet.replaceAll("\"", "\\\"");
- sRet = sRet.replaceAll("`", "\\`");
- return sRet;
-}
-
-void throwFeatureNotImplementedException( const sal_Char* _pAsciiFeatureName, const css::uno::Reference< XInterface >& _rxContext )
-{
- const rtl::OUString sMessage = rtl::OUString::createFromAscii( _pAsciiFeatureName ) + ": feature not implemented.";
- throw SQLException(
- sMessage,
- _rxContext,
- rtl::OUString("HYC00"),
- 0,
- Any()
- );
-}
-
-void throwInvalidArgumentException( const sal_Char* _pAsciiFeatureName, const css::uno::Reference< XInterface >& _rxContext )
-{
- const rtl::OUString sMessage = rtl::OUString::createFromAscii( _pAsciiFeatureName ) + ": invalid arguments.";
- throw SQLException(
- sMessage,
- _rxContext,
- rtl::OUString("HYC00"),
- 0,
- Any()
- );
-}
-
-void translateAndThrow(const ::sql::SQLException& _error, const css::uno::Reference< css::uno::XInterface >& _context, const rtl_TextEncoding encoding)
-{
- throw SQLException(
- convert(_error.what(), encoding),
- _context,
- convert(_error.getSQLState(), encoding),
- _error.getErrorCode(),
- Any()
- );
-}
-
-void throwSQLExceptionWithMsg(const char* msg, unsigned int errorNum, const css::uno::Reference< css::uno::XInterface >& _context, const rtl_TextEncoding encoding)
-{
- rtl::OString errorMsg{msg};
- // TODO error code?
- throw SQLException( rtl::OStringToOUString(errorMsg, encoding),
- _context, rtl::OUString(), errorNum, Any());
-}
-
-rtl::OUString getStringFromAny(const Any& _rAny)
-{
- rtl::OUString nReturn;
- OSL_VERIFY( _rAny >>= nReturn );
- return nReturn;
-}
-
-int mysqlToOOOType(int eType, int charsetnr) noexcept
-{
- // charset number 63 indicates binary
- switch (eType) {
- case MYSQL_TYPE_BIT:
- return css::sdbc::DataType::VARCHAR;
-
- case MYSQL_TYPE_TINY:
- return css::sdbc::DataType::TINYINT;
-
- case MYSQL_TYPE_SHORT:
- return css::sdbc::DataType::SMALLINT;
-
- case MYSQL_TYPE_INT24:
- case MYSQL_TYPE_LONG:
- return css::sdbc::DataType::INTEGER;
-
- case MYSQL_TYPE_LONGLONG:
- return css::sdbc::DataType::BIGINT;
-
- case MYSQL_TYPE_FLOAT:
- return css::sdbc::DataType::REAL;
-
- case MYSQL_TYPE_DOUBLE:
- return css::sdbc::DataType::DOUBLE;
-
- case MYSQL_TYPE_DECIMAL:
- case MYSQL_TYPE_NEWDECIMAL:
- return css::sdbc::DataType::DECIMAL;
-
- case MYSQL_TYPE_STRING:
- if(charsetnr == 63)
- return css::sdbc::DataType::BINARY;
- return css::sdbc::DataType::CHAR;
-
- case MYSQL_TYPE_ENUM:
- case MYSQL_TYPE_SET:
- case MYSQL_TYPE_VAR_STRING:
- if(charsetnr == 63)
- return css::sdbc::DataType::VARBINARY;
- return css::sdbc::DataType::VARCHAR;
-
- case MYSQL_TYPE_BLOB:
- if(charsetnr == 63)
- return css::sdbc::DataType::LONGVARBINARY;
- return css::sdbc::DataType::LONGVARCHAR;
-
- case MYSQL_TYPE_TIMESTAMP:
- case MYSQL_TYPE_DATETIME:
- return css::sdbc::DataType::TIMESTAMP;
-
- case MYSQL_TYPE_DATE:
- return css::sdbc::DataType::DATE;
-
- case MYSQL_TYPE_TIME:
- return css::sdbc::DataType::TIME;
-
- case MYSQL_TYPE_GEOMETRY:
- return css::sdbc::DataType::VARCHAR;
-
- case MYSQL_TYPE_NULL:
- return css::sdbc::DataType::SQLNULL;
- }
-
- OSL_FAIL( "mysqlToOOOType: unhandled case, falling back to VARCHAR" );
- return css::sdbc::DataType::VARCHAR;
-}
-
-int mysqlStrToOOOType(const rtl::OUString& sType)
-{
- // TODO other types.
- if(sType.equalsIgnoreAsciiCase("tiny") || sType.equalsIgnoreAsciiCase("tinyint"))
- return css::sdbc::DataType::TINYINT;
- if(sType.equalsIgnoreAsciiCase("smallint"))
- return css::sdbc::DataType::SMALLINT;
- if(sType.equalsIgnoreAsciiCase("longtext"))
- return css::sdbc::DataType::LONGVARCHAR;
- if(sType.equalsIgnoreAsciiCase("int"))
- return css::sdbc::DataType::INTEGER;
- if(sType.equalsIgnoreAsciiCase("varchar") || sType.equalsIgnoreAsciiCase("set") ||
- sType.equalsIgnoreAsciiCase("enum"))
- return css::sdbc::DataType::VARCHAR;
- if(sType.equalsIgnoreAsciiCase("bigint"))
- return css::sdbc::DataType::BIGINT;
- if(sType.equalsIgnoreAsciiCase("blob") || sType.equalsIgnoreAsciiCase("longblob"))
- return css::sdbc::DataType::BLOB;
- if(sType.equalsIgnoreAsciiCase("varbinary"))
- return css::sdbc::DataType::VARBINARY;
- if(sType.equalsIgnoreAsciiCase("text"))
- return css::sdbc::DataType::CHAR;
- if(sType.equalsIgnoreAsciiCase("binary"))
- return css::sdbc::DataType::BINARY;
- if(sType.equalsIgnoreAsciiCase("time"))
- return css::sdbc::DataType::TIME;
- if(sType.equalsIgnoreAsciiCase("date"))
- return css::sdbc::DataType::DATE;
- if(sType.equalsIgnoreAsciiCase("datetime"))
- return css::sdbc::DataType::TIMESTAMP;
- if(sType.equalsIgnoreAsciiCase("decimal"))
- return css::sdbc::DataType::DECIMAL;
- if(sType.equalsIgnoreAsciiCase("real") || sType.equalsIgnoreAsciiCase("float"))
- return css::sdbc::DataType::REAL;
- if(sType.equalsIgnoreAsciiCase("double"))
- return css::sdbc::DataType::DOUBLE;
- if(sType.equalsIgnoreAsciiCase("bit") || sType.equalsIgnoreAsciiCase("bool") ||
- sType.equalsIgnoreAsciiCase("boolean"))
- return css::sdbc::DataType::BOOLEAN;
- OSL_FAIL("Unknown type name from string, failing back to varchar.");
- return css::sdbc::DataType::VARCHAR;
-}
-
-rtl::OUString mysqlTypeToStr(MYSQL_FIELD* field)
-{
- bool isUnsigned = (field->flags & UNSIGNED_FLAG) != 0;
- bool isZerofill = (field->flags & ZEROFILL_FLAG) != 0;
- switch (field->type)
- {
- case MYSQL_TYPE_BIT:
- return OUString{"BIT"};
- case MYSQL_TYPE_DECIMAL:
- case MYSQL_TYPE_NEWDECIMAL:
- return isUnsigned ? (isZerofill? OUString{"DECIMAL UNSIGNED ZEROFILL"} : OUString{"DECIMAL UNSIGNED"}): OUString{"DECIMAL"};
- case MYSQL_TYPE_TINY:
- return isUnsigned ? (isZerofill? OUString{"TINYINT UNSIGNED ZEROFILL"} : OUString{"TINYINT UNSIGNED"}): OUString{"TINYINT"};
- case MYSQL_TYPE_SHORT:
- return isUnsigned ? (isZerofill? OUString{"SMALLINT UNSIGNED ZEROFILL"} : OUString{"SMALLINT UNSIGNED"}): OUString{"SMALLINT"};
- case MYSQL_TYPE_LONG:
- return isUnsigned ? (isZerofill? OUString{"INT UNSIGNED ZEROFILL"} : OUString{"INT UNSIGNED"}): OUString{"INT"};
- case MYSQL_TYPE_FLOAT:
- return isUnsigned ? (isZerofill? OUString{"FLOAT UNSIGNED ZEROFILL"} : OUString{"FLOAT UNSIGNED"}): OUString{"FLOAT"};
- case MYSQL_TYPE_DOUBLE:
- return isUnsigned ? (isZerofill? OUString{"DOUBLE UNSIGNED ZEROFILL"} : OUString{"DOUBLE UNSIGNED"}): OUString{"DOUBLE"};
- case MYSQL_TYPE_NULL:
- return OUString{"NULL"};
- case MYSQL_TYPE_TIMESTAMP:
- return OUString{"TIMESTAMP"};
- case MYSQL_TYPE_LONGLONG:
- return isUnsigned ? (isZerofill? OUString{"BIGINT UNSIGNED ZEROFILL"} : OUString{"BIGINT UNSIGNED"}) : OUString{"BIGINT"};
- case MYSQL_TYPE_INT24:
- return isUnsigned ? (isZerofill? OUString{"MEDIUMINT UNSIGNED ZEROFILL"} : OUString{"MEDIUMINT UNSIGNED"}) : OUString{"MEDIUMINT"};
- case MYSQL_TYPE_DATE:
- return OUString{"DATE"};
- case MYSQL_TYPE_TIME:
- return OUString{"TIME"};
- case MYSQL_TYPE_DATETIME:
- return OUString{"DATETIME"};
- case MYSQL_TYPE_TINY_BLOB:
- {
- return OUString{"TINYBLOB"};
- }
- case MYSQL_TYPE_MEDIUM_BLOB:
- {
- return OUString{"MEDIUMBLOB"};
- }
- case MYSQL_TYPE_LONG_BLOB:
- {
- return OUString{"LONGBLOB"};
- }
- case MYSQL_TYPE_BLOB:
- {
- return OUString{"BLOB"};
- }
- case MYSQL_TYPE_VARCHAR:
- case MYSQL_TYPE_VAR_STRING:
- if (field->flags & ENUM_FLAG) {
- return OUString{"ENUM"};
- }
- if (field->flags & SET_FLAG) {
- return OUString{"SET"};
- }
- return OUString{"VARCHAR"};
- case MYSQL_TYPE_STRING:
- if (field->flags & ENUM_FLAG) {
- return OUString{"ENUM"};
- }
- if (field->flags & SET_FLAG) {
- return OUString{"SET"};
- }
- return OUString{"CHAR"};
- case MYSQL_TYPE_YEAR:
- return OUString{"YEAR"};
- case MYSQL_TYPE_GEOMETRY:
- return OUString{"GEOMETRY"};
- default:
- return OUString{"UNKNOWN"};
- }
-
-}
-
-rtl::OUString convert(const ::std::string& _string, const rtl_TextEncoding encoding)
-{
- return rtl::OUString( _string.c_str(), _string.size(), encoding );
-}
-
-::std::string convert(const rtl::OUString& _string, const rtl_TextEncoding encoding)
-{
- return ::std::string( rtl::OUStringToOString( _string, encoding ).getStr() );
-}
-
-
-} /* namespace */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_statement.hxx b/mysqlc/source/mysqlc_statement.hxx
deleted file mode 100644
index 76cef613fec0..000000000000
--- a/mysqlc/source/mysqlc_statement.hxx
+++ /dev/null
@@ -1,196 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
-#define INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
-
-#include "mysqlc_connection.hxx"
-#include "mysqlc_subcomponent.hxx"
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdbc/SQLWarning.hpp>
-#include <com/sun/star/sdbc/XBatchExecution.hpp>
-#include <com/sun/star/sdbc/XCloseable.hpp>
-#include <com/sun/star/sdbc/XMultipleResults.hpp>
-#include <com/sun/star/sdbc/XStatement.hpp>
-#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
-#include <com/sun/star/util/XCancellable.hpp>
-
-#include <cppconn/statement.h>
-#include <cppuhelper/compbase5.hxx>
-#include <rtl/ref.hxx>
-
-namespace connectivity
-{
- namespace mysqlc
- {
- using ::com::sun::star::sdbc::SQLWarning;
- using ::com::sun::star::sdbc::SQLException;
- using ::com::sun::star::uno::Any;
- using ::com::sun::star::uno::RuntimeException;
-
- typedef ::cppu::WeakComponentImplHelper5< css::sdbc::XStatement,
- css::sdbc::XWarningsSupplier,
- css::util::XCancellable,
- css::sdbc::XCloseable,
- css::sdbc::XMultipleResults> OCommonStatement_IBase;
-
- class OCommonStatement;
- typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase;
-
-
- //************ Class: OCommonStatement
- // is a base class for the normal statement and for the prepared statement
-
- class OCommonStatement :public OBase_Mutex
- ,public OCommonStatement_IBase
- ,public ::cppu::OPropertySetHelper
- ,public OPropertyArrayUsageHelper<OCommonStatement>
- ,public OStatement_CBase
-
- {
- friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >;
-
- private:
- SQLWarning m_aLastWarning;
-
- protected:
- rtl::Reference<OConnection> m_xConnection; // The owning Connection object
-
- css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
- MYSQL_RES* m_pMysqlResult = nullptr;
-
- // number of rows affected by an UPDATE, DELETE or INSERT statement.
- sal_Int32 m_nAffectedRows = 0;
-
- protected:
- void disposeResultSet();
-
- // OPropertyArrayUsageHelper
- ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
-
- // OPropertySetHelper
- ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
- sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue,
- sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
-
- void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
-
- void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
- virtual ~OCommonStatement();
-
- protected:
- OCommonStatement(OConnection* _pConnection);
-
- public:
- using OCommonStatement_IBase::rBHelper;
- using OCommonStatement_IBase::operator css::uno::Reference< css::uno::XInterface >;
-
- // OComponentHelper
- void SAL_CALL disposing() SAL_OVERRIDE;
-
- // XInterface
- void SAL_CALL release() throw() SAL_OVERRIDE;
-
- void SAL_CALL acquire() throw() SAL_OVERRIDE;
-
- // XInterface
- Any SAL_CALL queryInterface(const css::uno::Type & rType) SAL_OVERRIDE;
-
- //XTypeProvider
- css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE;
-
- // XPropertySet
- css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() SAL_OVERRIDE;
-
- // XStatement
- css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const rtl::OUString& sql) SAL_OVERRIDE;
-
- sal_Int32 SAL_CALL executeUpdate(const rtl::OUString& sql) SAL_OVERRIDE;
-
- sal_Bool SAL_CALL execute( const rtl::OUString& sql ) SAL_OVERRIDE;
-
- css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() SAL_OVERRIDE;
-
- // XWarningsSupplier
- Any SAL_CALL getWarnings() SAL_OVERRIDE;
-
- void SAL_CALL clearWarnings() SAL_OVERRIDE;
-
- // XCancellable
- void SAL_CALL cancel() SAL_OVERRIDE;
-
- // XCloseable
- void SAL_CALL close() SAL_OVERRIDE;
-
- // XMultipleResults
- css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() SAL_OVERRIDE;
-
- sal_Int32 SAL_CALL getUpdateCount() SAL_OVERRIDE;
-
- sal_Bool SAL_CALL getMoreResults() SAL_OVERRIDE;
-
- // other methods
- OConnection* getOwnConnection() const { return m_xConnection.get();}
-
- private:
- using ::cppu::OPropertySetHelper::getFastPropertyValue;
- };
-
-
- class OStatement final : public OCommonStatement,
- public css::sdbc::XBatchExecution,
- public css::lang::XServiceInfo
-
- {
- virtual ~OStatement(){}
-
- public:
- // A constructor which is required for the return of the objects
- OStatement(OConnection* _pConnection) :
- OCommonStatement(_pConnection) {}
-
- virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
-
- virtual sal_Bool SAL_CALL supportsService(
- rtl::OUString const & ServiceName)
- SAL_OVERRIDE;
-
- virtual css::uno::Sequence<rtl::OUString> SAL_CALL
- getSupportedServiceNames()
- SAL_OVERRIDE;
-
- Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
-
- void SAL_CALL acquire() throw() SAL_OVERRIDE;
- void SAL_CALL release() throw() SAL_OVERRIDE;
-
- // XBatchExecution
- void SAL_CALL addBatch(const rtl::OUString& sql) SAL_OVERRIDE;
-
- void SAL_CALL clearBatch() SAL_OVERRIDE;
-
- css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() SAL_OVERRIDE;
-
- };
- }
-}
-#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/mysqlc/source/mysqlc_subcomponent.hxx b/mysqlc/source/mysqlc_subcomponent.hxx
deleted file mode 100644
index c0dc8eb3acb2..000000000000
--- a/mysqlc/source/mysqlc_subcomponent.hxx
+++ /dev/null
@@ -1,201 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
-#define INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
-
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <cppuhelper/interfacecontainer.h>
-#include <cppuhelper/propshlp.hxx>
-#include <cppuhelper/supportsservice.hxx>
-#include <cppuhelper/weak.hxx>
-#include <osl/diagnose.h>
-#include <osl/mutex.hxx>
-
-namespace cppu {
- class IPropertyArrayHelper;
-}
-
-namespace com
-{
- namespace sun
- {
- namespace star
- {
- namespace lang
- {
- class XComponent;
- }
- }
- }
-}
-
-namespace connectivity
-{
- namespace mysqlc
- {
- void release(oslInterlockedCount& _refCount,
- ::cppu::OBroadcastHelper& rBHelper,
- css::uno::Reference< css::uno::XInterface >& _xInterface,
- css::lang::XComponent* _pObject);
-
- /// @throws css::lang::DisposedException
- void checkDisposed(bool _bThrow);
-
- template <class SELF, class WEAK> class OSubComponent
- {
- protected:
- // the parent must support the tunnel implementation
- css::uno::Reference< css::uno::XInterface > m_xParent;
- SELF* m_pDerivedImplementation;
-
- public:
- OSubComponent(
- const css::uno::Reference< css::uno::XInterface >& _xParent,
- SELF* _pDerivedImplementation)
- :m_xParent(_xParent)
- ,m_pDerivedImplementation(_pDerivedImplementation)
- {
- }
-
- protected:
- void dispose_ChildImpl()
- {
- ::osl::MutexGuard aGuard(m_pDerivedImplementation->rBHelper.rMutex);
- m_xParent = nullptr;
- }
- void release_ChildImpl()
- {
- release(m_pDerivedImplementation->m_refCount,
- m_pDerivedImplementation->rBHelper,
- m_xParent,
- m_pDerivedImplementation);
-
- m_pDerivedImplementation->WEAK::release();
- }
- };
-
- template <class TYPE>
- class OPropertyArrayUsageHelper
- {
- protected:
- static sal_Int32 s_nRefCount;
- static ::cppu::IPropertyArrayHelper* s_pProps;
- static ::osl::Mutex s_aMutex;
-
- public:
- OPropertyArrayUsageHelper();
- virtual ~OPropertyArrayUsageHelper();
-
- /** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
- class, which is created if necessary.
- */
- ::cppu::IPropertyArrayHelper* getArrayHelper();
-
- protected:
- /** used to implement the creation of the array helper which is shared amongst all instances of the class.
- This method needs to be implemented in derived classes.
- <BR>
- The method gets called with s_aMutex acquired.
- @return an pointer to the newly created array helper. Must not be NULL.
- */
- virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const = 0;
- };
-
- template<class TYPE>
- sal_Int32 OPropertyArrayUsageHelper< TYPE >::s_nRefCount = 0;
-
- template<class TYPE>
- ::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper< TYPE >::s_pProps = nullptr;
-
- template<class TYPE>
- ::osl::Mutex OPropertyArrayUsageHelper< TYPE >::s_aMutex;
-
- template <class TYPE>
- OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
- {
- ::osl::MutexGuard aGuard(s_aMutex);
- ++s_nRefCount;
- }
-
- template <class TYPE>
- OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
- {
- ::osl::MutexGuard aGuard(s_aMutex);
- OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
- if (!--s_nRefCount)
- {
- delete s_pProps;
- s_pProps = nullptr;
- }
- }
-
- template <class TYPE>
- ::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
- {
- OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
- if (!s_pProps) {
- ::osl::MutexGuard aGuard(s_aMutex);
- if (!s_pProps) {
- s_pProps = createArrayHelper();
- OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
- }
- }
- return s_pProps;
- }
-
- class OBase_Mutex
- {
- public:
- ::osl::Mutex m_aMutex;
- };
-
- namespace internal
- {
- template <class T>
- void implCopySequence(const T* _pSource, T*& _pDest, sal_Int32 _nSourceLen)
- {
- for (sal_Int32 i=0; i<_nSourceLen; ++i, ++_pSource, ++_pDest)
- *_pDest = *_pSource;
- }
- }
-
- /// concat two sequences
- template <class T>
- css::uno::Sequence<T> concatSequences(const css::uno::Sequence<T>& _rLeft, const css::uno::Sequence<T>& _rRight)
- {
- sal_Int32 nLeft(_rLeft.getLength()), nRight(_rRight.getLength());
- const T* pLeft = _rLeft.getConstArray();
- const T* pRight = _rRight.getConstArray();
-
- sal_Int32 nReturnLen(nLeft + nRight);
- css::uno::Sequence<T> aReturn(nReturnLen);
- T* pReturn = aReturn.getArray();
-
- internal::implCopySequence(pLeft, pReturn, nLeft);
- internal::implCopySequence(pRight, pReturn, nRight);
-
- return aReturn;
- }
- }
-}
-
-#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk
index 360b9eedcb9f..b5a9784bf5d7 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -334,8 +334,9 @@ endif
ifeq ($(ENABLE_JAVA),TRUE)
postprocess_FILES_main += \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/hsqldb)/org/openoffice/Office/DataAccess/Drivers-hsqldb.xcu \
- $(call gb_XcuModuleTarget_get_target,connectivity/registry/jdbc)/org/openoffice/Office/DataAccess/Drivers-jdbc.xcu
-postprocess_DRIVERS += hsqldb jdbc
+ $(call gb_XcuModuleTarget_get_target,connectivity/registry/jdbc)/org/openoffice/Office/DataAccess/Drivers-jdbc.xcu \
+ $(call gb_XcuModuleTarget_get_target,connectivity/registry/mysql)/org/openoffice/Office/DataAccess/Drivers-mysql.xcu
+postprocess_DRIVERS += hsqldb jdbc mysql
endif
ifeq ($(ENABLE_FIREBIRD_SDBC),TRUE)
postprocess_FILES_main += \
diff --git a/postprocess/Rdb_services.mk b/postprocess/Rdb_services.mk
index 5450f835eae7..2b4ec9479f63 100644
--- a/postprocess/Rdb_services.mk
+++ b/postprocess/Rdb_services.mk
@@ -259,6 +259,7 @@ $(eval $(call gb_Rdb_add_components,services,\
$(if $(ENABLE_JAVA), \
connectivity/source/drivers/hsqldb/hsqldb \
connectivity/source/drivers/jdbc/jdbc \
+ connectivity/source/drivers/mysql/mysql \
) \
connectivity/source/manager/sdbc2 \
connectivity/source/drivers/writer/writer \