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@gmail.com>
This commit is contained in:
Tamas Bunth
2018-08-24 17:19:51 +02:00
committed by Tamás Bunth
parent 84c02b6d9f
commit 26b40fcfc6
81 changed files with 4349 additions and 5962 deletions
+1 -2
View File
@@ -405,7 +405,7 @@ $(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 \
@@ -722,7 +722,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,UNOVERLIBS,ure, \
$(eval $(call gb_Helper_register_libraries,EXTENSIONLIBS, \
active_native \
mysqlc \
passive_native \
))
+4 -1
View File
@@ -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),)
-1
View File
@@ -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) \
+8 -22
View File
@@ -1005,11 +1005,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.])
@@ -1731,12 +1726,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,
@@ -8320,18 +8315,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)
@@ -12550,9 +12539,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])
+3 -4
View File
@@ -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:
-48
View File
@@ -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:
@@ -11,7 +11,6 @@ $(eval $(call gb_Library_Library,mysqlc))
$(eval $(call gb_Library_use_externals,mysqlc,\
boost_headers \
mysql-connector-cpp \
mariadb-connector-c \
))
@@ -19,6 +18,13 @@ ifeq ($(OS)-$(SYSTEM_MARIADB_CONNECTOR_C),MACOSX-)
$(eval $(call gb_Library_use_external,mysqlc,iconv))
endif
$(eval $(call gb_Library_set_include,firebird_sdbc,\
-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,\
@@ -48,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:
+7 -2
View File
@@ -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 \
@@ -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>
@@ -1,138 +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/YCatalog.hxx>
#include <mysql/YUsers.hxx>
#include <mysql/YTables.hxx>
#include <mysql/YViews.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <comphelper/types.hxx>
using namespace connectivity;
using namespace connectivity::mysql;
using namespace connectivity::sdbcx;
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;
OMySQLCatalog::OMySQLCatalog(const Reference< XConnection >& _xConnection) : OCatalog(_xConnection)
,m_xConnection(_xConnection)
{
}
void OMySQLCatalog::refreshObjects(const Sequence< OUString >& _sKindOfObject,::std::vector< OUString>& _rNames)
{
Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
"%",
"%",
_sKindOfObject);
fillNames(xResult,_rNames);
}
void OMySQLCatalog::refreshTables()
{
::std::vector< OUString> aVector;
Sequence< OUString > sTableTypes(3);
sTableTypes[0] = "VIEW";
sTableTypes[1] = "TABLE";
sTableTypes[2] = "%"; // just to be sure to include anything else ....
refreshObjects(sTableTypes,aVector);
if ( m_pTables )
m_pTables->reFill(aVector);
else
m_pTables.reset( new OTables(m_xMetaData,*this,m_aMutex,aVector) );
}
void OMySQLCatalog::refreshViews()
{
Sequence< OUString > aTypes { "VIEW" };
// let's simply assume the server is new enough to support views. Current drivers
// as of this writing might not return the proper information in getTableTypes, so
// don't rely on it.
::std::vector< OUString> aVector;
refreshObjects(aTypes,aVector);
if ( m_pViews )
m_pViews->reFill(aVector);
else
m_pViews.reset( new OViews(m_xMetaData,*this,m_aMutex,aVector) );
}
void OMySQLCatalog::refreshGroups()
{
}
void OMySQLCatalog::refreshUsers()
{
::std::vector< OUString> aVector;
Reference< XStatement > xStmt = m_xConnection->createStatement( );
Reference< XResultSet > xResult = xStmt->executeQuery("SELECT grantee FROM information_schema.user_privileges GROUP BY grantee");
if ( xResult.is() )
{
Reference< XRow > xRow(xResult,UNO_QUERY);
while( xResult->next() )
aVector.push_back(xRow->getString(1));
::comphelper::disposeComponent(xResult);
}
::comphelper::disposeComponent(xStmt);
if(m_pUsers)
m_pUsers->reFill(aVector);
else
m_pUsers.reset( new OUsers(*this,m_aMutex,aVector,m_xConnection,this) );
}
Any SAL_CALL OMySQLCatalog::queryInterface( const Type & rType )
{
if ( rType == cppu::UnoType<XGroupsSupplier>::get())
return Any();
return OCatalog::queryInterface(rType);
}
Sequence< Type > SAL_CALL OMySQLCatalog::getTypes( )
{
Sequence< Type > aTypes = OCatalog::getTypes();
std::vector<Type> aOwnTypes;
aOwnTypes.reserve(aTypes.getLength());
const Type* pBegin = aTypes.getConstArray();
const Type* pEnd = pBegin + aTypes.getLength();
for(;pBegin != pEnd;++pBegin)
{
if ( !(*pBegin == cppu::UnoType<XGroupsSupplier>::get()))
{
aOwnTypes.push_back(*pBegin);
}
}
return Sequence< Type >(aOwnTypes.data(), aOwnTypes.size());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,78 +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/YColumns.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity::mysql;
using namespace connectivity::sdbcx;
using namespace connectivity;
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;
OMySQLColumns::OMySQLColumns( ::cppu::OWeakObject& _rParent
,::osl::Mutex& _rMutex
,const ::std::vector< OUString> &_rVector
) : OColumnsHelper(_rParent,true/*_bCase*/,_rMutex,_rVector,true/*_bUseHardRef*/)
{
}
Reference< XPropertySet > OMySQLColumns::createDescriptor()
{
return new OMySQLColumn;
}
OMySQLColumn::OMySQLColumn()
: connectivity::sdbcx::OColumn( true )
{
construct();
}
void OMySQLColumn::construct()
{
m_sAutoIncrement = "auto_increment";
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),PROPERTY_ID_AUTOINCREMENTCREATION,0,&m_sAutoIncrement, cppu::UnoType<decltype(m_sAutoIncrement)>::get());
}
::cppu::IPropertyArrayHelper* OMySQLColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
{
return doCreateArrayHelper();
}
::cppu::IPropertyArrayHelper & SAL_CALL OMySQLColumn::getInfoHelper()
{
return *OMySQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
}
Sequence< OUString > SAL_CALL OMySQLColumn::getSupportedServiceNames( )
{
Sequence< OUString > aSupported { "com.sun.star.sdbcx.Column" };
return aSupported;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,492 +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/YDriver.hxx>
#include <mysql/YCatalog.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbcharset.hxx>
#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <TConnection.hxx>
#include <strings.hrc>
#include <resource/sharedresources.hxx>
namespace connectivity
{
using namespace mysql;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
namespace mysql
{
Reference< XInterface > ODriverDelegator_CreateInstance(const Reference< css::lang::XMultiServiceFactory >& _rxFac)
{
return *(new ODriverDelegator( comphelper::getComponentContext(_rxFac) ));
}
}
namespace
{
OUString getJavaDriverClass(
css::uno::Sequence<css::beans::PropertyValue> const & info)
{
return comphelper::NamedValueCollection(info).getOrDefault(
"JavaDriverClass", OUString("com.mysql.jdbc.Driver"));
}
}
ODriverDelegator::ODriverDelegator(const Reference< XComponentContext >& _rxContext)
: ODriverDelegator_BASE(m_aMutex)
,m_xContext(_rxContext)
{
}
ODriverDelegator::~ODriverDelegator()
{
try
{
::comphelper::disposeComponent(m_xODBCDriver);
::comphelper::disposeComponent(m_xNativeDriver);
TJDBCDrivers::iterator aIter = m_aJdbcDrivers.begin();
TJDBCDrivers::const_iterator aEnd = m_aJdbcDrivers.end();
for ( ;aIter != aEnd;++aIter )
::comphelper::disposeComponent(aIter->second);
}
catch(const Exception&)
{
}
}
void ODriverDelegator::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
for (auto const& connection : m_aConnections)
{
Reference<XInterface > xTemp = connection.first.get();
::comphelper::disposeComponent(xTemp);
}
m_aConnections.clear();
TWeakPairVector().swap(m_aConnections);
ODriverDelegator_BASE::disposing();
}
namespace
{
enum class T_DRIVERTYPE
{
Odbc,
Jdbc,
Native
};
bool isOdbcUrl(const OUString& _sUrl)
{
return _sUrl.startsWith("sdbc:mysql:odbc:");
}
bool isNativeUrl(const OUString& _sUrl)
{
return _sUrl.startsWith("sdbc:mysql:mysqlc:");
}
T_DRIVERTYPE lcl_getDriverType(const OUString& _sUrl)
{
T_DRIVERTYPE eRet = T_DRIVERTYPE::Jdbc;
if ( isOdbcUrl(_sUrl ) )
eRet = T_DRIVERTYPE::Odbc;
else if ( isNativeUrl(_sUrl ) )
eRet = T_DRIVERTYPE::Native;
return eRet;
}
OUString transformUrl(const OUString& _sUrl)
{
OUString sNewUrl = _sUrl.copy(11);
if ( isOdbcUrl( _sUrl ) )
sNewUrl = "sdbc:" + sNewUrl;
else if ( isNativeUrl( _sUrl ) )
sNewUrl = "sdbc:" + sNewUrl;
else
{
sNewUrl = "jdbc:mysql://" + sNewUrl.copy(5);
}
return sNewUrl;
}
Reference< XDriver > lcl_loadDriver(const Reference< XComponentContext >& _rxContext,const OUString& _sUrl)
{
Reference<XDriverManager2> xDriverAccess = DriverManager::create(_rxContext);
Reference< XDriver > xDriver = xDriverAccess->getDriverByURL(_sUrl);
return xDriver;
}
Sequence< PropertyValue > lcl_convertProperties(T_DRIVERTYPE _eType,const Sequence< PropertyValue >& info,const OUString& _sUrl)
{
std::vector<PropertyValue> aProps;
const PropertyValue* pSupported = info.getConstArray();
const PropertyValue* pEnd = pSupported + info.getLength();
aProps.reserve(info.getLength() + 5);
bool jdc = false;
for (;pSupported != pEnd; ++pSupported)
{
aProps.push_back( *pSupported );
if (pSupported->Name == "JavaDriverClass")
{
jdc = true;
}
}
if ( _eType == T_DRIVERTYPE::Odbc )
{
aProps.push_back( PropertyValue(
"Silent"
,0
,makeAny(true)
,PropertyState_DIRECT_VALUE) );
aProps.push_back( PropertyValue(
"PreventGetVersionColumns"
,0
,makeAny(true)
,PropertyState_DIRECT_VALUE) );
}
else if ( _eType == T_DRIVERTYPE::Jdbc )
{
if (!jdc)
{
aProps.push_back( PropertyValue(
"JavaDriverClass"
,0
,makeAny(OUString("com.mysql.jdbc.Driver"))
,PropertyState_DIRECT_VALUE) );
}
}
else
{
aProps.push_back( PropertyValue(
"PublicConnectionURL"
,0
,makeAny(_sUrl)
,PropertyState_DIRECT_VALUE) );
}
aProps.push_back( PropertyValue(
"IsAutoRetrievingEnabled"
,0
,makeAny(true)
,PropertyState_DIRECT_VALUE) );
aProps.push_back( PropertyValue(
"AutoRetrievingStatement"
,0
,makeAny(OUString("SELECT LAST_INSERT_ID()"))
,PropertyState_DIRECT_VALUE) );
aProps.push_back( PropertyValue(
"ParameterNameSubstitution"
,0
,makeAny(true)
,PropertyState_DIRECT_VALUE) );
return Sequence< PropertyValue >(aProps.data(), aProps.size());
}
}
Reference< XDriver > ODriverDelegator::loadDriver( const OUString& url, const Sequence< PropertyValue >& info )
{
Reference< XDriver > xDriver;
const OUString sCuttedUrl = transformUrl(url);
const T_DRIVERTYPE eType = lcl_getDriverType( url );
if ( eType == T_DRIVERTYPE::Odbc )
{
if ( !m_xODBCDriver.is() )
m_xODBCDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xODBCDriver;
} // if ( bIsODBC )
else if ( eType == T_DRIVERTYPE::Native )
{
if ( !m_xNativeDriver.is() )
m_xNativeDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xNativeDriver;
}
else
{
OUString sDriverClass(getJavaDriverClass(info));
TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass);
if ( aFind == m_aJdbcDrivers.end() )
aFind = m_aJdbcDrivers.emplace(sDriverClass,lcl_loadDriver(m_xContext,sCuttedUrl)).first;
xDriver = aFind->second;
}
return xDriver;
}
Reference< XConnection > SAL_CALL ODriverDelegator::connect( const OUString& url, const Sequence< PropertyValue >& info )
{
Reference< XConnection > xConnection;
if ( acceptsURL(url) )
{
Reference< XDriver > xDriver;
xDriver = loadDriver(url,info);
if ( xDriver.is() )
{
OUString sCuttedUrl = transformUrl(url);
const T_DRIVERTYPE eType = lcl_getDriverType( url );
Sequence< PropertyValue > aConvertedProperties = lcl_convertProperties(eType,info,url);
if ( eType == T_DRIVERTYPE::Jdbc )
{
::comphelper::NamedValueCollection aSettings( info );
OUString sIanaName = aSettings.getOrDefault( "CharSet", OUString() );
if ( !sIanaName.isEmpty() )
{
::dbtools::OCharsetMap aLookupIanaName;
::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.findIanaName(sIanaName);
if (aLookup != aLookupIanaName.end() )
{
OUString sAdd;
if ( RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding() )
{
static const char s_sCharSetOp[] = "useUnicode=true&";
if ( !sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp) )
{
sAdd = s_sCharSetOp;
} // if ( !sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp) )
} // if ( RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding() )
if ( sCuttedUrl.indexOf('?') == -1 )
sCuttedUrl += "?";
else
sCuttedUrl += "&";
sCuttedUrl += sAdd;
sCuttedUrl += "characterEncoding=";
sCuttedUrl += sIanaName;
}
}
} // if ( !bIsODBC )
xConnection = xDriver->connect( sCuttedUrl, aConvertedProperties );
if ( xConnection.is() )
{
OMetaConnection* pMetaConnection = nullptr;
// now we have to set the URL to get the correct answer for metadata()->getURL()
Reference< XUnoTunnel> xTunnel(xConnection,UNO_QUERY);
if ( xTunnel.is() )
{
pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
if ( pMetaConnection )
pMetaConnection->setURL(url);
}
m_aConnections.push_back(TWeakPair(WeakReferenceHelper(xConnection),TWeakConnectionPair(WeakReferenceHelper(),pMetaConnection)));
}
}
}
return xConnection;
}
sal_Bool SAL_CALL ODriverDelegator::acceptsURL( const OUString& url )
{
Sequence< PropertyValue > info;
bool bOK = url.startsWith( "sdbc:mysql:odbc:" )
|| url.startsWith( "sdbc:mysql:jdbc:" )
|| ( url.startsWith( "sdbc:mysql:mysqlc:" )
&& loadDriver( url, info ).is()
);
return bOK;
}
Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& info )
{
std::vector< DriverPropertyInfo > aDriverInfo;
if ( !acceptsURL(url) )
return Sequence< DriverPropertyInfo >();
Sequence< OUString > aBoolean(2);
aBoolean[0] = "0";
aBoolean[1] = "1";
aDriverInfo.push_back(DriverPropertyInfo(
"CharSet"
,"CharSet of the database."
,false
,OUString()
,Sequence< OUString >())
);
aDriverInfo.push_back(DriverPropertyInfo(
"SuppressVersionColumns"
,"Display version columns (when available)."
,false
,"0"
,aBoolean)
);
const T_DRIVERTYPE eType = lcl_getDriverType( url );
if ( eType == T_DRIVERTYPE::Jdbc )
{
aDriverInfo.push_back(DriverPropertyInfo(
"JavaDriverClass"
,"The JDBC driver class name."
,true
,getJavaDriverClass(info)
,Sequence< OUString >())
);
}
else if ( eType == T_DRIVERTYPE::Native )
{
aDriverInfo.push_back(DriverPropertyInfo(
"LocalSocket"
,"The file path of a socket to connect to a local MySQL server."
,false
,OUString()
,Sequence< OUString >())
);
aDriverInfo.push_back(DriverPropertyInfo(
"NamedPipe"
,"The name of a pipe to connect to a local MySQL server."
,false
,OUString()
,Sequence< OUString >())
);
}
return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
}
sal_Int32 SAL_CALL ODriverDelegator::getMajorVersion( )
{
return 1;
}
sal_Int32 SAL_CALL ODriverDelegator::getMinorVersion( )
{
return 0;
}
Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByConnection( const Reference< XConnection >& connection )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);
Reference< XTablesSupplier > xTab;
Reference< XUnoTunnel> xTunnel(connection,UNO_QUERY);
if ( xTunnel.is() )
{
OMetaConnection* pConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
if ( pConnection )
{
TWeakPairVector::const_iterator aEnd = m_aConnections.end();
for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
{
if ( i->second.second == pConnection )
{
xTab.set(i->second.first.get().get(),UNO_QUERY);
if ( !xTab.is() )
{
xTab = new OMySQLCatalog(connection);
i->second.first = WeakReferenceHelper(xTab);
}
break;
}
}
}
} // if ( xTunnel.is() )
if ( !xTab.is() )
{
TWeakPairVector::const_iterator aEnd = m_aConnections.end();
for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
{
Reference< XConnection > xTemp(i->first.get(),UNO_QUERY);
if ( xTemp == connection )
{
xTab.set(i->second.first.get().get(),UNO_QUERY);
if ( !xTab.is() )
{
xTab = new OMySQLCatalog(connection);
i->second.first = WeakReferenceHelper(xTab);
}
break;
}
}
}
return xTab;
}
Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByURL( const OUString& url, const Sequence< PropertyValue >& info )
{
if ( ! acceptsURL(url) )
{
::connectivity::SharedResources aResources;
const OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
::dbtools::throwGenericSQLException(sMessage ,*this);
} // if ( ! acceptsURL(url) )
return getDataDefinitionByConnection(connect(url,info));
}
// XServiceInfo
OUString ODriverDelegator::getImplementationName_Static( )
{
return OUString("org.openoffice.comp.drivers.MySQL.Driver");
}
Sequence< OUString > ODriverDelegator::getSupportedServiceNames_Static( )
{
Sequence< OUString > aSNS( 2 );
aSNS[0] = "com.sun.star.sdbc.Driver";
aSNS[1] = "com.sun.star.sdbcx.Driver";
return aSNS;
}
OUString SAL_CALL ODriverDelegator::getImplementationName( )
{
return getImplementationName_Static();
}
sal_Bool SAL_CALL ODriverDelegator::supportsService( const OUString& _rServiceName )
{
return cppu::supportsService(this, _rServiceName);
}
Sequence< OUString > SAL_CALL ODriverDelegator::getSupportedServiceNames( )
{
return getSupportedServiceNames_Static();
}
} // namespace connectivity
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,356 +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 <string.h>
#include <mysql/YTable.hxx>
#include <mysql/YTables.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbcx/Privilege.hpp>
#include <comphelper/property.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/sdbcx/VColumn.hxx>
#include <connectivity/TKeys.hxx>
#include <connectivity/TIndexes.hxx>
#include <connectivity/TColumnsHelper.hxx>
#include <mysql/YCatalog.hxx>
#include <mysql/YColumns.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity::mysql;
using namespace connectivity::sdbcx;
using namespace connectivity;
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;
namespace connectivity
{
namespace mysql
{
class OMySQLKeysHelper : public OKeysHelper
{
protected:
virtual OUString getDropForeignKey() const override
{
return OUString(" DROP FOREIGN KEY ");
}
public:
OMySQLKeysHelper( OTableHelper* _pTable,
::osl::Mutex& _rMutex,
const ::std::vector< OUString>& _rVector
) : OKeysHelper(_pTable,_rMutex,_rVector){}
};
}
}
OMySQLTable::OMySQLTable( sdbcx::OCollection* _pTables,
const Reference< XConnection >& _xConnection)
:OTableHelper(_pTables,_xConnection,true)
{
// we create a new table here, so we should have all the rights or ;-)
m_nPrivileges = Privilege::DROP |
Privilege::REFERENCE |
Privilege::ALTER |
Privilege::CREATE |
Privilege::READ |
Privilege::DELETE |
Privilege::UPDATE |
Privilege::INSERT |
Privilege::SELECT;
construct();
}
OMySQLTable::OMySQLTable( sdbcx::OCollection* _pTables,
const Reference< XConnection >& _xConnection,
const OUString& Name,
const OUString& Type,
const OUString& Description ,
const OUString& SchemaName,
const OUString& CatalogName,
sal_Int32 _nPrivileges
) : OTableHelper( _pTables,
_xConnection,
true,
Name,
Type,
Description,
SchemaName,
CatalogName)
, m_nPrivileges(_nPrivileges)
{
construct();
}
void OMySQLTable::construct()
{
OTableHelper::construct();
if ( !isNew() )
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRIVILEGES), PROPERTY_ID_PRIVILEGES,PropertyAttribute::READONLY,&m_nPrivileges, cppu::UnoType<decltype(m_nPrivileges)>::get());
}
::cppu::IPropertyArrayHelper* OMySQLTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
{
return doCreateArrayHelper();
}
::cppu::IPropertyArrayHelper & OMySQLTable::getInfoHelper()
{
return *static_cast<OMySQLTable_PROP*>(this)->getArrayHelper(isNew() ? 1 : 0);
}
sdbcx::OCollection* OMySQLTable::createColumns(const ::std::vector< OUString>& _rNames)
{
OMySQLColumns* pColumns = new OMySQLColumns(*this,m_aMutex,_rNames);
pColumns->setParent(this);
return pColumns;
}
sdbcx::OCollection* OMySQLTable::createKeys(const ::std::vector< OUString>& _rNames)
{
return new OMySQLKeysHelper(this,m_aMutex,_rNames);
}
sdbcx::OCollection* OMySQLTable::createIndexes(const ::std::vector< OUString>& _rNames)
{
return new OIndexesHelper(this,m_aMutex,_rNames);
}
Sequence< sal_Int8 > OMySQLTable::getUnoTunnelImplementationId()
{
static ::cppu::OImplementationId implId;
return implId.getImplementationId();
}
// css::lang::XUnoTunnel
sal_Int64 OMySQLTable::getSomething( const Sequence< sal_Int8 > & rId )
{
return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
? reinterpret_cast< sal_Int64 >( this )
: OTable_TYPEDEF::getSomething(rId);
}
// XAlterTable
void SAL_CALL OMySQLTable::alterColumnByName( const OUString& colName, const Reference< XPropertySet >& descriptor )
{
::osl::MutexGuard aGuard(m_aMutex);
checkDisposed(
#ifdef __GNUC__
::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
#else
rBHelper.bDisposed
#endif
);
if ( !m_xColumns || !m_xColumns->hasByName(colName) )
throw NoSuchElementException(colName,*this);
if ( !isNew() )
{
// first we have to check what should be altered
Reference<XPropertySet> xProp;
m_xColumns->getByName(colName) >>= xProp;
// first check the types
sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
::dbtools::OPropertyMap& rProp = OMetaConnection::getPropMap();
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nOldType;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nNewType;
// and precisions and scale
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION)) >>= nOldPrec;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION))>>= nNewPrec;
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nOldScale;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nNewScale;
// second: check the "is nullable" value
sal_Int32 nOldNullable = 0,nNewNullable = 0;
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nOldNullable;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNewNullable;
// check also the auto_increment
bool bOldAutoIncrement = false,bAutoIncrement = false;
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bOldAutoIncrement;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
bool bColumnNameChanged = false;
OUString sOldDesc,sNewDesc;
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sOldDesc;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sNewDesc;
if ( nOldType != nNewType
|| nOldPrec != nNewPrec
|| nOldScale != nNewScale
|| nNewNullable != nOldNullable
|| bOldAutoIncrement != bAutoIncrement
|| sOldDesc != sNewDesc )
{
// special handling because they changed the type names to distinguish
// if a column should be an auto_incmrement one
if ( bOldAutoIncrement != bAutoIncrement )
{
OUString sTypeName;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName;
static const char s_sAutoIncrement[] = "auto_increment";
if ( bAutoIncrement )
{
if ( sTypeName.indexOf(s_sAutoIncrement) == -1 )
{
sTypeName += " ";
sTypeName += s_sAutoIncrement;
}
}
else
{
sal_Int32 nIndex = 0;
if ( !sTypeName.isEmpty() && (nIndex = sTypeName.indexOf(s_sAutoIncrement)) != -1 )
{
sTypeName = sTypeName.copy(0,nIndex);
descriptor->setPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME),makeAny(sTypeName));
}
}
}
alterColumnType(nNewType,colName,descriptor);
bColumnNameChanged = true;
}
// third: check the default values
OUString sNewDefault,sOldDefault;
xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sOldDefault;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sNewDefault;
if(!sOldDefault.isEmpty())
{
dropDefaultValue(colName);
if(!sNewDefault.isEmpty() && sOldDefault != sNewDefault)
alterDefaultValue(sNewDefault,colName);
}
else if(!sNewDefault.isEmpty())
alterDefaultValue(sNewDefault,colName);
// now we should look if the name of the column changed
OUString sNewColumnName;
descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) && !bColumnNameChanged )
{
const OUString sQuote = getMetaData()->getIdentifierQuoteString( );
OUString sSql = getAlterTableColumnPart() +
" CHANGE " + ::dbtools::quoteName(sQuote,colName) +
" " + OTables::adjustSQL(::dbtools::createStandardColumnPart(descriptor,getConnection(),static_cast<OTables*>(m_pTables),getTypeCreatePattern()));
executeStatement(sSql);
}
m_xColumns->refresh();
}
else
{
if(m_xColumns)
{
m_xColumns->dropByName(colName);
m_xColumns->appendByDescriptor(descriptor);
}
}
}
void OMySQLTable::alterColumnType(sal_Int32 nNewType,const OUString& _rColName, const Reference<XPropertySet>& _xDescriptor)
{
const OUString sQuote = getMetaData()->getIdentifierQuoteString( );
OUString sSql = getAlterTableColumnPart() +
" CHANGE " + ::dbtools::quoteName(sQuote,_rColName) +
" ";
OColumn* pColumn = new OColumn(true);
Reference<XPropertySet> xProp = pColumn;
::comphelper::copyProperties(_xDescriptor,xProp);
xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType));
sSql += OTables::adjustSQL(::dbtools::createStandardColumnPart(xProp,getConnection(),static_cast<OTables*>(m_pTables),getTypeCreatePattern()));
executeStatement(sSql);
}
OUString OMySQLTable::getTypeCreatePattern() const
{
return OUString("(M,D)");
}
void OMySQLTable::alterDefaultValue(const OUString& _sNewDefault,const OUString& _rColName)
{
const OUString sQuote = getMetaData()->getIdentifierQuoteString( );
OUString sSql = getAlterTableColumnPart() +
" ALTER " + ::dbtools::quoteName(sQuote,_rColName) +
" SET DEFAULT '" + _sNewDefault + "'";
executeStatement(sSql);
}
void OMySQLTable::dropDefaultValue(const OUString& _rColName)
{
const OUString sQuote = getMetaData()->getIdentifierQuoteString( );
OUString sSql = getAlterTableColumnPart() +
" ALTER " + ::dbtools::quoteName(sQuote,_rColName) +
" DROP DEFAULT";
executeStatement(sSql);
}
OUString OMySQLTable::getAlterTableColumnPart()
{
OUString sSql( "ALTER TABLE " );
OUString sComposedName(
::dbtools::composeTableName( getMetaData(), m_CatalogName, m_SchemaName, m_Name, true, ::dbtools::EComposeRule::InTableDefinitions ) );
sSql += sComposedName;
return sSql;
}
void OMySQLTable::executeStatement(const OUString& _rStatement )
{
OUString sSQL = _rStatement;
if(sSQL.endsWith(","))
sSQL = sSQL.replaceAt(sSQL.getLength()-1, 1, ")");
Reference< XStatement > xStmt = getConnection()->createStatement( );
if ( xStmt.is() )
{
xStmt->execute(sSQL);
::comphelper::disposeComponent(xStmt);
}
}
OUString OMySQLTable::getRenameStart() const
{
return OUString("RENAME TABLE ");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,216 +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/YTables.hxx>
#include <mysql/YViews.hxx>
#include <mysql/YTable.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbcx/Privilege.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <mysql/YCatalog.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbexception.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/types.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity;
using namespace ::cppu;
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;
using namespace dbtools;
sdbcx::ObjectType OTables::createObject(const OUString& _rName)
{
OUString sCatalog,sSchema,sTable;
::dbtools::qualifiedNameComponents(m_xMetaData,_rName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
Sequence< OUString > sTableTypes(3);
sTableTypes[0] = "VIEW";
sTableTypes[1] = "TABLE";
sTableTypes[2] = "%"; // just to be sure to include anything else ....
Any aCatalog;
if ( !sCatalog.isEmpty() )
aCatalog <<= sCatalog;
Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
sdbcx::ObjectType xRet = nullptr;
if ( xResult.is() )
{
Reference< XRow > xRow(xResult,UNO_QUERY);
if ( xResult->next() ) // there can be only one table with this name
{
sal_Int32 const nPrivileges = Privilege::DROP |
Privilege::REFERENCE |
Privilege::ALTER |
Privilege::CREATE |
Privilege::READ |
Privilege::DELETE |
Privilege::UPDATE |
Privilege::INSERT |
Privilege::SELECT;
OMySQLTable* pRet = new OMySQLTable( this
,static_cast<OMySQLCatalog&>(m_rParent).getConnection()
,sTable
,xRow->getString(4)
,xRow->getString(5)
,sSchema
,sCatalog
,nPrivileges);
xRet = pRet;
}
::comphelper::disposeComponent(xResult);
}
return xRet;
}
void OTables::impl_refresh( )
{
static_cast<OMySQLCatalog&>(m_rParent).refreshTables();
}
void OTables::disposing()
{
m_xMetaData.clear();
OCollection::disposing();
}
Reference< XPropertySet > OTables::createDescriptor()
{
return new OMySQLTable(this,static_cast<OMySQLCatalog&>(m_rParent).getConnection());
}
// XAppend
sdbcx::ObjectType OTables::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
createTable(descriptor);
return createObject( _rForName );
}
// XDrop
void OTables::dropObject(sal_Int32 _nPos,const OUString& _sElementName)
{
Reference< XInterface > xObject( getObject( _nPos ) );
bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
if (!bIsNew)
{
Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
OUString sCatalog,sSchema,sTable;
::dbtools::qualifiedNameComponents(m_xMetaData,_sElementName,sCatalog,sSchema,sTable,::dbtools::EComposeRule::InDataManipulation);
OUString aSql( "DROP " );
Reference<XPropertySet> xProp(xObject,UNO_QUERY);
bool bIsView = xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == "VIEW";
if(bIsView) // here we have a view
aSql += "VIEW ";
else
aSql += "TABLE ";
OUString sComposedName(
::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, true, ::dbtools::EComposeRule::InDataManipulation ) );
aSql += sComposedName;
Reference< XStatement > xStmt = xConnection->createStatement( );
if ( xStmt.is() )
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
// if no exception was thrown we must delete it from the views
if ( bIsView )
{
OViews* pViews = static_cast<OViews*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateViews());
if ( pViews && pViews->hasByName(_sElementName) )
pViews->dropByNameImpl(_sElementName);
}
}
}
OUString OTables::adjustSQL(const OUString& _sSql)
{
OUString sSQL = _sSql;
static const char s_sUNSIGNED[] = "UNSIGNED";
sal_Int32 nIndex = sSQL.indexOf(s_sUNSIGNED);
while(nIndex != -1 )
{
sal_Int32 nParen = sSQL.indexOf(')',nIndex);
sal_Int32 nPos = nIndex + strlen(s_sUNSIGNED);
OUString sNewUnsigned( sSQL.copy(nPos,nParen - nPos + 1));
sSQL = sSQL.replaceAt(nIndex, strlen(s_sUNSIGNED) + sNewUnsigned.getLength(), sNewUnsigned + s_sUNSIGNED);
nIndex = sSQL.indexOf(s_sUNSIGNED,nIndex + strlen(s_sUNSIGNED) + sNewUnsigned.getLength());
}
return sSQL;
}
void OTables::createTable( const Reference< XPropertySet >& descriptor )
{
const Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
const OUString aSql = adjustSQL(::dbtools::createSqlCreateTableStatement(descriptor,xConnection, this, "(M,D)"));
Reference< XStatement > xStmt = xConnection->createStatement( );
if ( xStmt.is() )
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
}
void OTables::appendNew(const OUString& _rsNewTable)
{
insertElement(_rsNewTable,nullptr);
// notify our container listeners
ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
OInterfaceIteratorHelper2 aListenerLoop(m_aContainerListeners);
while (aListenerLoop.hasMoreElements())
static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
}
OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
{
OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::EComposeRule::InDataManipulation, false );
}
void OTables::addComment(const Reference< XPropertySet >& descriptor,OUStringBuffer& _rOut)
{
OUString sDesc;
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sDesc;
if ( !sDesc.isEmpty() )
{
_rOut.append(" COMMENT '");
_rOut.append(sDesc);
_rOut.append("'");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-320
View File
@@ -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: */
@@ -1,105 +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/YUsers.hxx>
#include <mysql/YUser.hxx>
#include <mysql/YTable.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <connectivity/sdbcx/IRefreshable.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity;
using namespace connectivity::mysql;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
OUsers::OUsers( ::cppu::OWeakObject& _rParent,
::osl::Mutex& _rMutex,
const ::std::vector< OUString> &_rVector,
const css::uno::Reference< css::sdbc::XConnection >& _xConnection,
connectivity::sdbcx::IRefreshableUsers* _pParent)
: sdbcx::OCollection(_rParent, true, _rMutex, _rVector)
,m_xConnection(_xConnection)
,m_pParent(_pParent)
{
}
sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
{
return new OMySQLUser(m_xConnection,_rName);
}
void OUsers::impl_refresh()
{
m_pParent->refreshUsers();
}
Reference< XPropertySet > OUsers::createDescriptor()
{
OUserExtend* pNew = new OUserExtend(m_xConnection);
return pNew;
}
// XAppend
sdbcx::ObjectType OUsers::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
OUString aSql( "GRANT USAGE ON * TO " );
OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
aSql += ::dbtools::quoteName(aQuote,_rForName) + " @\"%\" ";
OUString sPassword;
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPassword;
if ( !sPassword.isEmpty() )
{
aSql += " IDENTIFIED BY '";
aSql += sPassword;
aSql += "'";
}
Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is())
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
return createObject( _rForName );
}
// XDrop
void OUsers::dropObject(sal_Int32 /*_nPos*/,const OUString& _sElementName)
{
OUString aSql( "DROP USER " );
OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
aSql += ::dbtools::quoteName(aQuote,_sElementName);
Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is())
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,151 +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/YViews.hxx>
#include <mysql/YTables.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <com/sun/star/sdbcx/CheckOption.hpp>
#include <mysql/YCatalog.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbexception.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <connectivity/sdbcx/VView.hxx>
#include <comphelper/types.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace ::cppu;
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;
using namespace dbtools;
typedef connectivity::sdbcx::OCollection OCollection_TYPE;
sdbcx::ObjectType OViews::createObject(const OUString& _rName)
{
OUString sCatalog,sSchema,sTable;
::dbtools::qualifiedNameComponents(m_xMetaData,
_rName,
sCatalog,
sSchema,
sTable,
::dbtools::EComposeRule::InDataManipulation);
return new ::connectivity::sdbcx::OView(isCaseSensitive(),
sTable,
m_xMetaData,
OUString(),
sSchema,
sCatalog
);
}
void OViews::impl_refresh( )
{
static_cast<OMySQLCatalog&>(m_rParent).refreshTables();
}
void OViews::disposing()
{
m_xMetaData.clear();
OCollection::disposing();
}
Reference< XPropertySet > OViews::createDescriptor()
{
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
connectivity::sdbcx::OView* pNew = new connectivity::sdbcx::OView(true, xConnection->getMetaData());
return pNew;
}
// XAppend
sdbcx::ObjectType OViews::appendObject( const OUString& _rForName, const Reference< XPropertySet >& descriptor )
{
createView(descriptor);
return createObject( _rForName );
}
// XDrop
void OViews::dropObject(sal_Int32 _nPos,const OUString& /*_sElementName*/)
{
if ( m_bInDrop )
return;
Reference< XInterface > xObject( getObject( _nPos ) );
bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
if (!bIsNew)
{
OUString aSql( "DROP VIEW" );
Reference<XPropertySet> xProp(xObject,UNO_QUERY);
aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::EComposeRule::InTableDefinitions, true );
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
Reference< XStatement > xStmt = xConnection->createStatement( );
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
}
void OViews::dropByNameImpl(const OUString& elementName)
{
m_bInDrop = true;
OCollection_TYPE::dropByName(elementName);
m_bInDrop = false;
}
void OViews::createView( const Reference< XPropertySet >& descriptor )
{
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
OUString aSql( "CREATE VIEW " );
OUString sCommand;
aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InTableDefinitions, true );
aSql += " AS ";
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
aSql += sCommand;
Reference< XStatement > xStmt = xConnection->createStatement( );
if ( xStmt.is() )
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
// insert the new view also in the tables collection
OTables* pTables = static_cast<OTables*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateTables());
if ( pTables )
{
OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false );
pTables->appendNew(sName);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -1,69 +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/YDriver.hxx>
#include <cppuhelper/factory.hxx>
using namespace connectivity::mysql;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::lang::XSingleServiceFactory;
using ::com::sun::star::lang::XMultiServiceFactory;
typedef Reference< XSingleServiceFactory > (*createFactoryFunc)
(
const Reference< XMultiServiceFactory > & rServiceManager,
const OUString & rComponentName,
::cppu::ComponentInstantiation pCreateFunction,
const Sequence< OUString > & rServiceNames,
rtl_ModuleCount*
);
extern "C" SAL_DLLPUBLIC_EXPORT void* mysql_component_getFactory(
const sal_Char* pImplementationName,
void* pServiceManager,
void* /*pRegistryKey*/)
{
if (!pServiceManager)
{
return nullptr;
}
Reference< XSingleServiceFactory > xRet;
const Reference< XMultiServiceFactory > xServiceManager( static_cast<XMultiServiceFactory*>(pServiceManager) );
const OUString sImplementationName( OUString::createFromAscii(pImplementationName) );
if( ODriverDelegator::getImplementationName_Static() == sImplementationName )
try
{
xRet = ::cppu::createSingleFactory( xServiceManager, sImplementationName, ODriverDelegator_CreateInstance,
ODriverDelegator::getSupportedServiceNames_Static());
}
catch(...)
{
}
if(xRet.is())
xRet->acquire();
return xRet.get();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -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>
@@ -21,18 +21,11 @@
#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 <cppconn/driver.h>
#include <cppconn/connection.h>
#include <cppconn/statement.h>
#include <cppconn/metadata.h>
#include <cppconn/exception.h>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/TransactionIsolation.hpp>
@@ -42,6 +35,8 @@
#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>
@@ -49,7 +44,6 @@ 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;
@@ -57,44 +51,44 @@ 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
}
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)
: 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);
}
OConnection::~OConnection()
{
if (!isClosed()) {
close();
}
}
void OConnection::construct(const rtl::OUString& url, const Sequence< PropertyValue >& info)
{
MutexGuard aGuard(m_aMutex);
sal_Int32 nIndex;
bool bEmbedded = false;
rtl::OUString token;
rtl::OUString aHostName("localhost");
sal_Int32 nPort = 3306;
@@ -105,92 +99,106 @@ void OConnection::construct(const rtl::OUString& url, const Sequence< PropertyVa
// parse url. Url has the following format:
// external server: sdbc:mysqlc:[hostname]:[port]/[dbname]
if (url.startsWith(MYSQLC_URI_PREFIX)) {
if (url.startsWith(MYSQLC_URI_PREFIX))
{
nIndex = 12;
} else {
bEmbedded = true;
nIndex = 20;
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OConnection::construct (embedded MySQL)", *this);
}
else
{
// sdbc:mysql:mysqlc:[hostname]:[port]/[dbname]
nIndex = 18;
}
token = url.getToken(0, '/', nIndex);
if (!token.isEmpty()) {
if (!token.isEmpty())
{
sal_Int32 nIndex1 = 0;
rtl::OUString hostandport = token.getToken(0,':', nIndex1);
if (!hostandport.isEmpty()) {
rtl::OUString hostandport = token.getToken(0, ':', nIndex1);
if (!hostandport.isEmpty())
{
aHostName = hostandport;
hostandport = token.getToken(0, ':', nIndex1);
if (!hostandport.isEmpty() && nIndex1) {
if (!hostandport.isEmpty() && nIndex1)
{
nPort = hostandport.toInt32();
}
token = url.getToken(0, '/', nIndex);
if (!token.isEmpty() && 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();
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.equalsAscii("user")) {
OSL_VERIFY( pIter->Value >>= aUser );
} else if (pIter->Name.equalsAscii("password")) {
OSL_VERIFY( pIter->Value >>= aPass );
} else if (pIter->Name.equalsAscii("LocalSocket")) {
OSL_VERIFY( pIter->Value >>= sUnixSocket );
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.equalsAscii("NamedPipe")) {
OSL_VERIFY( pIter->Value >>= sNamedPipe );
}
else if (pIter->Name == "NamedPipe")
{
OSL_VERIFY(pIter->Value >>= sNamedPipe);
namedPipePassed = !sNamedPipe.isEmpty();
} else if ( pIter->Name.equalsAscii("PublicConnectionURL")) {
OSL_VERIFY( pIter->Value >>= m_settings.connectionURL );
} else if ( pIter->Name.equalsAscii("NewURL")) { // legacy name for "PublicConnectionURL"
OSL_VERIFY( pIter->Value >>= m_settings.connectionURL );
}
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);
}
}
if (!bEmbedded) {
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());
} else {
// TODO: support for embedded server
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());
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"});
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()
@@ -205,71 +213,62 @@ css::uno::Sequence<rtl::OUString> OConnection::getSupportedServiceNames()
return s;
}
sal_Bool OConnection::supportsService(rtl::OUString const & ServiceName)
sal_Bool OConnection::supportsService(rtl::OUString const& ServiceName)
{
return cppu::supportsService(this, ServiceName);
}
Reference< XStatement > SAL_CALL OConnection::createStatement()
Reference<XStatement> SAL_CALL OConnection::createStatement()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// create a statement
Reference< XStatement > xReturn;
Reference<XStatement> xReturn;
// the statement can only be executed once
try {
xReturn = new OStatement(this);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
xReturn = new OStatement(this);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
}
Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement(const rtl::OUString& _sSql)
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 ?
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());
if (nErrorNum != 0)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), nErrorNum, *this,
getConnectionEncoding());
Reference< XPreparedStatement > xStatement;
Reference<XPreparedStatement> xStatement;
xStatement = new OPreparedStatement(this, pStmt);
m_aStatements.push_back( WeakReferenceHelper( xStatement ) );
m_aStatements.push_back(WeakReferenceHelper(xStatement));
return xStatement;
}
Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall(const rtl::OUString& /*_sSql*/ )
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 >();
return Reference<XPreparedStatement>();
}
rtl::OUString SAL_CALL OConnection::nativeSQL(const rtl::OUString& _sSql)
rtl::OUString SAL_CALL OConnection::nativeSQL(const rtl::OUString& /*_sSql*/)
{
MutexGuard aGuard(m_aMutex);
const rtl::OUString sSqlStatement = transFormPreparedStatement( _sSql );
// const rtl::OUString sSqlStatement = transFormPreparedStatement( _sSql );
rtl::OUString sNativeSQL;
try {
sNativeSQL = mysqlc_sdbc_driver::convert(m_settings.cppConnection->nativeSQL(mysqlc_sdbc_driver::convert(sSqlStatement, getConnectionEncoding())),
getConnectionEncoding());
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
// TODO
return sNativeSQL;
}
@@ -277,8 +276,9 @@ 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());
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()
@@ -291,11 +291,6 @@ sal_Bool SAL_CALL OConnection::getAutoCommit()
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
bool autoCommit = false;
try {
autoCommit = m_settings.cppConnection->getAutoCommit();
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
return autoCommit;
}
@@ -304,8 +299,9 @@ 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());
if (!mysql_commit(&m_mysql))
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(&m_mysql), mysql_errno(&m_mysql),
*this, getConnectionEncoding());
}
void SAL_CALL OConnection::rollback()
@@ -313,8 +309,9 @@ 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());
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()
@@ -325,12 +322,12 @@ sal_Bool SAL_CALL OConnection::isClosed()
return OConnection_BASE::rBHelper.bDisposed;
}
Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData()
Reference<XDatabaseMetaData> SAL_CALL OConnection::getMetaData()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
Reference<XDatabaseMetaData> xMetaData = m_xMetaData;
if (!xMetaData.is())
{
xMetaData = new ODatabaseMetaData(*this, &m_mysql);
@@ -357,18 +354,12 @@ sal_Bool SAL_CALL OConnection::isReadOnly()
return m_settings.readOnly;
}
void SAL_CALL OConnection::setCatalog(const rtl::OUString& catalog)
void SAL_CALL OConnection::setCatalog(const rtl::OUString& /*catalog*/)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// TODO How?
try {
// m_settings.cppConnection->setCatalog(rtl::OUStringToOString(catalog, m_settings.encoding).getStr());
m_settings.cppConnection->setSchema(rtl::OUStringToOString(catalog, getConnectionEncoding()).getStr());
} catch (sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
}
rtl::OUString SAL_CALL OConnection::getCatalog()
@@ -377,46 +368,15 @@ rtl::OUString SAL_CALL OConnection::getCatalog()
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
// TODO How?
rtl::OUString catalog;
try {
catalog = mysqlc_sdbc_driver::convert(m_settings.cppConnection->getSchema(), getConnectionEncoding());
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
return catalog;
return OUString{};
}
void SAL_CALL OConnection::setTransactionIsolation(sal_Int32 level)
void SAL_CALL OConnection::setTransactionIsolation(sal_Int32 /*level*/)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
sql::enum_transaction_isolation cpplevel = sql::TRANSACTION_SERIALIZABLE;
switch (level) {
case TransactionIsolation::READ_UNCOMMITTED:
cpplevel = sql::TRANSACTION_READ_UNCOMMITTED;
break;
case TransactionIsolation::READ_COMMITTED:
cpplevel = sql::TRANSACTION_READ_COMMITTED;
break;
case TransactionIsolation::REPEATABLE_READ:
cpplevel = sql::TRANSACTION_REPEATABLE_READ;
break;
case TransactionIsolation::SERIALIZABLE:
cpplevel = sql::TRANSACTION_SERIALIZABLE;
break;
case TransactionIsolation::NONE:
cpplevel = sql::TRANSACTION_SERIALIZABLE;
break;
default:;
/* XXX: Exception ?? */
}
try {
m_settings.cppConnection->setTransactionIsolation(cpplevel);
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
// TODO
}
sal_Int32 SAL_CALL OConnection::getTransactionIsolation()
@@ -424,19 +384,7 @@ sal_Int32 SAL_CALL OConnection::getTransactionIsolation()
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
try {
switch (m_settings.cppConnection->getTransactionIsolation()) {
case sql::TRANSACTION_SERIALIZABLE: return TransactionIsolation::SERIALIZABLE;
case sql::TRANSACTION_REPEATABLE_READ: return TransactionIsolation::REPEATABLE_READ;
case sql::TRANSACTION_READ_COMMITTED: return TransactionIsolation::READ_COMMITTED;
case sql::TRANSACTION_READ_UNCOMMITTED: return TransactionIsolation::READ_UNCOMMITTED;
default:
;
}
} catch (const sql::SQLException & e) {
mysqlc_sdbc_driver::translateAndThrow(e, *this, getConnectionEncoding());
}
return TransactionIsolation::NONE;
return 0; // TODO
}
Reference<XNameAccess> SAL_CALL OConnection::getTypeMap()
@@ -444,11 +392,11 @@ Reference<XNameAccess> SAL_CALL OConnection::getTypeMap()
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
Reference<XNameAccess > t = m_typeMap;
Reference<XNameAccess> t = m_typeMap;
return t;
}
void SAL_CALL OConnection::setTypeMap(const Reference<XNameAccess >& typeMap)
void SAL_CALL OConnection::setTypeMap(const Reference<XNameAccess>& typeMap)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
@@ -469,6 +417,7 @@ void SAL_CALL OConnection::close()
checkDisposed(OConnection_BASE::rBHelper.bDisposed);
}
mysql_close(&m_mysql);
mysql_library_end();
dispose();
}
@@ -492,14 +441,15 @@ void OConnection::disposing()
for (auto const& statement : m_aStatements)
{
Reference< XComponent > xComp(statement.get(), UNO_QUERY);
if (xComp.is()) {
Reference<XComponent> xComp(statement.get(), UNO_QUERY);
if (xComp.is())
{
xComp->dispose();
}
}
m_aStatements.clear();
m_xMetaData = WeakReference< XDatabaseMetaData >();
m_xMetaData = WeakReference<XDatabaseMetaData>();
OConnection_BASE::disposing();
}
@@ -516,22 +466,34 @@ sal_Int32 OConnection::getMysqlVersion()
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(rtl::OUString("ActiveConnection"), makeAny(xCon));
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&) {}
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&) { }
if (m_xParameterSubstitution.is())
{
try
{
sSqlStatement = m_xParameterSubstitution->substituteVariables(sSqlStatement, true);
}
catch (const Exception&)
{
}
}
return sSqlStatement;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -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: */
@@ -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_*/,
const rtl::OUString& /*primaryTable_*/, const Any& /*foreignCatalog*/,
const rtl::OUString& /*foreignSchema*/, const rtl::OUString& /*foreignTable*/)
{
Reference<XResultSet> xResultSet(getOwnConnection().getDriver().getFactory()->createInstance(
"org.openoffice.comp.helper.DatabaseMetaDataResultSet"),
UNO_QUERY);
std::vector<std::vector<Any>> rRows;
// TODO
lcl_setRows_throw(xResultSet, 13, rRows);
return xResultSet;
}
Reference<XResultSet> SAL_CALL ODatabaseMetaData::getUDTs(
const Any& /* catalog */, const rtl::OUString& /* schemaPattern */,
const rtl::OUString& /* typeNamePattern */, const Sequence<sal_Int32>& /* types */)
{
mysqlc_sdbc_driver::throwFeatureNotImplementedException("ODatabaseMetaData::getUDTs", *this);
return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -0,0 +1,245 @@
/* -*- 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_DATABASEMETADATA_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_DATABASEMETADATA_HXX
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include <cppuhelper/implbase1.hxx>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::uno::Any;
//************ Class: ODatabaseMetaData
typedef ::cppu::WeakImplHelper1<css::sdbc::XDatabaseMetaData> ODatabaseMetaData_BASE;
class ODatabaseMetaData final : public ODatabaseMetaData_BASE
{
OConnection& m_rConnection;
MYSQL* m_pMySql;
rtl::OUString identifier_quote_string;
public:
const OConnection& getOwnConnection() const { return m_rConnection; }
explicit ODatabaseMetaData(OConnection& _rCon, MYSQL* pMySql);
virtual ~ODatabaseMetaData() override;
// as I mentioned before this interface is really BIG
// XDatabaseMetaData
sal_Bool SAL_CALL allProceduresAreCallable() SAL_OVERRIDE;
sal_Bool SAL_CALL allTablesAreSelectable() SAL_OVERRIDE;
rtl::OUString SAL_CALL getURL() SAL_OVERRIDE;
rtl::OUString SAL_CALL getUserName() SAL_OVERRIDE;
sal_Bool SAL_CALL isReadOnly() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedHigh() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedLow() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedAtStart() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedAtEnd() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDatabaseProductName() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDatabaseProductVersion() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDriverName() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDriverVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDriverMajorVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDriverMinorVersion() SAL_OVERRIDE;
sal_Bool SAL_CALL usesLocalFiles() SAL_OVERRIDE;
sal_Bool SAL_CALL usesLocalFilePerTable() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMixedCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesUpperCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesLowerCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesMixedCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers() SAL_OVERRIDE;
rtl::OUString SAL_CALL getIdentifierQuoteString() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSQLKeywords() SAL_OVERRIDE;
rtl::OUString SAL_CALL getNumericFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getStringFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSystemFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getTimeDateFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSearchStringEscape() SAL_OVERRIDE;
rtl::OUString SAL_CALL getExtraNameCharacters() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsAlterTableWithAddColumn() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsAlterTableWithDropColumn() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsColumnAliasing() SAL_OVERRIDE;
sal_Bool SAL_CALL nullPlusNonNullIsNull() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTypeConversion() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsConvert(sal_Int32 fromType, sal_Int32 toType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTableCorrelationNames() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDifferentTableCorrelationNames() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsExpressionsInOrderBy() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOrderByUnrelated() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupBy() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupByUnrelated() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupByBeyondSelect() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsLikeEscapeClause() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMultipleResultSets() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMultipleTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsNonNullableColumns() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMinimumSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCoreSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsExtendedSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92EntryLevelSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92IntermediateSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92FullSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsIntegrityEnhancementFacility() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOuterJoins() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsFullOuterJoins() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsLimitedOuterJoins() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSchemaTerm() SAL_OVERRIDE;
rtl::OUString SAL_CALL getProcedureTerm() SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogTerm() SAL_OVERRIDE;
sal_Bool SAL_CALL isCatalogAtStart() SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogSeparator() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInDataManipulation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInProcedureCalls() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInTableDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInIndexDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInDataManipulation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInProcedureCalls() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInTableDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsPositionedDelete() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsPositionedUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSelectForUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsStoredProcedures() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInComparisons() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInExists() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInIns() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInQuantifieds() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCorrelatedSubqueries() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsUnion() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsUnionAll() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxBinaryLiteralLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCharLiteralLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInGroupBy() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInIndex() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInOrderBy() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInSelect() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInTable() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxConnections() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCursorNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxIndexLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxSchemaNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxProcedureNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCatalogNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxRowSize() SAL_OVERRIDE;
sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxStatementLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxStatements() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxTableNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxTablesInSelect() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxUserNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDefaultTransactionIsolation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTransactionIsolationLevel(sal_Int32 level) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly() SAL_OVERRIDE;
sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getProcedures(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& procedureNamePattern) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getProcedureColumns(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& procedureNamePattern,
const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getTables(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& tableNamePattern,
const css::uno::Sequence<rtl::OUString>& types) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getSchemas() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getCatalogs() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getTableTypes() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getColumns(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& tableNamePattern,
const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getColumnPrivileges(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table,
const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getTablePrivileges(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& tableNamePattern) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getBestRowIdentifier(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table, sal_Int32 scope,
sal_Bool nullable) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getVersionColumns(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getPrimaryKeys(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getImportedKeys(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getExportedKeys(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getCrossReference(const Any& primaryCatalog, const rtl::OUString& primarySchema,
const rtl::OUString& primaryTable, const Any& foreignCatalog,
const rtl::OUString& foreignSchema,
const rtl::OUString& foreignTable) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getTypeInfo() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getIndexInfo(const Any& catalog, const rtl::OUString& schema,
const rtl::OUString& table, sal_Bool unique,
sal_Bool approximate) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsResultSetType(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsResultSetConcurrency(sal_Int32 setType,
sal_Int32 concurrency) SAL_OVERRIDE;
sal_Bool SAL_CALL ownUpdatesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL ownDeletesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL ownInsertsAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersUpdatesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersDeletesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersInsertsAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL updatesAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL deletesAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL insertsAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsBatchUpdates() SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL getUDTs(const Any& catalog, const rtl::OUString& schemaPattern,
const rtl::OUString& typeNamePattern,
const css::uno::Sequence<sal_Int32>& types) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() SAL_OVERRIDE;
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_DATABASEMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -0,0 +1,169 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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_driver.hxx"
#include "mysqlc_connection.hxx"
#include "mysqlc_general.hxx"
using namespace css::uno;
using namespace css::lang;
using namespace css::beans;
using namespace css::sdbc;
using namespace connectivity::mysqlc;
#include <cppuhelper/supportsservice.hxx>
#include <stdio.h>
MysqlCDriver::MysqlCDriver(const Reference<XMultiServiceFactory>& _rxFactory)
: ODriver_BASE(m_aMutex)
, m_xFactory(_rxFactory)
{
}
void MysqlCDriver::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
// when driver will be destroyed so all our connections have to be destroyed as well
for (auto const& connection : m_xConnections)
{
Reference<XComponent> xComp(connection.get(), UNO_QUERY);
if (xComp.is())
{
xComp->dispose();
}
}
m_xConnections.clear();
ODriver_BASE::disposing();
}
// static ServiceInfo
OUString MysqlCDriver::getImplementationName_Static()
{
return OUString("com.sun.star.comp.sdbc.mysqlc.MysqlCDriver");
}
Sequence<OUString> MysqlCDriver::getSupportedServiceNames_Static()
{
Sequence<OUString> aSNS(1);
aSNS[0] = "com.sun.star.sdbc.Driver";
return aSNS;
}
OUString SAL_CALL MysqlCDriver::getImplementationName() { return getImplementationName_Static(); }
sal_Bool SAL_CALL MysqlCDriver::supportsService(const OUString& _rServiceName)
{
return cppu::supportsService(this, _rServiceName);
}
Sequence<OUString> SAL_CALL MysqlCDriver::getSupportedServiceNames()
{
return getSupportedServiceNames_Static();
}
void MysqlCDriver::impl_initCppConn_lck_throw()
{
#ifdef BUNDLE_MARIADB
if (!m_bAttemptedLoadCConn)
{
const OUString sModuleName(BUNDLE_MARIADB);
m_hCConnModule = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
m_bAttemptedLoadCConn = true;
}
// attempted to load - was it successful?
if (!m_hCConnModule)
{
OSL_FAIL("MysqlCDriver::impl_initCppConn_lck_throw: could not load the " BUNDLE_MARIADB
" library!");
throw SQLException("Unable to load the " BUNDLE_MARIADB " library.", *this,
OUString("08001"), // "unable to connect"
0, Any());
}
#endif
}
Reference<XConnection> SAL_CALL MysqlCDriver::connect(const OUString& url,
const Sequence<PropertyValue>& info)
{
::osl::MutexGuard aGuard(m_aMutex);
if (!acceptsURL(url))
{
return nullptr;
}
Reference<XConnection> xConn;
// create a new connection with the given properties and append it to our vector
OConnection* pCon = new OConnection(*this);
xConn = pCon;
pCon->construct(url, info);
m_xConnections.push_back(WeakReferenceHelper(*pCon));
return xConn;
}
sal_Bool SAL_CALL MysqlCDriver::acceptsURL(const OUString& url)
{
return url.startsWith("sdbc:mysqlc:") || url.startsWith("sdbc:mysql:mysqlc:");
}
Sequence<DriverPropertyInfo> SAL_CALL
MysqlCDriver::getPropertyInfo(const OUString& url, const Sequence<PropertyValue>& /* info */)
{
if (acceptsURL(url))
{
::std::vector<DriverPropertyInfo> aDriverInfo;
aDriverInfo.push_back(DriverPropertyInfo("Hostname", "Name of host", true, "localhost",
Sequence<OUString>()));
aDriverInfo.push_back(
DriverPropertyInfo("Port", "Port", true, "3306", Sequence<OUString>()));
return Sequence<DriverPropertyInfo>(&(aDriverInfo[0]), aDriverInfo.size());
}
return Sequence<DriverPropertyInfo>();
}
sal_Int32 SAL_CALL MysqlCDriver::getMajorVersion() { return MARIADBC_VERSION_MAJOR; }
sal_Int32 SAL_CALL MysqlCDriver::getMinorVersion() { return MARIADBC_VERSION_MINOR; }
namespace connectivity
{
namespace mysqlc
{
Reference<XInterface> MysqlCDriver_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
{
return (*(new MysqlCDriver(_rxFactory)));
}
void checkDisposed(bool _bThrow)
{
if (_bThrow)
{
throw DisposedException();
}
}
} /* mysqlc */
} /* connectivity */
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* 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_DRIVER_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/compbase2.hxx>
#include <osl/module.h>
namespace connectivity
{
namespace mysqlc
{
using css::sdbc::SQLException;
using css::uno::Exception;
using css::uno::Reference;
using css::uno::RuntimeException;
using css::uno::Sequence;
using rtl::OUString;
Reference<css::uno::XInterface>
MysqlCDriver_CreateInstance(const Reference<css::lang::XMultiServiceFactory>& _rxFactory);
typedef ::cppu::WeakComponentImplHelper2<css::sdbc::XDriver, css::lang::XServiceInfo> ODriver_BASE;
typedef void* (*OMysqlCConnection_CreateInstanceFunction)(void* _pDriver);
class MysqlCDriver : public ODriver_BASE
{
protected:
Reference<css::lang::XMultiServiceFactory> m_xFactory;
::osl::Mutex m_aMutex; // mutex is need to control member access
OWeakRefArray m_xConnections; // vector containing a list
// of all the Connection objects
// for this Driver
#ifndef SYSTEM_MYSQL_CPPCONN
#ifdef BUNDLE_MARIADB
oslModule m_hCConnModule;
bool m_bAttemptedLoadCConn;
#endif
#endif
public:
explicit MysqlCDriver(const Reference<css::lang::XMultiServiceFactory>& _rxFactory);
// OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
static OUString getImplementationName_Static();
static Sequence<OUString> getSupportedServiceNames_Static();
// XServiceInfo
OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsService(const OUString& ServiceName) SAL_OVERRIDE;
Sequence<OUString> SAL_CALL getSupportedServiceNames() SAL_OVERRIDE;
// XDriver
Reference<css::sdbc::XConnection> SAL_CALL
connect(const OUString& url, const Sequence<css::beans::PropertyValue>& info) SAL_OVERRIDE;
sal_Bool SAL_CALL acceptsURL(const OUString& url) SAL_OVERRIDE;
Sequence<css::sdbc::DriverPropertyInfo>
SAL_CALL getPropertyInfo(const OUString& url,
const Sequence<css::beans::PropertyValue>& info) SAL_OVERRIDE;
sal_Int32 SAL_CALL getMajorVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMinorVersion() SAL_OVERRIDE;
const Reference<css::lang::XMultiServiceFactory>& getFactory() const { return m_xFactory; }
static rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; }
private:
void impl_initCppConn_lck_throw();
};
} /* mysqlc */
} /* connectivity */
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
@@ -0,0 +1,354 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "mysqlc_general.hxx"
#include "mysqlc_resultsetmetadata.hxx"
#include <sal/log.hxx>
#include <rtl/ustring.hxx>
using com::sun::star::sdbc::SQLException;
using com::sun::star::uno::Any;
using com::sun::star::uno::Reference;
using com::sun::star::uno::XInterface;
using namespace rtl;
namespace mysqlc_sdbc_driver
{
void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize)
{
assert(mem);
switch (eType)
{
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_INT24:
*mem = malloc(sizeof(sal_Int32));
break;
case MYSQL_TYPE_SHORT:
*mem = malloc(sizeof(sal_Int16));
break;
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_TINY:
*mem = malloc(sizeof(sal_Int8));
break;
case MYSQL_TYPE_LONGLONG:
*mem = malloc(sizeof(sal_Int64));
break;
case MYSQL_TYPE_FLOAT:
*mem = malloc(sizeof(float));
break;
case MYSQL_TYPE_DOUBLE:
*mem = malloc(sizeof(double));
break;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_YEAR: // FIXME below
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_GEOMETRY:
*mem = malloc(sizeof(MYSQL_TIME));
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
*mem = malloc(sizeof(char) * nSize);
break;
case MYSQL_TYPE_NULL:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
*mem = nullptr;
break;
default:
SAL_WARN("mysqlc", "unknown enum_field_type");
}
}
/// Use this intead of mysql_real_escape_string, because that one also escapes
/// single quote ('), which should not be escaped
rtl::OString escapeSql(const rtl::OString& from)
{
rtl::OString sRet = from.replaceAll("\\", "\\\\");
sRet = sRet.replaceAll("\"", "\\\"");
sRet = sRet.replaceAll("`", "\\`");
return sRet;
}
void throwFeatureNotImplementedException(const sal_Char* _pAsciiFeatureName,
const css::uno::Reference<XInterface>& _rxContext)
{
const rtl::OUString sMessage
= rtl::OUString::createFromAscii(_pAsciiFeatureName) + ": feature not implemented.";
throw SQLException(sMessage, _rxContext, "HYC00", 0, Any());
}
void throwInvalidArgumentException(const sal_Char* _pAsciiFeatureName,
const css::uno::Reference<XInterface>& _rxContext)
{
const rtl::OUString sMessage
= rtl::OUString::createFromAscii(_pAsciiFeatureName) + ": invalid arguments.";
throw SQLException(sMessage, _rxContext, "HYC00", 0, Any());
}
void throwSQLExceptionWithMsg(const char* msg, unsigned int errorNum,
const css::uno::Reference<css::uno::XInterface>& _context,
const rtl_TextEncoding encoding)
{
rtl::OString errorMsg{ msg };
// TODO error code?
throw SQLException(rtl::OStringToOUString(errorMsg, encoding), _context, rtl::OUString(),
errorNum, Any());
}
rtl::OUString getStringFromAny(const Any& _rAny)
{
rtl::OUString nReturn;
OSL_VERIFY(_rAny >>= nReturn);
return nReturn;
}
sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept
{
// charset number 63 indicates binary
switch (eType)
{
case MYSQL_TYPE_BIT:
return css::sdbc::DataType::VARCHAR;
case MYSQL_TYPE_TINY:
return css::sdbc::DataType::TINYINT;
case MYSQL_TYPE_SHORT:
return css::sdbc::DataType::SMALLINT;
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_LONG:
return css::sdbc::DataType::INTEGER;
case MYSQL_TYPE_LONGLONG:
return css::sdbc::DataType::BIGINT;
case MYSQL_TYPE_FLOAT:
return css::sdbc::DataType::REAL;
case MYSQL_TYPE_DOUBLE:
return css::sdbc::DataType::DOUBLE;
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
return css::sdbc::DataType::DECIMAL;
case MYSQL_TYPE_STRING:
if (charsetnr == 63)
return css::sdbc::DataType::BINARY;
return css::sdbc::DataType::CHAR;
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_VAR_STRING:
if (charsetnr == 63)
return css::sdbc::DataType::VARBINARY;
return css::sdbc::DataType::VARCHAR;
case MYSQL_TYPE_BLOB:
if (charsetnr == 63)
return css::sdbc::DataType::LONGVARBINARY;
return css::sdbc::DataType::LONGVARCHAR;
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME:
return css::sdbc::DataType::TIMESTAMP;
case MYSQL_TYPE_DATE:
return css::sdbc::DataType::DATE;
case MYSQL_TYPE_TIME:
return css::sdbc::DataType::TIME;
case MYSQL_TYPE_GEOMETRY:
return css::sdbc::DataType::VARCHAR;
case MYSQL_TYPE_NULL:
return css::sdbc::DataType::SQLNULL;
}
OSL_FAIL("mysqlToOOOType: unhandled case, falling back to VARCHAR");
return css::sdbc::DataType::VARCHAR;
}
sal_Int32 mysqlStrToOOOType(const rtl::OUString& sType)
{
// TODO other types.
if (sType.equalsIgnoreAsciiCase("tiny") || sType.equalsIgnoreAsciiCase("tinyint"))
return css::sdbc::DataType::TINYINT;
if (sType.equalsIgnoreAsciiCase("smallint"))
return css::sdbc::DataType::SMALLINT;
if (sType.equalsIgnoreAsciiCase("longtext"))
return css::sdbc::DataType::LONGVARCHAR;
if (sType.equalsIgnoreAsciiCase("int"))
return css::sdbc::DataType::INTEGER;
if (sType.equalsIgnoreAsciiCase("varchar") || sType.equalsIgnoreAsciiCase("set")
|| sType.equalsIgnoreAsciiCase("enum"))
return css::sdbc::DataType::VARCHAR;
if (sType.equalsIgnoreAsciiCase("bigint"))
return css::sdbc::DataType::BIGINT;
if (sType.equalsIgnoreAsciiCase("blob") || sType.equalsIgnoreAsciiCase("longblob"))
return css::sdbc::DataType::BLOB;
if (sType.equalsIgnoreAsciiCase("varbinary"))
return css::sdbc::DataType::VARBINARY;
if (sType.equalsIgnoreAsciiCase("text"))
return css::sdbc::DataType::CHAR;
if (sType.equalsIgnoreAsciiCase("binary"))
return css::sdbc::DataType::BINARY;
if (sType.equalsIgnoreAsciiCase("time"))
return css::sdbc::DataType::TIME;
if (sType.equalsIgnoreAsciiCase("date"))
return css::sdbc::DataType::DATE;
if (sType.equalsIgnoreAsciiCase("datetime"))
return css::sdbc::DataType::TIMESTAMP;
if (sType.equalsIgnoreAsciiCase("decimal"))
return css::sdbc::DataType::DECIMAL;
if (sType.equalsIgnoreAsciiCase("real") || sType.equalsIgnoreAsciiCase("float"))
return css::sdbc::DataType::REAL;
if (sType.equalsIgnoreAsciiCase("double"))
return css::sdbc::DataType::DOUBLE;
if (sType.equalsIgnoreAsciiCase("bit") || sType.equalsIgnoreAsciiCase("bool")
|| sType.equalsIgnoreAsciiCase("boolean"))
return css::sdbc::DataType::BOOLEAN;
OSL_FAIL("Unknown type name from string, failing back to varchar.");
return css::sdbc::DataType::VARCHAR;
}
rtl::OUString mysqlTypeToStr(MYSQL_FIELD* field)
{
bool isUnsigned = (field->flags & UNSIGNED_FLAG) != 0;
bool isZerofill = (field->flags & ZEROFILL_FLAG) != 0;
switch (field->type)
{
case MYSQL_TYPE_BIT:
return OUString{ "BIT" };
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_NEWDECIMAL:
return isUnsigned ? (isZerofill ? OUString{ "DECIMAL UNSIGNED ZEROFILL" }
: OUString{ "DECIMAL UNSIGNED" })
: OUString{ "DECIMAL" };
case MYSQL_TYPE_TINY:
return isUnsigned ? (isZerofill ? OUString{ "TINYINT UNSIGNED ZEROFILL" }
: OUString{ "TINYINT UNSIGNED" })
: OUString{ "TINYINT" };
case MYSQL_TYPE_SHORT:
return isUnsigned ? (isZerofill ? OUString{ "SMALLINT UNSIGNED ZEROFILL" }
: OUString{ "SMALLINT UNSIGNED" })
: OUString{ "SMALLINT" };
case MYSQL_TYPE_LONG:
return isUnsigned ? (isZerofill ? OUString{ "INT UNSIGNED ZEROFILL" }
: OUString{ "INT UNSIGNED" })
: OUString{ "INT" };
case MYSQL_TYPE_FLOAT:
return isUnsigned ? (isZerofill ? OUString{ "FLOAT UNSIGNED ZEROFILL" }
: OUString{ "FLOAT UNSIGNED" })
: OUString{ "FLOAT" };
case MYSQL_TYPE_DOUBLE:
return isUnsigned ? (isZerofill ? OUString{ "DOUBLE UNSIGNED ZEROFILL" }
: OUString{ "DOUBLE UNSIGNED" })
: OUString{ "DOUBLE" };
case MYSQL_TYPE_NULL:
return OUString{ "NULL" };
case MYSQL_TYPE_TIMESTAMP:
return OUString{ "TIMESTAMP" };
case MYSQL_TYPE_LONGLONG:
return isUnsigned ? (isZerofill ? OUString{ "BIGINT UNSIGNED ZEROFILL" }
: OUString{ "BIGINT UNSIGNED" })
: OUString{ "BIGINT" };
case MYSQL_TYPE_INT24:
return isUnsigned ? (isZerofill ? OUString{ "MEDIUMINT UNSIGNED ZEROFILL" }
: OUString{ "MEDIUMINT UNSIGNED" })
: OUString{ "MEDIUMINT" };
case MYSQL_TYPE_DATE:
return OUString{ "DATE" };
case MYSQL_TYPE_TIME:
return OUString{ "TIME" };
case MYSQL_TYPE_DATETIME:
return OUString{ "DATETIME" };
case MYSQL_TYPE_TINY_BLOB:
{
return OUString{ "TINYBLOB" };
}
case MYSQL_TYPE_MEDIUM_BLOB:
{
return OUString{ "MEDIUMBLOB" };
}
case MYSQL_TYPE_LONG_BLOB:
{
return OUString{ "LONGBLOB" };
}
case MYSQL_TYPE_BLOB:
{
return OUString{ "BLOB" };
}
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_VAR_STRING:
if (field->flags & ENUM_FLAG)
{
return OUString{ "ENUM" };
}
if (field->flags & SET_FLAG)
{
return OUString{ "SET" };
}
return OUString{ "VARCHAR" };
case MYSQL_TYPE_STRING:
if (field->flags & ENUM_FLAG)
{
return OUString{ "ENUM" };
}
if (field->flags & SET_FLAG)
{
return OUString{ "SET" };
}
return OUString{ "CHAR" };
case MYSQL_TYPE_YEAR:
return OUString{ "YEAR" };
case MYSQL_TYPE_GEOMETRY:
return OUString{ "GEOMETRY" };
default:
return OUString{ "UNKNOWN" };
}
}
rtl::OUString convert(const ::std::string& _string, const rtl_TextEncoding encoding)
{
return rtl::OUString(_string.c_str(), _string.size(), encoding);
}
::std::string convert(const rtl::OUString& _string, const rtl_TextEncoding encoding)
{
return ::std::string(rtl::OUStringToOString(_string, encoding).getStr());
}
} /* namespace */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -0,0 +1,125 @@
/* -*- 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_GENERAL_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_GENERAL_HXX
#include <config_lgpl.h>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <osl/diagnose.h>
#include <mysql.h>
#if defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#if defined __GNUC__
#pragma GCC diagnostic pop
#endif
namespace mysqlc_sdbc_driver
{
template <typename T>
void resetSqlVar(void** target, T* pValue, enum_field_types type, sal_Int32 nSize = 0)
{
if (*target)
{
free(*target);
*target = nullptr;
}
constexpr auto nUnitSize = sizeof(T);
switch (type)
{
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
*target = malloc(nUnitSize);
memcpy(*target, pValue, nUnitSize);
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
*target = malloc(nUnitSize * nSize);
memcpy(*target, pValue, nUnitSize * nSize);
break;
case MYSQL_TYPE_NULL:
// nothing I guess
break;
default:
OSL_FAIL("resetSqlVar: unknown enum_field_type");
}
}
void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize = 0);
rtl::OString escapeSql(const rtl::OString& from);
rtl::OUString getStringFromAny(const css::uno::Any& _rAny);
/// @throws css::sdbc::SQLException
void throwFeatureNotImplementedException(
const sal_Char* _pAsciiFeatureName,
const css::uno::Reference<css::uno::XInterface>& _rxContext);
/// @throws css::sdbc::SQLException
void throwInvalidArgumentException(const sal_Char* _pAsciiFeatureName,
const css::uno::Reference<css::uno::XInterface>& _rxContext);
void throwSQLExceptionWithMsg(const char* msg, unsigned int errorNum,
const css::uno::Reference<css::uno::XInterface>& _context,
const rtl_TextEncoding encoding);
sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept;
rtl::OUString mysqlTypeToStr(MYSQL_FIELD* pField);
sal_Int32 mysqlStrToOOOType(const rtl::OUString& sType);
rtl::OUString convert(const ::std::string& _string, const rtl_TextEncoding encoding);
::std::string convert(const rtl::OUString& _string, const rtl_TextEncoding encoding);
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -50,9 +50,6 @@ using namespace com::sun::star::util;
using namespace ::comphelper;
using ::osl::MutexGuard;
#include <cppconn/resultset.h>
#include <cppconn/resultset_metadata.h>
#include <stdio.h>
rtl::OUString SAL_CALL OPreparedResultSet::getImplementationName()
@@ -130,8 +127,8 @@ sal_Int32 SAL_CALL OPreparedResultSet::findColumn(const rtl::OUString& columnNam
return i + 1; // sdbc indexes from 1
}
throw SQLException("The column name '" + columnName + "' is not valid.", *this,
rtl::OUString("42S22"), 0, Any());
throw SQLException("The column name '" + columnName + "' is not valid.", *this, "42S22", 0,
Any());
}
uno::Reference<XInputStream> SAL_CALL OPreparedResultSet::getBinaryStream(sal_Int32 column)
@@ -90,7 +90,7 @@ class OPreparedResultSet final : public OBase_Mutex,
void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
// you can't delete objects of this type
virtual ~OPreparedResultSet();
virtual ~OPreparedResultSet() override;
public:
virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
@@ -28,11 +28,6 @@
#include <boost/config.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <cppconn/connection.h>
#include <cppconn/exception.h>
#include <cppconn/parameter_metadata.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/statement.h>
#include <cppuhelper/typeprovider.hxx>
#include <stdio.h>
@@ -63,19 +58,19 @@ css::uno::Sequence<rtl::OUString> OPreparedStatement::getSupportedServiceNames()
return s;
}
sal_Bool OPreparedStatement::supportsService(rtl::OUString const & ServiceName)
sal_Bool OPreparedStatement::supportsService(rtl::OUString const& ServiceName)
{
return cppu::supportsService(this, ServiceName);
}
OPreparedStatement::OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pStmt)
:OCommonStatement(_pConnection)
,m_pStmt(pStmt)
: OCommonStatement(_pConnection)
, m_pStmt(pStmt)
{
m_paramCount = mysql_stmt_param_count(m_pStmt);
m_binds.reserve(m_paramCount);
m_bindMetas.reserve(m_paramCount);
for(unsigned i=0; i<m_paramCount; ++i)
for (unsigned i = 0; i < m_paramCount; ++i)
{
MYSQL_BIND bind;
memset(&bind, 0, sizeof(MYSQL_BIND));
@@ -87,37 +82,28 @@ OPreparedStatement::OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pS
}
}
OPreparedStatement::~OPreparedStatement()
{
}
OPreparedStatement::~OPreparedStatement() {}
void SAL_CALL OPreparedStatement::acquire()
throw()
{
OCommonStatement::acquire();
}
void SAL_CALL OPreparedStatement::acquire() throw() { OCommonStatement::acquire(); }
void SAL_CALL OPreparedStatement::release()
throw()
{
OCommonStatement::release();
}
void SAL_CALL OPreparedStatement::release() throw() { OCommonStatement::release(); }
Any SAL_CALL OPreparedStatement::queryInterface(const Type & rType)
Any SAL_CALL OPreparedStatement::queryInterface(const Type& rType)
{
Any aRet = OCommonStatement::queryInterface(rType);
if (!aRet.hasValue()) {
if (!aRet.hasValue())
{
aRet = OPreparedStatement_BASE::queryInterface(rType);
}
return aRet;
}
Sequence< Type > SAL_CALL OPreparedStatement::getTypes()
Sequence<Type> SAL_CALL OPreparedStatement::getTypes()
{
return concatSequences(OPreparedStatement_BASE::getTypes(), OCommonStatement::getTypes());
}
Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
Reference<XResultSetMetaData> SAL_CALL OPreparedStatement::getMetaData()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -126,8 +112,8 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
{
MYSQL_RES* pRes = mysql_stmt_result_metadata(m_pStmt);
// TODO warning or error if no meta data.
m_xMetaData = new OResultSetMetaData( *m_xConnection.get(), pRes,
getOwnConnection()->getConnectionEncoding());
m_xMetaData = new OResultSetMetaData(*m_xConnection.get(), pRes,
getOwnConnection()->getConnectionEncoding());
}
return m_xMetaData;
}
@@ -137,7 +123,7 @@ void SAL_CALL OPreparedStatement::close()
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
if(mysql_stmt_close(m_pStmt))
if (mysql_stmt_close(m_pStmt))
{
SAL_WARN("mysqlc", "failed to close mysql prepared statement");
}
@@ -152,19 +138,21 @@ sal_Bool SAL_CALL OPreparedStatement::execute()
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
if(!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
int nFail = mysql_stmt_execute(m_pStmt);
if(nFail != 0)
if (nFail != 0)
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
return !nFail;
@@ -175,20 +163,22 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate()
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
if(!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
int nFail = mysql_stmt_execute(m_pStmt);
if(nFail != 0)
if (nFail != 0)
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
sal_Int32 affectedRows = mysql_stmt_affected_rows(m_pStmt);
@@ -201,16 +191,16 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 parameter, const rtl::OUSt
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
rtl::OString stringie(rtl::OUStringToOString(x,
m_xConnection->getConnectionEncoding()));
const sal_Int32 nIndex = parameter-1;
rtl::OString stringie(rtl::OUStringToOString(x, m_xConnection->getConnectionEncoding()));
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_STRING;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, stringie.getStr(), MYSQL_TYPE_STRING, stringie.getLength());
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, stringie.getStr(), MYSQL_TYPE_STRING,
stringie.getLength());
m_bindMetas[nIndex].is_null = 0;
m_bindMetas[nIndex].length = stringie.getLength();
}
Reference< XConnection > SAL_CALL OPreparedStatement::getConnection()
Reference<XConnection> SAL_CALL OPreparedStatement::getConnection()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -218,28 +208,30 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection()
return m_xConnection.get();
}
Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery()
Reference<XResultSet> SAL_CALL OPreparedStatement::executeQuery()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
if(!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
if (!m_binds.empty() && mysql_stmt_bind_param(m_pStmt, m_binds.data()))
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
int nFail = mysql_stmt_execute(m_pStmt);
if(nFail != 0)
if (nFail != 0)
{
MYSQL* pMysql = m_xConnection.get()->getMysqlConnection();
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt),
mysql_errno(pMysql), *this, m_xConnection.get()->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_stmt_error(m_pStmt), mysql_errno(pMysql),
*this,
m_xConnection.get()->getConnectionEncoding());
}
Reference< XResultSet > xResultSet;
Reference<XResultSet> xResultSet;
xResultSet = new OPreparedResultSet(*m_xConnection.get(), this, m_pStmt);
return xResultSet;
}
@@ -250,7 +242,7 @@ void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 parameter, sal_Bool x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_TINY;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_TINY);
m_bindMetas[nIndex].is_null = 0;
@@ -262,7 +254,7 @@ void SAL_CALL OPreparedStatement::setByte(sal_Int32 parameter, sal_Int8 x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_TINY;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_TINY);
m_bindMetas[nIndex].is_null = 0;
@@ -280,7 +272,7 @@ void SAL_CALL OPreparedStatement::setDate(sal_Int32 parameter, const Date& aData
my_time.month = aData.Month;
my_time.day = aData.Day;
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DATE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &my_time, MYSQL_TYPE_DATE);
m_bindMetas[nIndex].is_null = 0;
@@ -298,7 +290,7 @@ void SAL_CALL OPreparedStatement::setTime(sal_Int32 parameter, const Time& aVal)
my_time.minute = aVal.Minutes;
my_time.second = aVal.Seconds;
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_TIME;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &my_time, MYSQL_TYPE_TIME);
m_bindMetas[nIndex].is_null = 0;
@@ -319,7 +311,7 @@ void SAL_CALL OPreparedStatement::setTimestamp(sal_Int32 parameter, const DateTi
my_time.month = aVal.Month;
my_time.day = aVal.Day;
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_TIME;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &my_time, MYSQL_TYPE_DATETIME);
m_bindMetas[nIndex].is_null = 0;
@@ -331,7 +323,7 @@ void SAL_CALL OPreparedStatement::setDouble(sal_Int32 parameter, double x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DOUBLE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_DOUBLE);
m_bindMetas[nIndex].is_null = 0;
@@ -343,7 +335,7 @@ void SAL_CALL OPreparedStatement::setFloat(sal_Int32 parameter, float x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_FLOAT;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_FLOAT);
m_bindMetas[nIndex].is_null = 0;
@@ -355,7 +347,7 @@ void SAL_CALL OPreparedStatement::setInt(sal_Int32 parameter, sal_Int32 x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_LONG;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_LONG);
m_bindMetas[nIndex].is_null = 0;
@@ -367,7 +359,7 @@ void SAL_CALL OPreparedStatement::setLong(sal_Int32 parameter, sal_Int64 aVal)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_LONGLONG;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &aVal, MYSQL_TYPE_LONGLONG);
m_bindMetas[nIndex].is_null = 0;
@@ -379,13 +371,13 @@ void SAL_CALL OPreparedStatement::setNull(sal_Int32 parameter, sal_Int32 /*sqlTy
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_bindMetas[nIndex].is_null = 1;
free(m_binds[nIndex].buffer);
m_binds[nIndex].buffer = nullptr;
}
void SAL_CALL OPreparedStatement::setClob(sal_Int32 parameter, const Reference< XClob >& /* x */)
void SAL_CALL OPreparedStatement::setClob(sal_Int32 parameter, const Reference<XClob>& /* x */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -394,7 +386,7 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 parameter, const Reference<
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setClob", *this);
}
void SAL_CALL OPreparedStatement::setBlob(sal_Int32 parameter, const Reference< XBlob >& /* x */)
void SAL_CALL OPreparedStatement::setBlob(sal_Int32 parameter, const Reference<XBlob>& /* x */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -403,7 +395,7 @@ void SAL_CALL OPreparedStatement::setBlob(sal_Int32 parameter, const Reference<
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setBlob", *this);
}
void SAL_CALL OPreparedStatement::setArray(sal_Int32 parameter, const Reference< XArray >& /* x */)
void SAL_CALL OPreparedStatement::setArray(sal_Int32 parameter, const Reference<XArray>& /* x */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -412,7 +404,7 @@ void SAL_CALL OPreparedStatement::setArray(sal_Int32 parameter, const Reference<
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setArray", *this);
}
void SAL_CALL OPreparedStatement::setRef(sal_Int32 parameter, const Reference< XRef >& /* x */)
void SAL_CALL OPreparedStatement::setRef(sal_Int32 parameter, const Reference<XRef>& /* x */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
@@ -421,66 +413,72 @@ void SAL_CALL OPreparedStatement::setRef(sal_Int32 parameter, const Reference< X
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setRef", *this);
}
void SAL_CALL OPreparedStatement::setObjectWithInfo(sal_Int32 parameterIndex, const Any& value, sal_Int32 targetSqlType, sal_Int32 /* scale */)
void SAL_CALL OPreparedStatement::setObjectWithInfo(sal_Int32 parameterIndex, const Any& value,
sal_Int32 targetSqlType, sal_Int32 /* scale */)
{
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
MutexGuard aGuard(m_aMutex);
checkParameterIndex( parameterIndex );
checkParameterIndex(parameterIndex);
const sal_Int32 nIndex = parameterIndex - 1;
if ( !value.hasValue() )
if (!value.hasValue())
{
free(m_binds[nIndex].buffer);
m_binds[nIndex].buffer = nullptr;
m_bindMetas[parameterIndex-1].is_null = 1;
m_bindMetas[parameterIndex - 1].is_null = 1;
return;
}
switch ( targetSqlType )
switch (targetSqlType)
{
case DataType::DECIMAL:
case DataType::NUMERIC:
{
double nValue(0.0);
rtl::OUString sValue;
if ( value >>= nValue )
case DataType::DECIMAL:
case DataType::NUMERIC:
{
setDouble( parameterIndex, nValue );
break;
}
else if ( value >>= sValue )
{
rtl::OString sAscii = rtl::OUStringToOString(sValue, getOwnConnection()->getConnectionEncoding());
std::stringstream sStream{sAscii.getStr()};
sStream >> nValue;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DOUBLE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &nValue, MYSQL_TYPE_DOUBLE, sValue.getLength());
m_bindMetas[nIndex].is_null = 0;
break;
}
double nValue(0.0);
rtl::OUString sValue;
if (value >>= nValue)
{
setDouble(parameterIndex, nValue);
break;
}
else if (value >>= sValue)
{
rtl::OString sAscii
= rtl::OUStringToOString(sValue, getOwnConnection()->getConnectionEncoding());
std::stringstream sStream{ sAscii.getStr() };
sStream >> nValue;
m_binds[nIndex].buffer_type = MYSQL_TYPE_DOUBLE;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &nValue, MYSQL_TYPE_DOUBLE,
sValue.getLength());
m_bindMetas[nIndex].is_null = 0;
break;
}
#if defined __GNUC__ && __GNUC__ >= 7
[[fallthrough]];
[[fallthrough]];
#else
BOOST_FALLTHROUGH;
BOOST_FALLTHROUGH;
#endif
}
}
// TODO other types
// TODO other types
default:
mysqlc_sdbc_driver::throwInvalidArgumentException( "OPreparedStatement::setObjectWithInfo", *this );
break;
default:
mysqlc_sdbc_driver::throwInvalidArgumentException(
"OPreparedStatement::setObjectWithInfo", *this);
break;
}
}
void SAL_CALL OPreparedStatement::setObjectNull(sal_Int32 parameter, sal_Int32 /* sqlType */, const rtl::OUString& /* typeName */)
void SAL_CALL OPreparedStatement::setObjectNull(sal_Int32 parameter, sal_Int32 /* sqlType */,
const rtl::OUString& /* typeName */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setObjectNull", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setObjectNull",
*this);
}
void SAL_CALL OPreparedStatement::setObject(sal_Int32 parameter, const Any& /* x */)
@@ -498,44 +496,46 @@ void SAL_CALL OPreparedStatement::setShort(sal_Int32 parameter, sal_Int16 x)
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_SHORT;
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_SHORT);
m_bindMetas[nIndex].is_null = 0;
}
void SAL_CALL OPreparedStatement::setBytes(sal_Int32 parameter, const Sequence< sal_Int8 >& x)
void SAL_CALL OPreparedStatement::setBytes(sal_Int32 parameter, const Sequence<sal_Int8>& x)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
const sal_Int32 nIndex = parameter-1;
const sal_Int32 nIndex = parameter - 1;
m_binds[nIndex].buffer_type = MYSQL_TYPE_BLOB; // FIXME
mysqlc_sdbc_driver::resetSqlVar(&m_binds[nIndex].buffer, &x, MYSQL_TYPE_BLOB);
m_bindMetas[nIndex].is_null = 0;
}
void SAL_CALL OPreparedStatement::setCharacterStream(sal_Int32 parameter,
const Reference< XInputStream >& /* x */,
sal_Int32 /* length */)
const Reference<XInputStream>& /* x */,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setCharacterStream", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException(
"OPreparedStatement::setCharacterStream", *this);
}
void SAL_CALL OPreparedStatement::setBinaryStream(sal_Int32 parameter,
const Reference< XInputStream >& /* x */,
sal_Int32 /* length */)
const Reference<XInputStream>& /* x */,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
checkParameterIndex(parameter);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setBinaryStream", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::setBinaryStream",
*this);
}
void SAL_CALL OPreparedStatement::clearParameters()
@@ -543,7 +543,7 @@ void SAL_CALL OPreparedStatement::clearParameters()
MutexGuard aGuard(m_aMutex);
checkDisposed(OPreparedStatement::rBHelper.bDisposed);
for(size_t i=0; i<m_binds.size(); ++i)
for (size_t i = 0; i < m_binds.size(); ++i)
{
m_bindMetas[i].is_null = 1;
free(m_binds[i].buffer);
@@ -553,7 +553,8 @@ void SAL_CALL OPreparedStatement::clearParameters()
void SAL_CALL OPreparedStatement::clearBatch()
{
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::clearBatch", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::clearBatch",
*this);
}
void SAL_CALL OPreparedStatement::addBatch()
@@ -561,15 +562,15 @@ void SAL_CALL OPreparedStatement::addBatch()
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OPreparedStatement::addBatch", *this);
}
Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch()
Sequence<sal_Int32> SAL_CALL OPreparedStatement::executeBatch()
{
Sequence< sal_Int32 > aRet= Sequence< sal_Int32 > ();
Sequence<sal_Int32> aRet = Sequence<sal_Int32>();
return aRet;
}
void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
{
switch(nHandle)
switch (nHandle)
{
case PROPERTY_ID_RESULTSETCONCURRENCY:
break;
@@ -581,14 +582,15 @@ void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,cons
break;
default:
/* XXX: Recursion ?? */
OPreparedStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
OPreparedStatement::setFastPropertyValue_NoBroadcast(nHandle, rValue);
}
}
void OPreparedStatement::checkParameterIndex(sal_Int32 column)
{
if (column < 1 || column > static_cast<sal_Int32>(m_paramCount)) {
throw SQLException("Parameter index out of range", *this, rtl::OUString(), 1, Any ());
if (column < 1 || column > static_cast<sal_Int32>(m_paramCount))
{
throw SQLException("Parameter index out of range", *this, rtl::OUString(), 1, Any());
}
}
@@ -0,0 +1,161 @@
/* -*- 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_PREPAREDSTATEMENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_PREPAREDSTATEMENT_HXX
#include "mysqlc_statement.hxx"
#include "mysqlc_resultset.hxx"
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
#include <com/sun/star/io/XInputStream.hpp>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::sdbc::XResultSetMetaData;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Type;
struct BindMetaData
{
char is_null = 0;
unsigned long length = 0;
char error = 0;
};
typedef ::cppu::ImplHelper5<css::sdbc::XPreparedStatement, css::sdbc::XParameters,
css::sdbc::XPreparedBatchExecution,
css::sdbc::XResultSetMetaDataSupplier, css::lang::XServiceInfo>
OPreparedStatement_BASE;
class OPreparedStatement final : public OCommonStatement, public OPreparedStatement_BASE
{
unsigned int m_paramCount = 0; // number of placeholders
Reference<XResultSetMetaData> m_xMetaData;
MYSQL_STMT* m_pStmt;
std::vector<MYSQL_BIND> m_binds;
std::vector<BindMetaData> m_bindMetas;
void checkParameterIndex(sal_Int32 parameter);
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
const Any& rValue) SAL_OVERRIDE;
virtual ~OPreparedStatement() override;
public:
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;
OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pStmt);
//XInterface
Any SAL_CALL queryInterface(const Type& rType) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence<Type> SAL_CALL getTypes() SAL_OVERRIDE;
// XPreparedStatement
Reference<css::sdbc::XResultSet> SAL_CALL executeQuery() SAL_OVERRIDE;
sal_Int32 SAL_CALL executeUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL execute() SAL_OVERRIDE;
Reference<css::sdbc::XConnection> SAL_CALL getConnection() SAL_OVERRIDE;
// XStatement
using OCommonStatement::execute;
using OCommonStatement::executeQuery;
using OCommonStatement::executeUpdate;
// XParameters
void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType) SAL_OVERRIDE;
void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType,
const rtl::OUString& typeName) SAL_OVERRIDE;
void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x) SAL_OVERRIDE;
void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x) SAL_OVERRIDE;
void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x) SAL_OVERRIDE;
void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x) SAL_OVERRIDE;
void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x) SAL_OVERRIDE;
void SAL_CALL setFloat(sal_Int32 parameter, float x) SAL_OVERRIDE;
void SAL_CALL setDouble(sal_Int32 parameter, double x) SAL_OVERRIDE;
void SAL_CALL setString(sal_Int32 parameter, const rtl::OUString& x) SAL_OVERRIDE;
void SAL_CALL setBytes(sal_Int32 parameter, const css::uno::Sequence<sal_Int8>& x) SAL_OVERRIDE;
void SAL_CALL setDate(sal_Int32 parameter, const css::util::Date& x) SAL_OVERRIDE;
void SAL_CALL setTime(sal_Int32 parameter, const css::util::Time& x) SAL_OVERRIDE;
void SAL_CALL setTimestamp(sal_Int32 parameter, const css::util::DateTime& x) SAL_OVERRIDE;
void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference<css::io::XInputStream>& x,
sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference<css::io::XInputStream>& x,
sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL setObject(sal_Int32 parameter, const Any& x) SAL_OVERRIDE;
void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType,
sal_Int32 scale) SAL_OVERRIDE;
void SAL_CALL setRef(sal_Int32 parameter, const Reference<css::sdbc::XRef>& x) SAL_OVERRIDE;
void SAL_CALL setBlob(sal_Int32 parameter, const Reference<css::sdbc::XBlob>& x) SAL_OVERRIDE;
void SAL_CALL setClob(sal_Int32 parameter, const Reference<css::sdbc::XClob>& x) SAL_OVERRIDE;
void SAL_CALL setArray(sal_Int32 parameter, const Reference<css::sdbc::XArray>& x) SAL_OVERRIDE;
void SAL_CALL clearParameters() SAL_OVERRIDE;
// XPreparedBatchExecution
void SAL_CALL addBatch() SAL_OVERRIDE;
void SAL_CALL clearBatch() SAL_OVERRIDE;
css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XResultSetMetaDataSupplier
Reference<css::sdbc::XResultSetMetaData> SAL_CALL getMetaData() SAL_OVERRIDE;
};
} /* mysqlc */
} /* connectivity */
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_PREPAREDSTATEMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -43,10 +43,9 @@ enum
PROPERTY_ID_USEBOOKMARKS,
PROPERTY_ID_ISBOOKMARKABLE
};
}/* mysqlc */
}/* connectivity */
} /* mysqlc */
} /* connectivity */
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_PROPERTYIDS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -50,41 +50,37 @@ using namespace com::sun::star::util;
using namespace ::comphelper;
using ::osl::MutexGuard;
#include <cppconn/resultset.h>
#include <cppconn/resultset_metadata.h>
#include <stdio.h>
namespace
{
// copied from string misc, it should be replaced when library is not an
// extension anymore
std::vector<OUString> lcl_split(const OUString& rStr, sal_Unicode cSeparator)
// copied from string misc, it should be replaced when library is not an
// extension anymore
std::vector<OUString> lcl_split(const OUString& rStr, sal_Unicode cSeparator)
{
std::vector<OUString> vec;
sal_Int32 idx = 0;
do
{
std::vector< OUString > vec;
sal_Int32 idx = 0;
do
OUString kw = rStr.getToken(0, cSeparator, idx);
kw = kw.trim();
if (!kw.isEmpty())
{
OUString kw =
rStr.getToken(0, cSeparator, idx);
kw = kw.trim();
if (!kw.isEmpty())
{
vec.push_back(kw);
}
} while (idx >= 0);
return vec;
}
vec.push_back(kw);
}
} while (idx >= 0);
return vec;
}
}
rtl::OUString SAL_CALL OResultSet::getImplementationName()
{
return rtl::OUString( "com.sun.star.sdbcx.mysqlc.ResultSet" );
return rtl::OUString("com.sun.star.sdbcx.mysqlc.ResultSet");
}
uno::Sequence< rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames()
uno::Sequence<rtl::OUString> SAL_CALL OResultSet::getSupportedServiceNames()
{
uno::Sequence< rtl::OUString > aSupported(2);
uno::Sequence<rtl::OUString> aSupported(2);
aSupported[0] = "com.sun.star.sdbc.ResultSet";
aSupported[1] = "com.sun.star.sdbcx.ResultSet";
return aSupported;
@@ -95,23 +91,22 @@ sal_Bool SAL_CALL OResultSet::supportsService(const rtl::OUString& _rServiceName
return cppu::supportsService(this, _rServiceName);
}
OResultSet::OResultSet(OConnection& rConn, OCommonStatement * pStmt, MYSQL_RES * pResult, rtl_TextEncoding _encoding )
OResultSet::OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES* pResult,
rtl_TextEncoding _encoding)
: OResultSet_BASE(m_aMutex)
,OPropertySetHelper(OResultSet_BASE::rBHelper)
,m_rConnection(rConn)
,m_pMysql(rConn.getMysqlConnection())
,m_aStatement(static_cast<OWeakObject*>(pStmt))
,m_xMetaData(nullptr)
,m_pResult(pResult)
,fieldCount( 0 )
,m_encoding( _encoding )
, OPropertySetHelper(OResultSet_BASE::rBHelper)
, m_rConnection(rConn)
, m_pMysql(rConn.getMysqlConnection())
, m_aStatement(static_cast<OWeakObject*>(pStmt))
, m_xMetaData(nullptr)
, m_pResult(pResult)
, fieldCount(0)
, m_encoding(_encoding)
{
fieldCount = mysql_num_fields(pResult);
}
OResultSet::~OResultSet()
{
}
OResultSet::~OResultSet() {}
void OResultSet::disposing()
{
@@ -120,23 +115,24 @@ void OResultSet::disposing()
MutexGuard aGuard(m_aMutex);
m_aStatement = nullptr;
m_xMetaData = nullptr;
m_xMetaData = nullptr;
}
Any SAL_CALL OResultSet::queryInterface(const Type & rType)
Any SAL_CALL OResultSet::queryInterface(const Type& rType)
{
Any aRet = OPropertySetHelper::queryInterface(rType);
if (!aRet.hasValue()) {
if (!aRet.hasValue())
{
aRet = OResultSet_BASE::queryInterface(rType);
}
return aRet;
}
uno::Sequence< Type > SAL_CALL OResultSet::getTypes()
uno::Sequence<Type> SAL_CALL OResultSet::getTypes()
{
OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
OTypeCollection aTypes(cppu::UnoType<XMultiPropertySet>::get(),
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
return concatSequences(aTypes.getTypes(), OResultSet_BASE::getTypes());
}
@@ -146,23 +142,18 @@ sal_Int32 SAL_CALL OResultSet::findColumn(const rtl::OUString& columnName)
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
MYSQL_FIELD* pFields = mysql_fetch_field(m_pResult);
for(unsigned int i = 0; i< fieldCount; ++i)
{
if(columnName.equalsIgnoreAsciiCaseAscii(pFields[i].name))
return i + 1; // sdbc indexes from 1
}
MYSQL_FIELD* pFields = mysql_fetch_field(m_pResult);
for (unsigned int i = 0; i < fieldCount; ++i)
{
if (columnName.equalsIgnoreAsciiCaseAscii(pFields[i].name))
return i + 1; // sdbc indexes from 1
}
throw SQLException(
"The column name '" + columnName + "' is not valid.",
*this,
rtl::OUString("42S22"),
0,
Any()
);
throw SQLException("The column name '" + columnName + "' is not valid.", *this, "42S22", 0,
Any());
}
uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream(sal_Int32 column)
uno::Reference<XInputStream> SAL_CALL OResultSet::getBinaryStream(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -172,13 +163,14 @@ uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream(sal_Int32 co
return nullptr;
}
uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream(sal_Int32 column)
uno::Reference<XInputStream> SAL_CALL OResultSet::getCharacterStream(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getCharacterStream", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getCharacterStream",
*this);
return nullptr;
}
@@ -188,8 +180,8 @@ sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return false;
@@ -205,8 +197,8 @@ sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0;
@@ -216,20 +208,20 @@ sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 column)
return static_cast<sal_Int8>(std::atoi(pValue));
}
uno::Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 column)
uno::Sequence<sal_Int8> SAL_CALL OResultSet::getBytes(sal_Int32 column)
{
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
MutexGuard aGuard(m_aMutex);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return uno::Sequence< sal_Int8>();
return uno::Sequence<sal_Int8>();
}
m_bWasNull = false;
return uno::Sequence< sal_Int8 > (reinterpret_cast<sal_Int8 const *>(
pValue), m_aLengths[column-1]);
return uno::Sequence<sal_Int8>(reinterpret_cast<sal_Int8 const*>(pValue),
m_aLengths[column - 1]);
}
Date SAL_CALL OResultSet::getDate(sal_Int32 column)
@@ -239,8 +231,8 @@ Date SAL_CALL OResultSet::getDate(sal_Int32 column)
checkColumnIndex(column);
Date d; // TODO initialize
char* dateStr = m_aRow[column-1];
if(!dateStr)
char* dateStr = m_aRow[column - 1];
if (!dateStr)
{
m_bWasNull = true;
return d;
@@ -248,18 +240,20 @@ Date SAL_CALL OResultSet::getDate(sal_Int32 column)
rtl::OString dateString(dateStr);
rtl::OString token;
sal_Int32 nIndex = 0, i=0;
do {
token = dateString.getToken (0, '-', nIndex);
switch (i) {
sal_Int32 nIndex = 0, i = 0;
do
{
token = dateString.getToken(0, '-', nIndex);
switch (i)
{
case 0:
d.Year = static_cast<sal_uInt16>(token.toUInt32());
d.Year = static_cast<sal_uInt16>(token.toUInt32());
break;
case 1:
d.Month = static_cast<sal_uInt16>(token.toUInt32());
d.Month = static_cast<sal_uInt16>(token.toUInt32());
break;
case 2:
d.Day = static_cast<sal_uInt16>(token.toUInt32());
d.Day = static_cast<sal_uInt16>(token.toUInt32());
break;
default:;
}
@@ -275,8 +269,8 @@ double SAL_CALL OResultSet::getDouble(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0.0;
@@ -292,8 +286,8 @@ float SAL_CALL OResultSet::getFloat(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0.0f;
@@ -307,8 +301,8 @@ sal_Int32 SAL_CALL OResultSet::getInt(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0;
@@ -332,8 +326,8 @@ sal_Int64 SAL_CALL OResultSet::getLong(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0LL;
@@ -343,17 +337,18 @@ sal_Int64 SAL_CALL OResultSet::getLong(sal_Int32 column)
return std::atol(pValue);
}
uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData()
uno::Reference<XResultSetMetaData> SAL_CALL OResultSet::getMetaData()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if (!m_xMetaData.is()) {
if (!m_xMetaData.is())
{
m_xMetaData = new OResultSetMetaData(m_rConnection, m_pResult, m_encoding);
}
return m_xMetaData;
}
uno::Reference< XArray > SAL_CALL OResultSet::getArray(sal_Int32 column)
uno::Reference<XArray> SAL_CALL OResultSet::getArray(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -363,7 +358,7 @@ uno::Reference< XArray > SAL_CALL OResultSet::getArray(sal_Int32 column)
return nullptr;
}
uno::Reference< XClob > SAL_CALL OResultSet::getClob(sal_Int32 column)
uno::Reference<XClob> SAL_CALL OResultSet::getClob(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -373,7 +368,7 @@ uno::Reference< XClob > SAL_CALL OResultSet::getClob(sal_Int32 column)
return nullptr;
}
uno::Reference< XBlob > SAL_CALL OResultSet::getBlob(sal_Int32 column)
uno::Reference<XBlob> SAL_CALL OResultSet::getBlob(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -383,7 +378,7 @@ uno::Reference< XBlob > SAL_CALL OResultSet::getBlob(sal_Int32 column)
return nullptr;
}
uno::Reference< XRef > SAL_CALL OResultSet::getRef(sal_Int32 column)
uno::Reference<XRef> SAL_CALL OResultSet::getRef(sal_Int32 column)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -393,13 +388,14 @@ uno::Reference< XRef > SAL_CALL OResultSet::getRef(sal_Int32 column)
return nullptr;
}
Any SAL_CALL OResultSet::getObject(sal_Int32 column, const uno::Reference< XNameAccess >& /* typeMap */)
Any SAL_CALL OResultSet::getObject(sal_Int32 column,
const uno::Reference<XNameAccess>& /* typeMap */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
Any aRet= Any();
Any aRet = Any();
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getObject", *this);
return aRet;
@@ -411,8 +407,8 @@ sal_Int16 SAL_CALL OResultSet::getShort(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return 0;
@@ -427,14 +423,14 @@ rtl::OUString SAL_CALL OResultSet::getString(sal_Int32 column)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return rtl::OUString{};
}
m_bWasNull = false;
return rtl::OUString(pValue, static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding);
return rtl::OUString(pValue, static_cast<sal_Int32>(m_aLengths[column - 1]), m_encoding);
}
Time SAL_CALL OResultSet::getTime(sal_Int32 column)
@@ -444,28 +440,30 @@ Time SAL_CALL OResultSet::getTime(sal_Int32 column)
checkColumnIndex(column);
Time t; // initialize
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return t;
}
rtl::OUString timeString{pValue, static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding};
rtl::OUString timeString{ pValue, static_cast<sal_Int32>(m_aLengths[column - 1]), m_encoding };
rtl::OUString token;
sal_Int32 nIndex, i=0;
sal_Int32 nIndex, i = 0;
nIndex = timeString.indexOf(' ') + 1;
do {
token = timeString.getToken (0, ':', nIndex);
switch (i) {
do
{
token = timeString.getToken(0, ':', nIndex);
switch (i)
{
case 0:
t.Hours = static_cast<sal_uInt16>(token.toUInt32());
t.Hours = static_cast<sal_uInt16>(token.toUInt32());
break;
case 1:
t.Minutes = static_cast<sal_uInt16>(token.toUInt32());
t.Minutes = static_cast<sal_uInt16>(token.toUInt32());
break;
case 2:
t.Seconds = static_cast<sal_uInt16>(token.toUInt32());
t.Seconds = static_cast<sal_uInt16>(token.toUInt32());
break;
}
i++;
@@ -481,17 +479,16 @@ DateTime SAL_CALL OResultSet::getTimestamp(sal_Int32 column)
MutexGuard aGuard(m_aMutex);
checkColumnIndex(column);
char* pValue = m_aRow[column-1];
if(!pValue)
char* pValue = m_aRow[column - 1];
if (!pValue)
{
m_bWasNull = true;
return DateTime{}; // init
}
// YY-MM-DD HH:MM:SS
std::vector<rtl::OUString> dateAndTime = lcl_split(rtl::OUString{pValue,
static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding},
u' ');
std::vector<rtl::OUString> dateAndTime = lcl_split(
rtl::OUString{ pValue, static_cast<sal_Int32>(m_aLengths[column - 1]), m_encoding }, u' ');
auto dateParts = lcl_split(dateAndTime.at(0), u'-');
auto timeParts = lcl_split(dateAndTime.at(1), u':');
@@ -581,7 +578,7 @@ sal_Bool SAL_CALL OResultSet::last()
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
mysql_data_seek(m_pResult, fieldCount-1);
mysql_data_seek(m_pResult, fieldCount - 1);
next();
return true;
@@ -593,11 +590,11 @@ sal_Bool SAL_CALL OResultSet::absolute(sal_Int32 row)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
sal_Int32 nFields = static_cast<sal_Int32>(fieldCount);
sal_Int32 nToGo = row < 0 ? nFields - row : row-1;
sal_Int32 nToGo = row < 0 ? nFields - row : row - 1;
if(nToGo >= nFields)
if (nToGo >= nFields)
nToGo = nFields - 1;
if(nToGo < 0)
if (nToGo < 0)
nToGo = 0;
mysql_data_seek(m_pResult, nToGo);
@@ -612,13 +609,13 @@ sal_Bool SAL_CALL OResultSet::relative(sal_Int32 row)
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
sal_Int32 nFields = static_cast<sal_Int32>(fieldCount);
if(row == 0)
if (row == 0)
return true;
sal_Int32 nToGo = m_nCurrentField + row;
if(nToGo >= nFields)
if (nToGo >= nFields)
nToGo = nFields - 1;
if(nToGo < 0)
if (nToGo < 0)
nToGo = 0;
mysql_data_seek(m_pResult, nToGo);
@@ -632,15 +629,15 @@ sal_Bool SAL_CALL OResultSet::previous()
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(m_nCurrentField <= 1)
if (m_nCurrentField <= 1)
return false;
mysql_data_seek(m_pResult, m_nCurrentField-2);
mysql_data_seek(m_pResult, m_nCurrentField - 2);
next();
return true;
}
uno::Reference< uno::XInterface > SAL_CALL OResultSet::getStatement()
uno::Reference<uno::XInterface> SAL_CALL OResultSet::getStatement()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -682,9 +679,9 @@ sal_Bool SAL_CALL OResultSet::next()
m_nCurrentField = mysql_field_tell(m_pResult);
unsigned errorNum = mysql_errno(m_pMysql);
if(errorNum)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(m_pMysql),
errorNum, *this, m_encoding);
if (errorNum)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(m_pMysql), errorNum, *this,
m_encoding);
return m_aRow != nullptr;
}
@@ -703,13 +700,11 @@ void SAL_CALL OResultSet::cancel()
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
}
void SAL_CALL OResultSet::clearWarnings()
{
}
void SAL_CALL OResultSet::clearWarnings() {}
Any SAL_CALL OResultSet::getWarnings()
{
Any aRet= Any();
Any aRet = Any();
return aRet;
}
@@ -831,7 +826,7 @@ void SAL_CALL OResultSet::updateString(sal_Int32 column, const rtl::OUString& /*
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateString", *this);
}
void SAL_CALL OResultSet::updateBytes(sal_Int32 column, const uno::Sequence< sal_Int8 >& /* x */)
void SAL_CALL OResultSet::updateBytes(sal_Int32 column, const uno::Sequence<sal_Int8>& /* x */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
@@ -863,22 +858,26 @@ void SAL_CALL OResultSet::updateTimestamp(sal_Int32 column, const DateTime& /* x
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateTimestamp", *this);
}
void SAL_CALL OResultSet::updateBinaryStream(sal_Int32 column, const uno::Reference< XInputStream >& /* x */,
sal_Int32 /* length */)
void SAL_CALL OResultSet::updateBinaryStream(sal_Int32 column,
const uno::Reference<XInputStream>& /* x */,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBinaryStream", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBinaryStream",
*this);
}
void SAL_CALL OResultSet::updateCharacterStream(sal_Int32 column, const uno::Reference< XInputStream >& /* x */,
void SAL_CALL OResultSet::updateCharacterStream(sal_Int32 column,
const uno::Reference<XInputStream>& /* x */,
sal_Int32 /* length */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateCharacterStream", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateCharacterStream",
*this);
}
void SAL_CALL OResultSet::refreshRow()
@@ -896,12 +895,14 @@ void SAL_CALL OResultSet::updateObject(sal_Int32 column, const Any& /* x */)
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateObject", *this);
}
void SAL_CALL OResultSet::updateNumericObject(sal_Int32 column, const Any& /* x */, sal_Int32 /* scale */)
void SAL_CALL OResultSet::updateNumericObject(sal_Int32 column, const Any& /* x */,
sal_Int32 /* scale */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
checkColumnIndex(column);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNumericObject", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNumericObject",
*this);
}
// XRowLocate
@@ -925,12 +926,14 @@ sal_Bool SAL_CALL OResultSet::moveToBookmark(const Any& /* bookmark */)
return false;
}
sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark(const Any& /* bookmark */, sal_Int32 /* rows */)
sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark(const Any& /* bookmark */,
sal_Int32 /* rows */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveRelativeToBookmark", *this);
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveRelativeToBookmark",
*this);
return false;
}
@@ -944,10 +947,7 @@ sal_Int32 SAL_CALL OResultSet::compareBookmarks(const Any& /* n1 */, const Any&
return CompareBookmark::NOT_EQUAL;
}
sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks()
{
return false;
}
sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks() { return false; }
sal_Int32 SAL_CALL OResultSet::hashBookmark(const Any& /* bookmark */)
{
@@ -956,44 +956,42 @@ sal_Int32 SAL_CALL OResultSet::hashBookmark(const Any& /* bookmark */)
}
// XDeleteRows
uno::Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows(const uno::Sequence< Any >& /* rows */)
uno::Sequence<sal_Int32> SAL_CALL OResultSet::deleteRows(const uno::Sequence<Any>& /* rows */)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
uno::Sequence< sal_Int32 > aRet = uno::Sequence< sal_Int32 >();
uno::Sequence<sal_Int32> aRet = uno::Sequence<sal_Int32>();
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::deleteRows", *this);
return aRet;
}
IPropertyArrayHelper * OResultSet::createArrayHelper() const
IPropertyArrayHelper* OResultSet::createArrayHelper() const
{
uno::Sequence< Property > aProps(5);
uno::Sequence<Property> aProps(5);
Property* pProperties = aProps.getArray();
sal_Int32 nPos = 0;
pProperties[nPos++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("FetchSize", PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("IsBookmarkable",
PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY);
pProperties[nPos++] = Property("ResultSetConcurrency",
PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
pProperties[nPos++] = Property("ResultSetType",
PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
pProperties[nPos++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION,
cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("FetchSize", PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("IsBookmarkable", PROPERTY_ID_ISBOOKMARKABLE,
cppu::UnoType<bool>::get(), PropertyAttribute::READONLY);
pProperties[nPos++] = Property("ResultSetConcurrency", PROPERTY_ID_RESULTSETCONCURRENCY,
cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
pProperties[nPos++] = Property("ResultSetType", PROPERTY_ID_RESULTSETTYPE,
cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
return new OPropertyArrayHelper(aProps);
}
IPropertyArrayHelper & OResultSet::getInfoHelper()
{
return *getArrayHelper();
}
IPropertyArrayHelper& OResultSet::getInfoHelper() { return *getArrayHelper(); }
sal_Bool OResultSet::convertFastPropertyValue(Any & /* rConvertedValue */,
Any & /* rOldValue */,
sal_Int32 nHandle,
const Any& /* rValue */)
sal_Bool OResultSet::convertFastPropertyValue(Any& /* rConvertedValue */, Any& /* rOldValue */,
sal_Int32 nHandle, const Any& /* rValue */)
{
switch (nHandle) {
switch (nHandle)
{
case PROPERTY_ID_ISBOOKMARKABLE:
case PROPERTY_ID_CURSORNAME:
case PROPERTY_ID_RESULTSETCONCURRENCY:
@@ -1001,15 +999,15 @@ sal_Bool OResultSet::convertFastPropertyValue(Any & /* rConvertedValue */,
throw css::lang::IllegalArgumentException();
case PROPERTY_ID_FETCHDIRECTION:
case PROPERTY_ID_FETCHSIZE:
default:
;
default:;
}
return false;
}
void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& /* rValue */)
{
switch (nHandle) {
switch (nHandle)
{
case PROPERTY_ID_ISBOOKMARKABLE:
case PROPERTY_ID_CURSORNAME:
case PROPERTY_ID_RESULTSETCONCURRENCY:
@@ -1019,14 +1017,14 @@ void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any&
break;
case PROPERTY_ID_FETCHSIZE:
break;
default:
;
default:;
}
}
void OResultSet::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) const
{
switch (nHandle) {
switch (nHandle)
{
case PROPERTY_ID_ISBOOKMARKABLE:
_rValue <<= false;
break;
@@ -1045,31 +1043,23 @@ void OResultSet::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) const
_rValue <<= sal_Int32(50);
break;
;
default:
;
default:;
}
}
void SAL_CALL OResultSet::acquire()
throw()
{
OResultSet_BASE::acquire();
}
void SAL_CALL OResultSet::acquire() throw() { OResultSet_BASE::acquire(); }
void SAL_CALL OResultSet::release()
throw()
{
OResultSet_BASE::release();
}
void SAL_CALL OResultSet::release() throw() { OResultSet_BASE::release(); }
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo()
css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL OResultSet::getPropertySetInfo()
{
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
void OResultSet::checkColumnIndex(sal_Int32 index)
{
if (index < 1 || index > static_cast<int>(fieldCount)) {
if (index < 1 || index > static_cast<int>(fieldCount))
{
/* static object for efficiency or thread safety is a problem ? */
throw SQLException("index out of range", *this, rtl::OUString(), 1, Any());
}
@@ -0,0 +1,246 @@
/* -*- 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_RESULTSET_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSET_HXX
#include "mysqlc_preparedstatement.hxx"
#include "mysqlc_statement.hxx"
#include "mysqlc_subcomponent.hxx"
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XCloseable.hpp>
#include <com/sun/star/sdbc/XColumnLocate.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XRowUpdate.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/sdbcx/XDeleteRows.hpp>
#include <com/sun/star/sdbcx/XRowLocate.hpp>
#include <com/sun/star/util/XCancellable.hpp>
#include <cppuhelper/compbase12.hxx>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::RuntimeException;
/*
** OResultSet
*/
typedef ::cppu::WeakComponentImplHelper12<
css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier,
css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XResultSetUpdate,
css::sdbc::XRowUpdate, css::sdbcx::XRowLocate, css::sdbcx::XDeleteRows, css::sdbc::XCloseable,
css::sdbc::XColumnLocate, css::lang::XServiceInfo>
OResultSet_BASE;
class OResultSet final : public OBase_Mutex,
public OResultSet_BASE,
public ::cppu::OPropertySetHelper,
public OPropertyArrayUsageHelper<OResultSet>
{
OConnection& m_rConnection;
MYSQL_ROW m_aRow;
unsigned long* m_aLengths = nullptr;
MYSQL* m_pMysql = nullptr;
css::uno::WeakReferenceHelper m_aStatement;
css::uno::Reference<css::sdbc::XResultSetMetaData> m_xMetaData;
MYSQL_RES* m_pResult;
unsigned int fieldCount;
rtl_TextEncoding m_encoding;
sal_Int32 m_nCurrentField = 0;
bool m_bWasNull = false; // did the last getXXX result null?
// OPropertyArrayUsageHelper
::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
// OPropertySetHelper
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
const Any& rValue) SAL_OVERRIDE;
void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
// you can't delete objects of this type
virtual ~OResultSet() override;
public:
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;
OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES* pResult,
rtl_TextEncoding _encoding);
// ::cppu::OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
Any SAL_CALL queryInterface(const css::uno::Type& rType) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() SAL_OVERRIDE;
// XPropertySet
css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() SAL_OVERRIDE;
// XResultSet
sal_Bool SAL_CALL next() SAL_OVERRIDE;
sal_Bool SAL_CALL isBeforeFirst() SAL_OVERRIDE;
sal_Bool SAL_CALL isAfterLast() SAL_OVERRIDE;
sal_Bool SAL_CALL isFirst() SAL_OVERRIDE;
sal_Bool SAL_CALL isLast() SAL_OVERRIDE;
void SAL_CALL beforeFirst() SAL_OVERRIDE;
void SAL_CALL afterLast() SAL_OVERRIDE;
sal_Bool SAL_CALL first() SAL_OVERRIDE;
sal_Bool SAL_CALL last() SAL_OVERRIDE;
sal_Int32 SAL_CALL getRow() SAL_OVERRIDE;
sal_Bool SAL_CALL absolute(sal_Int32 row) SAL_OVERRIDE;
sal_Bool SAL_CALL relative(sal_Int32 rows) SAL_OVERRIDE;
sal_Bool SAL_CALL previous() SAL_OVERRIDE;
void SAL_CALL refreshRow() SAL_OVERRIDE;
sal_Bool SAL_CALL rowUpdated() SAL_OVERRIDE;
sal_Bool SAL_CALL rowInserted() SAL_OVERRIDE;
sal_Bool SAL_CALL rowDeleted() SAL_OVERRIDE;
css::uno::Reference<css::uno::XInterface> SAL_CALL getStatement() SAL_OVERRIDE;
// XRow
sal_Bool SAL_CALL wasNull() SAL_OVERRIDE;
rtl::OUString SAL_CALL getString(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL getBoolean(sal_Int32 column) SAL_OVERRIDE;
sal_Int8 SAL_CALL getByte(sal_Int32 column) SAL_OVERRIDE;
sal_Int16 SAL_CALL getShort(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getInt(sal_Int32 column) SAL_OVERRIDE;
sal_Int64 SAL_CALL getLong(sal_Int32 column) SAL_OVERRIDE;
float SAL_CALL getFloat(sal_Int32 column) SAL_OVERRIDE;
double SAL_CALL getDouble(sal_Int32 column) SAL_OVERRIDE;
css::uno::Sequence<sal_Int8> SAL_CALL getBytes(sal_Int32 column) SAL_OVERRIDE;
css::util::Date SAL_CALL getDate(sal_Int32 column) SAL_OVERRIDE;
css::util::Time SAL_CALL getTime(sal_Int32 column) SAL_OVERRIDE;
css::util::DateTime SAL_CALL getTimestamp(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference<css::io::XInputStream>
SAL_CALL getBinaryStream(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference<css::io::XInputStream>
SAL_CALL getCharacterStream(sal_Int32 column) SAL_OVERRIDE;
Any SAL_CALL getObject(sal_Int32 column, const my_XNameAccessRef& typeMap) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XRef> SAL_CALL getRef(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XBlob> SAL_CALL getBlob(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XClob> SAL_CALL getClob(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XArray> SAL_CALL getArray(sal_Int32 column) SAL_OVERRIDE;
// XResultSetMetaDataSupplier
css::uno::Reference<css::sdbc::XResultSetMetaData> SAL_CALL getMetaData() SAL_OVERRIDE;
// XCancellable
void SAL_CALL cancel() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XWarningsSupplier
Any SAL_CALL getWarnings() SAL_OVERRIDE;
void SAL_CALL clearWarnings() SAL_OVERRIDE;
// XResultSetUpdate
void SAL_CALL insertRow() SAL_OVERRIDE;
void SAL_CALL updateRow() SAL_OVERRIDE;
void SAL_CALL deleteRow() SAL_OVERRIDE;
void SAL_CALL cancelRowUpdates() SAL_OVERRIDE;
void SAL_CALL moveToInsertRow() SAL_OVERRIDE;
void SAL_CALL moveToCurrentRow() SAL_OVERRIDE;
// XRowUpdate
void SAL_CALL updateNull(sal_Int32 column) SAL_OVERRIDE;
void SAL_CALL updateBoolean(sal_Int32 column, sal_Bool x) SAL_OVERRIDE;
void SAL_CALL updateByte(sal_Int32 column, sal_Int8 x) SAL_OVERRIDE;
void SAL_CALL updateShort(sal_Int32 column, sal_Int16 x) SAL_OVERRIDE;
void SAL_CALL updateInt(sal_Int32 column, sal_Int32 x) SAL_OVERRIDE;
void SAL_CALL updateLong(sal_Int32 column, sal_Int64 x) SAL_OVERRIDE;
void SAL_CALL updateFloat(sal_Int32 column, float x) SAL_OVERRIDE;
void SAL_CALL updateDouble(sal_Int32 column, double x) SAL_OVERRIDE;
void SAL_CALL updateString(sal_Int32 column, const rtl::OUString& x) SAL_OVERRIDE;
void SAL_CALL updateBytes(sal_Int32 column, const css::uno::Sequence<sal_Int8>& x) SAL_OVERRIDE;
void SAL_CALL updateDate(sal_Int32 column, const css::util::Date& x) SAL_OVERRIDE;
void SAL_CALL updateTime(sal_Int32 column, const css::util::Time& x) SAL_OVERRIDE;
void SAL_CALL updateTimestamp(sal_Int32 column, const css::util::DateTime& x) SAL_OVERRIDE;
void SAL_CALL updateBinaryStream(sal_Int32 column,
const css::uno::Reference<css::io::XInputStream>& x,
sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL updateCharacterStream(sal_Int32 column,
const css::uno::Reference<css::io::XInputStream>& x,
sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL updateObject(sal_Int32 column, const Any& x) SAL_OVERRIDE;
void SAL_CALL updateNumericObject(sal_Int32 column, const Any& x, sal_Int32 scale) SAL_OVERRIDE;
// XColumnLocate
sal_Int32 SAL_CALL findColumn(const rtl::OUString& columnName) SAL_OVERRIDE;
// XRowLocate
Any SAL_CALL getBookmark() SAL_OVERRIDE;
sal_Bool SAL_CALL moveToBookmark(const Any& bookmark) SAL_OVERRIDE;
sal_Bool SAL_CALL moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) SAL_OVERRIDE;
sal_Int32 SAL_CALL compareBookmarks(const Any& first, const Any& second) SAL_OVERRIDE;
sal_Bool SAL_CALL hasOrderedBookmarks() SAL_OVERRIDE;
sal_Int32 SAL_CALL hashBookmark(const Any& bookmark) SAL_OVERRIDE;
// XDeleteRows
css::uno::Sequence<sal_Int32>
SAL_CALL deleteRows(const css::uno::Sequence<Any>& rows) SAL_OVERRIDE;
/// @throws SQLException
/// @throws RuntimeException
void checkColumnIndex(sal_Int32 index);
private:
using ::cppu::OPropertySetHelper::getFastPropertyValue;
};
} /* mysqlc */
} /* connectivity */
#endif // CONNECTIVITY_SRESULTSET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -20,7 +20,6 @@
#include "mysqlc_resultsetmetadata.hxx"
#include "mysqlc_resultset.hxx"
#include "mysqlc_general.hxx"
#include <cppconn/exception.h>
#include <com/sun/star/sdbc/XRow.hpp>
#include <rtl/ustrbuf.hxx>
@@ -49,10 +48,7 @@ sal_Int32 SAL_CALL OResultSetMetaData::getColumnType(sal_Int32 column)
return mysqlc_sdbc_driver::mysqlToOOOType(pField->type, pField->charsetnr);
}
sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount()
{
return mysql_num_fields(m_pRes);
}
sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount() { return mysql_num_fields(m_pRes); }
sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive(sal_Int32 column)
{
@@ -60,12 +56,12 @@ sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive(sal_Int32 column)
// MYSQL_FIELD::charsetnr is the collation identifier
// _ci postfix means it's insensitive
MYSQL_FIELD* pField = getField(column);
rtl::OUStringBuffer sql{"SHOW COLLATION WHERE Id ="};
rtl::OUStringBuffer sql{ "SHOW COLLATION WHERE Id =" };
sql.append(rtl::OUString::number(pField->charsetnr));
Reference< XStatement > stmt = m_rConnection.createStatement();
Reference< XResultSet > rs = stmt->executeQuery(sql.makeStringAndClear());
Reference< XRow > xRow( rs, UNO_QUERY_THROW );
Reference<XStatement> stmt = m_rConnection.createStatement();
Reference<XResultSet> rs = stmt->executeQuery(sql.makeStringAndClear());
Reference<XRow> xRow(rs, UNO_QUERY_THROW);
rs->next(); // fetch first and only row
rtl::OUString sColName = xRow->getString(1); // first column is Collation name
@@ -168,10 +164,7 @@ sal_Int32 SAL_CALL OResultSetMetaData::isNullable(sal_Int32 column)
return (pField->flags & NOT_NULL_FLAG) ? 0 : 1;
}
sal_Bool SAL_CALL OResultSetMetaData::isSearchable(sal_Int32 /*column*/)
{
return true;
}
sal_Bool SAL_CALL OResultSetMetaData::isSearchable(sal_Int32 /*column*/) { return true; }
sal_Bool SAL_CALL OResultSetMetaData::isReadOnly(sal_Int32 column)
{
@@ -195,15 +188,15 @@ sal_Bool SAL_CALL OResultSetMetaData::isWritable(sal_Int32 column)
void OResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex)
{
unsigned nColCount = mysql_num_fields(m_pRes);
if (columnIndex < 1 || columnIndex > static_cast<sal_Int32>(nColCount)) {
if (columnIndex < 1 || columnIndex > static_cast<sal_Int32>(nColCount))
{
rtl::OUStringBuffer buf;
buf.appendAscii( "Column index out of range (expected 1 to " );
buf.append( sal_Int32( nColCount ) );
buf.appendAscii( ", got " );
buf.append( columnIndex );
buf.append( '.' );
throw SQLException( buf.makeStringAndClear(), *this, rtl::OUString(), 1, Any() );
buf.append("Column index out of range (expected 1 to ");
buf.append(sal_Int32(nColCount));
buf.append(", got ");
buf.append(columnIndex);
buf.append('.');
throw SQLException(buf.makeStringAndClear(), *this, rtl::OUString(), 1, Any());
}
}
@@ -0,0 +1,109 @@
/* -*- 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_RESULTSETMETADATA_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSETMETADATA_HXX
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <cppuhelper/implbase1.hxx>
#include <mysql.h>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::RuntimeException;
//************ Class: ResultSetMetaData
typedef ::cppu::WeakImplHelper1<css::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
class OResultSetMetaData final : public OResultSetMetaData_BASE
{
private:
OConnection& m_rConnection;
MYSQL_RES* m_pRes;
rtl_TextEncoding m_encoding;
virtual ~OResultSetMetaData() override = default;
MYSQL_FIELD* getField(sal_Int32 column) const;
public:
OResultSetMetaData(OConnection& rConn, MYSQL_RES* pResult, rtl_TextEncoding _encoding)
: m_rConnection(rConn)
, m_pRes(pResult)
, m_encoding(_encoding)
{
}
rtl::OUString convert(const ::std::string& _string) const
{
return rtl::OUString(_string.c_str(), _string.size(), m_encoding);
}
sal_Int32 SAL_CALL getColumnCount() SAL_OVERRIDE;
sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isCaseSensitive(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isSearchable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isCurrency(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL isNullable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isSigned(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnLabel(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnName(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getSchemaName(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getPrecision(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getScale(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getTableName(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogName(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getColumnType(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnTypeName(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isReadOnly(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isWritable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnServiceName(sal_Int32 column) SAL_OVERRIDE;
/// @throws SQLException
/// @throws RuntimeException
void checkColumnIndex(sal_Int32 columnIndex);
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSETMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -24,45 +24,39 @@
#include <uno/lbnames.h>
using namespace connectivity::mysqlc;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::lang::XSingleServiceFactory;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::lang::XSingleServiceFactory;
using ::com::sun::star::lang::XMultiServiceFactory;
typedef Reference< XSingleServiceFactory > (*createFactoryFunc)
(
const Reference< XMultiServiceFactory > & rServiceManager,
const rtl::OUString & rComponentName,
::cppu::ComponentInstantiation pCreateFunction,
const Sequence< rtl::OUString > & rServiceNames,
rtl_ModuleCount*
);
typedef Reference<XSingleServiceFactory> (*createFactoryFunc)(
const Reference<XMultiServiceFactory>& rServiceManager, const rtl::OUString& rComponentName,
::cppu::ComponentInstantiation pCreateFunction, const Sequence<rtl::OUString>& rServiceNames,
rtl_ModuleCount*);
struct ProviderRequest
{
Reference< XSingleServiceFactory > xRet;
Reference< XMultiServiceFactory > const xServiceManager;
Reference<XSingleServiceFactory> xRet;
Reference<XMultiServiceFactory> const xServiceManager;
rtl::OUString const sImplementationName;
ProviderRequest(
void* pServiceManager,
sal_Char const* pImplementationName
) : xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
, sImplementationName(rtl::OUString::createFromAscii(pImplementationName))
ProviderRequest(void* pServiceManager, sal_Char const* pImplementationName)
: xServiceManager(static_cast<XMultiServiceFactory*>(pServiceManager))
, sImplementationName(rtl::OUString::createFromAscii(pImplementationName))
{
}
bool CREATE_PROVIDER(
const rtl::OUString& Implname,
const Sequence< rtl::OUString > & Services,
::cppu::ComponentInstantiation Factory,
createFactoryFunc creator
)
bool CREATE_PROVIDER(const rtl::OUString& Implname, const Sequence<rtl::OUString>& Services,
::cppu::ComponentInstantiation Factory, createFactoryFunc creator)
{
if (!xRet.is() && (Implname == sImplementationName)) {
try {
xRet = creator( xServiceManager, sImplementationName,Factory, Services,nullptr);
} catch (...) {
if (!xRet.is() && (Implname == sImplementationName))
{
try
{
xRet = creator(xServiceManager, sImplementationName, Factory, Services, nullptr);
}
catch (...)
{
}
}
return xRet.is();
@@ -71,22 +65,21 @@ struct ProviderRequest
void* getProvider() const { return xRet.get(); }
};
extern "C" SAL_DLLPUBLIC_EXPORT void* component_getFactory(
const sal_Char * pImplementationName,
void * pServiceManager,
void * /* pRegistryKey */)
extern "C" SAL_DLLPUBLIC_EXPORT void* component_getFactory(const sal_Char* pImplementationName,
void* pServiceManager,
void* /* pRegistryKey */)
{
void* pRet = nullptr;
if (pServiceManager) {
ProviderRequest aReq(pServiceManager,pImplementationName);
if (pServiceManager)
{
ProviderRequest aReq(pServiceManager, pImplementationName);
aReq.CREATE_PROVIDER(
MysqlCDriver::getImplementationName_Static(),
MysqlCDriver::getSupportedServiceNames_Static(),
MysqlCDriver_CreateInstance, ::cppu::createSingleFactory)
;
aReq.CREATE_PROVIDER(MysqlCDriver::getImplementationName_Static(),
MysqlCDriver::getSupportedServiceNames_Static(),
MysqlCDriver_CreateInstance, ::cppu::createSingleFactory);
if(aReq.xRet.is()) {
if (aReq.xRet.is())
{
aReq.xRet->acquire();
}
@@ -97,8 +90,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void* component_getFactory(
};
extern "C" SAL_DLLPUBLIC_EXPORT void
component_getImplementationEnvironment(
char const ** ppEnvTypeName, uno_Environment **)
component_getImplementationEnvironment(char const** ppEnvTypeName, uno_Environment**)
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
@@ -33,9 +33,6 @@
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <cppconn/connection.h>
#include <cppconn/exception.h>
#include <cppconn/statement.h>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <osl/thread.h>
@@ -53,20 +50,18 @@ using namespace com::sun::star::util;
using ::osl::MutexGuard;
OCommonStatement::OCommonStatement(OConnection* _pConnection)
:OCommonStatement_IBase(m_aMutex)
,OPropertySetHelper(OCommonStatement_IBase::rBHelper)
,m_xConnection(_pConnection)
: OCommonStatement_IBase(m_aMutex)
, OPropertySetHelper(OCommonStatement_IBase::rBHelper)
, m_xConnection(_pConnection)
{
}
OCommonStatement::~OCommonStatement()
{
}
OCommonStatement::~OCommonStatement() {}
void OCommonStatement::disposeResultSet()
{
// free the cursor if alive
if(m_pMysqlResult != nullptr)
if (m_pMysqlResult != nullptr)
{
mysql_free_result(m_pMysqlResult);
m_pMysqlResult = nullptr;
@@ -81,20 +76,21 @@ void OCommonStatement::disposing()
OCommonStatement_IBase::disposing();
}
Any SAL_CALL OCommonStatement::queryInterface(const Type & rType)
Any SAL_CALL OCommonStatement::queryInterface(const Type& rType)
{
Any aRet = OCommonStatement_IBase::queryInterface(rType);
if (!aRet.hasValue()) {
if (!aRet.hasValue())
{
aRet = OPropertySetHelper::queryInterface(rType);
}
return aRet;
}
Sequence< Type > SAL_CALL OCommonStatement::getTypes()
Sequence<Type> SAL_CALL OCommonStatement::getTypes()
{
::cppu::OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
::cppu::OTypeCollection aTypes(cppu::UnoType<XMultiPropertySet>::get(),
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
return concatSequences(aTypes.getTypes(), OCommonStatement_IBase::getTypes());
}
@@ -129,10 +125,10 @@ sal_Bool SAL_CALL OCommonStatement::execute(const rtl::OUString& sql)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
const rtl::OUString sSqlStatement = m_xConnection->transFormPreparedStatement( sql );
const rtl::OUString sSqlStatement = m_xConnection->transFormPreparedStatement(sql);
rtl::OString toExec = rtl::OUStringToOString(sSqlStatement,
m_xConnection->getConnectionSettings().encoding);
rtl::OString toExec
= rtl::OUStringToOString(sSqlStatement, m_xConnection->getConnectionSettings().encoding);
MYSQL* pMySql = m_xConnection->getMysqlConnection();
@@ -141,42 +137,43 @@ sal_Bool SAL_CALL OCommonStatement::execute(const rtl::OUString& sql)
// toExec = mysqlc_sdbc_driver::escapeSql(toExec);
int failure = mysql_real_query(pMySql, toExec.getStr(), toExec.getLength());
if(failure)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql),
mysql_errno(pMySql), *this, m_xConnection->getConnectionEncoding());
if (failure)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql), mysql_errno(pMySql),
*this, m_xConnection->getConnectionEncoding());
m_nAffectedRows = mysql_affected_rows(pMySql);
return !failure;
}
Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery(const rtl::OUString& sql)
Reference<XResultSet> SAL_CALL OCommonStatement::executeQuery(const rtl::OUString& sql)
{
MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
const rtl::OUString sSqlStatement = sql; // TODO m_xConnection->transFormPreparedStatement( sql );
rtl::OString toExec = rtl::OUStringToOString(sSqlStatement,
m_xConnection->getConnectionSettings().encoding);
const rtl::OUString sSqlStatement
= sql; // TODO m_xConnection->transFormPreparedStatement( sql );
rtl::OString toExec
= rtl::OUStringToOString(sSqlStatement, m_xConnection->getConnectionSettings().encoding);
MYSQL* pMySql = m_xConnection->getMysqlConnection();
// toExec = mysqlc_sdbc_driver::escapeSql(toExec);
int failure = mysql_real_query(pMySql, toExec.getStr(), toExec.getLength());
if(failure)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql),
mysql_errno(pMySql), *this, m_xConnection->getConnectionEncoding());
if (failure)
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql), mysql_errno(pMySql),
*this, m_xConnection->getConnectionEncoding());
m_pMysqlResult = mysql_store_result(pMySql);
if(m_pMysqlResult == nullptr)
if (m_pMysqlResult == nullptr)
{
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql),
mysql_errno(pMySql), *this, m_xConnection->getConnectionEncoding());
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(pMySql), mysql_errno(pMySql),
*this, m_xConnection->getConnectionEncoding());
}
m_xResultSet = new OResultSet(*getOwnConnection(),this, m_pMysqlResult,
m_xConnection->getConnectionEncoding());
m_xResultSet = new OResultSet(*getOwnConnection(), this, m_pMysqlResult,
m_xConnection->getConnectionEncoding());
return m_xResultSet;
}
Reference< XConnection > SAL_CALL OCommonStatement::getConnection()
Reference<XConnection> SAL_CALL OCommonStatement::getConnection()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
@@ -185,15 +182,13 @@ Reference< XConnection > SAL_CALL OCommonStatement::getConnection()
return m_xConnection.get();
}
sal_Int32 SAL_CALL OCommonStatement::getUpdateCount()
{
return m_nAffectedRows;
}
sal_Int32 SAL_CALL OCommonStatement::getUpdateCount() { return m_nAffectedRows; }
Any SAL_CALL OStatement::queryInterface(const Type & rType)
Any SAL_CALL OStatement::queryInterface(const Type& rType)
{
Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
if (!aRet.hasValue()) {
Any aRet = ::cppu::queryInterface(rType, static_cast<XBatchExecution*>(this));
if (!aRet.hasValue())
{
aRet = OCommonStatement::queryInterface(rType);
}
return aRet;
@@ -205,12 +200,12 @@ void SAL_CALL OStatement::addBatch(const rtl::OUString&)
checkDisposed(rBHelper.bDisposed);
}
Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch()
Sequence<sal_Int32> SAL_CALL OStatement::executeBatch()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
Sequence< sal_Int32 > aRet = Sequence< sal_Int32 >();
Sequence<sal_Int32> aRet = Sequence<sal_Int32>();
return aRet;
}
@@ -223,7 +218,7 @@ sal_Int32 SAL_CALL OCommonStatement::executeUpdate(const rtl::OUString& sql)
return m_nAffectedRows;
}
Reference< XResultSet > SAL_CALL OCommonStatement::getResultSet()
Reference<XResultSet> SAL_CALL OCommonStatement::getResultSet()
{
MutexGuard aGuard(m_aMutex);
checkDisposed(rBHelper.bDisposed);
@@ -252,35 +247,42 @@ void SAL_CALL OCommonStatement::clearWarnings()
m_aLastWarning = SQLWarning();
}
::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const
::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper() const
{
// this properties are define by the service statement
// they must in alphabetic order
Sequence< Property > aProps(10);
Sequence<Property> aProps(10);
Property* pProperties = aProps.getArray();
sal_Int32 nPos = 0;
pProperties[nPos++] = Property("CursorName", PROPERTY_ID_CURSORNAME, cppu::UnoType<rtl::OUString>::get(), 0);
pProperties[nPos++] = Property("EscapeProcessing", PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0);
pProperties[nPos++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("FetchSize", PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("MaxFieldSize", PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("MaxRows", PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("QueryTimeOut", PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("ResultSetConcurrency", PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("ResultSetType", PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("UseBookmarks", PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0);
pProperties[nPos++]
= Property("CursorName", PROPERTY_ID_CURSORNAME, cppu::UnoType<rtl::OUString>::get(), 0);
pProperties[nPos++]
= Property("EscapeProcessing", PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0);
pProperties[nPos++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION,
cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("FetchSize", PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("MaxFieldSize", PROPERTY_ID_MAXFIELDSIZE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("MaxRows", PROPERTY_ID_MAXROWS, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("QueryTimeOut", PROPERTY_ID_QUERYTIMEOUT, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++] = Property("ResultSetConcurrency", PROPERTY_ID_RESULTSETCONCURRENCY,
cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("ResultSetType", PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), 0);
pProperties[nPos++]
= Property("UseBookmarks", PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0);
return new ::cppu::OPropertyArrayHelper(aProps);
}
::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper()
{
return *getArrayHelper();
}
::cppu::IPropertyArrayHelper& OCommonStatement::getInfoHelper() { return *getArrayHelper(); }
sal_Bool OCommonStatement::convertFastPropertyValue(
Any & /* rConvertedValue */, Any & /* rOldValue */,
sal_Int32 /* nHandle */, const Any& /* rValue */)
sal_Bool OCommonStatement::convertFastPropertyValue(Any& /* rConvertedValue */,
Any& /* rOldValue */, sal_Int32 /* nHandle */,
const Any& /* rValue */)
{
// here we have to try to convert
return false;
@@ -289,7 +291,8 @@ sal_Bool OCommonStatement::convertFastPropertyValue(
void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& /* rValue */)
{
// set the value to what ever is necessary
switch (nHandle) {
switch (nHandle)
{
case PROPERTY_ID_QUERYTIMEOUT:
case PROPERTY_ID_MAXFIELDSIZE:
case PROPERTY_ID_MAXROWS:
@@ -300,14 +303,14 @@ void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const
case PROPERTY_ID_FETCHSIZE:
case PROPERTY_ID_ESCAPEPROCESSING:
case PROPERTY_ID_USEBOOKMARKS:
default:
;
default:;
}
}
void OCommonStatement::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) const
{
switch (nHandle) {
switch (nHandle)
{
case PROPERTY_ID_QUERYTIMEOUT:
case PROPERTY_ID_MAXFIELDSIZE:
case PROPERTY_ID_MAXROWS:
@@ -321,8 +324,7 @@ void OCommonStatement::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) con
case PROPERTY_ID_USEBOOKMARKS:
_rValue <<= false;
break;
default:
;
default:;
}
}
@@ -338,36 +340,20 @@ css::uno::Sequence<rtl::OUString> OStatement::getSupportedServiceNames()
return s;
}
sal_Bool OStatement::supportsService(rtl::OUString const & ServiceName)
sal_Bool OStatement::supportsService(rtl::OUString const& ServiceName)
{
return cppu::supportsService(this, ServiceName);
}
void SAL_CALL OCommonStatement::acquire()
throw()
{
OCommonStatement_IBase::acquire();
}
void SAL_CALL OCommonStatement::acquire() throw() { OCommonStatement_IBase::acquire(); }
void SAL_CALL OCommonStatement::release()
throw()
{
OCommonStatement_IBase::release();
}
void SAL_CALL OCommonStatement::release() throw() { OCommonStatement_IBase::release(); }
void SAL_CALL OStatement::acquire()
throw()
{
OCommonStatement::acquire();
}
void SAL_CALL OStatement::acquire() throw() { OCommonStatement::acquire(); }
void SAL_CALL OStatement::release()
throw()
{
OCommonStatement::release();
}
void SAL_CALL OStatement::release() throw() { OCommonStatement::release(); }
Reference< css::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo()
Reference<css::beans::XPropertySetInfo> SAL_CALL OCommonStatement::getPropertySetInfo()
{
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
@@ -0,0 +1,185 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
#include "mysqlc_connection.hxx"
#include "mysqlc_subcomponent.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbc/XBatchExecution.hpp>
#include <com/sun/star/sdbc/XCloseable.hpp>
#include <com/sun/star/sdbc/XMultipleResults.hpp>
#include <com/sun/star/sdbc/XStatement.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/util/XCancellable.hpp>
#include <cppuhelper/compbase5.hxx>
#include <rtl/ref.hxx>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::sdbc::SQLWarning;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::RuntimeException;
typedef ::cppu::WeakComponentImplHelper5<css::sdbc::XStatement, css::sdbc::XWarningsSupplier,
css::util::XCancellable, css::sdbc::XCloseable,
css::sdbc::XMultipleResults>
OCommonStatement_IBase;
//************ Class: OCommonStatement
// is a base class for the normal statement and for the prepared statement
class OCommonStatement : public OBase_Mutex,
public OCommonStatement_IBase,
public ::cppu::OPropertySetHelper,
public OPropertyArrayUsageHelper<OCommonStatement>
{
private:
SQLWarning m_aLastWarning;
protected:
rtl::Reference<OConnection> m_xConnection; // The owning Connection object
css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
MYSQL_RES* m_pMysqlResult = nullptr;
// number of rows affected by an UPDATE, DELETE or INSERT statement.
sal_Int32 m_nAffectedRows = 0;
protected:
void disposeResultSet();
// OPropertyArrayUsageHelper
::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
// OPropertySetHelper
::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
const Any& rValue) SAL_OVERRIDE;
void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
virtual ~OCommonStatement() override;
protected:
OCommonStatement(OConnection* _pConnection);
public:
using OCommonStatement_IBase::rBHelper;
using OCommonStatement_IBase::operator css::uno::Reference<css::uno::XInterface>;
// OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
void SAL_CALL release() throw() SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
// XInterface
Any SAL_CALL queryInterface(const css::uno::Type& rType) SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() SAL_OVERRIDE;
// XPropertySet
css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() SAL_OVERRIDE;
// XStatement
css::uno::Reference<css::sdbc::XResultSet>
SAL_CALL executeQuery(const rtl::OUString& sql) SAL_OVERRIDE;
sal_Int32 SAL_CALL executeUpdate(const rtl::OUString& sql) SAL_OVERRIDE;
sal_Bool SAL_CALL execute(const rtl::OUString& sql) SAL_OVERRIDE;
css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() SAL_OVERRIDE;
// XWarningsSupplier
Any SAL_CALL getWarnings() SAL_OVERRIDE;
void SAL_CALL clearWarnings() SAL_OVERRIDE;
// XCancellable
void SAL_CALL cancel() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XMultipleResults
css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() SAL_OVERRIDE;
sal_Int32 SAL_CALL getUpdateCount() SAL_OVERRIDE;
sal_Bool SAL_CALL getMoreResults() SAL_OVERRIDE;
// other methods
OConnection* getOwnConnection() const { return m_xConnection.get(); }
private:
using ::cppu::OPropertySetHelper::getFastPropertyValue;
};
class OStatement final : public OCommonStatement,
public css::sdbc::XBatchExecution,
public css::lang::XServiceInfo
{
virtual ~OStatement() override = default;
public:
// A constructor which is required for the return of the objects
OStatement(OConnection* _pConnection)
: OCommonStatement(_pConnection)
{
}
virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const& ServiceName) SAL_OVERRIDE;
virtual css::uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() SAL_OVERRIDE;
Any SAL_CALL queryInterface(const css::uno::Type& rType) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
// XBatchExecution
void SAL_CALL addBatch(const rtl::OUString& sql) SAL_OVERRIDE;
void SAL_CALL clearBatch() SAL_OVERRIDE;
css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() SAL_OVERRIDE;
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -0,0 +1,164 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <cppuhelper/propshlp.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
namespace cppu
{
class IPropertyArrayHelper;
}
namespace com
{
namespace sun
{
namespace star
{
namespace lang
{
class XComponent;
}
}
}
}
namespace connectivity
{
namespace mysqlc
{
/// @throws css::lang::DisposedException
void checkDisposed(bool _bThrow);
template <class TYPE> class OPropertyArrayUsageHelper
{
protected:
static sal_Int32 s_nRefCount;
static ::cppu::IPropertyArrayHelper* s_pProps;
static ::osl::Mutex s_aMutex;
public:
OPropertyArrayUsageHelper();
virtual ~OPropertyArrayUsageHelper();
/** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
class, which is created if necessary.
*/
::cppu::IPropertyArrayHelper* getArrayHelper();
protected:
/** used to implement the creation of the array helper which is shared amongst all instances of the class.
This method needs to be implemented in derived classes.
<BR>
The method gets called with s_aMutex acquired.
@return an pointer to the newly created array helper. Must not be NULL.
*/
virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const = 0;
};
template <class TYPE> sal_Int32 OPropertyArrayUsageHelper<TYPE>::s_nRefCount = 0;
template <class TYPE>
::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::s_pProps = nullptr;
template <class TYPE>::osl::Mutex OPropertyArrayUsageHelper<TYPE>::s_aMutex;
template <class TYPE> OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
{
::osl::MutexGuard aGuard(s_aMutex);
++s_nRefCount;
}
template <class TYPE> OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
{
::osl::MutexGuard aGuard(s_aMutex);
OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : "
"suspicious call : have a refcount of 0 !");
if (!--s_nRefCount)
{
delete s_pProps;
s_pProps = nullptr;
}
}
template <class TYPE>::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
{
OSL_ENSURE(
s_nRefCount,
"OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
if (!s_pProps)
{
::osl::MutexGuard aGuard(s_aMutex);
if (!s_pProps)
{
s_pProps = createArrayHelper();
OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper "
"returned nonsense !");
}
}
return s_pProps;
}
class OBase_Mutex
{
public:
::osl::Mutex m_aMutex;
};
namespace internal
{
template <class T> void implCopySequence(const T* _pSource, T*& _pDest, sal_Int32 _nSourceLen)
{
for (sal_Int32 i = 0; i < _nSourceLen; ++i, ++_pSource, ++_pDest)
*_pDest = *_pSource;
}
}
/// concat two sequences
template <class T>
css::uno::Sequence<T> concatSequences(const css::uno::Sequence<T>& _rLeft,
const css::uno::Sequence<T>& _rRight)
{
sal_Int32 nLeft(_rLeft.getLength()), nRight(_rRight.getLength());
const T* pLeft = _rLeft.getConstArray();
const T* pRight = _rRight.getConstArray();
sal_Int32 nReturnLen(nLeft + nRight);
css::uno::Sequence<T> aReturn(nReturnLen);
T* pReturn = aReturn.getArray();
internal::implCopySequence(pLeft, pReturn, nLeft);
internal::implCopySequence(pRight, pReturn, nRight);
return aReturn;
}
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -0,0 +1,680 @@
/* -*- 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 <stdio.h>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/ColumnSearch.hpp>
#include "mysqlc_types.hxx"
using namespace com::sun::star::sdbc;
TypeInfoDef mysqlc_types[] = {
// ------------- MySQL-Type: BIT. SDBC-Type: Bit -------------
{
"BIT", // Typename
com::sun::star::sdbc::DataType::BIT, // sdbc-type
1, // Precision
"", // Literal prefix
"", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BIT", // local type name
0, // minimum scale
0 // maximum scale
},
// ------------ MySQL-Type: BOOL. SDBC-Type: Bit -------------
{
"BOOL", // Typename
com::sun::star::sdbc::DataType::BIT, // sdbc-type
1, // Precision
"", // Literal prefix
"", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BOOL", // local type name
0, // minimum scale
0 // maximum scale
},
// --------- MySQL-Type: TINYINT SDBC-Type: TINYINT ----------
{
"TINYINT", // Typename
com::sun::star::sdbc::DataType::TINYINT, // sdbc-type
3, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"TINYINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BIGINT SDBC-Type: BIGINT ----------
{
"BIGINT", // Typename
com::sun::star::sdbc::DataType::BIGINT, // sdbc-type
19, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"BIGINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONG VARBINARY SDBC-Type: LONGVARBINARY ----------
{
"LONG VARBINARY", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
16777215, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONG VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMBLOB SDBC-Type: LONGVARBINARY ----------
{
"MEDIUMBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
16777215, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"MEDIUMBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONGBLOB SDBC-Type: LONGVARBINARY ----------
{
"LONGBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
-1, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONGBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BLOB SDBC-Type: LONGVARBINARY ----------
{
"BLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TINYBLOB SDBC-Type: LONGVARBINARY ----------
{
"TINYBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TINYBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: VARBINARY SDBC-Type: VARBINARY ----------
{
"VARBINARY", // Typename
com::sun::star::sdbc::DataType::VARBINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BINARY SDBC-Type: BINARY ----------
{
"BINARY", // Typename
com::sun::star::sdbc::DataType::BINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONG VARCHAR SDBC-Type: LONG VARCHAR ----------
{
"LONG VARCHAR", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONG VARCHAR", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMTEXT SDBC-Type: LONG VARCHAR ----------
{
"MEDIUMTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"MEDIUMTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONGTEXT SDBC-Type: LONG VARCHAR ----------
{
"LONGTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONGTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TEXT SDBC-Type: LONG VARCHAR ----------
{
"TEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TINYTEXT SDBC-Type: LONG VARCHAR ----------
{
"TINYTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TINYTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: CHAR SDBC-Type: CHAR ----------
{
"CHAR", // Typename
com::sun::star::sdbc::DataType::CHAR, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"NUMERIC", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DECIMAL SDBC-Type: DECIMAL ----------
{
"DECIMAL", // Typename
com::sun::star::sdbc::DataType::DECIMAL, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M[,D])] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DECIMAL", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: NUMERIC SDBC-Type: NUMERIC ----------
{
"NUMERIC", // Typename
com::sun::star::sdbc::DataType::NUMERIC, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M[,D])] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"NUMERIC", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: INTEGER SDBC-Type: INTEGER ----------
{
"INTEGER", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"INTEGER", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: INT SDBC-Type: INTEGER ----------
{
"INT", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"INT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMINT SDBC-Type: INTEGER ----------
{
"MEDIUMINT", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
7, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"MEDIUMINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: SMALLINT SDBC-Type: INTEGER ----------
{
"SMALLINT", // Typename
com::sun::star::sdbc::DataType::SMALLINT, // sdbc-type
5, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"SMALLINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: FLOAT SDBC-Type: REAL ----------
{
"FLOAT", // Typename
com::sun::star::sdbc::DataType::REAL, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"FLOAT", // local type name
-38, // minimum scale
38 // maximum scale
},
// ----------- MySQL-Type: DOUBLE SDBC-Type: DOUBLE ----------
{
"DOUBLE", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DOUBLE", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: DOUBLE PRECISION SDBC-Type: DOUBLE ----------
{
"DOUBLE PRECISION", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DOUBLE PRECISION", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: REAL SDBC-Type: DOUBLE ----------
{
"REAL", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"REAL", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: VARCHAR SDBC-Type: VARCHAR ----------
{
"VARCHAR", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
255, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARCHAR", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: ENUM SDBC-Type: VARCHAR ----------
{
"ENUM", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"ENUM", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: SET SDBC-Type: VARCHAR ----------
{
"SET", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
64, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"SET", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DATE SDBC-Type: DATE ----------
{
"DATE", // Typename
com::sun::star::sdbc::DataType::DATE, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"DATE", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIME SDBC-Type: TIME ----------
{
"TIME", // Typename
com::sun::star::sdbc::DataType::TIME, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TIME", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DATETIME SDBC-Type: TIMESTAMP ----------
{
"DATETIME", // Typename
com::sun::star::sdbc::DataType::TIMESTAMP, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"DATETIME", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIMESTAMP SDBC-Type: TIMESTAMP ----------
{
"TIMESTAMP", // Typename
com::sun::star::sdbc::DataType::TIMESTAMP, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"[(M)]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TIMESTAMP", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIMESTAMP SDBC-Type: TIMESTAMP ----------
{ nullptr, 0, 0, nullptr, nullptr, nullptr, 0, false, 0, false, false, false, nullptr, 0, 0 }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@@ -20,20 +20,21 @@
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_TYPES_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_TYPES_HXX
struct TypeInfoDef {
const char *typeName;
struct TypeInfoDef
{
const char* typeName;
sal_Int32 dataType;
sal_Int32 precision;
const char *literalPrefix;
const char *literalSuffix;
const char *createParams;
const char* literalPrefix;
const char* literalSuffix;
const char* createParams;
sal_Int16 nullable;
bool caseSensitive;
sal_Int16 searchable;
bool isUnsigned;
bool fixedPrecScale;
bool autoIncrement;
const char *localTypeName;
const char* localTypeName;
sal_Int32 minScale;
sal_Int32 maxScale;
};
-1
View File
@@ -73,7 +73,6 @@ $(eval $(call gb_Module_add_moduledirs,external,\
$(call gb_Helper_optional,MORE_FONTS,more_fonts) \
$(call gb_Helper_optional,MSPUB,libmspub) \
$(call gb_Helper_optional,MWAW,libmwaw) \
$(call gb_Helper_optional,MYSQL_CONNECTOR_CPP,mysql-connector-cpp) \
$(call gb_Helper_optional,MYTHES,mythes) \
$(call gb_Helper_optional,NEON,neon) \
$(call gb_Helper_optional,NSS,nss) \
@@ -115,6 +115,8 @@ $(eval $(call gb_StaticLibrary_add_generated_cobjects,mariadb-connector-c,\
UnpackedTarball/mariadb-connector-c/libmariadb/client_plugin \
UnpackedTarball/mariadb-connector-c/libmariadb/my_auth \
UnpackedTarball/mariadb-connector-c/libmariadb/ma_secure \
$(if $(filter $(OS),WNT), \
UnpackedTarball/mariadb-connector-c/win-iconv/win_iconv,) \
))
# vim: set noet sw=4 ts=4:
-7
View File
@@ -1,7 +0,0 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
include $(module_directory)/../../solenv/gbuild/partial_build.mk
# vim: set noet sw=4 ts=4:
@@ -1,17 +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_Module_Module,mysql-connector-cpp))
$(eval $(call gb_Module_add_targets,mysql-connector-cpp,\
UnpackedTarball_mysql-connector-cpp \
Library_mysqlcppconn \
))
# vim: set noet sw=4 ts=4:
-1
View File
@@ -1 +0,0 @@
From [http://dev.mysql.com/downloads/connector/cpp/]
@@ -1,26 +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_UnpackedTarball_UnpackedTarball,mysql-connector-cpp))
$(eval $(call gb_UnpackedTarball_set_tarball,mysql-connector-cpp,$(MYSQL_CONNECTOR_CPP_TARBALL)))
$(eval $(call gb_UnpackedTarball_add_file,mysql-connector-cpp,cppconn/config.h,external/mysql-connector-cpp/config.h))
$(eval $(call gb_UnpackedTarball_add_file,mysql-connector-cpp,version_info.h,external/mysql-connector-cpp/version_info.h))
$(eval $(call gb_UnpackedTarball_add_file,mysql-connector-cpp,driver/nativeapi/binding_config.h,external/mysql-connector-cpp/binding_config.h))
$(eval $(call gb_UnpackedTarball_add_patches,mysql-connector-cpp,\
external/mysql-connector-cpp/patches/mysql-connector-c++-1.1.0.patch \
external/mysql-connector-cpp/patches/warnings.patch.0 \
external/mysql-connector-cpp/patches/enable-libmysql-proxy.patch \
external/mysql-connector-cpp/patches/dynexcspec.patch.0 \
))
# vim: set noet sw=4 ts=4:
-5
View File
@@ -1,5 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#define HAVE_DLFCN_H 1
#define MYSQLCLIENT_STATIC_BINDING 1
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-39
View File
@@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include <sal/types.h>
#define HAVE_FUNCTION_STRTOL 1
#define HAVE_FUNCTION_STRTOUL 1
#define HAVE_FUNCTION_STRTOL 1
#define HAVE_FUNCTION_STRTOULL 1
#if defined(MACOSX) || defined(__sun) || defined(LINUX) || defined (_MSC_VER)
#define HAVE_STDINT_H
#ifndef _MSC_VER
#define HAVE_INTTYPES_H
#endif
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
// if we do not have the standard C99 integer types, then define them based on the respective SAL types
#if !defined(_SYS_TYPES_H)
typedef sal_Int8 int8_t;
typedef sal_Int16 int16_t;
typedef sal_Int32 int32_t;
#endif // !defined(_SYS_TYPES_H)
typedef sal_uInt8 uint8_t;
typedef sal_uInt16 uint16_t;
typedef sal_uInt32 uint32_t;
typedef sal_Int64 int64_t;
typedef sal_uInt64 uint64_t;
#endif // !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-15
View File
@@ -1,15 +0,0 @@
--- cppconn/exception.h
+++ cppconn/exception.h
@@ -36,10 +36,10 @@
{
#define MEMORY_ALLOC_OPERATORS(Class) \
- void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
+ void* operator new(size_t size) { return ::operator new(size); } \
void* operator new(size_t, void*) throw(); \
void* operator new(size_t, const std::nothrow_t&) throw(); \
- void* operator new[](size_t) throw (std::bad_alloc); \
+ void* operator new[](size_t); \
void* operator new[](size_t, void*) throw(); \
void* operator new[](size_t, const std::nothrow_t&) throw(); \
void* operator new(size_t N, std::allocator<Class>&);
@@ -1,27 +0,0 @@
--- UnpackedTarball/mysqlcppconn/driver/nativeapi/mysql_client_api.cpp 2014-07-30 13:41:37.000000000 +0200
+++ UnpackedTarball/mysqlcppconn/driver/nativeapi/mysql_client_api.cpp 2014-09-17 22:12:26.000000000 +0200
@@ -32,10 +32,10 @@
#ifdef MYSQLCLIENT_STATIC_BINDING
/* MySQL client library is linked */
-# include "libmysql_static_proxy.h"
+ #include "libmysql_static_proxy.h"
#else
/* MySQL client library will be dynamically loaded */
-# include "libmysql_dynamic_proxy.h"
+ #include "libmysql_dynamic_proxy.h"
#endif
namespace sql
@@ -76,9 +76,9 @@
#include "binding_config.h"
#ifdef MYSQLCLIENT_STATIC_BINDING
-# include "libmysql_static_proxy.cpp"
+ #include "libmysql_static_proxy.cpp"
#else
-# include "libmysql_dynamic_proxy.cpp"
+ #include "libmysql_dynamic_proxy.cpp"
#endif
/*
@@ -1,115 +0,0 @@
--- misc/mysql-connector-c++-1.1.0/cppconn/build_config.h 2010-09-10 11:47:47.000000000 +0200
+++ misc/build/mysql-connector-c++-1.1.0/cppconn/build_config.h 2011-11-12 00:45:19.000000000 +0100
@@ -25,25 +25,21 @@
#ifndef _SQL_BUILD_CONFIG_H_
#define _SQL_BUILD_CONFIG_H_
-#ifndef CPPCONN_PUBLIC_FUNC
+#include <sal/types.h>
-#if defined(_WIN32)
// mysqlcppconn_EXPORTS is added by cmake and defined for dynamic lib build only
#ifdef mysqlcppconn_EXPORTS
- #define CPPCONN_PUBLIC_FUNC __declspec(dllexport)
+ #define CPPCONN_PUBLIC_FUNC SAL_DLLPUBLIC_EXPORT
#else
// this is for static build
#ifdef CPPCONN_LIB_BUILD
#define CPPCONN_PUBLIC_FUNC
#else
// this is for clients using dynamic lib
- #define CPPCONN_PUBLIC_FUNC __declspec(dllimport)
+ #define CPPCONN_PUBLIC_FUNC SAL_DLLPUBLIC_IMPORT
#endif
#endif
-#else
- #define CPPCONN_PUBLIC_FUNC
-#endif
-#endif //#ifndef CPPCONN_PUBLIC_FUNC
+ #define CPPCONN_PUBLIC_EXCEPTION SAL_EXCEPTION_DLLPUBLIC_EXPORT
#endif //#ifndef _SQL_BUILD_CONFIG_H_
--- misc/mysql-connector-c++-1.1.0/cppconn/exception.h 2009-08-20 17:51:23.000000000 +0200
+++ misc/build/mysql-connector-c++-1.1.0/cppconn/exception.h 2009-09-11 09:41:41.076379817 +0200
@@ -37,7 +37,7 @@
#pragma warning(push)
#pragma warning(disable: 4275)
#endif
-class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error
+class CPPCONN_PUBLIC_EXCEPTION SQLException : public std::runtime_error
{
#ifdef _WIN32
#pragma warning(pop)
@@ -83,26 +83,26 @@
MEMORY_ALLOC_OPERATORS(SQLException)
};
-struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException
+struct CPPCONN_PUBLIC_EXCEPTION MethodNotImplementedException : public SQLException
{
MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {}
};
-struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException
+struct CPPCONN_PUBLIC_EXCEPTION InvalidArgumentException : public SQLException
{
InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {}
};
-struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException
+struct CPPCONN_PUBLIC_EXCEPTION InvalidInstanceException : public SQLException
{
InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {}
};
-struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException
+struct CPPCONN_PUBLIC_EXCEPTION NonScrollableException : public SQLException
{
NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
--- misc/mysql-connector-c++-1.1.0/driver/mysql_debug.h 2009-08-13 17:13:46.000000000 +0200
+++ misc/build/mysql-connector-c++-1.1.0/driver/mysql_debug.h 2009-08-14 09:56:37.015625000 +0200
@@ -25,16 +25,6 @@
-#if defined(WE_HAVE_VARARGS_MACRO_SUPPORT) && (CPPCONN_TRACE_ENABLED || defined(SAL_DLLPRIVATE))
- #define CPP_ENTER(msg) const boost::shared_ptr< MySQL_DebugLogger > __l = this->logger;(void)__l;\
- MySQL_DebugEnterEvent __this_func(__LINE__, __FILE__, msg, this->logger)
- #define CPP_ENTER_WL(l, msg) const boost::shared_ptr< MySQL_DebugLogger > __l = (l);(void)__l;\
- MySQL_DebugEnterEvent __this_func(__LINE__, __FILE__, msg, (l))
- #define CPP_INFO(msg) {if (__l) __l->log("INF", msg); }
- #define CPP_INFO_FMT(...) {if (__l) __l->log_va("INF", __VA_ARGS__); }
- #define CPP_ERR(msg) {if (__l) __l->log("ERR", msg); }
- #define CPP_ERR_FMT(...) {if (__l) __l->log_va("ERR", __VA_ARGS__); }
-#else
#define CPP_ENTER(msg)
#define CPP_ENTER_WL(l, msg)
#define CPP_INFO(msg)
@@ -42,7 +32,6 @@
#define CPP_ENTER_WL(l, msg)
static inline void CPP_INFO_FMT(...) {}
static inline void CPP_ERR_FMT(...) {}
-#endif
#include <stack>
#include "mysql_util.h"
--- misc/mysql-connector-c++-1.1.0/driver/mysql_prepared_statement.cpp 2013-03-06 10:29:26.890721534 +0100
+++ misc/build/mysql-connector-c++-1.1.0/driver/mysql_prepared_statement.cpp 2013-03-06 10:32:02.979904080 +0100
@@ -46,6 +46,10 @@
#include "mysql_debug.h"
+#ifndef CR_INVALID_BUFFER_USE
+#define CR_INVALID_BUFFER_USE 2035
+#endif
+
namespace sql
{
-11
View File
@@ -1,11 +0,0 @@
--- cppconn/warning.h
+++ cppconn/warning.h
@@ -59,7 +59,7 @@
virtual ~SQLWarning(){};
- SQLWarning(const SQLWarning& e){};
+ SQLWarning(const SQLWarning&){};
private:
const SQLWarning & operator = (const SQLWarning & rhs);
-42
View File
@@ -1,42 +0,0 @@
/*
Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
The MySQL Connector/C++ is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
MySQL Connectors. There are special exceptions to the terms and
conditions of the GPLv2 as it is applied to this software, see the
FLOSS License Exception
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Please do not edit this file - it is generated by cmake. Edit its source file instead. */
#define MYCPPCONN_MAJOR_VERSION 1
#define MYCPPCONN_MINOR_VERSION 1
#define MYCPPCONN_PATCH_VERSION 4
#define SETUP_VERSION "1.01.0004"
#define DRIVER_VERSION "0" SETUP_VERSION
#define MYCPPCONN_VERSION SETUP_VERSION
#define MYCPPCONN_FILEVER 1,1,4,0
#define MYCPPCONN_PRODUCTVER MYCPPCONN_FILEVER
#define MYCPPCONN_STRFILEVER "1, 1, 4, 0\0"
#define MYCPPCONN_STRPRODUCTVER MYCPPCONN_STRFILEVER
#define MYCPPCONN_STRSERIES "1.1"
#define MYCPPCONN_STRQUALITY "GA"
#define MYCPPCONN_STRVERSION "1.1.4"
-15
View File
@@ -1,15 +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_Configuration_Configuration,mysql,nodeliver))
$(eval $(call gb_Configuration_add_localized_datas,mysql,mysqlc/source/registry/data,\
org/openoffice/Office/DataAccess/Drivers.xcu \
))
-35
View File
@@ -1,35 +0,0 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Extension_Extension,mysql-connector-ooo,mysqlc/source))
$(eval $(call gb_Extension_use_default_description,mysql-connector-ooo,mysqlc/source/description-en-US.txt))
$(eval $(call gb_Extension_use_default_license,mysql-connector-ooo))
$(eval $(call gb_Extension_add_library,mysql-connector-ooo,mysqlc))
$(eval $(call gb_Extension_add_file,mysql-connector-ooo,components.rdb,$(call gb_Rdb_get_target,mysqlc)))
$(eval $(call gb_Extension_add_file,mysql-connector-ooo,registry/data/org/openoffice/Office/DataAccess/Drivers.xcu,$(call gb_XcuFile_for_extension,mysqlc/source/registry/data/org/openoffice/Office/DataAccess/Drivers.xcu)))
$(eval $(call gb_Extension_add_files,mysql-connector-ooo,images,\
$(SRCDIR)/icon-themes/colibre/desktop/res/extension_32.png \
))
ifeq ($(SYSTEM_MYSQL_CONNECTOR_CPP),)
$(eval $(call gb_Extension_add_library,mysql-connector-ooo,mysqlcppconn))
endif
ifneq ($(BUNDLE_MARIADB_CONNECTOR_C),)
$(eval $(call gb_Extension_add_files,mysql-connector-ooo,,\
$(LIBMARIADB_PATH)/$(LIBMARIADB) \
))
endif
# vim: set noet sw=4 ts=4:
-7
View File
@@ -1,7 +0,0 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
include $(module_directory)/../solenv/gbuild/partial_build.mk
# vim: set noet sw=4 ts=4:
-23
View File
@@ -1,23 +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_Module_Module,mysqlc))
ifeq ($(ENABLE_MARIADBC),TRUE)
$(eval $(call gb_Module_add_targets,mysqlc,\
Configuration_mysql \
Library_mysqlc \
Rdb_mysqlc \
Extension_mysql-connector-ooo \
))
endif
# vim: set noet sw=4 ts=4:
-79
View File
@@ -1,79 +0,0 @@
The MySQL driver for LibreOffice.
It ships as an extension (.oxt file).
== Requirements ==
The MySQL driver for LibreOffice (MySQL Connector/LibreOffice - C/LibO)
requires two external libraries to be built:
1) The MySQL Client Library (libmysql) or MariaDB Client library
2) The MySQL Connector/C++ Library (libmysqlcppconn)
The MariaDB client library is provided as an external and will be
automatically built if you pass "--without-system-mariadb" to
autogen.sh.
libmysqlcppconn is provided as an external and will be automatically
compiled if you pass "--without-system-mysql-cppconn" to autogen.sh.
The MySQL driver for LibreOffice does not reimplement the MySQL
Client/Server communication protocol. The protocol implementation is
part of the MySQL Client Library. The SDBC(X) driver is implemented as
a wrapper of the MySQL Connector/C++ Library which implements a
JDBC-like interface (which suits SDBC(X) well) and which in turn uses
the C based MySQL Client Library.
== Variants ==
If configured with --with-system-mariadb --disable-bundle-mariadb, the
driver will *not* ship a copy of the MySQL client C library and will
expect it to be installed in a standard location on each system that
it runs on. That is usually the right choice to create a native
package/port for GNU/Linux, BSD, etc, where the packaging system
handles dependencies and will ensure the availability of the MySQL
client C library in the standard location.
If configured with --with-system-mariadb --enable-bundle-mariadb, the
driver will ship a copy of the MariaDB (or MySQL) client C library so
that it works "out of the box" on any system. That (or
--without-system-mariadb) is usually the right choice to create a
stand-alone .oxt file that users can just install through the
LibreOffice extensions manager, as is typical for Microsoft Windows
and Apple MacOS X native (as opposed to MacPorts / fink / pkgsrc /
...).
--disable-bundle-mariadb is the default.
== Installing the Requirements ==
On modern/free-as-in-free-speech Unices, libmysql and libmysqlcppconn
are probably available as a package/port. Install them using your
distribution's tools. Make sure to install the development packages
(whose name usually ends with -dev or -devel), and not only the
libraries themselves.
Else you can install the MariaDB Client Library from official MariaDB
packages at https://downloads.mariadb.org/client-native/ .
They have source and binary distributions for several platforms.
At least series 2.0 is recommended, as series 1.0 are known to be too
buggy. Additionally, version 2.0.0 is known to be incompatible with
MySQL Connector/C++ version 1.1.4, which --without-system-mysqlcppconn
uses, and which --with-system-mysqlcppconn could use
(see https://mariadb.atlassian.net/browse/CONC-104).
Use a version where the above incompatibility has been solved.
Alternatively, MySQL Client Library from official MySQL
packages are at http://dev.mysql.com/downloads/connector/c/ .
You can also install the MySQL Client Library (libmysql) as part of
the MariaDB or MySQL Server, version 5.0 or later. Check the MariaDB
or MySQL manual for instructions:
https://mariadb.com/kb/en/mariadb/documentation/getting-started/getting-installing-and-upgrading-mariadb/
http://dev.mysql.com/doc/refman/5.5/en/installing.html
The typical installation path of the libmysql.so on Unix is
/usr/local/mysql/lib/mysql/ .
Official packages for libmysqlcppconn can be downloaded from
http://dev.mysql.com/downloads/connector/cpp/
-16
View File
@@ -1,16 +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_Rdb_Rdb,mysqlc))
$(eval $(call gb_Rdb_add_components,mysqlc,\
mysqlc/source/mysqlc \
))
# vim: set noet sw=4 ts=4:
-191
View File
@@ -1,191 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
#include <memory>
#include "mysqlc_subcomponent.hxx"
#include "mysqlc_types.hxx"
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/sdbc/ColumnSearch.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <cppconn/driver.h>
#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/weakref.hxx>
#include <rtl/string.hxx>
#include <rtl/ref.hxx>
#include <mysql.h>
#include <map>
namespace sql
{
class SQLException;
}
namespace connectivity
{
class OMetaConnection;
class ODatabaseMetaData;
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLWarning;
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
typedef css::uno::Reference< css::container::XNameAccess > my_XNameAccessRef;
typedef ::cppu::WeakComponentImplHelper3< css::sdbc::XConnection,
css::sdbc::XWarningsSupplier,
css::lang::XServiceInfo
> OMetaConnection_BASE;
struct ConnectionSettings
{
rtl_TextEncoding encoding;
std::unique_ptr<sql::Connection> cppConnection;
rtl::OUString schema;
rtl::OUString connectionURL;
bool readOnly;
};
class MysqlCDriver;
typedef OMetaConnection_BASE OConnection_BASE;
typedef std::vector< css::uno::WeakReferenceHelper > OWeakRefArray;
class OConnection final : public OBase_Mutex,
public OConnection_BASE
{
private:
MYSQL m_mysql;
ConnectionSettings m_settings;
css::uno::Reference< css::container::XNameAccess > m_typeMap;
css::uno::Reference< css::util::XStringSubstitution > m_xParameterSubstitution;
// Data attributes
css::uno::WeakReference< css::sdbc::XDatabaseMetaData > m_xMetaData;
OWeakRefArray m_aStatements; // vector containing a list
// of all the Statement objects
// for this Connection
rtl::Reference<MysqlCDriver> m_xDriver; // Pointer to the owning driver object
public:
MYSQL* getMysqlConnection() { return &m_mysql; }
/// @throws SQLException
/// @throws RuntimeException
sal_Int32 getMysqlVersion();
/// @throws SQLException
void construct(const rtl::OUString& url,const css::uno::Sequence< css::beans::PropertyValue >& info);
OConnection(MysqlCDriver& _rDriver );
virtual ~OConnection();
rtl_TextEncoding getConnectionEncoding() const { return m_settings.encoding; }
// OComponentHelper
virtual void SAL_CALL disposing() SAL_OVERRIDE;
// 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: */
-219
View File
@@ -1,219 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_DATABASEMETADATA_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_DATABASEMETADATA_HXX
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppconn/metadata.h>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::uno::Any;
//************ Class: ODatabaseMetaData
typedef ::cppu::WeakImplHelper1< css::sdbc::XDatabaseMetaData> ODatabaseMetaData_BASE;
class ODatabaseMetaData final : public ODatabaseMetaData_BASE
{
OConnection& m_rConnection;
MYSQL * m_pMySql;
rtl::OUString identifier_quote_string;
bool identifier_quote_string_set;
rtl::OUString impl_getStringMetaData( const sal_Char* _methodName, const sql::SQLString& (sql::DatabaseMetaData::*Method)() );
rtl::OUString impl_getStringMetaData( const sal_Char* _methodName, sql::SQLString (sql::DatabaseMetaData::*Method)() );
sal_Int32 impl_getInt32MetaData( const sal_Char* _methodName, unsigned int (sql::DatabaseMetaData::*Method)() );
bool impl_getBoolMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*Method)() );
bool impl_getBoolMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*Method)(int), sal_Int32 _arg );
bool impl_getRSTypeMetaData( const sal_Char* _methodName, bool (sql::DatabaseMetaData::*Method)(int), sal_Int32 _resultSetType );
public:
const OConnection& getOwnConnection() const { return m_rConnection; }
explicit ODatabaseMetaData(OConnection& _rCon, MYSQL* pMySql);
virtual ~ODatabaseMetaData();
// as I mentioned before this interface is really BIG
// XDatabaseMetaData
sal_Bool SAL_CALL allProceduresAreCallable() SAL_OVERRIDE;
sal_Bool SAL_CALL allTablesAreSelectable() SAL_OVERRIDE;
rtl::OUString SAL_CALL getURL() SAL_OVERRIDE;
rtl::OUString SAL_CALL getUserName() SAL_OVERRIDE;
sal_Bool SAL_CALL isReadOnly() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedHigh() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedLow() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedAtStart() SAL_OVERRIDE;
sal_Bool SAL_CALL nullsAreSortedAtEnd() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDatabaseProductName() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDatabaseProductVersion() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDriverName() SAL_OVERRIDE;
rtl::OUString SAL_CALL getDriverVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDriverMajorVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDriverMinorVersion() SAL_OVERRIDE;
sal_Bool SAL_CALL usesLocalFiles() SAL_OVERRIDE;
sal_Bool SAL_CALL usesLocalFilePerTable() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMixedCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesUpperCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesLowerCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesMixedCaseIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers() SAL_OVERRIDE;
sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers() SAL_OVERRIDE;
rtl::OUString SAL_CALL getIdentifierQuoteString() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSQLKeywords() SAL_OVERRIDE;
rtl::OUString SAL_CALL getNumericFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getStringFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSystemFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getTimeDateFunctions() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSearchStringEscape() SAL_OVERRIDE;
rtl::OUString SAL_CALL getExtraNameCharacters() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsAlterTableWithAddColumn() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsAlterTableWithDropColumn() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsColumnAliasing() SAL_OVERRIDE;
sal_Bool SAL_CALL nullPlusNonNullIsNull() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTypeConversion() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsConvert(sal_Int32 fromType, sal_Int32 toType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTableCorrelationNames() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDifferentTableCorrelationNames() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsExpressionsInOrderBy() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOrderByUnrelated() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupBy() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupByUnrelated() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsGroupByBeyondSelect() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsLikeEscapeClause() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMultipleResultSets() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMultipleTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsNonNullableColumns() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsMinimumSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCoreSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsExtendedSQLGrammar() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92EntryLevelSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92IntermediateSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsANSI92FullSQL() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsIntegrityEnhancementFacility() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOuterJoins() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsFullOuterJoins() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsLimitedOuterJoins() SAL_OVERRIDE;
rtl::OUString SAL_CALL getSchemaTerm() SAL_OVERRIDE;
rtl::OUString SAL_CALL getProcedureTerm() SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogTerm() SAL_OVERRIDE;
sal_Bool SAL_CALL isCatalogAtStart() SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogSeparator() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInDataManipulation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInProcedureCalls() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInTableDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInIndexDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInDataManipulation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInProcedureCalls() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInTableDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsPositionedDelete() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsPositionedUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSelectForUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsStoredProcedures() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInComparisons() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInExists() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInIns() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsSubqueriesInQuantifieds() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsCorrelatedSubqueries() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsUnion() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsUnionAll() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxBinaryLiteralLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCharLiteralLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInGroupBy() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInIndex() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInOrderBy() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInSelect() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxColumnsInTable() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxConnections() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCursorNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxIndexLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxSchemaNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxProcedureNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxCatalogNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxRowSize() SAL_OVERRIDE;
sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxStatementLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxStatements() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxTableNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxTablesInSelect() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMaxUserNameLength() SAL_OVERRIDE;
sal_Int32 SAL_CALL getDefaultTransactionIsolation() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsTransactionIsolationLevel(sal_Int32 level) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly() SAL_OVERRIDE;
sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit() SAL_OVERRIDE;
sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedures(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& procedureNamePattern) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getProcedureColumns(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& procedureNamePattern, const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTables(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& tableNamePattern, const css::uno::Sequence< rtl::OUString >& types) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getSchemas() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCatalogs() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTableTypes() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumns(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& tableNamePattern, const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getColumnPrivileges(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table, const rtl::OUString& columnNamePattern) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTablePrivileges(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& tableNamePattern) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getBestRowIdentifier(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table, sal_Int32 scope, sal_Bool nullable) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getVersionColumns(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getPrimaryKeys(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getImportedKeys(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getExportedKeys(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getCrossReference(const Any& primaryCatalog, const rtl::OUString& primarySchema, const rtl::OUString& primaryTable, const Any& foreignCatalog, const rtl::OUString& foreignSchema, const rtl::OUString& foreignTable) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getTypeInfo() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getIndexInfo(const Any& catalog, const rtl::OUString& schema, const rtl::OUString& table, sal_Bool unique, sal_Bool approximate) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsResultSetType(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsResultSetConcurrency(sal_Int32 setType, sal_Int32 concurrency) SAL_OVERRIDE;
sal_Bool SAL_CALL ownUpdatesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL ownDeletesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL ownInsertsAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersUpdatesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersDeletesAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL othersInsertsAreVisible(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL updatesAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL deletesAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL insertsAreDetected(sal_Int32 setType) SAL_OVERRIDE;
sal_Bool SAL_CALL supportsBatchUpdates() SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getUDTs(const Any& catalog, const rtl::OUString& schemaPattern, const rtl::OUString& typeNamePattern, const css::uno::Sequence< sal_Int32 >& types) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() SAL_OVERRIDE;
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_DATABASEMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-283
View File
@@ -1,283 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
************************************************************************/
#include "mysqlc_driver.hxx"
#include "mysqlc_connection.hxx"
#include "mysqlc_general.hxx"
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::sdbc;
using namespace connectivity::mysqlc;
#include <cppuhelper/supportsservice.hxx>
#include <stdio.h>
#include <cppconn/exception.h>
#ifdef SYSTEM_MYSQL_CPPCONN
#include <mysql_driver.h>
#endif
MysqlCDriver::MysqlCDriver(const Reference< XMultiServiceFactory >& _rxFactory)
: ODriver_BASE(m_aMutex)
,m_xFactory(_rxFactory)
#ifndef SYSTEM_MYSQL_CPPCONN
,m_hCppConnModule( nullptr )
,m_bAttemptedLoadCppConn( false )
#endif
{
cppDriver = nullptr;
}
void MysqlCDriver::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
// when driver will be destroyed so all our connections have to be destroyed as well
for (auto const& connection : m_xConnections)
{
Reference< XComponent > xComp(connection.get(), UNO_QUERY);
if (xComp.is()) {
xComp->dispose();
}
}
m_xConnections.clear();
ODriver_BASE::disposing();
}
// static ServiceInfo
rtl::OUString MysqlCDriver::getImplementationName_Static()
{
return rtl::OUString( "com.sun.star.comp.sdbc.mysqlc.MysqlCDriver" );
}
Sequence< rtl::OUString > MysqlCDriver::getSupportedServiceNames_Static()
{
// which service is supported
// for more information @see com.sun.star.sdbc.Driver
Sequence< rtl::OUString > aSNS(1);
aSNS[0] = "com.sun.star.sdbc.Driver";
return aSNS;
}
rtl::OUString SAL_CALL MysqlCDriver::getImplementationName()
{
return getImplementationName_Static();
}
sal_Bool SAL_CALL MysqlCDriver::supportsService(const rtl::OUString& _rServiceName)
{
return cppu::supportsService(this, _rServiceName);
}
Sequence< rtl::OUString > SAL_CALL MysqlCDriver::getSupportedServiceNames()
{
return getSupportedServiceNames_Static();
}
#ifndef SYSTEM_MYSQL_CPPCONN
extern "C" { static void thisModule() {} }
#endif
void MysqlCDriver::impl_initCppConn_lck_throw()
{
#ifdef SYSTEM_MYSQL_CPPCONN
cppDriver = get_driver_instance();
#else
#ifdef BUNDLE_MARIADB
if ( !m_bAttemptedLoadCConn )
{
const rtl::OUString sModuleName(BUNDLE_MARIADB);
m_hCConnModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
m_bAttemptedLoadCConn = true;
}
// attempted to load - was it successful?
if ( !m_hCConnModule )
{
OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not load the " BUNDLE_MARIADB " library!");
throw SQLException(
"Unable to load the " BUNDLE_MARIADB " library.",
*this,
rtl::OUString( "08001" ), // "unable to connect"
0,
Any()
);
}
#endif
if ( !m_bAttemptedLoadCppConn )
{
const rtl::OUString sModuleName(CPPCONN_LIB);
m_hCppConnModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
m_bAttemptedLoadCppConn = true;
}
// attempted to load - was it successful?
if ( !m_hCppConnModule )
{
OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not load the " CPPCONN_LIB " library!");
throw SQLException(
"Unable to load the " CPPCONN_LIB " library.",
*this,
rtl::OUString( "08001" ), // "unable to connect"
0,
Any()
);
}
// find the factory symbol
const rtl::OUString sSymbolName = "sql_mysql_get_driver_instance";
typedef void* (* FGetMySQLDriver)();
const FGetMySQLDriver pFactoryFunction = reinterpret_cast<FGetMySQLDriver>( osl_getFunctionSymbol( m_hCppConnModule, sSymbolName.pData ) );
if ( !pFactoryFunction )
{
OSL_FAIL( "MysqlCDriver::impl_initCppConn_lck_throw: could not find the factory symbol in " CPPCONN_LIB "!");
throw SQLException(
CPPCONN_LIB " is invalid: missing the driver factory function.",
*this,
rtl::OUString( "08001" ), // "unable to connect"
0,
Any()
);
}
cppDriver = static_cast< sql::Driver* >( (*pFactoryFunction)() );
#endif
if ( !cppDriver )
{
throw SQLException(
"Unable to obtain the MySQL_Driver instance from Connector/C++.",
*this,
rtl::OUString( "08001" ), // "unable to connect"
0,
Any()
);
}
}
Reference< XConnection > SAL_CALL MysqlCDriver::connect(const rtl::OUString& url, const Sequence< PropertyValue >& info)
{
::osl::MutexGuard aGuard( m_aMutex );
if (!acceptsURL(url)) {
return nullptr;
}
if ( !cppDriver )
{
impl_initCppConn_lck_throw();
if ( !cppDriver )
throw RuntimeException("MySQLCDriver::connect: internal error.", *this );
}
Reference< XConnection > xConn;
// create a new connection with the given properties and append it to our vector
try {
OConnection* pCon = new OConnection(*this);
xConn = pCon;
pCon->construct(url,info);
m_xConnections.push_back(WeakReferenceHelper(*pCon));
}
catch (const sql::SQLException &e)
{
mysqlc_sdbc_driver::translateAndThrow(e, *this, getDefaultEncoding());
}
return xConn;
}
sal_Bool SAL_CALL MysqlCDriver::acceptsURL(const rtl::OUString& url)
{
return url.startsWith("sdbc:mysqlc:");
}
Sequence< DriverPropertyInfo > SAL_CALL MysqlCDriver::getPropertyInfo(const rtl::OUString& url, const Sequence< PropertyValue >& /* info */)
{
if (acceptsURL(url)) {
::std::vector< DriverPropertyInfo > aDriverInfo;
aDriverInfo.push_back(DriverPropertyInfo(
rtl::OUString("Hostname")
,rtl::OUString("Name of host")
,true
,rtl::OUString("localhost")
,Sequence< rtl::OUString >())
);
aDriverInfo.push_back(DriverPropertyInfo(
rtl::OUString("Port")
,rtl::OUString("Port")
,true
,rtl::OUString("3306")
,Sequence< rtl::OUString >())
);
return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
}
return Sequence< DriverPropertyInfo >();
}
sal_Int32 SAL_CALL MysqlCDriver::getMajorVersion()
{
return MARIADBC_VERSION_MAJOR;
}
sal_Int32 SAL_CALL MysqlCDriver::getMinorVersion()
{
return MARIADBC_VERSION_MINOR;
}
namespace connectivity
{
namespace mysqlc
{
Reference< XInterface > MysqlCDriver_CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory)
{
return(*(new MysqlCDriver(_rxFactory)));
}
void checkDisposed(bool _bThrow)
{
if (_bThrow) {
throw DisposedException();
}
}
} /* mysqlc */
} /* connectivity */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-124
View File
@@ -1,124 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
************************************************************************/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
#include <config_lgpl.h>
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/compbase2.hxx>
#include <cppconn/driver.h>
#include <osl/module.h>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
/// @throws Exception
Reference< css::uno::XInterface > MysqlCDriver_CreateInstance(const Reference< css::lang::XMultiServiceFactory >& _rxFactory);
typedef ::cppu::WeakComponentImplHelper2< css::sdbc::XDriver,
css::lang::XServiceInfo > ODriver_BASE;
typedef void* (* OMysqlCConnection_CreateInstanceFunction)(void* _pDriver);
class MysqlCDriver : public ODriver_BASE
{
protected:
Reference< css::lang::XMultiServiceFactory > m_xFactory;
::osl::Mutex m_aMutex; // mutex is need to control member access
OWeakRefArray m_xConnections; // vector containing a list
// of all the Connection objects
// for this Driver
#ifndef SYSTEM_MYSQL_CPPCONN
#ifdef BUNDLE_MARIADB
oslModule m_hCConnModule;
bool m_bAttemptedLoadCConn;
#endif
oslModule m_hCppConnModule;
bool m_bAttemptedLoadCppConn;
#endif
sql::Driver * cppDriver;
public:
explicit MysqlCDriver(const Reference< css::lang::XMultiServiceFactory >& _rxFactory);
// OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
/// @throws RuntimeException
static rtl::OUString getImplementationName_Static();
/// @throws RuntimeException
static Sequence< rtl::OUString > getSupportedServiceNames_Static();
// XServiceInfo
rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) SAL_OVERRIDE;
Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() SAL_OVERRIDE;
// XDriver
Reference< css::sdbc::XConnection > SAL_CALL connect(const rtl::OUString& url, const Sequence< css::beans::PropertyValue >& info) SAL_OVERRIDE;
sal_Bool SAL_CALL acceptsURL(const rtl::OUString& url) SAL_OVERRIDE;
Sequence< css::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo(const rtl::OUString& url, const Sequence< css::beans::PropertyValue >& info) SAL_OVERRIDE;
sal_Int32 SAL_CALL getMajorVersion() SAL_OVERRIDE;
sal_Int32 SAL_CALL getMinorVersion() SAL_OVERRIDE;
const Reference< css::lang::XMultiServiceFactory >& getFactory() const { return m_xFactory; }
static rtl_TextEncoding getDefaultEncoding() { return RTL_TEXTENCODING_UTF8; }
private:
void impl_initCppConn_lck_throw();
};
} /* mysqlc */
} /* connectivity */
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_DRIVER_HXX
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-128
View File
@@ -1,128 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_GENERAL_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_GENERAL_HXX
#include <config_lgpl.h>
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <osl/diagnose.h>
#include <mysql.h>
#if defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#include <cppconn/exception.h>
#if defined __GNUC__
#pragma GCC diagnostic pop
#endif
namespace mysqlc_sdbc_driver
{
template<typename T>
void resetSqlVar(void** target, T* pValue, enum_field_types type, sal_Int32 nSize = 0)
{
if(*target)
{
free(*target);
*target = nullptr;
}
constexpr auto nUnitSize = sizeof(T);
switch(type)
{
case MYSQL_TYPE_INT24:
case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_NEWDATE:
case MYSQL_TYPE_BIT:
case MYSQL_TYPE_GEOMETRY:
case MYSQL_TYPE_LONG:
case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_TINY:
case MYSQL_TYPE_LONGLONG:
case MYSQL_TYPE_FLOAT:
case MYSQL_TYPE_DOUBLE:
case MYSQL_TYPE_TIME:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
case MYSQL_TYPE_TIMESTAMP:
*target = malloc(nUnitSize);
memcpy(*target, pValue, nUnitSize);
break;
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_VARCHAR:
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_ENUM:
case MYSQL_TYPE_SET:
case MYSQL_TYPE_VAR_STRING:
case MYSQL_TYPE_TINY_BLOB:
case MYSQL_TYPE_MEDIUM_BLOB:
case MYSQL_TYPE_LONG_BLOB:
*target = malloc(nUnitSize*nSize);
memcpy(*target, pValue, nUnitSize*nSize);
break;
case MYSQL_TYPE_NULL:
// nothing I guess
break;
default:
OSL_FAIL("resetSqlVar: unknown enum_field_type");
}
}
void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize = 0);
rtl::OString escapeSql(const rtl::OString& from);
rtl::OUString getStringFromAny(const css::uno::Any& _rAny);
/// @throws css::sdbc::SQLException
void throwFeatureNotImplementedException(
const sal_Char* _pAsciiFeatureName,
const css::uno::Reference< css::uno::XInterface >& _rxContext
);
/// @throws css::sdbc::SQLException
void throwInvalidArgumentException(
const sal_Char* _pAsciiFeatureName,
const css::uno::Reference< css::uno::XInterface >& _rxContext
);
void translateAndThrow(const ::sql::SQLException& _error, const css::uno::Reference< css::uno::XInterface >& _context, const rtl_TextEncoding encoding);
void throwSQLExceptionWithMsg(const char* msg, unsigned int errorNum, const css::uno::Reference< css::uno::XInterface >& _context, const rtl_TextEncoding encoding);
int mysqlToOOOType(int eType, int charsetnr) noexcept;
rtl::OUString mysqlTypeToStr(MYSQL_FIELD* pField);
int mysqlStrToOOOType(const rtl::OUString& sType);
rtl::OUString convert(const ::std::string& _string, const rtl_TextEncoding encoding);
::std::string convert(const rtl::OUString& _string, const rtl_TextEncoding encoding);
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-163
View File
@@ -1,163 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_PREPAREDSTATEMENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_PREPAREDSTATEMENT_HXX
#include "mysqlc_statement.hxx"
#include "mysqlc_resultset.hxx"
#include <com/sun/star/sdbc/XPreparedStatement.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <cppconn/prepared_statement.h>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Type;
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::sdbc::XResultSetMetaData;
struct BindMetaData
{
char is_null = 0;
unsigned long length = 0;
char error = 0;
};
typedef ::cppu::ImplHelper5< css::sdbc::XPreparedStatement,
css::sdbc::XParameters,
css::sdbc::XPreparedBatchExecution,
css::sdbc::XResultSetMetaDataSupplier,
css::lang::XServiceInfo> OPreparedStatement_BASE;
class OPreparedStatement final : public OCommonStatement,
public OPreparedStatement_BASE
{
unsigned int m_paramCount = 0; // number of placeholders
Reference< XResultSetMetaData > m_xMetaData;
MYSQL_STMT* m_pStmt;
std::vector<MYSQL_BIND> m_binds;
std::vector<BindMetaData> m_bindMetas;
void checkParameterIndex(sal_Int32 parameter);
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
virtual ~OPreparedStatement();
public:
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;
OPreparedStatement(OConnection* _pConnection, MYSQL_STMT* pStmt);
//XInterface
Any SAL_CALL queryInterface(const Type & rType) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence< Type > SAL_CALL getTypes() SAL_OVERRIDE;
// XPreparedStatement
Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() SAL_OVERRIDE;
sal_Int32 SAL_CALL executeUpdate() SAL_OVERRIDE;
sal_Bool SAL_CALL execute() SAL_OVERRIDE;
Reference< css::sdbc::XConnection > SAL_CALL getConnection() SAL_OVERRIDE;
// XStatement
using OCommonStatement::executeQuery;
using OCommonStatement::executeUpdate;
using OCommonStatement::execute;
// XParameters
void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType) SAL_OVERRIDE;
void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const rtl::OUString& typeName) SAL_OVERRIDE;
void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x) SAL_OVERRIDE;
void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x) SAL_OVERRIDE;
void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x) SAL_OVERRIDE;
void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x) SAL_OVERRIDE;
void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x) SAL_OVERRIDE;
void SAL_CALL setFloat(sal_Int32 parameter, float x) SAL_OVERRIDE;
void SAL_CALL setDouble(sal_Int32 parameter, double x) SAL_OVERRIDE;
void SAL_CALL setString(sal_Int32 parameter, const rtl::OUString& x) SAL_OVERRIDE;
void SAL_CALL setBytes(sal_Int32 parameter, const css::uno::Sequence< sal_Int8 >& x) SAL_OVERRIDE;
void SAL_CALL setDate(sal_Int32 parameter, const css::util::Date& x) SAL_OVERRIDE;
void SAL_CALL setTime(sal_Int32 parameter, const css::util::Time& x) SAL_OVERRIDE;
void SAL_CALL setTimestamp(sal_Int32 parameter, const css::util::DateTime& x) SAL_OVERRIDE;
void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< css::io::XInputStream >& x, sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< css::io::XInputStream >& x, sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL setObject(sal_Int32 parameter, const Any& x) SAL_OVERRIDE;
void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale) SAL_OVERRIDE;
void SAL_CALL setRef(sal_Int32 parameter, const Reference< css::sdbc::XRef >& x) SAL_OVERRIDE;
void SAL_CALL setBlob(sal_Int32 parameter, const Reference< css::sdbc::XBlob >& x) SAL_OVERRIDE;
void SAL_CALL setClob(sal_Int32 parameter, const Reference< css::sdbc::XClob >& x) SAL_OVERRIDE;
void SAL_CALL setArray(sal_Int32 parameter, const Reference< css::sdbc::XArray >& x) SAL_OVERRIDE;
void SAL_CALL clearParameters() SAL_OVERRIDE;
// XPreparedBatchExecution
void SAL_CALL addBatch() SAL_OVERRIDE;
void SAL_CALL clearBatch() SAL_OVERRIDE;
css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XResultSetMetaDataSupplier
Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() SAL_OVERRIDE;
};
} /* mysqlc */
} /* connectivity */
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_PREPAREDSTATEMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-247
View File
@@ -1,247 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSET_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSET_HXX
#include "mysqlc_preparedstatement.hxx"
#include "mysqlc_statement.hxx"
#include "mysqlc_subcomponent.hxx"
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XCloseable.hpp>
#include <com/sun/star/sdbc/XColumnLocate.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XRowUpdate.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/sdbcx/XDeleteRows.hpp>
#include <com/sun/star/sdbcx/XRowLocate.hpp>
#include <com/sun/star/util/XCancellable.hpp>
#include <cppuhelper/compbase12.hxx>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::Any;
/*
** OResultSet
*/
typedef ::cppu::WeakComponentImplHelper12< css::sdbc::XResultSet,
css::sdbc::XRow,
css::sdbc::XResultSetMetaDataSupplier,
css::util::XCancellable,
css::sdbc::XWarningsSupplier,
css::sdbc::XResultSetUpdate,
css::sdbc::XRowUpdate,
css::sdbcx::XRowLocate,
css::sdbcx::XDeleteRows,
css::sdbc::XCloseable,
css::sdbc::XColumnLocate,
css::lang::XServiceInfo> OResultSet_BASE;
class OResultSet final : public OBase_Mutex,
public OResultSet_BASE,
public ::cppu::OPropertySetHelper,
public OPropertyArrayUsageHelper<OResultSet>
{
OConnection &m_rConnection;
MYSQL_ROW m_aRow;
unsigned long *m_aLengths = nullptr;
MYSQL *m_pMysql = nullptr;
css::uno::WeakReferenceHelper m_aStatement;
css::uno::Reference< css::sdbc::XResultSetMetaData> m_xMetaData;
MYSQL_RES *m_pResult;
unsigned int fieldCount;
rtl_TextEncoding m_encoding;
sal_Int32 m_nCurrentField = 0;
bool m_bWasNull = false; // did the last getXXX result null?
// OPropertyArrayUsageHelper
::cppu::IPropertyArrayHelper* createArrayHelper() const SAL_OVERRIDE;
// OPropertySetHelper
::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
// you can't delete objects of this type
virtual ~OResultSet();
public:
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;
OResultSet(OConnection& rConn, OCommonStatement* pStmt, MYSQL_RES *pResult, rtl_TextEncoding _encoding );
// ::cppu::OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
Any SAL_CALL queryInterface(const css::uno::Type & rType) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE;
// XPropertySet
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() SAL_OVERRIDE;
// XResultSet
sal_Bool SAL_CALL next() SAL_OVERRIDE;
sal_Bool SAL_CALL isBeforeFirst() SAL_OVERRIDE;
sal_Bool SAL_CALL isAfterLast() SAL_OVERRIDE;
sal_Bool SAL_CALL isFirst() SAL_OVERRIDE;
sal_Bool SAL_CALL isLast() SAL_OVERRIDE;
void SAL_CALL beforeFirst() SAL_OVERRIDE;
void SAL_CALL afterLast() SAL_OVERRIDE;
sal_Bool SAL_CALL first() SAL_OVERRIDE;
sal_Bool SAL_CALL last() SAL_OVERRIDE;
sal_Int32 SAL_CALL getRow() SAL_OVERRIDE;
sal_Bool SAL_CALL absolute(sal_Int32 row) SAL_OVERRIDE;
sal_Bool SAL_CALL relative(sal_Int32 rows) SAL_OVERRIDE;
sal_Bool SAL_CALL previous() SAL_OVERRIDE;
void SAL_CALL refreshRow() SAL_OVERRIDE;
sal_Bool SAL_CALL rowUpdated() SAL_OVERRIDE;
sal_Bool SAL_CALL rowInserted() SAL_OVERRIDE;
sal_Bool SAL_CALL rowDeleted() SAL_OVERRIDE;
css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() SAL_OVERRIDE;
// XRow
sal_Bool SAL_CALL wasNull() SAL_OVERRIDE;
rtl::OUString SAL_CALL getString(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL getBoolean(sal_Int32 column) SAL_OVERRIDE;
sal_Int8 SAL_CALL getByte(sal_Int32 column) SAL_OVERRIDE;
sal_Int16 SAL_CALL getShort(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getInt(sal_Int32 column) SAL_OVERRIDE;
sal_Int64 SAL_CALL getLong(sal_Int32 column) SAL_OVERRIDE;
float SAL_CALL getFloat(sal_Int32 column) SAL_OVERRIDE;
double SAL_CALL getDouble(sal_Int32 column) SAL_OVERRIDE;
css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 column) SAL_OVERRIDE;
css::util::Date SAL_CALL getDate(sal_Int32 column) SAL_OVERRIDE;
css::util::Time SAL_CALL getTime(sal_Int32 column) SAL_OVERRIDE;
css::util::DateTime SAL_CALL getTimestamp(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 column) SAL_OVERRIDE;
Any SAL_CALL getObject(sal_Int32 column, const my_XNameAccessRef& typeMap) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 column) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 column) SAL_OVERRIDE;
// XResultSetMetaDataSupplier
css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() SAL_OVERRIDE;
// XCancellable
void SAL_CALL cancel() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XWarningsSupplier
Any SAL_CALL getWarnings() SAL_OVERRIDE;
void SAL_CALL clearWarnings() SAL_OVERRIDE;
// XResultSetUpdate
void SAL_CALL insertRow() SAL_OVERRIDE;
void SAL_CALL updateRow() SAL_OVERRIDE;
void SAL_CALL deleteRow() SAL_OVERRIDE;
void SAL_CALL cancelRowUpdates() SAL_OVERRIDE;
void SAL_CALL moveToInsertRow() SAL_OVERRIDE;
void SAL_CALL moveToCurrentRow() SAL_OVERRIDE;
// XRowUpdate
void SAL_CALL updateNull(sal_Int32 column) SAL_OVERRIDE;
void SAL_CALL updateBoolean(sal_Int32 column, sal_Bool x) SAL_OVERRIDE;
void SAL_CALL updateByte(sal_Int32 column, sal_Int8 x) SAL_OVERRIDE;
void SAL_CALL updateShort(sal_Int32 column, sal_Int16 x) SAL_OVERRIDE;
void SAL_CALL updateInt(sal_Int32 column, sal_Int32 x) SAL_OVERRIDE;
void SAL_CALL updateLong(sal_Int32 column, sal_Int64 x) SAL_OVERRIDE;
void SAL_CALL updateFloat(sal_Int32 column, float x) SAL_OVERRIDE;
void SAL_CALL updateDouble(sal_Int32 column, double x) SAL_OVERRIDE;
void SAL_CALL updateString(sal_Int32 column, const rtl::OUString& x) SAL_OVERRIDE;
void SAL_CALL updateBytes(sal_Int32 column, const css::uno::Sequence< sal_Int8 >& x) SAL_OVERRIDE;
void SAL_CALL updateDate(sal_Int32 column, const css::util::Date& x) SAL_OVERRIDE;
void SAL_CALL updateTime(sal_Int32 column, const css::util::Time& x) SAL_OVERRIDE;
void SAL_CALL updateTimestamp(sal_Int32 column, const css::util::DateTime& x) SAL_OVERRIDE;
void SAL_CALL updateBinaryStream(sal_Int32 column, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL updateCharacterStream(sal_Int32 column, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length) SAL_OVERRIDE;
void SAL_CALL updateObject(sal_Int32 column, const Any& x) SAL_OVERRIDE;
void SAL_CALL updateNumericObject(sal_Int32 column, const Any& x, sal_Int32 scale) SAL_OVERRIDE;
// XColumnLocate
sal_Int32 SAL_CALL findColumn(const rtl::OUString& columnName) SAL_OVERRIDE;
// XRowLocate
Any SAL_CALL getBookmark() SAL_OVERRIDE;
sal_Bool SAL_CALL moveToBookmark(const Any& bookmark) SAL_OVERRIDE;
sal_Bool SAL_CALL moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) SAL_OVERRIDE;
sal_Int32 SAL_CALL compareBookmarks(const Any& first, const Any& second) SAL_OVERRIDE;
sal_Bool SAL_CALL hasOrderedBookmarks() SAL_OVERRIDE;
sal_Int32 SAL_CALL hashBookmark(const Any& bookmark) SAL_OVERRIDE;
// XDeleteRows
css::uno::Sequence< sal_Int32 > SAL_CALL deleteRows(const css::uno::Sequence< Any >& rows) SAL_OVERRIDE;
/// @throws SQLException
/// @throws RuntimeException
void checkColumnIndex(sal_Int32 index);
private:
using ::cppu::OPropertySetHelper::getFastPropertyValue;
};
} /* mysqlc */
} /* connectivity */
#endif // CONNECTIVITY_SRESULTSET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-110
View File
@@ -1,110 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSETMETADATA_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSETMETADATA_HXX
#include "mysqlc_connection.hxx"
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppconn/resultset_metadata.h>
#include <mysql.h>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::RuntimeException;
using ::com::sun::star::uno::RuntimeException;
//************ Class: ResultSetMetaData
typedef ::cppu::WeakImplHelper1< css::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
class OResultSetMetaData final : public OResultSetMetaData_BASE
{
private:
OConnection& m_rConnection;
MYSQL_RES * m_pRes;
rtl_TextEncoding m_encoding;
virtual ~OResultSetMetaData() = default;
MYSQL_FIELD* getField(sal_Int32 column) const;
public:
OResultSetMetaData(OConnection& rConn,
MYSQL_RES * pResult, rtl_TextEncoding _encoding )
:m_rConnection(rConn)
,m_pRes(pResult)
,m_encoding( _encoding )
{
}
rtl::OUString convert( const ::std::string& _string ) const
{
return rtl::OUString( _string.c_str(), _string.size(), m_encoding );
}
sal_Int32 SAL_CALL getColumnCount() SAL_OVERRIDE;
sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isCaseSensitive(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isSearchable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isCurrency(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL isNullable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isSigned(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnLabel(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnName(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getSchemaName(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getPrecision(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getScale(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getTableName(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getCatalogName(sal_Int32 column) SAL_OVERRIDE;
sal_Int32 SAL_CALL getColumnType(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnTypeName(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isReadOnly(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isWritable(sal_Int32 column) SAL_OVERRIDE;
sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) SAL_OVERRIDE;
rtl::OUString SAL_CALL getColumnServiceName(sal_Int32 column) SAL_OVERRIDE;
/// @throws SQLException
/// @throws RuntimeException
void checkColumnIndex(sal_Int32 columnIndex);
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_RESULTSETMETADATA_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-189
View File
@@ -1,189 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
#include "mysqlc_connection.hxx"
#include "mysqlc_subcomponent.hxx"
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sdbc/SQLWarning.hpp>
#include <com/sun/star/sdbc/XBatchExecution.hpp>
#include <com/sun/star/sdbc/XCloseable.hpp>
#include <com/sun/star/sdbc/XMultipleResults.hpp>
#include <com/sun/star/sdbc/XStatement.hpp>
#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
#include <com/sun/star/util/XCancellable.hpp>
#include <cppconn/statement.h>
#include <cppuhelper/compbase5.hxx>
#include <rtl/ref.hxx>
namespace connectivity
{
namespace mysqlc
{
using ::com::sun::star::sdbc::SQLWarning;
using ::com::sun::star::sdbc::SQLException;
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::RuntimeException;
typedef ::cppu::WeakComponentImplHelper5< css::sdbc::XStatement,
css::sdbc::XWarningsSupplier,
css::util::XCancellable,
css::sdbc::XCloseable,
css::sdbc::XMultipleResults> OCommonStatement_IBase;
//************ Class: OCommonStatement
// is a base class for the normal statement and for the prepared statement
class OCommonStatement :public OBase_Mutex
,public OCommonStatement_IBase
,public ::cppu::OPropertySetHelper
,public OPropertyArrayUsageHelper<OCommonStatement>
{
private:
SQLWarning m_aLastWarning;
protected:
rtl::Reference<OConnection> m_xConnection; // The owning Connection object
css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
MYSQL_RES* m_pMysqlResult = nullptr;
// number of rows affected by an UPDATE, DELETE or INSERT statement.
sal_Int32 m_nAffectedRows = 0;
protected:
void disposeResultSet();
// OPropertyArrayUsageHelper
::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
// OPropertySetHelper
::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue,
sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) SAL_OVERRIDE;
void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const SAL_OVERRIDE;
virtual ~OCommonStatement();
protected:
OCommonStatement(OConnection* _pConnection);
public:
using OCommonStatement_IBase::rBHelper;
using OCommonStatement_IBase::operator css::uno::Reference< css::uno::XInterface >;
// OComponentHelper
void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
void SAL_CALL release() throw() SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
// XInterface
Any SAL_CALL queryInterface(const css::uno::Type & rType) SAL_OVERRIDE;
//XTypeProvider
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE;
// XPropertySet
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() SAL_OVERRIDE;
// XStatement
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const rtl::OUString& sql) SAL_OVERRIDE;
sal_Int32 SAL_CALL executeUpdate(const rtl::OUString& sql) SAL_OVERRIDE;
sal_Bool SAL_CALL execute( const rtl::OUString& sql ) SAL_OVERRIDE;
css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() SAL_OVERRIDE;
// XWarningsSupplier
Any SAL_CALL getWarnings() SAL_OVERRIDE;
void SAL_CALL clearWarnings() SAL_OVERRIDE;
// XCancellable
void SAL_CALL cancel() SAL_OVERRIDE;
// XCloseable
void SAL_CALL close() SAL_OVERRIDE;
// XMultipleResults
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() SAL_OVERRIDE;
sal_Int32 SAL_CALL getUpdateCount() SAL_OVERRIDE;
sal_Bool SAL_CALL getMoreResults() SAL_OVERRIDE;
// other methods
OConnection* getOwnConnection() const { return m_xConnection.get();}
private:
using ::cppu::OPropertySetHelper::getFastPropertyValue;
};
class OStatement final : public OCommonStatement,
public css::sdbc::XBatchExecution,
public css::lang::XServiceInfo
{
virtual ~OStatement(){}
public:
// A constructor which is required for the return of the objects
OStatement(OConnection* _pConnection) :
OCommonStatement(_pConnection) {}
virtual rtl::OUString SAL_CALL getImplementationName() SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService(
rtl::OUString const & ServiceName)
SAL_OVERRIDE;
virtual css::uno::Sequence<rtl::OUString> SAL_CALL
getSupportedServiceNames()
SAL_OVERRIDE;
Any SAL_CALL queryInterface( const css::uno::Type & rType ) SAL_OVERRIDE;
void SAL_CALL acquire() throw() SAL_OVERRIDE;
void SAL_CALL release() throw() SAL_OVERRIDE;
// XBatchExecution
void SAL_CALL addBatch(const rtl::OUString& sql) SAL_OVERRIDE;
void SAL_CALL clearBatch() SAL_OVERRIDE;
css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() SAL_OVERRIDE;
};
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-163
View File
@@ -1,163 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
#define INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <cppuhelper/propshlp.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weak.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
namespace cppu {
class IPropertyArrayHelper;
}
namespace com
{
namespace sun
{
namespace star
{
namespace lang
{
class XComponent;
}
}
}
}
namespace connectivity
{
namespace mysqlc
{
/// @throws css::lang::DisposedException
void checkDisposed(bool _bThrow);
template <class TYPE>
class OPropertyArrayUsageHelper
{
protected:
static sal_Int32 s_nRefCount;
static ::cppu::IPropertyArrayHelper* s_pProps;
static ::osl::Mutex s_aMutex;
public:
OPropertyArrayUsageHelper();
virtual ~OPropertyArrayUsageHelper();
/** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
class, which is created if necessary.
*/
::cppu::IPropertyArrayHelper* getArrayHelper();
protected:
/** used to implement the creation of the array helper which is shared amongst all instances of the class.
This method needs to be implemented in derived classes.
<BR>
The method gets called with s_aMutex acquired.
@return an pointer to the newly created array helper. Must not be NULL.
*/
virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const = 0;
};
template<class TYPE>
sal_Int32 OPropertyArrayUsageHelper< TYPE >::s_nRefCount = 0;
template<class TYPE>
::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper< TYPE >::s_pProps = nullptr;
template<class TYPE>
::osl::Mutex OPropertyArrayUsageHelper< TYPE >::s_aMutex;
template <class TYPE>
OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
{
::osl::MutexGuard aGuard(s_aMutex);
++s_nRefCount;
}
template <class TYPE>
OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
{
::osl::MutexGuard aGuard(s_aMutex);
OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
if (!--s_nRefCount)
{
delete s_pProps;
s_pProps = nullptr;
}
}
template <class TYPE>
::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
{
OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
if (!s_pProps) {
::osl::MutexGuard aGuard(s_aMutex);
if (!s_pProps) {
s_pProps = createArrayHelper();
OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
}
}
return s_pProps;
}
class OBase_Mutex
{
public:
::osl::Mutex m_aMutex;
};
namespace internal
{
template <class T>
void implCopySequence(const T* _pSource, T*& _pDest, sal_Int32 _nSourceLen)
{
for (sal_Int32 i=0; i<_nSourceLen; ++i, ++_pSource, ++_pDest)
*_pDest = *_pSource;
}
}
/// concat two sequences
template <class T>
css::uno::Sequence<T> concatSequences(const css::uno::Sequence<T>& _rLeft, const css::uno::Sequence<T>& _rRight)
{
sal_Int32 nLeft(_rLeft.getLength()), nRight(_rRight.getLength());
const T* pLeft = _rLeft.getConstArray();
const T* pRight = _rRight.getConstArray();
sal_Int32 nReturnLen(nLeft + nRight);
css::uno::Sequence<T> aReturn(nReturnLen);
T* pReturn = aReturn.getArray();
internal::implCopySequence(pLeft, pReturn, nLeft);
internal::implCopySequence(pRight, pReturn, nRight);
return aReturn;
}
}
}
#endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_SUBCOMPONENT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-682
View File
@@ -1,682 +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 <stdio.h>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/ColumnSearch.hpp>
#include "mysqlc_types.hxx"
using namespace com::sun::star::sdbc;
TypeInfoDef mysqlc_types[] = {
// ------------- MySQL-Type: BIT. SDBC-Type: Bit -------------
{
"BIT", // Typename
com::sun::star::sdbc::DataType::BIT, // sdbc-type
1, // Precision
"", // Literal prefix
"", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BIT", // local type name
0, // minimum scale
0 // maximum scale
},
// ------------ MySQL-Type: BOOL. SDBC-Type: Bit -------------
{
"BOOL", // Typename
com::sun::star::sdbc::DataType::BIT, // sdbc-type
1, // Precision
"", // Literal prefix
"", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BOOL", // local type name
0, // minimum scale
0 // maximum scale
},
// --------- MySQL-Type: TINYINT SDBC-Type: TINYINT ----------
{
"TINYINT", // Typename
com::sun::star::sdbc::DataType::TINYINT, // sdbc-type
3, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"TINYINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BIGINT SDBC-Type: BIGINT ----------
{
"BIGINT", // Typename
com::sun::star::sdbc::DataType::BIGINT, // sdbc-type
19, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"BIGINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONG VARBINARY SDBC-Type: LONGVARBINARY ----------
{
"LONG VARBINARY", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
16777215, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONG VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMBLOB SDBC-Type: LONGVARBINARY ----------
{
"MEDIUMBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
16777215, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"MEDIUMBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONGBLOB SDBC-Type: LONGVARBINARY ----------
{
"LONGBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
-1, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONGBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BLOB SDBC-Type: LONGVARBINARY ----------
{
"BLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"BLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TINYBLOB SDBC-Type: LONGVARBINARY ----------
{
"TINYBLOB", // Typename
com::sun::star::sdbc::DataType::LONGVARBINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TINYBLOB", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: VARBINARY SDBC-Type: VARBINARY ----------
{
"VARBINARY", // Typename
com::sun::star::sdbc::DataType::VARBINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: BINARY SDBC-Type: BINARY ----------
{
"BINARY", // Typename
com::sun::star::sdbc::DataType::BINARY, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
true, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARBINARY", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONG VARCHAR SDBC-Type: LONG VARCHAR ----------
{
"LONG VARCHAR", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONG VARCHAR", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMTEXT SDBC-Type: LONG VARCHAR ----------
{
"MEDIUMTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"MEDIUMTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: LONGTEXT SDBC-Type: LONG VARCHAR ----------
{
"LONGTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"LONGTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TEXT SDBC-Type: LONG VARCHAR ----------
{
"TEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TINYTEXT SDBC-Type: LONG VARCHAR ----------
{
"TINYTEXT", // Typename
com::sun::star::sdbc::DataType::LONGVARCHAR, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TINYTEXT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: CHAR SDBC-Type: CHAR ----------
{
"CHAR", // Typename
com::sun::star::sdbc::DataType::CHAR, // sdbc-type
0xFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"NUMERIC", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DECIMAL SDBC-Type: DECIMAL ----------
{
"DECIMAL", // Typename
com::sun::star::sdbc::DataType::DECIMAL, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M[,D])] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DECIMAL", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: NUMERIC SDBC-Type: NUMERIC ----------
{
"NUMERIC", // Typename
com::sun::star::sdbc::DataType::NUMERIC, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M[,D])] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"NUMERIC", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: INTEGER SDBC-Type: INTEGER ----------
{
"INTEGER", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"INTEGER", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: INT SDBC-Type: INTEGER ----------
{
"INT", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"INT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: MEDIUMINT SDBC-Type: INTEGER ----------
{
"MEDIUMINT", // Typename
com::sun::star::sdbc::DataType::INTEGER, // sdbc-type
7, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"MEDIUMINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: SMALLINT SDBC-Type: INTEGER ----------
{
"SMALLINT", // Typename
com::sun::star::sdbc::DataType::SMALLINT, // sdbc-type
5, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M)] [UNSIGNED] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
true, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"SMALLINT", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: FLOAT SDBC-Type: REAL ----------
{
"FLOAT", // Typename
com::sun::star::sdbc::DataType::REAL, // sdbc-type
10, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"FLOAT", // local type name
-38, // minimum scale
38 // maximum scale
},
// ----------- MySQL-Type: DOUBLE SDBC-Type: DOUBLE ----------
{
"DOUBLE", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DOUBLE", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: DOUBLE PRECISION SDBC-Type: DOUBLE ----------
{
"DOUBLE PRECISION", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"DOUBLE PRECISION", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: REAL SDBC-Type: DOUBLE ----------
{
"REAL", // Typename
com::sun::star::sdbc::DataType::DOUBLE, // sdbc-type
17, // Precision
"", // Literal prefix
"", // Literal suffix
"[(M,D)] [ZEROFILL]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
true, // auto_increment
"REAL", // local type name
-308, // minimum scale
308 // maximum scale
},
// ----------- MySQL-Type: VARCHAR SDBC-Type: VARCHAR ----------
{
"VARCHAR", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
255, // Precision
"'", // Literal prefix
"'", // Literal suffix
"(M)", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"VARCHAR", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: ENUM SDBC-Type: VARCHAR ----------
{
"ENUM", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
0xFFFF, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"ENUM", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: SET SDBC-Type: VARCHAR ----------
{
"SET", // Typename
com::sun::star::sdbc::DataType::VARCHAR, // sdbc-type
64, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"SET", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DATE SDBC-Type: DATE ----------
{
"DATE", // Typename
com::sun::star::sdbc::DataType::DATE, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"DATE", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIME SDBC-Type: TIME ----------
{
"TIME", // Typename
com::sun::star::sdbc::DataType::TIME, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TIME", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: DATETIME SDBC-Type: TIMESTAMP ----------
{
"DATETIME", // Typename
com::sun::star::sdbc::DataType::TIMESTAMP, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"DATETIME", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIMESTAMP SDBC-Type: TIMESTAMP ----------
{
"TIMESTAMP", // Typename
com::sun::star::sdbc::DataType::TIMESTAMP, // sdbc-type
0, // Precision
"'", // Literal prefix
"'", // Literal suffix
"[(M)]", // Create params
com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable
false, // case sensitive
com::sun::star::sdbc::ColumnSearch::FULL, // searchable
false, // unsignable
false, // fixed_prec_scale
false, // auto_increment
"TIMESTAMP", // local type name
0, // minimum scale
0 // maximum scale
},
// ----------- MySQL-Type: TIMESTAMP SDBC-Type: TIMESTAMP ----------
{
nullptr, 0, 0, nullptr, nullptr, nullptr, 0, false, 0, false, false, false, nullptr, 0, 0
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -2
View File
@@ -277,9 +277,9 @@ ifeq (DBCONNECTIVITY,$(filter DBCONNECTIVITY,$(BUILD_TYPE)))
postprocess_FILES_main += \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/dbase)/org/openoffice/Office/DataAccess/Drivers-dbase.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/flat)/org/openoffice/Office/DataAccess/Drivers-flat.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/mysql)/org/openoffice/Office/DataAccess/Drivers-mysql.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/mysqlc)/org/openoffice/Office/DataAccess/Drivers-mysql.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/odbc)/org/openoffice/Office/DataAccess/Drivers-odbc.xcu
postprocess_DRIVERS += dbase flat mysql odbc
postprocess_DRIVERS += dbase flat mysqlc odbc
ifeq (WNT,$(OS))
else ifeq (DBCONNECTIVITY,$(filter DBCONNECTIVITY,$(BUILD_TYPE)))
ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
+1 -1
View File
@@ -257,7 +257,7 @@ $(eval $(call gb_Rdb_add_components,services,\
connectivity/source/drivers/firebird/firebird_sdbc \
) \
connectivity/source/drivers/flat/flat \
connectivity/source/drivers/mysql/mysql \
connectivity/source/drivers/mysqlc/mysqlc \
$(if $(filter MACOSX,$(OS)), \
connectivity/source/drivers/macab/macab1 \
) \
+1 -1
View File
@@ -123,7 +123,7 @@ class CheckGbuildToJsonModules(unittest.TestCase):
shutil.rmtree(self.tempwork)
def test_gbuildtojson(self):
modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'mysqlc', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity']
modules = ['accessibility', 'android', 'animations', 'apple_remote', 'avmedia', 'basctl', 'basegfx', 'basic', 'bean', 'canvas', 'chart2', 'codemaker', 'comphelper', 'cppcanvas', 'cui', 'dbaccess', 'desktop', 'drawinglayer', 'dtrans', 'editeng', 'embeddedobj', 'embedserv', 'eventattacher', 'extras', 'filter', 'forms', 'formula', 'fpicker', 'framework', 'hwpfilter', 'i18nlangtag', 'i18nutil', 'idl', 'idlc', 'instsetoo_native', 'io', 'ios', 'jvmaccess', 'jvmfwk', 'l10ntools', 'librelogo', 'libreofficekit', 'linguistic', 'lotuswordpro', 'nlpsolver', 'o3tl', 'offapi', 'officecfg', 'onlineupdate', 'oovbaapi', 'oox', 'opencl', 'package', 'postprocess', 'pyuno', 'registry', 'remotebridges', 'reportbuilder', 'reportdesign', 'ridljar', 'salhelper', 'sax', 'sc', 'sccomp', 'scp2', 'scripting', 'sd', 'sdext', 'setup_native', 'sfx2', 'slideshow', 'smoketest', 'soltools', 'sot', 'starmath', 'store', 'svgio', 'emfio', 'svl', 'svtools', 'svx', 'sw', 'swext', 'sysui', 'test', 'testtools', 'toolkit', 'ucb', 'ucbhelper', 'udkapi', 'uitest', 'UnoControls', 'unodevtools', 'unoidl', 'unoil', 'unotest', 'unotools', 'unoxml', 'ure', 'uui', 'vbahelper', 'vcl', 'winaccessibility', 'wizards', 'writerperfect', 'xmerge', 'xmlhelp', 'xmloff', 'xmlreader', 'xmlscript', 'xmlsecurity']
if os.environ['OS'] == 'WNT':
# for now, use a limited subset for testing on windows as it is so annoyingly slow on this
modules = ['chart2', 'cui', 'dbaccess', 'framework', 'oox', 'sfx2', 'svl', 'svtools', 'svx', 'toolkit', 'vcl', 'xmloff']