[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - configure.ac connectivity/Configuration_mysql.mk connectivity/Library_mysqlc.mk connectivity/Library_mysql.mk connectivity/Module_connectivity.mk connectivity/registry connectivity/source external/mariadb-connector-c external/Module_external.mk external/mysql-connector-cpp mysqlc/Configuration_mysql.mk mysqlc/Library_mysqlc.mk mysqlc/Makefile mysqlc/Module_mysqlc.mk mysqlc/Rdb_mysqlc.mk mysqlc/README mysqlc/source postprocess/CustomTarget_registry.mk postprocess/Rdb_services.mk RepositoryExternal.mk Repository.mk RepositoryModule_host.mk solenv/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 28 18:29:38 UTC 2018
Repository.mk | 4
RepositoryExternal.mk | 5
RepositoryModule_host.mk | 1
configure.ac | 30
connectivity/Configuration_mysql.mk | 7
connectivity/Library_mysql.mk | 48
connectivity/Library_mysqlc.mk | 38
connectivity/Module_connectivity.mk | 9
connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu | 264 --
connectivity/source/drivers/mysql/YUser.cxx | 320 ---
connectivity/source/drivers/mysql/mysql.component | 26
connectivity/source/drivers/mysqlc/mysqlc_connection.cxx | 499 +++++
connectivity/source/drivers/mysqlc/mysqlc_connection.hxx | 183 +
connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx | 989 ++++++++++
connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.hxx | 245 ++
connectivity/source/drivers/mysqlc/mysqlc_driver.cxx | 169 +
connectivity/source/drivers/mysqlc/mysqlc_driver.hxx | 101 +
connectivity/source/drivers/mysqlc/mysqlc_general.cxx | 354 +++
connectivity/source/drivers/mysqlc/mysqlc_general.hxx | 125 +
connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx | 7
connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx | 2
connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx | 240 +-
connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.hxx | 161 +
connectivity/source/drivers/mysqlc/mysqlc_propertyids.hxx | 5
connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx | 361 +--
connectivity/source/drivers/mysqlc/mysqlc_resultset.hxx | 246 ++
connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx | 35
connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.hxx | 109 +
connectivity/source/drivers/mysqlc/mysqlc_services.cxx | 107 +
connectivity/source/drivers/mysqlc/mysqlc_statement.cxx | 177 -
connectivity/source/drivers/mysqlc/mysqlc_statement.hxx | 185 +
connectivity/source/drivers/mysqlc/mysqlc_subcomponent.hxx | 164 +
connectivity/source/drivers/mysqlc/mysqlc_types.cxx | 680 ++++++
connectivity/source/drivers/mysqlc/mysqlc_types.hxx | 13
external/Module_external.mk | 1
external/mariadb-connector-c/StaticLibrary_mariadb-connector-c.mk | 2
external/mysql-connector-cpp/Makefile | 7
external/mysql-connector-cpp/Module_mysql-connector-cpp.mk | 17
external/mysql-connector-cpp/README | 1
external/mysql-connector-cpp/UnpackedTarball_mysql-connector-cpp.mk | 26
external/mysql-connector-cpp/binding_config.h | 5
external/mysql-connector-cpp/config.h | 39
external/mysql-connector-cpp/patches/dynexcspec.patch.0 | 15
external/mysql-connector-cpp/patches/enable-libmysql-proxy.patch | 27
external/mysql-connector-cpp/patches/mysql-connector-c++-1.1.0.patch | 115 -
external/mysql-connector-cpp/patches/warnings.patch.0 | 11
external/mysql-connector-cpp/version_info.h | 42
mysqlc/Configuration_mysql.mk | 15
mysqlc/Makefile | 7
mysqlc/Module_mysqlc.mk | 23
mysqlc/README | 79
mysqlc/Rdb_mysqlc.mk | 16
mysqlc/source/mysqlc_connection.cxx | 544 -----
mysqlc/source/mysqlc_databasemetadata.hxx | 219 --
mysqlc/source/mysqlc_general.hxx | 128 -
mysqlc/source/mysqlc_preparedstatement.hxx | 163 -
mysqlc/source/mysqlc_resultset.hxx | 247 --
mysqlc/source/mysqlc_resultsetmetadata.hxx | 110 -
mysqlc/source/mysqlc_services.cxx | 115 -
mysqlc/source/mysqlc_types.cxx | 682 ------
postprocess/CustomTarget_registry.mk | 4
postprocess/Rdb_services.mk | 2
solenv/qa/python/gbuildtojson.py | 2
63 files changed, 4775 insertions(+), 3798 deletions(-)
New commits:
commit 6a232a01f9075b930b05e36a4979e8d58aeb74d3
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Thu Aug 16 17:56:12 2018 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Aug 28 20:29:26 2018 +0200
mysqlc: Fix issue by freeing result sets
Change-Id: I8a5f886306e028f06243768376b2a6c55df6063c
Reviewed-on: https://gerrit.libreoffice.org/59210
Tested-by: Jenkins
Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/59714
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
index 24e2b2560968..c52b587fba55 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx
@@ -32,6 +32,8 @@
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
+#include <sal/log.hxx>
+
using namespace rtl;
#include <comphelper/string.hxx>
@@ -559,6 +561,7 @@ void SAL_CALL OResultSet::close()
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
mysql_free_result(m_pResult);
+ m_pResult = nullptr;
dispose();
}
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
index 97cd50969879..cc6bf1492502 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_statement.cxx
@@ -61,10 +61,10 @@ OCommonStatement::~OCommonStatement() {}
void OCommonStatement::disposeResultSet()
{
// free the cursor if alive
- if (m_pMysqlResult != nullptr)
+ if (m_xResultSet.is())
{
- mysql_free_result(m_pMysqlResult);
- m_pMysqlResult = nullptr;
+ m_xResultSet.clear();
+ m_pMysqlResult = nullptr; // it is freed by XResultSet
}
}
commit 490c6cd0ed877a0bd22a7592b42d70edd83114ca
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
AuthorDate: Thu Aug 16 16:35:17 2018 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Aug 28 20:29:12 2018 +0200
Moving mysqlc into connectivity as a library
Additionally I erased the remains of the old mysql C++ connector.
Also update the code where the clang plugins were unhappy after moving
the mysqlc module.
Remove mysql-cpp-connector external.
Change-Id: I771cc7afacf5012fc349afb6b36828fb0fee5a66
Reviewed-on: https://gerrit.libreoffice.org/59200
Tested-by: Jenkins
Reviewed-by: Tamás Bunth <btomi96 at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/59713
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/Repository.mk b/Repository.mk
index a35e837c21de..415b10b78ed3 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -389,7 +389,8 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
msfilter \
$(call gb_Helper_optional,SCRIPTING,msforms) \
mtfrenderer \
- $(call gb_Helper_optional,DBCONNECTIVITY,mysql) \
+ $(call gb_Helper_optional,DBCONNECTIVITY,mysqlc) \
+ numbertext \
odbc \
odfflatxml \
offacc \
@@ -707,7 +708,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,UNOVERLIBS,ure, \
$(eval $(call gb_Helper_register_libraries,EXTENSIONLIBS, \
active_native \
- mysqlc \
passive_native \
))
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 22f1412191e7..dfcd99963389 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -228,8 +228,11 @@ endef
endif # SYSTEM_EPOXY
define gb_LinkTarget__use_iconv
+ifeq ($(COM),MSC)
+$(call gb_LinkTarget_add_libs,$(1),libiconv.lib)
+else
$(call gb_LinkTarget_add_libs,$(1),-liconv)
-
+endif
endef
ifneq ($(SYSTEM_MARIADB_CONNECTOR_C),)
diff --git a/RepositoryModule_host.mk b/RepositoryModule_host.mk
index 3b530286114e..e6f93c869ccd 100644
--- a/RepositoryModule_host.mk
+++ b/RepositoryModule_host.mk
@@ -81,7 +81,6 @@ $(eval $(call gb_Module_add_moduledirs,libreoffice,\
linguistic \
lotuswordpro \
$(call gb_Helper_optional,DESKTOP,l10ntools) \
- $(call gb_Helper_optional,MARIADBC,mysqlc) \
$(call gb_Helper_optional,NLPSOLVER,nlpsolver) \
o3tl \
$(call gb_Helper_optional,ODK,odk) \
diff --git a/configure.ac b/configure.ac
index a1d41b7715ee..70c0c11a1baf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -955,11 +955,6 @@ AC_ARG_ENABLE(dynamic-loading,
[Disable any use of dynamic loading of code. Work in progress, use only if you are hacking on it.])
)
-libo_FUZZ_ARG_ENABLE(ext-mariadb-connector,
- AS_HELP_STRING([--enable-ext-mariadb-connector],
- [Enable the build of the MariaDB/MySQL Connector extension.])
-)
-
libo_FUZZ_ARG_ENABLE(report-builder,
AS_HELP_STRING([--disable-report-builder],
[Disable the Report Builder.])
@@ -1644,12 +1639,12 @@ AC_ARG_WITH(system-apache-commons,
AC_ARG_WITH(system-mariadb,
AS_HELP_STRING([--with-system-mariadb],
[Use MariaDB/MySQL libraries already on system, for building the MariaDB Connector/LibreOffice
- extension.]),,
+ .]),,
[with_system_mariadb="$with_system_libs"])
AC_ARG_ENABLE(bundle-mariadb,
AS_HELP_STRING([--enable-bundle-mariadb],
- [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice extension.])
+ [When using MariaDB/MySQL libraries already on system, bundle them with the MariaDB Connector/LibreOffice.])
)
AC_ARG_WITH(system-mysql-cppconn,
@@ -8124,18 +8119,12 @@ AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_VERSION_MAJOR)
AC_SUBST(PYTHON_VERSION_MINOR)
-AC_MSG_CHECKING([whether to build the MariaDB/MySQL Connector extension])
-if test "x$enable_ext_mariadb_connector" = "xyes" -a "x$enable_extension_integration" != "xno"; then
- AC_MSG_RESULT([yes])
- ENABLE_MARIADBC=TRUE
- MARIADBC_MAJOR=1
- MARIADBC_MINOR=0
- MARIADBC_MICRO=2
- BUILD_TYPE="$BUILD_TYPE MARIADBC"
-else
- AC_MSG_RESULT([no])
- ENABLE_MARIADBC=
-fi
+ENABLE_MARIADBC=TRUE
+MARIADBC_MAJOR=1
+MARIADBC_MINOR=0
+MARIADBC_MICRO=2
+BUILD_TYPE="$BUILD_TYPE MARIADBC"
+
AC_SUBST(ENABLE_MARIADBC)
AC_SUBST(MARIADBC_MAJOR)
AC_SUBST(MARIADBC_MINOR)
@@ -12391,9 +12380,6 @@ if test "$enable_mpl_subset" = "yes"; then
if test "$WITH_WEBDAV" = "neon"; then
AC_MSG_ERROR([need --with-webdav=serf or --without-webdav - webdav support.])
fi
- if test "x$enable_ext_mariadb_connector" = "xyes"; then
- AC_MSG_ERROR([need to --disable-ext-mariadb-connector - mariadb/mysql support.])
- fi
if test -n "$ENABLE_PDFIMPORT"; then
if test "x$SYSTEM_POPPLER" = "x"; then
AC_MSG_ERROR([need to disable PDF import via poppler or use system library])
diff --git a/connectivity/Configuration_mysql.mk b/connectivity/Configuration_mysql.mk
index 1cb07ca71441..3e3f0b908ecb 100644
--- a/connectivity/Configuration_mysql.mk
+++ b/connectivity/Configuration_mysql.mk
@@ -7,14 +7,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
-$(eval $(call gb_Configuration_Configuration,driver_mysql))
+$(eval $(call gb_Configuration_Configuration,mysqlc))
-$(eval $(call gb_Configuration_add_spool_modules,driver_mysql,connectivity/registry/mysql,\
+$(eval $(call gb_Configuration_add_spool_modules,mysqlc,connectivity/registry/mysqlc,\
org/openoffice/Office/DataAccess/Drivers-mysql.xcu \
))
-$(eval $(call gb_Configuration_add_localized_datas,driver_mysql,connectivity/registry/mysql,\
+$(eval $(call gb_Configuration_add_localized_datas,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
deleted file mode 100644
index ac3c0c2619e8..000000000000
--- a/connectivity/Library_mysql.mk
+++ /dev/null
@@ -1,48 +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_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/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/mysqlc/Library_mysqlc.mk b/connectivity/Library_mysqlc.mk
similarity index 56%
rename from mysqlc/Library_mysqlc.mk
rename to connectivity/Library_mysqlc.mk
index f034eaeece76..eb8a5e5230c7 100644
--- a/mysqlc/Library_mysqlc.mk
+++ b/connectivity/Library_mysqlc.mk
@@ -11,10 +11,20 @@ $(eval $(call gb_Library_Library,mysqlc))
$(eval $(call gb_Library_use_externals,mysqlc,\
boost_headers \
- mysql-connector-cpp \
mariadb-connector-c \
))
+ifeq ($(OS)-$(SYSTEM_MARIADB_CONNECTOR_C),MACOSX-)
+$(eval $(call gb_Library_use_external,mysqlc,iconv))
+endif
+
+$(eval $(call gb_Library_set_include,mysqlc,\
+ -I$(SRCDIR)/connectivity/inc \
+ -I$(SRCDIR)/connectivity/source/inc \
+ $$(INCLUDE) \
+ -I$(WORKDIR)/YaccTarget/connectivity/source/parse \
+))
+
ifeq ($(SYSTEM_MYSQL_CONNECTOR_CPP),)
$(eval $(call gb_Library_add_libs,mysqlc,\
$(if $(filter-out WNT,$(OS)),$(if $(filter MACOSX SOLARIS,$(OS)),-lz -lm,\
@@ -44,21 +54,19 @@ $(eval $(call gb_Library_add_defs,mysqlc,\
))
$(eval $(call gb_Library_add_exception_objects,mysqlc,\
- mysqlc/source/mysqlc_driver \
- mysqlc/source/mysqlc_services \
- mysqlc/source/mysqlc_connection \
- mysqlc/source/mysqlc_resultset \
- mysqlc/source/mysqlc_prepared_resultset \
- mysqlc/source/mysqlc_resultsetmetadata \
- mysqlc/source/mysqlc_statement \
- mysqlc/source/mysqlc_preparedstatement \
- mysqlc/source/mysqlc_databasemetadata \
- mysqlc/source/mysqlc_types \
- mysqlc/source/mysqlc_general \
+ connectivity/source/drivers/mysqlc/mysqlc_driver \
+ connectivity/source/drivers/mysqlc/mysqlc_services \
+ connectivity/source/drivers/mysqlc/mysqlc_connection \
+ connectivity/source/drivers/mysqlc/mysqlc_resultset \
+ connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset \
+ connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata \
+ connectivity/source/drivers/mysqlc/mysqlc_statement \
+ connectivity/source/drivers/mysqlc/mysqlc_preparedstatement \
+ connectivity/source/drivers/mysqlc/mysqlc_databasemetadata \
+ connectivity/source/drivers/mysqlc/mysqlc_types \
+ connectivity/source/drivers/mysqlc/mysqlc_general \
))
-$(eval $(call gb_Library_set_componentfile,mysqlc,mysqlc/source/mysqlc))
-
-$(eval $(call gb_Library_set_external_code,mysqlc))
+$(eval $(call gb_Library_set_componentfile,mysqlc,connectivity/source/drivers/mysqlc/mysqlc))
# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index 3ba7ecf01d41..0fc587daa340 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -20,7 +20,6 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_calc \
Configuration_dbase \
Configuration_flat \
- Configuration_mysql \
Configuration_odbc \
Configuration_writer \
Library_calc \
@@ -28,7 +27,6 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Library_dbpool2 \
Library_file \
Library_flat \
- Library_mysql \
$(if $(filter ANDROID IOS,$(OS)),,Library_odbc) \
Library_sdbc2 \
Library_writer \
@@ -81,6 +79,13 @@ $(eval $(call gb_Module_add_targets,connectivity,\
))
endif
+ifeq ($(ENABLE_MARIADBC),TRUE)
+$(eval $(call gb_Module_add_targets,connectivity,\
+ Configuration_mysql \
+ Library_mysqlc \
+))
+endif
+
ifneq ($(BUILD_POSTGRESQL_SDBC),)
$(eval $(call gb_Module_add_targets,connectivity,\
Configuration_postgresql \
diff --git a/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu
deleted file mode 100644
index 77988448f722..000000000000
--- a/connectivity/registry/mysql/org/openoffice/Office/DataAccess/Drivers.xcu
+++ /dev/null
@@ -1,264 +0,0 @@
-<?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 oor:name="ParameterNameSubstitution" 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 oor:name="ParameterNameSubstitution" 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 oor:name="ParameterNameSubstitution" 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/mysqlc/source/registry/data/org/openoffice/Office/DataAccess/Drivers.xcu b/connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu
similarity index 100%
rename from mysqlc/source/registry/data/org/openoffice/Office/DataAccess/Drivers.xcu
rename to connectivity/registry/mysqlc/org/openoffice/Office/DataAccess/Drivers.xcu
diff --git a/connectivity/source/drivers/mysql/YUser.cxx b/connectivity/source/drivers/mysql/YUser.cxx
deleted file mode 100644
index bc9c8c55b22e..000000000000
--- a/connectivity/source/drivers/mysql/YUser.cxx
+++ /dev/null
@@ -1,320 +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 <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
deleted file mode 100644
index 9c3e7ad7c6cd..000000000000
--- a/connectivity/source/drivers/mysql/mysql.component
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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/mysqlc/source/DataAccess.xcu b/connectivity/source/drivers/mysqlc/DataAccess.xcu
similarity index 100%
rename from mysqlc/source/DataAccess.xcu
rename to connectivity/source/drivers/mysqlc/DataAccess.xcu
diff --git a/mysqlc/source/META-INF/manifest.xml b/connectivity/source/drivers/mysqlc/META-INF/manifest.xml
similarity index 100%
rename from mysqlc/source/META-INF/manifest.xml
rename to connectivity/source/drivers/mysqlc/META-INF/manifest.xml
diff --git a/mysqlc/source/description-en-US.txt b/connectivity/source/drivers/mysqlc/description-en-US.txt
similarity index 100%
rename from mysqlc/source/description-en-US.txt
rename to connectivity/source/drivers/mysqlc/description-en-US.txt
diff --git a/mysqlc/source/description.xml b/connectivity/source/drivers/mysqlc/description.xml
similarity index 100%
rename from mysqlc/source/description.xml
rename to connectivity/source/drivers/mysqlc/description.xml
diff --git a/mysqlc/source/mysqlc.component b/connectivity/source/drivers/mysqlc/mysqlc.component
similarity index 100%
rename from mysqlc/source/mysqlc.component
rename to connectivity/source/drivers/mysqlc/mysqlc.component
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx
new file mode 100644
index 000000000000..74c68b2dbe11
--- /dev/null
+++ b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx
@@ -0,0 +1,499 @@
+/* -*- 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 <memory>
+#include "mysqlc_connection.hxx"
+#include "mysqlc_databasemetadata.hxx"
+
+#include "mysqlc_driver.hxx"
+#include "mysqlc_statement.hxx"
+#include "mysqlc_preparedstatement.hxx"
+#include "mysqlc_general.hxx"
+
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+#include <osl/module.hxx>
+#include <osl/thread.h>
+#include <osl/file.h>
+#include <sal/log.hxx>
+#include <osl/diagnose.h>
+#include <rtl/uri.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace connectivity::mysqlc;
+
+#include <stdio.h>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using ::osl::MutexGuard;
+
+#define MYSQLC_URI_PREFIX "sdbc:mysqlc:"
+
+namespace
+{
+void lcl_executeUpdate(MYSQL* pMySql, const rtl::OString& sql)
+{
+ mysql_real_query(pMySql, sql.getStr(), sql.getLength());
+ // TODO handle error
+}
+}
+
+OConnection::OConnection(MysqlCDriver& _rDriver)
+ : OMetaConnection_BASE(m_aMutex)
+ , m_xMetaData(nullptr)
+ , m_xDriver(&_rDriver)
+{
+}
+
+OConnection::~OConnection()
+{
+ if (!isClosed())
+ {
+ close();
+ }
+}
+
+void OConnection::construct(const rtl::OUString& url, const Sequence<PropertyValue>& info)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ mysql_library_init(0, nullptr, nullptr);
+ mysql_init(&m_mysql);
+
+ // use TCP as connection
+ mysql_protocol_type protocol = MYSQL_PROTOCOL_TCP;
+ mysql_options(&m_mysql, MYSQL_OPT_PROTOCOL, &protocol);
+
+ sal_Int32 nIndex;
+ rtl::OUString token;
+ rtl::OUString aHostName("localhost");
+ sal_Int32 nPort = 3306;
+ rtl::OUString aDbName;
+
+ m_settings.encoding = MysqlCDriver::getDefaultEncoding();
+
+ // parse url. Url has the following format:
+ // external server: sdbc:mysqlc:[hostname]:[port]/[dbname]
+
+ if (url.startsWith(MYSQLC_URI_PREFIX))
+ {
+ nIndex = 12;
+ }
+ else
+ {
+ // sdbc:mysql:mysqlc:[hostname]:[port]/[dbname]
+ nIndex = 18;
+ }
+
+ token = url.getToken(0, '/', nIndex);
+ if (!token.isEmpty())
+ {
+ sal_Int32 nIndex1 = 0;
+ rtl::OUString hostandport = token.getToken(0, ':', nIndex1);
+ if (!hostandport.isEmpty())
+ {
+ aHostName = hostandport;
+ hostandport = token.getToken(0, ':', nIndex1);
+ if (!hostandport.isEmpty() && nIndex1)
+ {
+ nPort = hostandport.toInt32();
+ }
+ token = url.getToken(0, '/', nIndex);
+ if (!token.isEmpty() && nIndex)
+ {
+ aDbName = token;
+ }
+ }
+ }
+
+ // get user and password for mysql connection
+ const PropertyValue* pIter = info.getConstArray();
+ const PropertyValue* pEnd = pIter + info.getLength();
+ rtl::OUString aUser, aPass, sUnixSocket, sNamedPipe;
+ bool unixSocketPassed = false;
+ bool namedPipePassed = false;
+
+ m_settings.connectionURL = url;
+ for (; pIter != pEnd; ++pIter)
+ {
+ if (pIter->Name == "user")
+ {
+ OSL_VERIFY(pIter->Value >>= aUser);
+ }
+ else if (pIter->Name == "password")
+ {
+ OSL_VERIFY(pIter->Value >>= aPass);
+ }
+ else if (pIter->Name == "LocalSocket")
+ {
+ OSL_VERIFY(pIter->Value >>= sUnixSocket);
+ unixSocketPassed = !sUnixSocket.isEmpty();
+ }
+ else if (pIter->Name == "NamedPipe")
+ {
+ OSL_VERIFY(pIter->Value >>= sNamedPipe);
+ namedPipePassed = !sNamedPipe.isEmpty();
+ }
+ else if (pIter->Name == "PublicConnectionURL")
+ {
+ OSL_VERIFY(pIter->Value >>= m_settings.connectionURL);
+ }
+ else if (pIter->Name == "NewURL")
+ { // legacy name for "PublicConnectionURL"
+ OSL_VERIFY(pIter->Value >>= m_settings.connectionURL);
+ }
+ }
+
+ rtl::OString host_str = rtl::OUStringToOString(aHostName, m_settings.encoding);
+ rtl::OString user_str = rtl::OUStringToOString(aUser, m_settings.encoding);
+ rtl::OString pass_str = rtl::OUStringToOString(aPass, m_settings.encoding);
+ rtl::OString schema_str = rtl::OUStringToOString(aDbName, m_settings.encoding);
+ rtl::OString socket_str;
+ if (unixSocketPassed)
+ {
+ socket_str = rtl::OUStringToOString(sUnixSocket, m_settings.encoding);
+ }
+ else if (namedPipePassed)
+ {
+ socket_str = rtl::OUStringToOString(sNamedPipe, m_settings.encoding);
+ }
+
+ // flags can also be passed as last parameter
+ if (!mysql_real_connect(&m_mysql, host_str.getStr(), user_str.getStr(), pass_str.getStr(),
+ schema_str.getStr(), nPort, socket_str.getStr(), 0))
+ mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql),
+ *this, getConnectionEncoding());
+
+ m_settings.schema = aDbName;
+
+ // Check if the server is 4.1 or above
+ if (getMysqlVersion() < 40100)
+ {
+ throw SQLException("MariaDB LibreOffice Connector requires MySQL Server 4.1 or above",
+ *this, rtl::OUString(), 0, Any());
+ }
+
+ lcl_executeUpdate(&m_mysql, rtl::OString{ "SET session sql_mode='ANSI_QUOTES'" });
+ lcl_executeUpdate(&m_mysql, rtl::OString{ "SET NAMES utf8" });
+}
+
+rtl::OUString OConnection::getImplementationName()
+{
+ return rtl::OUString("com.sun.star.sdbc.drivers.mysqlc.OConnection");
+}
+
+css::uno::Sequence<rtl::OUString> OConnection::getSupportedServiceNames()
+{
+ css::uno::Sequence<rtl::OUString> s(1);
+ s[0] = "com.sun.star.sdbc.Connection";
+ return s;
+}
+
+sal_Bool OConnection::supportsService(rtl::OUString const& ServiceName)
+{
+ return cppu::supportsService(this, ServiceName);
+}
+
+Reference<XStatement> SAL_CALL OConnection::createStatement()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ Reference<XStatement> xReturn;
+ // the statement can only be executed once
+ xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+
+ return xReturn;
+}
+
+Reference<XPreparedStatement> SAL_CALL OConnection::prepareStatement(const rtl::OUString& _sSql)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ const rtl::OString sSqlStatement
+ = rtl::OUStringToOString(_sSql, getConnectionEncoding()); // FIXME transform statement ?
+
+ MYSQL_STMT* pStmt = mysql_stmt_init(&m_mysql);
+ mysql_stmt_prepare(pStmt, sSqlStatement.getStr(), sSqlStatement.getLength());
+
+ unsigned int nErrorNum = mysql_errno(&m_mysql);
+ if (nErrorNum != 0)
+ mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), nErrorNum, *this,
+ getConnectionEncoding());
+
+ Reference<XPreparedStatement> xStatement;
+ xStatement = new OPreparedStatement(this, pStmt);
+ m_aStatements.push_back(WeakReferenceHelper(xStatement));
+ return xStatement;
+}
+
+Reference<XPreparedStatement> SAL_CALL OConnection::prepareCall(const rtl::OUString& /*_sSql*/)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ mysqlc_sdbc_driver::throwFeatureNotImplementedException("OConnection::prepareCall", *this);
+ return Reference<XPreparedStatement>();
+}
+
+rtl::OUString SAL_CALL OConnection::nativeSQL(const rtl::OUString& /*_sSql*/)
+{
+ MutexGuard aGuard(m_aMutex);
+
+ // const rtl::OUString sSqlStatement = transFormPreparedStatement( _sSql );
+ rtl::OUString sNativeSQL;
+ // TODO
+ return sNativeSQL;
+}
+
+void SAL_CALL OConnection::setAutoCommit(sal_Bool autoCommit)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ if (!mysql_autocommit(&m_mysql, autoCommit))
+ mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql),
+ *this, getConnectionEncoding());
+}
+
+sal_Bool SAL_CALL OConnection::getAutoCommit()
+{
+ // you have to distinguish which if you are in autocommit mode or not
+ // at normal case true should be fine here
+
+ // TODO use SELECT @@autocommit query for that
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ bool autoCommit = false;
+ return autoCommit;
+}
+
+void SAL_CALL OConnection::commit()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ if (!mysql_commit(&m_mysql))
+ mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql),
+ *this, getConnectionEncoding());
+}
+
+void SAL_CALL OConnection::rollback()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ if (!mysql_rollback(&m_mysql))
+ mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql),
+ *this, getConnectionEncoding());
+}
+
+sal_Bool SAL_CALL OConnection::isClosed()
+{
+ MutexGuard aGuard(m_aMutex);
+
+ // just simple -> we are close when we are disposed that means someone called dispose(); (XComponent)
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+
+Reference<XDatabaseMetaData> SAL_CALL OConnection::getMetaData()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference<XDatabaseMetaData> xMetaData = m_xMetaData;
+ if (!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(*this, &m_mysql);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+
+void SAL_CALL OConnection::setReadOnly(sal_Bool readOnly)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ m_settings.readOnly = readOnly;
+}
+
+sal_Bool SAL_CALL OConnection::isReadOnly()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // return if your connection to readonly
+ return m_settings.readOnly;
+}
+
+void SAL_CALL OConnection::setCatalog(const rtl::OUString& /*catalog*/)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // TODO How?
+}
+
+rtl::OUString SAL_CALL OConnection::getCatalog()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // TODO How?
+ return OUString{};
+}
+
+void SAL_CALL OConnection::setTransactionIsolation(sal_Int32 /*level*/)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // TODO
+}
+
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ return 0; // TODO
+}
+
+Reference<XNameAccess> SAL_CALL OConnection::getTypeMap()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference<XNameAccess> t = m_typeMap;
+ return t;
+}
+
+void SAL_CALL OConnection::setTypeMap(const Reference<XNameAccess>& typeMap)
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ m_typeMap = typeMap;
+}
+
+// XCloseable
+void SAL_CALL OConnection::close()
+{
+ /*
+ we need block, because the mutex is a local variable,
+ which will guard the block
+ */
+ {
+ // we just dispose us
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ }
+ mysql_close(&m_mysql);
+ mysql_library_end();
+ dispose();
+}
+
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings()
+{
+ Any x = Any();
+ // when you collected some warnings -> return it
+ return x;
+}
+
+void SAL_CALL OConnection::clearWarnings()
+{
+ // you should clear your collected warnings here#
+}
+
+void OConnection::disposing()
+{
+ // we noticed that we should be destroyed in near future so we have to dispose our statements
+ MutexGuard aGuard(m_aMutex);
+
+ for (auto const& statement : m_aStatements)
+ {
+ Reference<XComponent> xComp(statement.get(), UNO_QUERY);
+ if (xComp.is())
+ {
+ xComp->dispose();
+ }
+ }
+ m_aStatements.clear();
+
+ m_xMetaData = WeakReference<XDatabaseMetaData>();
+
+ OConnection_BASE::disposing();
+}
+
+sal_Int32 OConnection::getMysqlVersion()
+{
+ MutexGuard aGuard(m_aMutex);
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ unsigned long version = mysql_get_server_version(&m_mysql);
+ return static_cast<sal_Int32>(version);
+}
+
+rtl::OUString OConnection::transFormPreparedStatement(const rtl::OUString& _sSQL)
+{
+ rtl::OUString sSqlStatement = _sSQL;
+ if (!m_xParameterSubstitution.is())
+ {
+ try
+ {
+ Sequence<Any> aArgs(1);
+ Reference<XConnection> xCon = this;
+ aArgs[0] <<= NamedValue("ActiveConnection", makeAny(xCon));
+
+ m_xParameterSubstitution.set(
+ m_xDriver->getFactory()->createInstanceWithArguments(
+ "org.openoffice.comp.helper.ParameterSubstitution", aArgs),
+ UNO_QUERY);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ if (m_xParameterSubstitution.is())
+ {
+ try
+ {
+ sSqlStatement = m_xParameterSubstitution->substituteVariables(sSqlStatement, true);
+ }
+ catch (const Exception&)
+ {
+ }
+ }
+ return sSqlStatement;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx b/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx
new file mode 100644
index 000000000000..f2bca68fff15
--- /dev/null
+++ b/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx
@@ -0,0 +1,183 @@
+/* -*- 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 <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::SQLException;
+using ::com::sun::star::sdbc::SQLWarning;
+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;
+ 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
+{
+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() override;
+
+ rtl_TextEncoding getConnectionEncoding() const { return m_settings.encoding; }
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing() 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/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
new file mode 100644
index 000000000000..1fe3f3976ae5
--- /dev/null
+++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx
@@ -0,0 +1,989 @@
+/* -*- 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)
+{
+}
+
+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 = !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_*/,
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list