summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndras Timar <atimar@suse.com>2012-11-11 18:24:14 +0100
committerAndras Timar <atimar@suse.com>2012-11-11 18:24:14 +0100
commit06ec1c089519ef3249464aa09eadf03a8db93a39 (patch)
tree85b2eb6d8ba6ca95e18e1ff82151224cb14106f6 /connectivity
parent8e0d67bed54633d555a4601a5d79e2d5ba7ab2bb (diff)
parent3f899eae02eaad0b967de749fe09b869ba93ad6d (diff)
Merge branch 'master' into feature/killsdf
Conflicts: Repository.mk RepositoryFixes.mk connectivity/prj/build.lst extensions/prj/build.lst filter/prj/build.lst fpicker/prj/build.lst l10ntools/StaticLibrary_transex.mk saxon/build.xml shell/prj/build.lst solenv/gbuild/AllLangResTarget.mk solenv/gbuild/Configuration.mk solenv/gbuild/UI.mk ucb/source/ucp/webdav/webdavcontent.cxx
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/CppunitTest_connectivity_ado.mk75
-rw-r--r--connectivity/Library_postgresql-sdbc-impl.mk2
-rw-r--r--connectivity/Module_connectivity.mk7
-rw-r--r--connectivity/inc/connectivity/PColumn.hxx15
-rw-r--r--connectivity/inc/connectivity/predicateinput.hxx6
-rw-r--r--connectivity/inc/connectivity/sdbcx/VColumn.hxx29
-rw-r--r--connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx5
-rw-r--r--connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx5
-rw-r--r--connectivity/inc/connectivity/sqlparse.hxx4
-rw-r--r--connectivity/inc/connectivity/virtualdbtools.hxx2
-rw-r--r--connectivity/prj/build.lst4
-rwxr-xr-xconnectivity/qa/connectivity/ado/DriverTest.cxx145
-rwxr-xr-xconnectivity/qa/connectivity/ado/TS001018407.mdbbin0 -> 2789376 bytes
-rw-r--r--connectivity/source/commontools/ParamterSubstitution.cxx3
-rw-r--r--connectivity/source/commontools/TColumnsHelper.cxx10
-rw-r--r--connectivity/source/commontools/TIndexColumns.cxx27
-rw-r--r--connectivity/source/commontools/TKeyColumns.cxx34
-rw-r--r--connectivity/source/commontools/TSortIndex.cxx3
-rw-r--r--connectivity/source/commontools/TTableHelper.cxx2
-rw-r--r--connectivity/source/commontools/dbtools.cxx1
-rw-r--r--connectivity/source/commontools/dbtools2.cxx14
-rw-r--r--connectivity/source/commontools/predicateinput.cxx24
-rw-r--r--connectivity/source/drivers/ado/AColumn.cxx2
-rw-r--r--connectivity/source/drivers/ado/APreparedStatement.cxx3
-rw-r--r--connectivity/source/drivers/ado/AStatement.cxx14
-rw-r--r--connectivity/source/drivers/ado/ATable.cxx2
-rw-r--r--connectivity/source/drivers/ado/Awrapado.cxx16
-rw-r--r--connectivity/source/drivers/calc/CTable.cxx3
-rw-r--r--connectivity/source/drivers/dbase/DIndexColumns.cxx5
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx52
-rw-r--r--connectivity/source/drivers/evoab2/NColumns.cxx15
-rw-r--r--connectivity/source/drivers/evoab2/NDriver.hxx5
-rw-r--r--connectivity/source/drivers/evoab2/NStatement.cxx4
-rw-r--r--connectivity/source/drivers/file/FColumns.cxx12
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx5
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx3
-rw-r--r--connectivity/source/drivers/flat/ETable.cxx5
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageAccess.cxx20
-rw-r--r--connectivity/source/drivers/hsqldb/StorageFileAccess.cxx6
-rw-r--r--connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx14
-rw-r--r--connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx14
-rw-r--r--connectivity/source/drivers/jdbc/JConnection.cxx2
-rw-r--r--connectivity/source/drivers/jdbc/jservices.cxx2
-rw-r--r--connectivity/source/drivers/kab/KColumns.cxx14
-rw-r--r--connectivity/source/drivers/kab/KDriver.hxx5
-rw-r--r--connectivity/source/drivers/kab/KStatement.cxx2
-rw-r--r--connectivity/source/drivers/macab/MacabColumns.cxx14
-rw-r--r--connectivity/source/drivers/macab/MacabDriver.hxx5
-rw-r--r--connectivity/source/drivers/macab/MacabStatement.cxx2
-rw-r--r--connectivity/source/drivers/mork/MColumns.cxx13
-rw-r--r--connectivity/source/drivers/mork/MPreparedStatement.cxx5
-rw-r--r--connectivity/source/drivers/mork/MStatement.cxx3
-rw-r--r--connectivity/source/drivers/mozab/MColumns.cxx13
-rw-r--r--connectivity/source/drivers/mozab/MPreparedStatement.cxx5
-rw-r--r--connectivity/source/drivers/mozab/MStatement.cxx4
-rw-r--r--connectivity/source/drivers/odbcbase/OPreparedStatement.cxx377
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSet.cxx4
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx195
-rw-r--r--connectivity/source/inc/ado/Aolewrap.hxx4
-rw-r--r--connectivity/source/inc/dbase/DTable.hxx4
-rw-r--r--connectivity/source/inc/odbc/OBoundParam.hxx78
-rw-r--r--connectivity/source/inc/odbc/OPreparedStatement.hxx14
-rw-r--r--connectivity/source/inc/odbc/OTools.hxx38
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx1
-rw-r--r--connectivity/source/parse/PColumn.cxx81
-rw-r--r--connectivity/source/parse/sqliterator.cxx35
-rw-r--r--connectivity/source/parse/sqlnode.cxx13
-rw-r--r--connectivity/source/sdbcx/VColumn.cxx36
-rw-r--r--connectivity/source/sdbcx/VIndexColumn.cxx10
-rw-r--r--connectivity/source/sdbcx/VKeyColumn.cxx10
-rw-r--r--connectivity/source/simpledbt/dbtfactory.cxx4
-rw-r--r--connectivity/source/simpledbt/dbtfactory.hxx2
-rw-r--r--connectivity/source/simpledbt/parser_s.cxx4
-rw-r--r--connectivity/source/simpledbt/parser_s.hxx2
-rw-r--r--connectivity/workben/postgresql/ddl.py179
-rw-r--r--connectivity/workben/postgresql/main.py84
-rw-r--r--connectivity/workben/postgresql/makefile.mk97
-rw-r--r--connectivity/workben/postgresql/metadata.py145
-rw-r--r--connectivity/workben/postgresql/preparedstatement.py222
-rw-r--r--connectivity/workben/postgresql/sdbcx.py300
-rw-r--r--connectivity/workben/postgresql/statement.py271
81 files changed, 899 insertions, 2017 deletions
diff --git a/connectivity/CppunitTest_connectivity_ado.mk b/connectivity/CppunitTest_connectivity_ado.mk
new file mode 100644
index 000000000000..784aa7864533
--- /dev/null
+++ b/connectivity/CppunitTest_connectivity_ado.mk
@@ -0,0 +1,75 @@
+# -*- 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_CppunitTest_CppunitTest,connectivity_ado))
+
+$(eval $(call gb_CppunitTest_set_include,connectivity_ado,\
+ -I$(SRCDIR)/connectivity/source/inc \
+ -I$(SRCDIR)/connectivity/source/drivers/ado \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,connectivity_ado,\
+ udkapi \
+ offapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,connectivity_ado))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_ado))
+
+ifeq ($(COM),GCC)
+$(eval $(call gb_CppunitTest_add_cxxflags,connectivity_ado,\
+ -fpermissive \
+))
+endif
+
+ifeq ($(WINDOWS_SDK_VERSION),80)
+$(eval $(call gb_CppunitTest_add_defs,connectivity_ado,\
+ -DNTDDI_VERSION=0x0601 \
+))
+endif
+
+$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_ado, \
+ connectivity/qa/connectivity/ado/DriverTest \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,connectivity_ado, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ dbtools \
+ i18nisolang1 \
+ ado \
+ sal \
+ salhelper \
+ sb \
+ test \
+ unotest \
+ ucbhelper \
+ utl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_components,connectivity_ado,\
+ configmgr/source/configmgr \
+ i18npool/util/i18npool \
+ connectivity/source/drivers/ado/ado \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,connectivity_ado))
+
+$(call gb_CppunitTest_get_target,connectivity_ado) : $(WORKDIR)/CppunitTest/TS001018407.mdb
+$(WORKDIR)/CppunitTest/TS001018407.mdb : $(SRCDIR)/connectivity/qa/connectivity/ado/TS001018407.mdb
+ mkdir -p $(dir $@)
+ $(call gb_Deliver_deliver,$<,$@)
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Library_postgresql-sdbc-impl.mk b/connectivity/Library_postgresql-sdbc-impl.mk
index 7e525a9af7f0..8fbb372c2a7e 100644
--- a/connectivity/Library_postgresql-sdbc-impl.mk
+++ b/connectivity/Library_postgresql-sdbc-impl.mk
@@ -64,7 +64,7 @@ $(eval $(call gb_Library_use_externals,postgresql-sdbc-impl,\
ifneq ($(SYSTEM_POSTGRESQL),YES)
ifneq ($(GUI)$(COM),WNTMSC)
-include $(OUTDIR)/inc/postgresql/libpq-flags.mk
+-include $(OUTDIR)/inc/postgresql/libpq-flags.mk
$(eval $(call gb_Library_add_libs,postgresql-sdbc-impl,\
$(if $(filter-out MACOSX,$(OS)),-Wl$(COMMA)--as-needed) \
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index ab3a4513094f..08cae215e1b3 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -136,6 +136,7 @@ $(eval $(call gb_Module_add_targets,connectivity,\
Configuration_mork \
Executable_mork_helper \
Library_mork \
+ Library_mozbootstrap \
))
$(eval $(call gb_Module_add_check_targets,connectivity,\
@@ -144,6 +145,12 @@ $(eval $(call gb_Module_add_check_targets,connectivity,\
endif
+ifeq ($(GUI),WNT)
+$(eval $(call gb_Module_add_check_targets,connectivity,\
+ CppunitTest_connectivity_ado \
+))
+endif
+
ifneq ($(filter QADEVOOO,$(BUILD_TYPE)),)
$(eval $(call gb_Module_add_subsequentcheck_targets,connectivity,\
Jar_ConnectivityTools \
diff --git a/connectivity/inc/connectivity/PColumn.hxx b/connectivity/inc/connectivity/PColumn.hxx
index 9ac4eb5a272c..7da2c0691769 100644
--- a/connectivity/inc/connectivity/PColumn.hxx
+++ b/connectivity/inc/connectivity/PColumn.hxx
@@ -41,7 +41,6 @@ namespace connectivity
public OParseColumn_BASE, public OParseColumn_PROP
{
::rtl::OUString m_aRealName;
- ::rtl::OUString m_aTableName;
::rtl::OUString m_sLabel;
sal_Bool m_bFunction;
sal_Bool m_bDbasePrecisionChanged;
@@ -65,21 +64,24 @@ namespace connectivity
sal_Int32 _Type,
sal_Bool _IsAutoIncrement,
sal_Bool _IsCurrency,
- sal_Bool _bCase);
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName);
virtual void construct();
void setRealName(const ::rtl::OUString& _rName) { m_aRealName = _rName; }
void setLabel(const ::rtl::OUString& i_sLabel) { m_sLabel = i_sLabel; }
- void setTableName(const ::rtl::OUString& _rName) { m_aTableName = _rName; }
+ void setTableName(const ::rtl::OUString& _rName) { m_TableName = _rName; }
void setFunction(sal_Bool _bFunction) { m_bFunction = _bFunction; }
void setAggregateFunction(sal_Bool _bFunction) { m_bAggregateFunction = _bFunction; }
void setIsSearchable( sal_Bool _bIsSearchable ) { m_bIsSearchable = _bIsSearchable; }
void setDbasePrecisionChanged(sal_Bool _bDbasePrecisionChanged) { m_bDbasePrecisionChanged = _bDbasePrecisionChanged; }
- ::rtl::OUString getRealName() const { return m_aRealName; }
- ::rtl::OUString getLabel() const { return m_sLabel; }
- ::rtl::OUString getTableName() const { return m_aTableName; }
+ const ::rtl::OUString& getRealName() const { return m_aRealName; }
+ const ::rtl::OUString& getLabel() const { return m_sLabel; }
+ const ::rtl::OUString& getTableName() const { return m_TableName; }
sal_Bool getFunction() const { return m_bFunction; }
sal_Bool getDbasePrecisionChanged() const { return m_bDbasePrecisionChanged; }
@@ -118,7 +120,6 @@ namespace connectivity
public OOrderColumn_BASE, public OOrderColumn_PROP
{
const sal_Bool m_bAscending;
- const ::rtl::OUString m_sTableName;
protected:
virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
diff --git a/connectivity/inc/connectivity/predicateinput.hxx b/connectivity/inc/connectivity/predicateinput.hxx
index 56abc6e2959a..776e357261b2 100644
--- a/connectivity/inc/connectivity/predicateinput.hxx
+++ b/connectivity/inc/connectivity/predicateinput.hxx
@@ -21,7 +21,7 @@
#define CONNECTIVITY_PREDICATEINPUT_HXX
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/util/XNumberFormatter.hpp>
#include <com/sun/star/i18n/XLocaleData4.hpp>
@@ -42,8 +42,6 @@ namespace dbtools
class OOO_DLLPUBLIC_DBTOOLS OPredicateInputController
{
private:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- m_xORB;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
m_xConnection;
::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >
@@ -56,7 +54,7 @@ namespace dbtools
public:
OPredicateInputController(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
const ::connectivity::IParseContext* _pParseContext = NULL
);
diff --git a/connectivity/inc/connectivity/sdbcx/VColumn.hxx b/connectivity/inc/connectivity/sdbcx/VColumn.hxx
index c58e7cf2d81e..ca7a0bcc0b1c 100644
--- a/connectivity/inc/connectivity/sdbcx/VColumn.hxx
+++ b/connectivity/inc/connectivity/sdbcx/VColumn.hxx
@@ -63,6 +63,10 @@ namespace connectivity
sal_Bool m_IsRowVersion;
sal_Bool m_IsCurrency;
+ ::rtl::OUString m_CatalogName;
+ ::rtl::OUString m_SchemaName;
+ ::rtl::OUString m_TableName;
+
using OColumnDescriptor_BASE::rBHelper;
virtual ::cppu::IPropertyArrayHelper* createArrayHelper( sal_Int32 _nId) const;
virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
@@ -74,17 +78,20 @@ namespace connectivity
OColumn( sal_Bool _bCase);
OColumn( const ::rtl::OUString& _Name,
- const ::rtl::OUString& _TypeName,
- const ::rtl::OUString& _DefaultValue,
- const ::rtl::OUString& _Description,
- sal_Int32 _IsNullable,
- sal_Int32 _Precision,
- sal_Int32 _Scale,
- sal_Int32 _Type,
- sal_Bool _IsAutoIncrement,
- sal_Bool _IsRowVersion,
- sal_Bool _IsCurrency,
- sal_Bool _bCase);
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ const ::rtl::OUString& _Description,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement,
+ sal_Bool _IsRowVersion,
+ sal_Bool _IsCurrency,
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName);
DECLARE_SERVICE_INFO();
//XInterface
diff --git a/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx b/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx
index d5c11c40b985..bdccd128f172 100644
--- a/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx
+++ b/connectivity/inc/connectivity/sdbcx/VIndexColumn.hxx
@@ -50,7 +50,10 @@ namespace connectivity
sal_Bool _IsAutoIncrement,
sal_Bool _IsRowVersion,
sal_Bool _IsCurrency,
- sal_Bool _bCase);
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName);
virtual void construct();
DECLARE_SERVICE_INFO();
diff --git a/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx b/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx
index 92624b5caad6..b3624bd69a3a 100644
--- a/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx
+++ b/connectivity/inc/connectivity/sdbcx/VKeyColumn.hxx
@@ -50,7 +50,10 @@ namespace connectivity
sal_Bool _IsAutoIncrement,
sal_Bool _IsRowVersion,
sal_Bool _IsCurrency,
- sal_Bool _bCase);
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName);
// just to make it not inline
virtual ~OKeyColumn();
diff --git a/connectivity/inc/connectivity/sqlparse.hxx b/connectivity/inc/connectivity/sqlparse.hxx
index a4a64b3a2480..e67aa7d034ce 100644
--- a/connectivity/inc/connectivity/sqlparse.hxx
+++ b/connectivity/inc/connectivity/sqlparse.hxx
@@ -163,7 +163,7 @@ namespace connectivity
m_xFormatter; // current number formatter
sal_Int32 m_nFormatKey; // numberformat, which should be used
sal_Int32 m_nDateFormatKey;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification> m_xCharClass;
static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4> s_xLocaleData;
::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData> xDummy; // can be deleted after 627
@@ -183,7 +183,7 @@ namespace connectivity
public:
// if NULL, a default context will be used
// the context must live as long as the parser
- OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory,const IParseContext* _pContext = NULL);
+ OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const IParseContext* _pContext = NULL);
~OSQLParser();
// Parsing an SQLStatement
diff --git a/connectivity/inc/connectivity/virtualdbtools.hxx b/connectivity/inc/connectivity/virtualdbtools.hxx
index 0f6f6520ed7b..7551bedac8d6 100644
--- a/connectivity/inc/connectivity/virtualdbtools.hxx
+++ b/connectivity/inc/connectivity/virtualdbtools.hxx
@@ -335,7 +335,7 @@ namespace connectivity
public:
/// creates a simple version of the class OSQLParser
virtual ::rtl::Reference< ISQLParser > createSQLParser(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const IParseContext* _pContext
) const = 0;
diff --git a/connectivity/prj/build.lst b/connectivity/prj/build.lst
index 8dc24e57c014..aa71c79177b8 100644
--- a/connectivity/prj/build.lst
+++ b/connectivity/prj/build.lst
@@ -1,2 +1,2 @@
-cn connectivity : shell comphelper MOZ:moz POSTGRESQL:postgresql svl UNIXODBC:unixODBC unoil javaunohelper HSQLDB:hsqldb QADEVOOO:qadevOOo officecfg NSS:nss LIBXSLT:libxslt NULL
-
+cn connectivity : shell comphelper MOZ:moz POSTGRESQL:postgresql svl UNIXODBC:unixODBC unoil javaunohelper HSQLDB:hsqldb QADEVOOO:qadevOOo officecfg NSS:nss LIBXSLT:libxslt NULL
+cn connectivity\prj nmake - all cn_prj NULL
diff --git a/connectivity/qa/connectivity/ado/DriverTest.cxx b/connectivity/qa/connectivity/ado/DriverTest.cxx
new file mode 100755
index 000000000000..ee96eebd2fa5
--- /dev/null
+++ b/connectivity/qa/connectivity/ado/DriverTest.cxx
@@ -0,0 +1,145 @@
+/* -*- 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/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+
+//#include "ado/ADriver.hxx"
+//#include "ado/AConnection.hxx"
+//#include <com/sun/star/sdbc/XDriver.hpp>
+
+#include "ado/AConnection.hxx"
+#include "ado/ADatabaseMetaData.hxx"
+#include "ado/ADriver.hxx"
+#include "ado/AStatement.hxx"
+#include "ado/ACallableStatement.hxx"
+#include "ado/APreparedStatement.hxx"
+#include "ado/ACatalog.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbexception.hxx"
+#include <osl/file.hxx>
+#include "resource/ado_res.hrc"
+
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+namespace connectivity { namespace ado {
+
+
+class AdoDriverTest: public test::BootstrapFixture
+{
+public:
+ AdoDriverTest() : test::BootstrapFixture(false, false) {};
+
+ void test_metadata();
+ void test_select_default_all();
+
+ virtual void setUp();
+ virtual void tearDown();
+
+ CPPUNIT_TEST_SUITE(AdoDriverTest);
+
+ CPPUNIT_TEST(test_metadata);
+ CPPUNIT_TEST(test_select_default_all);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+ Reference<XInterface> m_xAdoComponent;
+ Reference<XConnection> m_xConnection;
+};
+
+void AdoDriverTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+ m_xAdoComponent = getMultiServiceFactory()->createInstance("com.sun.star.comp.sdbc.ado.ODriver");
+ CPPUNIT_ASSERT_MESSAGE("no ado component!", m_xAdoComponent.is());
+
+ OUString url = OUString("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=") +
+ getPathFromWorkdir("/CppunitTest/TS001018407.mdb");
+
+ Sequence< PropertyValue > info;
+ Reference< XDriver> xDriver(m_xAdoComponent, UNO_QUERY);
+ if (!xDriver.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot connect to ado driver!", xDriver.is());
+ }
+
+ m_xConnection = xDriver->connect(url, info);
+ if (!m_xConnection.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot connect to students data soure!", m_xConnection.is());
+ }
+}
+
+void AdoDriverTest::tearDown()
+{
+ m_xAdoComponent = 0;
+ test::BootstrapFixture::tearDown();
+}
+
+void AdoDriverTest::test_metadata()
+{
+ Reference< XDatabaseMetaData > xDatabaseMetaData = m_xConnection->getMetaData();
+ if (!xDatabaseMetaData.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot retrieve meta data!", xDatabaseMetaData.is());
+ }
+
+ const Any catalog;
+ const OUString schemaPattern = "%";
+ const OUString tableNamePattern = "%";
+ const Sequence< OUString > types;
+
+ Reference< XResultSet > xResultSet =
+ xDatabaseMetaData->getTables(catalog, schemaPattern, tableNamePattern, types);
+ if (!xResultSet.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot retrieve tables!", xResultSet.is());
+ }
+}
+
+void AdoDriverTest::test_select_default_all()
+{
+ const OUString sql = "select \"FirstName\" from \"Students\" ORDER BY \"FirstName\"";
+ Reference< XPreparedStatement > xStatement = m_xConnection->prepareStatement(sql);
+ if (!xStatement.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot create prepared statement!", xStatement.is());
+ }
+
+ Reference< XResultSet > xResultSet = xStatement->executeQuery();
+ if (!xResultSet.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot execure sql statement!", xResultSet.is());
+ }
+
+ Reference< XRow > xDelegatorRow(xResultSet, UNO_QUERY);
+ if (!xDelegatorRow.is())
+ {
+ CPPUNIT_ASSERT_MESSAGE("cannot extract row from result set!", xDelegatorRow.is());
+ }
+
+ sal_Bool result = xResultSet->first();
+ CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result);
+/*
+ OUString mail = xDelegatorRow->getString(1);
+ CPPUNIT_ASSERT_MESSAGE("first row is not john@doe.org!", mail.equalsAscii("john@doe.org"));
+*/
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(AdoDriverTest);
+
+}}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/connectivity/qa/connectivity/ado/TS001018407.mdb b/connectivity/qa/connectivity/ado/TS001018407.mdb
new file mode 100755
index 000000000000..abe9f5ee33b3
--- /dev/null
+++ b/connectivity/qa/connectivity/ado/TS001018407.mdb
Binary files differ
diff --git a/connectivity/source/commontools/ParamterSubstitution.cxx b/connectivity/source/commontools/ParamterSubstitution.cxx
index 5a31a9308cab..68f1e163c7be 100644
--- a/connectivity/source/commontools/ParamterSubstitution.cxx
+++ b/connectivity/source/commontools/ParamterSubstitution.cxx
@@ -86,8 +86,7 @@ namespace connectivity
{
try
{
- uno::Reference< XMultiServiceFactory> xFac(m_xContext->getServiceManager(),uno::UNO_QUERY_THROW);
- OSQLParser aParser( xFac );
+ OSQLParser aParser( m_xContext );
::rtl::OUString sErrorMessage;
::rtl::OUString sNewSql;
OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sText);
diff --git a/connectivity/source/commontools/TColumnsHelper.cxx b/connectivity/source/commontools/TColumnsHelper.cxx
index 83bfe69746d1..ad725c4f1e64 100644
--- a/connectivity/source/commontools/TColumnsHelper.cxx
+++ b/connectivity/source/commontools/TColumnsHelper.cxx
@@ -115,6 +115,11 @@ sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName)
{
nField11 = ColumnValue::NO_NULLS;
} // if ( xKeys.is() )
+ ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aCatalog, aSchema, aTable;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)) >>= aCatalog;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ m_pTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName,
pColDesc->aField6,
pColDesc->sField13,
@@ -126,7 +131,10 @@ sdbcx::ObjectType OColumnsHelper::createObject(const ::rtl::OUString& _rName)
bAutoIncrement,
sal_False,
bIsCurrency,
- isCaseSensitive());
+ isCaseSensitive(),
+ aCatalog,
+ aSchema,
+ aTable);
xRet = pRet;
}
diff --git a/connectivity/source/commontools/TIndexColumns.cxx b/connectivity/source/commontools/TIndexColumns.cxx
index ca0e783fdfc6..c64e94bf1d14 100644
--- a/connectivity/source/commontools/TIndexColumns.cxx
+++ b/connectivity/source/commontools/TIndexColumns.cxx
@@ -47,13 +47,14 @@ OIndexColumns::OIndexColumns( OIndexHelper* _pIndex,
sdbcx::ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
{
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
- ::rtl::OUString aSchema,aTable;
+ ::rtl::OUString aCatalog, aSchema, aTable;
+ ::com::sun::star::uno::Any Catalog(m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)));
+ Catalog >>= aCatalog;
m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(
- m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
- aSchema,aTable,sal_False,sal_False);
+ Catalog, aSchema, aTable, sal_False, sal_False);
sal_Bool bAsc = sal_True;
if ( xResult.is() )
@@ -68,8 +69,7 @@ sdbcx::ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
}
xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(
- m_pIndex->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),
- aSchema,aTable,_rName);
+ Catalog, aSchema, aTable, _rName);
sdbcx::ObjectType xRet;
if ( xResult.is() )
@@ -87,14 +87,15 @@ sdbcx::ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
::rtl::OUString aColumnDef(xRow->getString(13));
OIndexColumn* pRet = new OIndexColumn(bAsc,
- _rName,
- aTypeName,
- aColumnDef,
- nNull,
- nSize,
- nDec,
- nDataType,
- sal_False,sal_False,sal_False,sal_True);
+ _rName,
+ aTypeName,
+ aColumnDef,
+ nNull,
+ nSize,
+ nDec,
+ nDataType,
+ sal_False,sal_False,sal_False,sal_True,
+ aCatalog, aSchema, aTable);
xRet = pRet;
break;
}
diff --git a/connectivity/source/commontools/TKeyColumns.cxx b/connectivity/source/commontools/TKeyColumns.cxx
index f9a9a223f82b..bb5a36a38f2a 100644
--- a/connectivity/source/commontools/TKeyColumns.cxx
+++ b/connectivity/source/commontools/TKeyColumns.cxx
@@ -48,13 +48,15 @@ OKeyColumnsHelper::OKeyColumnsHelper( OTableKeyHelper* _pKey,
sdbcx::ObjectType OKeyColumnsHelper::createObject(const ::rtl::OUString& _rName)
{
::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
- ::rtl::OUString aSchema,aTable;
+ ::rtl::OUString aCatalog, aSchema, aTable;
+ ::com::sun::star::uno::Any Catalog(m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)));
+ Catalog >>= aCatalog;
m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
// frist get the related column to _rName
Reference< XResultSet > xResult = m_pKey->getTable()->getMetaData()->getImportedKeys(
- m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable);
+ Catalog, aSchema, aTable);
::rtl::OUString aRefColumnName;
if ( xResult.is() )
@@ -75,8 +77,7 @@ sdbcx::ObjectType OKeyColumnsHelper::createObject(const ::rtl::OUString& _rName)
sdbcx::ObjectType xRet;
// now describe the column _rName and set his related column
- xResult = m_pKey->getTable()->getMetaData()->getColumns(
- m_pKey->getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME)),aSchema,aTable,_rName);
+ xResult = m_pKey->getTable()->getMetaData()->getColumns(Catalog, aSchema, aTable, _rName);
if ( xResult.is() )
{
@@ -101,17 +102,20 @@ sdbcx::ObjectType OKeyColumnsHelper::createObject(const ::rtl::OUString& _rName)
}
OKeyColumn* pRet = new OKeyColumn(aRefColumnName,
- _rName,
- aTypeName,
- sColumnDef,
- nNull,
- nSize,
- nDec,
- nDataType,
- sal_False,
- sal_False,
- sal_False,
- isCaseSensitive());
+ _rName,
+ aTypeName,
+ sColumnDef,
+ nNull,
+ nSize,
+ nDec,
+ nDataType,
+ sal_False,
+ sal_False,
+ sal_False,
+ isCaseSensitive(),
+ aCatalog,
+ aSchema,
+ aTable);
xRet = pRet;
}
}
diff --git a/connectivity/source/commontools/TSortIndex.cxx b/connectivity/source/commontools/TSortIndex.cxx
index a0fc73823167..a9d5bc5028b7 100644
--- a/connectivity/source/commontools/TSortIndex.cxx
+++ b/connectivity/source/commontools/TSortIndex.cxx
@@ -19,6 +19,7 @@
#include "TSortIndex.hxx"
#include <algorithm>
+#include <iterator>
#include <o3tl/compat_functional.hxx>
@@ -107,7 +108,7 @@ void OSortIndex::AddKeyValue(OKeyValue * pKeyValue)
OSL_ENSURE(pKeyValue,"Can not be null here!");
if(m_bFrozen)
{
- m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),NULL));
+ m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),(OKeyValue *)NULL));
delete pKeyValue;
}
else
diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx
index cec9e48009eb..6a5ad878f004 100644
--- a/connectivity/source/commontools/TTableHelper.cxx
+++ b/connectivity/source/commontools/TTableHelper.cxx
@@ -36,6 +36,8 @@
#include <o3tl/compat_functional.hxx>
+#include <iterator>
+
using namespace ::comphelper;
using namespace connectivity;
using namespace ::com::sun::star::uno;
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 2afd00192482..6c758f88ebdd 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -81,6 +81,7 @@
#include "connectivity/OSubComponent.hxx"
#include <algorithm>
+#include <iterator>
using namespace ::comphelper;
using namespace ::com::sun::star::uno;
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
index bb832535cbfe..4092e9e185de 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -389,6 +389,8 @@ namespace
Reference<XPropertySet> xProp;
Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
Reference< XResultSet > xResult = xMetaData->getColumns(_aCatalog, _aSchema, _aTable, _rQueryName);
+ ::rtl::OUString sCatalog;
+ _aCatalog >>= sCatalog;
if ( xResult.is() )
{
@@ -472,7 +474,10 @@ namespace
bAutoIncrement,
sal_False,
bIsCurrency,
- _bCase);
+ _bCase,
+ sCatalog,
+ _aSchema,
+ _aTable);
xProp = pRet;
break;
@@ -515,6 +520,8 @@ Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable
Reference<XDatabaseMetaData> xMetaData = _xConnection->getMetaData();
Any aCatalog;
aCatalog = _xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME));
+ ::rtl::OUString sCatalog;
+ aCatalog >>= sCatalog;
::rtl::OUString aSchema, aTable;
_xTable->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
@@ -536,7 +543,10 @@ Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable
_bIsAutoIncrement,
sal_False,
_bIsCurrency,
- _bCase);
+ _bCase,
+ sCatalog,
+ aSchema,
+ aTable);
}
diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx
index 4950de6fd7a7..8b6220ba6107 100644
--- a/connectivity/source/commontools/predicateinput.cxx
+++ b/connectivity/source/commontools/predicateinput.cxx
@@ -39,12 +39,12 @@ namespace dbtools
//.........................................................................
using ::com::sun::star::sdbc::XConnection;
- using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::util::XNumberFormatsSupplier;
using ::com::sun::star::util::NumberFormatter;
using ::com::sun::star::util::XNumberFormatter;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::beans::XPropertySetInfo;
using ::com::sun::star::lang::Locale;
@@ -100,19 +100,18 @@ namespace dbtools
//---------------------------------------------------------------------
OPredicateInputController::OPredicateInputController(
- const Reference< XMultiServiceFactory >& _rxORB, const Reference< XConnection >& _rxConnection, const IParseContext* _pParseContext )
- :m_xORB( _rxORB )
- ,m_xConnection( _rxConnection )
- ,m_aParser( m_xORB, _pParseContext )
+ const Reference< XComponentContext >& rxContext, const Reference< XConnection >& _rxConnection, const IParseContext* _pParseContext )
+ : m_xConnection( _rxConnection )
+ ,m_aParser( rxContext, _pParseContext )
{
try
{
// create a number formatter / number formats supplier pair
- OSL_ENSURE( m_xORB.is(), "OPredicateInputController::OPredicateInputController: need a service factory!" );
- if ( m_xORB.is() )
+ OSL_ENSURE( rxContext.is(), "OPredicateInputController::OPredicateInputController: need a service factory!" );
+ if ( rxContext.is() )
{
m_xFormatter = Reference< XNumberFormatter >(
- NumberFormatter::create(comphelper::getComponentContext(m_xORB)),
+ NumberFormatter::create(rxContext),
UNO_QUERY_THROW
);
}
@@ -124,9 +123,9 @@ namespace dbtools
m_xFormatter->attachNumberFormatsSupplier( xNumberFormats );
// create the locale data
- if ( m_xORB.is() )
+ if ( rxContext.is() )
{
- m_xLocaleData = LocaleData::create( comphelper::getComponentContext(m_xORB) );
+ m_xLocaleData = LocaleData::create( rxContext );
}
}
catch( const Exception& )
@@ -374,7 +373,10 @@ namespace dbtools
nType,
sal_False,
sal_False,
- xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
+ xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString());
Reference<XPropertySet> xColumn = pColumn;
pColumn->setFunction(sal_True);
pColumn->setRealName(sField);
diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx
index 7780447f7958..4c4e4f23b546 100644
--- a/connectivity/source/drivers/ado/AColumn.cxx
+++ b/connectivity/source/drivers/ado/AColumn.cxx
@@ -57,7 +57,7 @@ void WpADOColumn::Create()
}
// -------------------------------------------------------------------------
OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn)
- : connectivity::sdbcx::OColumn(::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),0,0,0,0,sal_False,sal_False,sal_False,_bCase)
+ : connectivity::sdbcx::OColumn(_bCase)
,m_pConnection(_pConnection)
{
construct();
diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx
index fd1e0b196b92..ed2373a4af80 100644
--- a/connectivity/source/drivers/ado/APreparedStatement.cxx
+++ b/connectivity/source/drivers/ado/APreparedStatement.cxx
@@ -25,6 +25,7 @@
#include "ado/ADriver.hxx"
#include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include "connectivity/dbexception.hxx"
#include "connectivity/dbtools.hxx"
@@ -59,7 +60,7 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OTypeInf
{
osl_atomic_increment( &m_refCount );
- OSQLParser aParser(_pConnection->getDriver()->getORB());
+ OSQLParser aParser(comphelper::getComponentContext(_pConnection->getDriver()->getORB()));
::rtl::OUString sErrorMessage;
::rtl::OUString sNewSql;
OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,sql);
diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx
index 6e97e8ebd729..0d042d84f2e7 100644
--- a/connectivity/source/drivers/ado/AStatement.cxx
+++ b/connectivity/source/drivers/ado/AStatement.cxx
@@ -509,7 +509,19 @@ sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeExcepti
//------------------------------------------------------------------------------
sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException)
{
- return m_eLockType;
+ sal_Int32 nValue;
+
+ switch(m_eLockType)
+ {
+ case adLockReadOnly:
+ nValue = ResultSetConcurrency::READ_ONLY;
+ break;
+ default:
+ nValue = ResultSetConcurrency::UPDATABLE;
+ break;
+ }
+
+ return nValue;
}
//------------------------------------------------------------------------------
sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx
index f2ae573249f6..2b31601aeeb0 100644
--- a/connectivity/source/drivers/ado/ATable.cxx
+++ b/connectivity/source/drivers/ado/ATable.cxx
@@ -48,7 +48,7 @@ using namespace com::sun::star::lang;
// -------------------------------------------------------------------------
OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable)
- : OTable_TYPEDEF(_pTables,_bCase,::rtl::OUString(),::rtl::OUString())
+ : OTable_TYPEDEF(_pTables,_bCase)
,m_pCatalog(_pCatalog)
{
construct();
diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx
index b4eb39746344..08535858cf55 100644
--- a/connectivity/source/drivers/ado/Awrapado.cxx
+++ b/connectivity/source/drivers/ado/Awrapado.cxx
@@ -1031,9 +1031,9 @@ sal_Bool WpADOParameter::put_Size(const sal_Int32& _nSize)
return (SUCCEEDED(pInterface->put_Size(_nSize)));
}
- ::rtl::OUString WpADOColumn::get_Name() const
+::rtl::OUString WpADOColumn::get_Name() const
{
- OSL_ENSURE(pInterface,"Interface is null!");
+ OSL_ENSURE(pInterface,"Interface is null!");
OLEString aBSTR;
pInterface->get_Name(&aBSTR);
return aBSTR;
@@ -1561,6 +1561,13 @@ WpBase::WpBase(IDispatch* pInt)
}
}
+WpBase::WpBase(const WpBase& aWrapper)
+ :pIUnknown(aWrapper.pIUnknown)
+{
+ if (pIUnknown)
+ pIUnknown->AddRef();
+}
+
//inline
WpBase& WpBase::operator=(const WpBase& rhs)
{
@@ -1588,11 +1595,6 @@ WpBase& WpBase::operator=(IDispatch* rhs)
return *this;
}
-WpBase::WpBase(const WpBase& aWrapper)
-{
- operator=(aWrapper);
-}
-
WpBase::~WpBase()
{
if (pIUnknown)
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx
index da8cbe573657..ff3c33319a48 100644
--- a/connectivity/source/drivers/calc/CTable.cxx
+++ b/connectivity/source/drivers/calc/CTable.cxx
@@ -514,7 +514,8 @@ void OCalcTable::fillColumns()
sdbcx::OColumn* pColumn = new sdbcx::OColumn( aAlias, aTypeName, ::rtl::OUString(),::rtl::OUString(),
ColumnValue::NULLABLE, nPrecision, nDecimals,
eType, sal_False, sal_False, bCurrency,
- bStoresMixedCaseQuotedIdentifiers);
+ bStoresMixedCaseQuotedIdentifiers,
+ m_CatalogName, getSchema(), getName());
Reference< XPropertySet> xCol = pColumn;
m_aColumns->get().push_back(xCol);
m_aTypes.push_back(eType);
diff --git a/connectivity/source/drivers/dbase/DIndexColumns.cxx b/connectivity/source/drivers/dbase/DIndexColumns.cxx
index 1fbff248ee24..73aa3d525cda 100644
--- a/connectivity/source/drivers/dbase/DIndexColumns.cxx
+++ b/connectivity/source/drivers/dbase/DIndexColumns.cxx
@@ -59,7 +59,10 @@ sdbcx::ObjectType ODbaseIndexColumns::createObject(const ::rtl::OUString& _rName
,sal_False
,sal_False
,sal_False
- ,pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+ ,pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers()
+ ,getString(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME)))
+ ,getString(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)))
+ ,getString(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME))));
return xRet;
}
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 28d4436931ec..499b238284cf 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -436,7 +436,8 @@ OSL_TRACE("column type: %c",aDBFColumn.db_typ);
sal_False,
bIsRowVersion,
bIsCurrency,
- bCase);
+ bCase,
+ m_CatalogName, getSchema(), getName());
m_aColumns->get().push_back(xCol);
} // for (; i < nFieldCount; i++)
OSL_ENSURE(i,"No columns in table!");
@@ -1505,7 +1506,7 @@ sal_Bool ODbaseTable::InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const Ref
sal_uInt32 nTempPos = m_nFilePos;
m_nFilePos = (sal_uIntPtr)m_aHeader.db_anz + 1;
- sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols );
+ sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols, true );
if ( bInsertRow )
{
sal_uInt32 nFileSize = 0, nMemoFileSize = 0;
@@ -1567,7 +1568,7 @@ sal_Bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,con
m_pMemoStream->Seek(STREAM_SEEK_TO_END);
nMemoFileSize = m_pMemoStream->Tell();
}
- if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer())
+ if (!UpdateBuffer(rRow, pOrgRow, _xCols, false) || !WriteBuffer())
{
if (HasMemoFields() && m_pMemoStream)
m_pMemoStream->SetStreamSize(nMemoFileSize); // restore old size
@@ -1668,7 +1669,7 @@ static double toDouble(const rtl::OString& rString)
}
//------------------------------------------------------------------
-sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols)
+sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow, const Reference<XIndexAccess>& _xCols, const bool bForceAllFields)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateBuffer" );
OSL_ENSURE(m_pBuffer,"Buffer is NULL!");
@@ -1814,10 +1815,13 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
++nPos; // the row values start at 1
- // If the variable is bound at all?
- if ( !rRow.get()[nPos]->isBound() )
+ const ORowSetValue &thisColVal = rRow.get()[nPos]->get();
+ const bool thisColIsBound = thisColVal.isBound();
+ const bool thisColIsNull = !thisColIsBound || thisColVal.isNull();
+ // don't overwrite non-bound columns
+ if ( ! (bForceAllFields || thisColIsBound) )
{
- // No - the next field.
+ // No - don't overwrite this field, it has not changed.
nByteOffset += nLen;
continue;
}
@@ -1828,19 +1832,19 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
OSL_ENSURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!");
// Update !!
- if (pOrgRow.is() && !rRow.get()[nPos]->getValue().isNull() )
- pIndex->Update(m_nFilePos,*(pOrgRow->get())[nPos],*rRow.get()[nPos]);
+ if (pOrgRow.is() && !thisColIsNull)
+ pIndex->Update(m_nFilePos, *(pOrgRow->get())[nPos], thisColVal);
else
- pIndex->Insert(m_nFilePos,*rRow.get()[nPos]);
+ pIndex->Insert(m_nFilePos, thisColVal);
}
char* pData = (char *)(m_pBuffer + nByteOffset);
- if (rRow.get()[nPos]->getValue().isNull())
+ if (thisColIsNull)
{
if ( bSetZero )
- memset(pData,0,nLen); // Clear to NULL
+ memset(pData,0,nLen); // Clear to NULL char ('\0')
else
- memset(pData,' ',nLen); // Clear to NULL
+ memset(pData,' ',nLen); // Clear to space/blank ('\0x20')
nByteOffset += nLen;
OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!");
continue;
@@ -1853,7 +1857,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
case DataType::TIMESTAMP:
{
sal_Int32 nJulianDate = 0, nJulianTime = 0;
- lcl_CalcJulDate(nJulianDate,nJulianTime,rRow.get()[nPos]->getValue());
+ lcl_CalcJulDate(nJulianDate,nJulianTime, thisColVal);
// Exactly 8 bytes to copy:
memcpy(pData,&nJulianDate,4);
memcpy(pData+4,&nJulianTime,4);
@@ -1862,10 +1866,10 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
case DataType::DATE:
{
::com::sun::star::util::Date aDate;
- if(rRow.get()[nPos]->getValue().getTypeKind() == DataType::DOUBLE)
- aDate = ::dbtools::DBTypeConversion::toDate(rRow.get()[nPos]->getValue().getDouble());
+ if(thisColVal.getTypeKind() == DataType::DOUBLE)
+ aDate = ::dbtools::DBTypeConversion::toDate(thisColVal.getDouble());
else
- aDate = rRow.get()[nPos]->getValue();
+ aDate = thisColVal;
char s[9];
snprintf(s,
sizeof(s),
@@ -1879,13 +1883,13 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
} break;
case DataType::INTEGER:
{
- sal_Int32 nValue = rRow.get()[nPos]->getValue();
+ sal_Int32 nValue = thisColVal;
memcpy(pData,&nValue,nLen);
}
break;
case DataType::DOUBLE:
{
- const double d = rRow.get()[nPos]->getValue();
+ const double d = thisColVal;
m_pColumns->getByIndex(i) >>= xCol;
if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency is treated separately
@@ -1905,7 +1909,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
{
memset(pData,' ',nLen); // Clear to NULL
- const double n = rRow.get()[nPos]->getValue();
+ const double n = thisColVal;
// one, because const_cast GetFormatPrecision on SvNumberFormat is not constant,
// even though it really could and should be
@@ -1937,7 +1941,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
}
} break;
case DataType::BIT:
- *pData = rRow.get()[nPos]->getValue().getBool() ? 'T' : 'F';
+ *pData = thisColVal.getBool() ? 'T' : 'F';
break;
case DataType::LONGVARBINARY:
case DataType::LONGVARCHAR:
@@ -1949,7 +1953,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
// Next initial character restore again:
pData[nLen] = cNext;
- if (!m_pMemoStream || !WriteMemo(rRow.get()[nPos]->get(), nBlockNo))
+ if (!m_pMemoStream || !WriteMemo(thisColVal, nBlockNo))
break;
rtl::OString aBlock(rtl::OString::valueOf(static_cast<sal_Int32>(nBlockNo)));
@@ -1965,7 +1969,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
{
memset(pData,' ',nLen); // Clear to NULL
- ::rtl::OUString sStringToWrite( rRow.get()[nPos]->getValue().getString() );
+ ::rtl::OUString sStringToWrite( thisColVal.getString() );
// convert the string, using the connection's encoding
::rtl::OString sEncoded;
@@ -2002,7 +2006,7 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c
}
// -----------------------------------------------------------------------------
-sal_Bool ODbaseTable::WriteMemo(ORowSetValue& aVariable, sal_uIntPtr& rBlockNr)
+sal_Bool ODbaseTable::WriteMemo(const ORowSetValue& aVariable, sal_uIntPtr& rBlockNr)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteMemo" );
// if the BlockNo 0 is given, the block will be appended at the end
diff --git a/connectivity/source/drivers/evoab2/NColumns.cxx b/connectivity/source/drivers/evoab2/NColumns.cxx
index c4cae93cfcfe..b131bc36bb95 100644
--- a/connectivity/source/drivers/evoab2/NColumns.cxx
+++ b/connectivity/source/drivers/evoab2/NColumns.cxx
@@ -37,10 +37,14 @@ using namespace connectivity::evoab;
// -------------------------------------------------------------------------
sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName)
{
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getTableName());
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
- Any(),
- m_pTable->getSchema(),
- m_pTable->getTableName(),
+ aCatalog,
+ sSchemaName,
+ sTableName,
_rName);
sdbcx::ObjectType xRet = NULL;
@@ -64,7 +68,10 @@ sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName)
sal_False,
sal_False,
sal_False,
- sal_True);
+ sal_True,
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/evoab2/NDriver.hxx b/connectivity/source/drivers/evoab2/NDriver.hxx
index e255a32fa987..a6bcf2ed85e2 100644
--- a/connectivity/source/drivers/evoab2/NDriver.hxx
+++ b/connectivity/source/drivers/evoab2/NDriver.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/compbase2.hxx>
#include "connectivity/CommonTools.hxx"
#include <osl/module.h>
@@ -79,7 +80,9 @@ namespace connectivity
public:
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- & getMSFactory(void) const { return m_xFactory; }
+ & getMSFactory(void) const { return m_xFactory; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ getComponentContext( ) const { return comphelper::getComponentContext( m_xFactory ); }
// static methods
static sal_Bool acceptsURL_Stat( const ::rtl::OUString& url );
diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx
index 711f09e8c150..bd377e5ffb55 100644
--- a/connectivity/source/drivers/evoab2/NStatement.cxx
+++ b/connectivity/source/drivers/evoab2/NStatement.cxx
@@ -55,7 +55,7 @@ OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection)
, m_xResultSet(NULL)
, m_pResultSet(NULL)
, m_pConnection(_pConnection)
- , m_aParser(_pConnection->getDriver().getMSFactory())
+ , m_aParser(_pConnection->getDriver().getComponentContext())
, m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL )
, m_pParseTree(NULL)
, m_nMaxFieldSize(0)
@@ -419,7 +419,7 @@ rtl::OUString OCommonStatement::getTableName()
if( m_pParseTree && m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT )
{
Any aCatalog;
- ::rtl::OUString aSchema, aComposedName;
+ ::rtl::OUString aSchema;
const OSQLParseNode *pSelectStmnt = m_aSQLIterator.getParseTree();
const OSQLParseNode *pAllTableNames = pSelectStmnt->getChild( 3 )->getChild( 0 )->getChild( 1 );
diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx
index f916b2ddd7bc..199c0acda4d3 100644
--- a/connectivity/source/drivers/file/FColumns.cxx
+++ b/connectivity/source/drivers/file/FColumns.cxx
@@ -37,9 +37,12 @@ using namespace ::com::sun::star::lang;
sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
{
-
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getName());
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
- m_pTable->getSchema(),m_pTable->getName(),_rName);
+ sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = NULL;
if(xResult.is())
@@ -60,7 +63,10 @@ sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
sal_False,
sal_False,
sal_False,
- m_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers());
+ m_pTable->getConnection()->getMetaData()->supportsMixedCaseQuotedIdentifiers(),
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index 0d810fcc2b32..f99cf3c959b6 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -506,7 +506,10 @@ sal_uInt32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Re
,eType
,sal_False
,sal_False
- ,m_aSQLIterator.isCaseSensitive());
+ ,m_aSQLIterator.isCaseSensitive()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString());
m_xParamColumns->get().push_back(xParaColumn);
return m_xParamColumns->get().size();
}
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index c606bbfe9dfc..49c604664d9b 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/FetchDirection.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/typeprovider.hxx>
#include "connectivity/dbexception.hxx"
@@ -57,7 +58,7 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
:OStatement_BASE(m_aMutex)
,::comphelper::OPropertyContainer(OStatement_BASE::rBHelper)
,m_xDBMetaData(_pConnection->getMetaData())
- ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_aParser( comphelper::getComponentContext(_pConnection->getDriver()->getFactory()) )
,m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL )
,m_pConnection(_pConnection)
,m_pParseTree(NULL)
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
index 14732280c6af..0d57cb18b971 100644
--- a/connectivity/source/drivers/flat/ETable.cxx
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -109,7 +109,7 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
m_aScales.assign(nFieldCount+1,-1);
const sal_Bool bCase = m_pConnection->getMetaData()->supportsMixedCaseQuotedIdentifiers();
- CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale);
+ CharClass aCharClass( comphelper::getComponentContext(pConnection->getDriver()->getFactory()), _aLocale);
// read description
const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
@@ -171,7 +171,8 @@ void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
sal_False,
sal_False,
sal_False,
- bCase);
+ bCase,
+ m_CatalogName, getSchema(), getName());
Reference< XPropertySet> xCol = pColumn;
m_aColumns->get().push_back(xCol);
}
diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
index 3de95a3199bb..125681bbe860 100644
--- a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
+++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
@@ -44,7 +44,7 @@ using namespace ::connectivity::hsqldb;
* Method: openStream
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key, jint mode)
{
#ifdef HSQLDB_DBG
@@ -62,7 +62,7 @@ SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStor
* Method: close
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
{
#ifdef HSQLDB_DBG
@@ -101,7 +101,7 @@ SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStor
* Method: getFilePointer
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
*/
-SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer
+SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
{
#ifdef HSQLDB_DBG
@@ -125,7 +125,7 @@ SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeSto
* Method: length
* Signature: (Ljava/lang/String;Ljava/lang/String;)J
*/
-SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length
+SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
{
#ifdef HSQLDB_DBG
@@ -192,7 +192,7 @@ jint read_from_storage_stream( JNIEnv * env, jobject /*obj_this*/, jstring name,
* Method: read
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2
(JNIEnv* env, jobject obj_this, jstring name, jstring key)
{
#ifdef HSQLDB_DBG
@@ -265,7 +265,7 @@ jint read_from_storage_stream_into_buffer( JNIEnv * env, jobject /*obj_this*/,js
* Method: read
* Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
(JNIEnv * env, jobject obj_this,jstring name, jstring key, jbyteArray buffer, jint off, jint len)
{
#ifdef HSQLDB_DBG
@@ -286,7 +286,7 @@ SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStor
* Method: readInt
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
{
#ifdef HSQLDB_DBG
@@ -354,7 +354,7 @@ SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStor
* Method: seek
* Signature: (Ljava/lang/String;Ljava/lang/String;J)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek
(JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key, jlong position)
{
#ifdef HSQLDB_DBG
@@ -466,7 +466,7 @@ void write_to_storage_stream_from_buffer( JNIEnv* env, jobject /*obj_this*/, jst
* Method: write
* Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write
(JNIEnv * env, jobject obj_this,jstring name, jstring key, jbyteArray buffer, jint off, jint len)
{
#ifdef HSQLDB_DBG
@@ -525,7 +525,7 @@ void write_to_storage_stream( JNIEnv* env, jobject /*obj_this*/, jstring name, j
* Method: writeInt
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt
(JNIEnv * env, jobject obj_this,jstring name, jstring key, jint v)
{
#ifdef HSQLDB_DBG
diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
index 897a4ffc8973..38f43765e41b 100644
--- a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
+++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
@@ -46,7 +46,7 @@ using namespace ::connectivity::hsqldb;
* Method: isStreamElement
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
*/
-SAL_DLLPUBLIC_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
+SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
{
TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
@@ -98,7 +98,7 @@ SAL_DLLPUBLIC_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_Storag
* Method: removeElement
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
{
#ifdef HSQLDB_DBG
@@ -133,7 +133,7 @@ SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFil
* Method: renameElement
* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring oldname, jstring newname)
{
#ifdef HSQLDB_DBG
diff --git a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
index 40f04a5c41ff..b6d578b27bc8 100644
--- a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
+++ b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
@@ -57,7 +57,7 @@ using namespace ::connectivity::hsqldb;
* Method: openStream
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jint mode)
{
#ifdef HSQLDB_DBG
@@ -75,7 +75,7 @@ SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNat
* Method: read
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2
(JNIEnv * env, jobject obj_this,jstring key, jstring name)
{
#ifdef HSQLDB_DBG
@@ -94,7 +94,7 @@ SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNat
* Method: read
* Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
(JNIEnv * env, jobject obj_this,jstring key, jstring name, jbyteArray buffer, jint off, jint len)
{
#ifdef HSQLDB_DBG
@@ -113,7 +113,7 @@ SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNat
* Method: close
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
+SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
{
#ifdef HSQLDB_DBG
@@ -133,7 +133,7 @@ SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNat
* Method: skip
* Signature: (Ljava/lang/String;Ljava/lang/String;J)J
*/
-SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
+SAL_JNI_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jlong n)
{
#ifdef HSQLDB_DBG
@@ -199,7 +199,7 @@ SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNa
* Method: available
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
{
#ifdef HSQLDB_DBG
@@ -241,7 +241,7 @@ SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNat
* Method: read
* Signature: (Ljava/lang/String;Ljava/lang/String;[B)I
*/
-SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
+SAL_JNI_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
(JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jbyteArray buffer)
{
#ifdef HSQLDB_DBG
diff --git a/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx
index e81447d5b6dd..61295b3c1a4e 100644
--- a/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx
+++ b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx
@@ -57,7 +57,7 @@ using namespace ::connectivity::hsqldb;
* Method: openStream
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
(JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
{
#ifdef HSQLDB_DBG
@@ -73,7 +73,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: write
* Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
(JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
{
#ifdef HSQLDB_DBG
@@ -91,7 +91,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: write
* Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
(JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
{
#ifdef HSQLDB_DBG
@@ -109,7 +109,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: close
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
(JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
{
#ifdef HSQLDB_DBG
@@ -141,7 +141,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: write
* Signature: (Ljava/lang/String;Ljava/lang/String;I)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
(JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
{
#ifdef HSQLDB_DBG
@@ -159,7 +159,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: flush
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
(JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
{
OSL_UNUSED( env );
@@ -178,7 +178,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb
* Method: sync
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
-extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
+extern "C" SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
(JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
{
#ifdef HSQLDB_DBG
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
index 6921c0d96050..a814c1b6665d 100644
--- a/connectivity/source/drivers/jdbc/JConnection.cxx
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -469,7 +469,7 @@ Reference< XStatement > SAL_CALL java_sql_Connection::createStatement( ) throw(
{
try
{
- OSQLParser aParser( m_pDriver->getContext().getLegacyServiceFactory() );
+ OSQLParser aParser( m_pDriver->getContext().getUNOContext() );
::rtl::OUString sErrorMessage;
::rtl::OUString sNewSql;
OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sSQL);
diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx
index 8ad3d81c1fa1..2d29006d7d61 100644
--- a/connectivity/source/drivers/jdbc/jservices.cxx
+++ b/connectivity/source/drivers/jdbc/jservices.cxx
@@ -75,7 +75,7 @@ struct ProviderRequest
};
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
-component_getImplementationEnvironment(
+jdbc_component_getImplementationEnvironment(
char const ** ppEnvTypeName, uno_Environment **)
{
// Recent Java 6 VMs make calls to JNI Attach/DetachCurrentThread (which
diff --git a/connectivity/source/drivers/kab/KColumns.cxx b/connectivity/source/drivers/kab/KColumns.cxx
index a047d1afe843..5ab9598073ee 100644
--- a/connectivity/source/drivers/kab/KColumns.cxx
+++ b/connectivity/source/drivers/kab/KColumns.cxx
@@ -37,11 +37,12 @@ using namespace ::com::sun::star::lang;
// -------------------------------------------------------------------------
sdbcx::ObjectType KabColumns::createObject(const ::rtl::OUString& _rName)
{
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getTableName());
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
- Any(),
- m_pTable->getSchema(),
- m_pTable->getTableName(),
- _rName);
+ aCatalog, sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = NULL;
if (xResult.is())
@@ -64,7 +65,10 @@ sdbcx::ObjectType KabColumns::createObject(const ::rtl::OUString& _rName)
sal_False,
sal_False,
sal_False,
- sal_True);
+ sal_True,
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/kab/KDriver.hxx b/connectivity/source/drivers/kab/KDriver.hxx
index b51058151279..1243f7425185 100644
--- a/connectivity/source/drivers/kab/KDriver.hxx
+++ b/connectivity/source/drivers/kab/KDriver.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/compbase3.hxx>
#include <osl/module.h>
@@ -161,8 +162,8 @@ namespace connectivity
static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
- getMSFactory() const { return m_xMSFactory; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ getComponentContext() const { return comphelper::getComponentContext(m_xMSFactory); }
/** returns the driver's implementation name (being pure ASCII) for reference in various places
*/
diff --git a/connectivity/source/drivers/kab/KStatement.cxx b/connectivity/source/drivers/kab/KStatement.cxx
index e898ee48f62f..a5babf0c2de3 100644
--- a/connectivity/source/drivers/kab/KStatement.cxx
+++ b/connectivity/source/drivers/kab/KStatement.cxx
@@ -62,7 +62,7 @@ IMPLEMENT_SERVICE_INFO(KabStatement, "com.sun.star.sdbc.drivers.KabStatement", "
KabCommonStatement::KabCommonStatement(KabConnection* _pConnection )
: KabCommonStatement_BASE(m_aMutex),
OPropertySetHelper(KabCommonStatement_BASE::rBHelper),
- m_aParser(_pConnection->getDriver()->getMSFactory()),
+ m_aParser(_pConnection->getDriver()->getComponentContext()),
m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ),
m_pParseTree(NULL),
m_pConnection(_pConnection),
diff --git a/connectivity/source/drivers/macab/MacabColumns.cxx b/connectivity/source/drivers/macab/MacabColumns.cxx
index 4d0b064ce28b..107ab4575784 100644
--- a/connectivity/source/drivers/macab/MacabColumns.cxx
+++ b/connectivity/source/drivers/macab/MacabColumns.cxx
@@ -37,11 +37,12 @@ using namespace ::com::sun::star::lang;
// -------------------------------------------------------------------------
sdbcx::ObjectType MacabColumns::createObject(const ::rtl::OUString& _rName)
{
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getTableName());
Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
- Any(),
- m_pTable->getSchema(),
- m_pTable->getTableName(),
- _rName);
+ aCatalog, sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = NULL;
if (xResult.is())
@@ -64,7 +65,10 @@ sdbcx::ObjectType MacabColumns::createObject(const ::rtl::OUString& _rName)
sal_False,
sal_False,
sal_False,
- sal_True);
+ sal_True,
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/macab/MacabDriver.hxx b/connectivity/source/drivers/macab/MacabDriver.hxx
index c908ee481d2c..cbfe0c035bdc 100644
--- a/connectivity/source/drivers/macab/MacabDriver.hxx
+++ b/connectivity/source/drivers/macab/MacabDriver.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/compbase3.hxx>
#include <osl/module.h>
@@ -134,8 +135,8 @@ namespace connectivity
static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
- getMSFactory() const { return m_xMSFactory; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ getComponentContext() const { return comphelper::getComponentContext(m_xMSFactory); }
/** returns the driver's implementation name (being pure ASCII) for reference in various places
*/
diff --git a/connectivity/source/drivers/macab/MacabStatement.cxx b/connectivity/source/drivers/macab/MacabStatement.cxx
index 7ea31f7e35b4..12cf3f4cef20 100644
--- a/connectivity/source/drivers/macab/MacabStatement.cxx
+++ b/connectivity/source/drivers/macab/MacabStatement.cxx
@@ -65,7 +65,7 @@ IMPLEMENT_SERVICE_INFO(MacabStatement, "com.sun.star.sdbc.drivers.MacabStatement
MacabCommonStatement::MacabCommonStatement(MacabConnection* _pConnection )
: MacabCommonStatement_BASE(m_aMutex),
OPropertySetHelper(MacabCommonStatement_BASE::rBHelper),
- m_aParser(_pConnection->getDriver()->getMSFactory()),
+ m_aParser(_pConnection->getDriver()->getComponentContext()),
m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ),
m_pParseTree(NULL),
m_pConnection(_pConnection),
diff --git a/connectivity/source/drivers/mork/MColumns.cxx b/connectivity/source/drivers/mork/MColumns.cxx
index 852bb4d4c012..22a2dd7f4495 100644
--- a/connectivity/source/drivers/mork/MColumns.cxx
+++ b/connectivity/source/drivers/mork/MColumns.cxx
@@ -42,8 +42,12 @@ using namespace ::com::sun::star::lang;
sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
{
- Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
- m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getTableName());
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
+ aCatalog, sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = NULL;
if(xResult.is())
@@ -65,7 +69,10 @@ sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
nPrec,
xRow->getInt(9),
nType,
- sal_False,sal_False,sal_False,sal_True);
+ sal_False,sal_False,sal_False,sal_True,
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/mork/MPreparedStatement.cxx b/connectivity/source/drivers/mork/MPreparedStatement.cxx
index c34de94576e1..803b9606b1d0 100644
--- a/connectivity/source/drivers/mork/MPreparedStatement.cxx
+++ b/connectivity/source/drivers/mork/MPreparedStatement.cxx
@@ -442,7 +442,10 @@ size_t OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Refere
,sal_False
,sal_False
,sal_False
- ,m_pSQLIterator->isCaseSensitive());
+ ,m_pSQLIterator->isCaseSensitive()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString());
m_xParamColumns->get().push_back(xParaColumn);
return nParameter;
}
diff --git a/connectivity/source/drivers/mork/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx
index 342ac2add17b..2beacfecd95a 100644
--- a/connectivity/source/drivers/mork/MStatement.cxx
+++ b/connectivity/source/drivers/mork/MStatement.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <comphelper/sequence.hxx>
#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
@@ -79,7 +80,7 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection )
,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this)
,m_pTable(NULL)
,m_pConnection(_pConnection)
- ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_aParser( comphelper::getComponentContext(_pConnection->getDriver()->getFactory()) )
,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) )
,rBHelper(OCommonStatement_IBASE::rBHelper)
{
diff --git a/connectivity/source/drivers/mozab/MColumns.cxx b/connectivity/source/drivers/mozab/MColumns.cxx
index f6fb6e217942..786280cbbe5e 100644
--- a/connectivity/source/drivers/mozab/MColumns.cxx
+++ b/connectivity/source/drivers/mozab/MColumns.cxx
@@ -43,8 +43,12 @@ using namespace ::com::sun::star::lang;
sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
{
- Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
- m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+ const Any aCatalog;
+ const ::rtl::OUString sCatalogName;
+ const ::rtl::OUString sSchemaName(m_pTable->getSchema());
+ const ::rtl::OUString sTableName(m_pTable->getTableName());
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
+ aCatalog, sSchemaName, sTableName, _rName);
sdbcx::ObjectType xRet = NULL;
if(xResult.is())
@@ -66,7 +70,10 @@ sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
nPrec,
xRow->getInt(9),
nType,
- sal_False,sal_False,sal_False,sal_True);
+ sal_False,sal_False,sal_False,sal_True,
+ sCatalogName,
+ sSchemaName,
+ sTableName);
xRet = pRet;
break;
}
diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.cxx b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
index 9a650effd215..971749d03cc0 100644
--- a/connectivity/source/drivers/mozab/MPreparedStatement.cxx
+++ b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
@@ -443,7 +443,10 @@ size_t OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Refere
,sal_False
,sal_False
,sal_False
- ,m_pSQLIterator->isCaseSensitive());
+ ,m_pSQLIterator->isCaseSensitive()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString());
m_xParamColumns->get().push_back(xParaColumn);
return nParameter;
}
diff --git a/connectivity/source/drivers/mozab/MStatement.cxx b/connectivity/source/drivers/mozab/MStatement.cxx
index c1041d909cae..9f6b2d5420d6 100644
--- a/connectivity/source/drivers/mozab/MStatement.cxx
+++ b/connectivity/source/drivers/mozab/MStatement.cxx
@@ -32,6 +32,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <comphelper/extract.hxx>
#include <comphelper/types.hxx>
+#include <comphelper/processfactory.hxx>
#include <connectivity/dbexception.hxx>
#include <com/sun/star/container/XIndexAccess.hpp>
@@ -73,7 +74,8 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection )
,m_xDBMetaData(_pConnection->getMetaData())
,m_pTable(NULL)
,m_pConnection(_pConnection)
- ,m_aParser(_pConnection->getDriver()->getMSFactory())
+ ,m_aParser(::comphelper::getComponentContext(
+ _pConnection->getDriver()->getMSFactory()))
,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) )
,m_pParseTree(NULL)
,rBHelper(OCommonStatement_IBASE::rBHelper)
diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
index a5d24dddc628..f5c05b80f76f 100644
--- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -30,6 +30,7 @@
#include "odbc/OResultSet.hxx"
#include "odbc/OResultSetMetaData.hxx"
#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <com/sun/star/lang/DisposedException.hpp>
#include "connectivity/dbtools.hxx"
@@ -37,6 +38,8 @@
#include "connectivity/FValue.hxx"
#include "resource/common_res.hrc"
#include "connectivity/sqlparse.hxx"
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/is_same.hpp>
using namespace ::comphelper;
using namespace connectivity;
@@ -52,6 +55,13 @@ using namespace com::sun::star::util;
IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.OPreparedStatement","com.sun.star.sdbc.PreparedStatement");
+namespace
+{
+ // for now, never use wchar,
+ // but most of code is prepared to handle it
+ // in case we make this configurable
+ const bool useWChar = false;
+}
OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql)
:OStatement_BASE2(_pConnection)
@@ -64,7 +74,7 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::O
{
if(_pConnection->isParameterSubstitutionEnabled())
{
- OSQLParser aParser(_pConnection->getDriver()->getORB());
+ OSQLParser aParser( comphelper::getComponentContext(_pConnection->getDriver()->getORB()) );
::rtl::OUString sErrorMessage;
::rtl::OUString sNewSql;
::std::auto_ptr<OSQLParseNode> pNode( aParser.parseTree(sErrorMessage,sql) );
@@ -199,31 +209,6 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc
{
}
- // Now loop while more data is needed (i.e. a data-at-
- // execution parameter was given). For each parameter
- // that needs data, put the data from the input stream.
-
- while (needData) {
-
- // Get the parameter number that requires data
-
- sal_Int32* paramIndex = 0;
- N3SQLParamData (m_aStatementHandle,(SQLPOINTER*)&paramIndex);
-
- // If the parameter index is -1, there is no more
- // data required
-
- if (*paramIndex == -1) {
- needData = sal_False;
- }
- else {
- // Now we have the proper parameter index,
- // get the data from the input stream
- // and do a SQLPutData
- putParamData(*paramIndex);
- }
- }
-
// Now determine if there is a result set associated with
// the SQL statement that was executed. Get the column
// count, and if it is not zero, there is a result set.
@@ -258,8 +243,7 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, Run
void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
{
- ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
- setParameter(parameterIndex,DataType::CHAR,aString.getLength(),(void*)&x);
+ setParameter(parameterIndex, DataType::CHAR, invalid_scale, x);
}
// -------------------------------------------------------------------------
@@ -294,111 +278,189 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ // Set the parameter as if it were an integer
+ setInt (parameterIndex, x ? 1 : 0 );
+}
+// -------------------------------------------------------------------------
+// The MutexGuard must _already_ be taken!
+void OPreparedStatement::setParameterPre(sal_Int32 parameterIndex)
+{
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ prepareStatement();
+ checkParameterIndex(parameterIndex);
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+}
+// -------------------------------------------------------------------------
+template <typename T> void OPreparedStatement::setScalarParameter(const sal_Int32 parameterIndex, const sal_Int32 i_nType, const SQLULEN i_nColSize, const T i_Value)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ setParameterPre(parameterIndex);
- sal_Int32 value = 0;
+ typedef typename boost::remove_reference< T >::type TnoRef;
- // If the parameter is sal_True, set the value to 1
- if (x) {
- value = 1;
- }
+ TnoRef *bindBuf = static_cast< TnoRef* >( allocBindBuf(parameterIndex, sizeof(i_Value)) );
+ *bindBuf = i_Value;
- // Set the parameter as if it were an integer
- setInt (parameterIndex, value);
+ setParameter(parameterIndex, i_nType, i_nColSize, invalid_scale, bindBuf, sizeof(i_Value), sizeof(i_Value));
}
// -------------------------------------------------------------------------
-void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData)
+
+void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_Int32 _nType, const sal_Int16 _nScale, const ::rtl::OUString &_sData)
{
::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ setParameterPre(parameterIndex);
- prepareStatement();
- // Allocate a buffer to be used in binding. This will be
- // a 'permanent' buffer that the bridge will fill in with
- // the bound data in native format.
+ assert (_nType == DataType::VARCHAR || _nType == DataType::CHAR || _nType == DataType::DECIMAL || _nType == DataType::NUMERIC);
-
- checkParameterIndex(parameterIndex);
- sal_Int32 nRealSize = _nSize;
- SQLSMALLINT fSqlType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(_nType));
- switch(fSqlType)
+ sal_Int32 nCharLen;
+ sal_Int32 nByteLen;
+ void *pData;
+ if (useWChar)
{
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- ++nRealSize;
- break;
- case SQL_BINARY:
- case SQL_VARBINARY:
- nRealSize=1; //dummy buffer, binary data isn't copied
- break;
- default:
- break;
+ /*
+ * On Windows, wchar is 16 bits (UTF-16 encoding), the ODBC "W" variants functions take UTF-16 encoded strings
+ * and character lengths are number of UTF-16 codepoints.
+ * Reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ms716246%28v=vs.85%29.aspx
+ * ODBC Programmer's reference > Developing Applications > Programming Considerations > Unicode > Unicode Function Arguments
+ * http://support.microsoft.com/kb/294169
+ *
+ * UnixODBC can be configured at compile-time so that the "W" variants expect
+ * UTF-16 or UTF-32 encoded strings, and character lengths are number of codepoints.
+ * However, UTF-16 is the default, what all/most distributions do
+ * and the established API that most drivers implement.
+ * As wchar is often 32 bits, this differs from C-style strings of wchar!
+ *
+ * Our internal OUString storage is always UTF-16, so no conversion to do here.
+ */
+ BOOST_STATIC_ASSERT( sizeof(sal_Unicode) == 2 );
+ nCharLen = _sData.getLength();
+ nByteLen = nCharLen * sizeof(sal_Unicode);
+ pData = allocBindBuf(parameterIndex, nByteLen);
+ memcpy(pData, _sData.getStr(), nByteLen);
+ }
+ else
+ {
+ ::rtl::OString sOData( ::rtl::OUStringToOString(_sData, getOwnConnection()->getTextEncoding()) );
+ nCharLen = sOData.getLength();
+ nByteLen = nCharLen;
+ pData = allocBindBuf(parameterIndex, nByteLen);
+ memcpy(pData, sOData.getStr(), nByteLen);
}
- sal_Int8* bindBuf = allocBindBuf(parameterIndex, nRealSize);
+ setParameter( parameterIndex, _nType, nCharLen, _nScale, pData, nByteLen, nByteLen );
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_Int32 _nType, const Sequence< sal_Int8 > &x)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ setParameterPre(parameterIndex);
- OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
- OTools::bindParameter( m_pConnection,
- m_aStatementHandle,
- parameterIndex,
- bindBuf,
- getLengthBuf(parameterIndex),
- fSqlType,
- sal_False,
- m_pConnection->useOldDateFormat(),
- _pData,
- (Reference <XInterface>)*this,
- getOwnConnection()->getTextEncoding());
+ assert(_nType == DataType::BINARY || _nType == DataType::VARBINARY);
+
+ // don't copy the sequence, just point the ODBC directly at the sequence's storage array
+ // Why BINARY/Sequence is treated differently than strings (which are copied), I'm not sure
+ OSL_VERIFY(allocBindBuf(parameterIndex, 0) == NULL);
+ boundParams[parameterIndex-1].setSequence(x); // this ensures that the sequence stays alive
+
+ setParameter( parameterIndex, _nType, x.getLength(), invalid_scale, x.getConstArray(), x.getLength(), x.getLength() );
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_Int32 _nType, const SQLULEN _nColumnSize, const sal_Int32 _nScale, const void* const _pData, const SQLULEN _nDataLen, const SQLLEN _nDataAllocLen)
+{
+ SQLSMALLINT fCType, fSqlType;
+ OTools::getBindTypes(useWChar, m_pConnection->useOldDateFormat(), OTools::jdbcTypeToOdbc(_nType), fCType, fSqlType);
+
+ SQLLEN *pDataLen=boundParams[parameterIndex-1].getBindLengthBuffer();
+ *pDataLen=_nDataLen;
+
+ SQLRETURN nRetcode;
+ nRetcode = (*(T3SQLBindParameter)m_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(
+ m_aStatementHandle,
+ // checkParameterIndex guarantees this is safe
+ static_cast<SQLUSMALLINT>(parameterIndex),
+ SQL_PARAM_INPUT,
+ fCType,
+ fSqlType,
+ _nColumnSize,
+ _nScale,
+ // we trust the ODBC driver not to touch it because SQL_PARAM_INPUT
+ const_cast<void*>(_pData),
+ _nDataAllocLen,
+ pDataLen);
+
+ OTools::ThrowException(m_pConnection, nRetcode, m_aStatementHandle, SQL_HANDLE_STMT, *this);
}
// -----------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setByte( const sal_Int32 parameterIndex, const sal_Int8 x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::TINYINT,sizeof(sal_Int8),&x);
+ setScalarParameter(parameterIndex, DataType::TINYINT, 3, x);
}
// -------------------------------------------------------------------------
-
+// For older compilers (that do not support partial specialisation of class templates)
+// uncomment if necessary (safe also on compilers that *do* support partial specialisation)
+//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(DATE_STRUCT);
+//BOOST_STATIC_ASSERT((boost::is_same<DATE_STRUCT, boost::remove_reference<DATE_STRUCT&>::type>::value));
void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException)
{
- DATE_STRUCT x = OTools::DateToOdbcDate(aData);
- setParameter(parameterIndex,DataType::DATE,sizeof(DATE_STRUCT),&x);
+ DATE_STRUCT x(OTools::DateToOdbcDate(aData));
+ setScalarParameter<DATE_STRUCT&>(parameterIndex, DataType::DATE, 10, x);
}
// -------------------------------------------------------------------------
-
void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
{
- TIME_STRUCT x = OTools::TimeToOdbcTime(aVal);
- setParameter(parameterIndex,DataType::TIME,sizeof(TIME_STRUCT),&x);
+ const sal_uInt16 hundredths (aVal.HundredthSeconds);
+ SQLULEN nColSize;
+ if(hundredths == 0)
+ nColSize = 8;
+ else if(hundredths % 10 == 0)
+ nColSize = 10;
+ else
+ nColSize = 11;
+ TIME_STRUCT x(OTools::TimeToOdbcTime(aVal));
+ setScalarParameter<TIME_STRUCT&>(parameterIndex, DataType::TIME, nColSize, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
{
- TIMESTAMP_STRUCT x = OTools::DateTimeToTimestamp(aVal);
- setParameter(parameterIndex,DataType::TIMESTAMP,sizeof(TIMESTAMP_STRUCT),&x);
+ sal_uInt16 s(aVal.Seconds);
+ sal_uInt16 hundredths(aVal.HundredthSeconds);
+ SQLULEN nColSize;
+ if(hundredths == 0)
+ {
+ if (s == 0)
+ nColSize=16;
+ else
+ nColSize=19;
+ }
+ else if(hundredths % 10 == 0)
+ nColSize = 21;
+ else
+ nColSize = 22;
+
+ TIMESTAMP_STRUCT x(OTools::DateTimeToTimestamp(aVal));
+ setScalarParameter<TIMESTAMP_STRUCT&>(parameterIndex, DataType::TIMESTAMP, nColSize, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::DOUBLE,sizeof(double),&x);
+ setScalarParameter(parameterIndex, DataType::DOUBLE, 15, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::FLOAT,sizeof(float),&x);
+ setScalarParameter(parameterIndex, DataType::FLOAT, 15, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::INTEGER,sizeof(sal_Int32),&x);
+ setScalarParameter(parameterIndex, DataType::INTEGER, 10, x);
}
// -------------------------------------------------------------------------
@@ -406,57 +468,44 @@ void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x
{
try
{
- setParameter(parameterIndex,DataType::BIGINT,sizeof(sal_Int64),&x);
+ setScalarParameter(parameterIndex, DataType::BIGINT, 19, x);
}
catch(SQLException&)
{
- setString(parameterIndex,ORowSetValue(x));
+ setString(parameterIndex, ORowSetValue(x));
}
}
// -------------------------------------------------------------------------
-void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, const sal_Int32 _nType ) throw(SQLException, RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ setParameterPre(parameterIndex);
+ OSL_VERIFY(allocBindBuf(parameterIndex, 0) == NULL);
+ SQLLEN * const lenBuf = getLengthBuf (parameterIndex);
+ *lenBuf = SQL_NULL_DATA;
- prepareStatement();
- // Get the buffer needed for the length
- checkParameterIndex(parameterIndex);
-
- sal_Int8* lenBuf = getLengthBuf (parameterIndex);
- *(SQLLEN*)lenBuf = SQL_NULL_DATA;
+ SQLSMALLINT fCType;
+ SQLSMALLINT fSqlType;
- SQLLEN prec = 0;
- SQLULEN nColumnSize = 0;
- if (sqlType == SQL_CHAR || sqlType == SQL_VARCHAR || sqlType == SQL_LONGVARCHAR)
- {
- prec = 1;
- nColumnSize = 1;
- }
-
- SQLSMALLINT fCType = 0;
- SQLSMALLINT fSqlType = 0;
-
- SQLSMALLINT nDecimalDigits = 0;
- OTools::getBindTypes( sal_False,
+ OTools::getBindTypes( useWChar,
m_pConnection->useOldDateFormat(),
- (SQLSMALLINT)sqlType,
+ OTools::jdbcTypeToOdbc(_nType),
fCType,
fSqlType);
SQLRETURN nReturn = N3SQLBindParameter( m_aStatementHandle,
- (SQLUSMALLINT)parameterIndex,
- (SQLSMALLINT)SQL_PARAM_INPUT,
+ static_cast<SQLUSMALLINT>(parameterIndex),
+ SQL_PARAM_INPUT,
fCType,
fSqlType,
- nColumnSize,
- nDecimalDigits,
+ 0,
+ 0,
NULL,
- prec,
- (SQLLEN*)lenBuf
+ 0,
+ lenBuf
);
OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
}
@@ -465,14 +514,14 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s
void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
{
if ( x.is() )
- setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
+ setStream(parameterIndex, x->getCharacterStream(), x->length(), DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
{
if ( x.is() )
- setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
+ setStream(parameterIndex, x->getBinaryStream(), x->length(), DataType::LONGVARBINARY);
}
// -------------------------------------------------------------------------
@@ -487,12 +536,6 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Re
::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this );
}
// -------------------------------------------------------------------------
-void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x )
-{
- ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
- setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x);
-}
-// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
{
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
@@ -504,31 +547,29 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c
switch (sqlType)
{
+ case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
if(x.hasValue())
{
::rtl::OUString sStr;
x >>= sStr;
- ::rtl::OString aString(::rtl::OUStringToOString(sStr,getOwnConnection()->getTextEncoding()));
- setParameter(parameterIndex,sqlType,aString.getLength(),&aString);
+ setParameter(parameterIndex, sqlType, scale, sStr);
}
else
setNull(parameterIndex,sqlType);
break;
case DataType::DECIMAL:
- {
- ORowSetValue aValue;
- aValue.fill(x);
- setDecimal(parameterIndex,aValue);
- }
- break;
case DataType::NUMERIC:
+ if(x.hasValue())
{
ORowSetValue aValue;
aValue.fill(x);
- setString(parameterIndex,aValue);
+ // TODO: make sure that this calls the string overload
+ setParameter(parameterIndex, sqlType, scale, aValue);
}
+ else
+ setNull(parameterIndex,sqlType);
break;
default:
::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale);
@@ -538,9 +579,6 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c
void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
- checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-
setNull(parameterIndex,sqlType);
}
// -------------------------------------------------------------------------
@@ -556,20 +594,21 @@ void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any
void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::SMALLINT,sizeof(sal_Int16),&x);
+ setScalarParameter(parameterIndex, DataType::SMALLINT, 5, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,DataType::BINARY,x.getLength(),(void*)&x);
- boundParams[parameterIndex-1].setSequence(x); // this assures that the sequence stays alive
+ setParameter(parameterIndex, DataType::BINARY, x);
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
{
+ // LEM: It is quite unclear to me what the interface here is.
+ // The XInputStream provides *bytes*, not characters.
setStream(parameterIndex, x, length, DataType::LONGVARCHAR);
}
// -------------------------------------------------------------------------
@@ -582,6 +621,7 @@ void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, con
void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
{
+ ::osl::MutexGuard aGuard( m_aMutex );
prepareStatement();
OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
SQLRETURN nRet = N3SQLFreeStmt (m_aStatementHandle, SQL_RESET_PARAMS);
@@ -591,6 +631,7 @@ void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, Runtim
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException)
{
+ ::dbtools::throwFunctionNotSupportedException( "XPreparedBatchExecution::clearBatch", *this );
// clearParameters( );
// m_aBatchList.erase();
}
@@ -598,11 +639,14 @@ void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeExce
void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException)
{
+ ::dbtools::throwFunctionNotSupportedException( "XPreparedBatchExecution::addBatch", *this );
}
// -------------------------------------------------------------------------
Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException)
{
+ ::dbtools::throwFunctionNotSupportedException( "XPreparedBatchExecution::executeBatch", *this );
+ // not reached, but keep -Werror happy
return Sequence< sal_Int32 > ();
}
// -------------------------------------------------------------------------
@@ -632,12 +676,6 @@ void OPreparedStatement::initBoundParam () throw(SQLException)
boundParams = new OBoundParam[numParams];
- // initialize each bound parameter
-
- for (sal_Int32 i = 0; i < numParams; i++)
- {
- boundParams[i].initialize ();
- }
}
}
// -------------------------------------------------------------------------
@@ -648,14 +686,13 @@ void OPreparedStatement::initBoundParam () throw(SQLException)
// parameter.
//--------------------------------------------------------------------
-sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen)
+void* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen)
{
- sal_Int8* b = NULL;
+ void* b = NULL;
// Sanity check the parameter number
- if ((index >= 1) &&
- (index <= numParams) && bufLen > 0 )
+ if ((index >= 1) && (index <= numParams))
{
b = boundParams[index - 1].allocBindDataBuffer(bufLen);
}
@@ -669,9 +706,9 @@ sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen)
// Gets the length buffer for the given parameter index
//--------------------------------------------------------------------
-sal_Int8* OPreparedStatement::getLengthBuf (sal_Int32 index)
+SQLLEN* OPreparedStatement::getLengthBuf (sal_Int32 index)
{
- sal_Int8* b = NULL;
+ SQLLEN* b = NULL;
// Sanity check the parameter number
@@ -762,7 +799,7 @@ void OPreparedStatement::setStream(
sal_Int32 ParameterIndex,
const Reference< XInputStream>& x,
SQLLEN length,
- sal_Int32 SQLtype)
+ sal_Int32 _nType)
throw(SQLException)
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -774,35 +811,33 @@ void OPreparedStatement::setStream(
checkParameterIndex(ParameterIndex);
// Get the buffer needed for the length
- sal_Int8* lenBuf = getLengthBuf(ParameterIndex);
+ SQLLEN * const lenBuf = getLengthBuf(ParameterIndex);
// Allocate a new buffer for the parameter data. This buffer
// will be returned by SQLParamData (it is set to the parameter
- // number, a 4-sal_Int8 integer)
+ // number, a sal_Int32)
- sal_Int8* dataBuf = allocBindBuf (ParameterIndex, 4);
+ sal_Int32* dataBuf = static_cast<sal_Int32*>( allocBindBuf(ParameterIndex, sizeof(ParameterIndex)) );
+ *dataBuf = ParameterIndex;
// Bind the parameter with SQL_LEN_DATA_AT_EXEC
- SQLSMALLINT Ctype = SQL_C_CHAR;
- SQLLEN atExec = SQL_LEN_DATA_AT_EXEC (length);
- memcpy (dataBuf, &ParameterIndex, sizeof(ParameterIndex));
- memcpy (lenBuf, &atExec, sizeof (atExec));
+ *lenBuf = SQL_LEN_DATA_AT_EXEC (length);
- if ((SQLtype == SQL_BINARY) || (SQLtype == SQL_VARBINARY) || (SQLtype == SQL_LONGVARBINARY))
- Ctype = SQL_C_BINARY;
+ SQLSMALLINT fCType, fSqlType;
+ OTools::getBindTypes(useWChar, m_pConnection->useOldDateFormat(), OTools::jdbcTypeToOdbc(_nType), fCType, fSqlType);
OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
N3SQLBindParameter(m_aStatementHandle,
- (SQLUSMALLINT)ParameterIndex,
- (SQLUSMALLINT)SQL_PARAM_INPUT,
- Ctype,
- (SQLSMALLINT)SQLtype,
- (SQLULEN)length,
- 0,
- dataBuf,
- sizeof(ParameterIndex),
- (SQLLEN*)lenBuf);
+ static_cast<SQLUSMALLINT>(ParameterIndex),
+ SQL_PARAM_INPUT,
+ fCType,
+ fSqlType,
+ length,
+ invalid_scale,
+ dataBuf,
+ sizeof(ParameterIndex),
+ lenBuf);
// Save the input stream
boundParams[ParameterIndex - 1].setInputStream (x, length);
@@ -865,7 +900,9 @@ void OPreparedStatement::prepareStatement()
// -----------------------------------------------------------------------------
void OPreparedStatement::checkParameterIndex(sal_Int32 _parameterIndex)
{
- if( !_parameterIndex || _parameterIndex > numParams)
+ if( _parameterIndex > numParams ||
+ _parameterIndex < 1 ||
+ _parameterIndex > std::numeric_limits<SQLUSMALLINT>::max() )
{
::connectivity::SharedResources aResources;
const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(STR_WRONG_PARAM_INDEX,
diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
index 7cfebcb23f4d..96d7d8ee4672 100644
--- a/connectivity/source/drivers/odbcbase/OResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -1058,7 +1058,7 @@ void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(
void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
{
sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
- SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
+ SQLSMALLINT nOdbcType = OTools::jdbcTypeToOdbc(nType);
m_aRow[columnIndex] = x;
m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarchar will be recognized by fillNeededData
updateValue(columnIndex,nOdbcType,(void*)&x);
@@ -1067,7 +1067,7 @@ void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUSt
void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
{
sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
- SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
+ SQLSMALLINT nOdbcType = OTools::jdbcTypeToOdbc(nType);
m_aRow[columnIndex] = x;
m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarbinary will be recognized by fillNeededData
updateValue(columnIndex,nOdbcType,(void*)&x);
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index b38dd2b29766..3e327803513a 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -150,190 +150,6 @@ void OTools::getValue( OConnection* _pConnection,
_aStatementHandle,SQL_HANDLE_STMT,_xInterface,sal_False);
_bWasNull = pcbValue == SQL_NULL_DATA;
}
-// -----------------------------------------------------------------------------
-void OTools::bindParameter( OConnection* _pConnection,
- SQLHANDLE _hStmt,
- sal_Int32 nPos,
- sal_Int8*& pDataBuffer,
- sal_Int8* pLenBuffer,
- SQLSMALLINT _nODBCtype,
- sal_Bool _bUseWChar,
- sal_Bool _bUseOldTimeDate,
- const void* _pValue,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
- rtl_TextEncoding _nTextEncoding)
- throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindParameter" );
- SQLRETURN nRetcode;
- SQLSMALLINT fSqlType;
- SQLSMALLINT fCType;
- SQLLEN nMaxLen = 0;
- SQLLEN* pLen = (SQLLEN*)pLenBuffer;
- SQLULEN nColumnSize=0;
- SQLSMALLINT nDecimalDigits=0;
- bool atExec;
-
- OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType);
-
- OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize, atExec);
- if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR))
- nColumnSize = 1;
-
- if (atExec)
- memcpy(pDataBuffer,&nPos,sizeof(nPos));
-
- nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt,
- (SQLUSMALLINT)nPos,
- SQL_PARAM_INPUT,
- fCType,
- fSqlType,
- nColumnSize,
- nDecimalDigits,
- pDataBuffer,
- nMaxLen,
- pLen);
-
- OTools::ThrowException(_pConnection,nRetcode,_hStmt,SQL_HANDLE_STMT,_xInterface);
-}
-// -----------------------------------------------------------------------------
-void OTools::bindData( SQLSMALLINT _nOdbcType,
- sal_Bool _bUseWChar,
- sal_Int8 *&_pData,
- SQLLEN*& pLen,
- const void* _pValue,
- rtl_TextEncoding _nTextEncoding,
- SQLULEN& _nColumnSize,
- bool &atExec)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindData" );
- _nColumnSize = 0;
- atExec = false;
-
- switch (_nOdbcType)
- {
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_DECIMAL:
- if(_bUseWChar)
- {
- *pLen = SQL_NTS;
- ::rtl::OUString sStr(*(::rtl::OUString*)_pValue);
- _nColumnSize = sStr.getLength();
- *((rtl::OUString*)_pData) = sStr;
-
- // Pointer on Char*
- _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
- }
- else
- {
- ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
- *pLen = SQL_NTS;
- _nColumnSize = aString.getLength();
- memcpy(_pData,aString.getStr(),aString.getLength());
- ((sal_Int8*)_pData)[aString.getLength()] = '\0';
- }
- break;
-
- case SQL_BIGINT:
- *((sal_Int64*)_pData) = *(sal_Int64*)_pValue;
- *pLen = sizeof(sal_Int64);
- _nColumnSize = *pLen;
- break;
-
- case SQL_NUMERIC:
- if(_bUseWChar)
- {
- ::rtl::OUString aString = rtl::OUString::valueOf(*(double*)_pValue);
- _nColumnSize = aString.getLength();
- *pLen = _nColumnSize;
- *((rtl::OUString*)_pData) = aString;
- // Pointer on Char*
- _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
- }
- else
- {
- ::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue);
- _nColumnSize = aString.getLength();
- *pLen = _nColumnSize;
- memcpy(_pData,aString.getStr(),aString.getLength());
- ((sal_Int8*)_pData)[_nColumnSize] = '\0';
- } break;
- case SQL_BIT:
- case SQL_TINYINT:
- *((sal_Int8*)_pData) = *(sal_Int8*)_pValue;
- *pLen = sizeof(sal_Int8);
- break;
-
- case SQL_SMALLINT:
- *((sal_Int16*)_pData) = *(sal_Int16*)_pValue;
- *pLen = sizeof(sal_Int16);
- break;
- case SQL_INTEGER:
- *((sal_Int32*)_pData) = *(sal_Int32*)_pValue;
- *pLen = sizeof(sal_Int32);
- break;
- case SQL_FLOAT:
- *((float*)_pData) = *(float*)_pValue;
- *pLen = sizeof(float);
- break;
- case SQL_REAL:
- case SQL_DOUBLE:
- *((double*)_pData) = *(double*)_pValue;
- *pLen = sizeof(double);
- break;
- case SQL_BINARY:
- case SQL_VARBINARY:
- {
- const ::com::sun::star::uno::Sequence< sal_Int8 >* pSeq = static_cast< const ::com::sun::star::uno::Sequence< sal_Int8 >* >(_pValue);
- OSL_ENSURE(pSeq,"OTools::bindData: Sequence is null!");
-
- if(pSeq)
- {
- _pData = (sal_Int8*)pSeq->getConstArray();
- *pLen = pSeq->getLength();
- }
- }
- break;
- case SQL_LONGVARBINARY:
- {
- sal_Int32 nLen = 0;
- nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
- *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
- }
- atExec = true;
- break;
- case SQL_LONGVARCHAR:
- {
- sal_Int32 nLen = 0;
- if(_bUseWChar)
- nLen = sizeof(sal_Unicode) * ((::rtl::OUString*)_pValue)->getLength();
- else
- {
- ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
- nLen = aString.getLength();
- }
- *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
- atExec = true;
- } break;
- case SQL_DATE:
- *(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue;
- *pLen = (SQLLEN)sizeof(DATE_STRUCT);
- _nColumnSize = 10;
- break;
- case SQL_TIME:
- *(TIME_STRUCT*)_pData = *(TIME_STRUCT*)_pValue;
- *pLen = (SQLLEN)sizeof(TIME_STRUCT);
- _nColumnSize = 8;
- break;
- case SQL_TIMESTAMP:
- *(TIMESTAMP_STRUCT*)_pData = *(TIMESTAMP_STRUCT*)_pValue;
- *pLen = (SQLLEN)sizeof(TIMESTAMP_STRUCT);
- // 20+sub-zero precision; we have hundredths of seconds
- _nColumnSize = 22;
- break;
- }
-}
// -------------------------------------------------------------------------
void OTools::bindValue( OConnection* _pConnection,
SQLHANDLE _aStatementHandle,
@@ -342,7 +158,7 @@ void OTools::bindValue( OConnection* _pConnection,
SQLSMALLINT _nMaxLen,
const void* _pValue,
void* _pData,
- SQLLEN *pLen,
+ SQLLEN * const pLen,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
rtl_TextEncoding _nTextEncoding,
sal_Bool _bUseOldTimeDate) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
@@ -779,7 +595,7 @@ void OTools::GetInfo(OConnection* _pConnection,
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
}
// -------------------------------------------------------------------------
-sal_Int32 OTools::MapOdbcType2Jdbc(sal_Int32 _nType)
+sal_Int32 OTools::MapOdbcType2Jdbc(SQLSMALLINT _nType)
{
sal_Int32 nValue = DataType::VARCHAR;
switch(_nType)
@@ -857,7 +673,7 @@ sal_Int32 OTools::MapOdbcType2Jdbc(sal_Int32 _nType)
// jdbcTypeToOdbc
// Convert the JDBC SQL type to the correct ODBC type
//--------------------------------------------------------------------
-sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
+SQLSMALLINT OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::jdbcTypeToOdbc" );
// For the most part, JDBC types match ODBC types. We'll
@@ -876,6 +692,11 @@ sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
case DataType::TIMESTAMP:
odbcType = SQL_TIMESTAMP;
break;
+ // ODBC doesn't have any notion of CLOB or BLOB
+ case DataType::CLOB:
+ odbcType = SQL_LONGVARCHAR;
+ case DataType::BLOB:
+ odbcType = SQL_LONGVARBINARY;
}
return odbcType;
diff --git a/connectivity/source/inc/ado/Aolewrap.hxx b/connectivity/source/inc/ado/Aolewrap.hxx
index 6f428bfd19f1..c4462a1eb11a 100644
--- a/connectivity/source/inc/ado/Aolewrap.hxx
+++ b/connectivity/source/inc/ado/Aolewrap.hxx
@@ -94,8 +94,8 @@ namespace connectivity
}
WpOLEBase(const WpOLEBase<T>& aWrapper)
- : WpBase(aWrapper)
- , pInterface(aWrapper.pInterface)
+ : WpBase( aWrapper )
+ , pInterface( aWrapper.pInterface )
{
}
diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx
index ad352d0a4ccf..691b65469ed2 100644
--- a/connectivity/source/inc/dbase/DTable.hxx
+++ b/connectivity/source/inc/dbase/DTable.hxx
@@ -105,9 +105,9 @@ namespace connectivity
sal_Bool ReadMemoHeader();
sal_Bool ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable);
- sal_Bool WriteMemo(ORowSetValue& aVariable, sal_uIntPtr& rBlockNr);
+ sal_Bool WriteMemo(const ORowSetValue& aVariable, sal_uIntPtr& rBlockNr);
sal_Bool WriteBuffer();
- sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols);
+ sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols, bool bForceAllFields);
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos);
void AllocBuffer();
diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx
index 8e587b4f2fc2..fca532bcade9 100644
--- a/connectivity/source/inc/odbc/OBoundParam.hxx
+++ b/connectivity/source/inc/odbc/OBoundParam.hxx
@@ -20,6 +20,7 @@
#define _CONNECTIVITY_OBOUNPARAM_HXX_
#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
#include "odbc/odbcbasedllapi.hxx"
namespace connectivity
@@ -31,50 +32,29 @@ namespace connectivity
public:
OBoundParam()
+ : binaryData(NULL)
+ , paramInputStreamLen(0)
+ , sqlType(::com::sun::star::sdbc::DataType::SQLNULL)
+ , outputParameter(false)
{
- paramLength = NULL;
- binaryData = NULL;
- pA1=0;
- pA2=0;
- pB1=0;
- pB2=0;
- pC1=0;
- pC2=0;
- pS1=0;
- pS2=0;
}
~OBoundParam()
{
- delete [] binaryData;
- delete [] paramLength;
+ free(binaryData);
}
//--------------------------------------------------------------------
- // initialize
- // Perform an necessary initialization
- //--------------------------------------------------------------------
- void initialize ()
- {
- // Allocate storage for the length. Note - the length is
- // stored in native format, and will have to be converted
- // to a Java sal_Int32. The jdbcodbc 'C' bridge provides an
- // interface to do this.
-
- paramLength = new sal_Int8[sizeof(SQLLEN)];
- }
-
- //--------------------------------------------------------------------
// allocBindDataBuffer
// Allocates and returns a new bind data buffer of the specified
// length
//--------------------------------------------------------------------
- sal_Int8* allocBindDataBuffer (sal_Int32 bufLen)
+ void* allocBindDataBuffer (sal_Int32 bufLen)
{
- if ( binaryData )
- delete [] binaryData;
- binaryData = new sal_Int8[bufLen];
-
- // Reset the input stream, we are doing a new bind
+ // Reset the input stream and sequence, we are doing a new bind
setInputStream (NULL, 0);
+ aSequence.realloc(0);
+
+ free(binaryData);
+ binaryData = (bufLen > 0) ? malloc(bufLen) : NULL;
return binaryData;
}
@@ -83,7 +63,7 @@ namespace connectivity
// getBindDataBuffer
// Returns the data buffer to be used when binding to a parameter
//--------------------------------------------------------------------
- sal_Int8* getBindDataBuffer ()
+ void* getBindDataBuffer ()
{
return binaryData;
}
@@ -92,9 +72,9 @@ namespace connectivity
// getBindLengthBuffer
// Returns the length buffer to be used when binding to a parameter
//--------------------------------------------------------------------
- sal_Int8* getBindLengthBuffer ()
+ SQLLEN* getBindLengthBuffer ()
{
- return paramLength;
+ return &paramLength;
}
//--------------------------------------------------------------------
@@ -176,20 +156,20 @@ namespace connectivity
// Data attributes
//====================================================================
- sal_Int8* binaryData; // Storage area to be used
- // when binding the parameter
+ void *binaryData; // Storage area to be used
+ // when binding the parameter
- sal_Int8* paramLength; // Storage area to be used
- // for the bound length of the
- // parameter. Note that this
- // data is in native format.
+ SQLLEN paramLength; // Storage area to be used
+ // for the bound length of the
+ // parameter. Note that this
+ // data is in native format.
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream;
::com::sun::star::uno::Sequence< sal_Int8 > aSequence;
// When an input stream is
- // bound to a parameter, the
- // input stream is saved
- // until needed.
+ // bound to a parameter, a
+ // reference to the input stream is saved
+ // until not needed anymore.
sal_Int32 paramInputStreamLen; // Length of input stream
@@ -197,16 +177,6 @@ namespace connectivity
// register an OUT parameter
sal_Bool outputParameter; // true for OUTPUT parameters
-
-
- sal_Int32 pA1; //pointers
- sal_Int32 pA2;
- sal_Int32 pB1;
- sal_Int32 pB2;
- sal_Int32 pC1;
- sal_Int32 pC2;
- sal_Int32 pS1;
- sal_Int32 pS2;// reserved for strings(UTFChars)
};
}
}
diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx
index 0d34099f39ab..139ea3fda327 100644
--- a/connectivity/source/inc/odbc/OPreparedStatement.hxx
+++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx
@@ -46,6 +46,7 @@ namespace connectivity
public OPreparedStatement_BASE
{
protected:
+ static const short invalid_scale = -1;
struct Parameter
{
::com::sun::star::uno::Any aValue;
@@ -74,15 +75,20 @@ namespace connectivity
void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException);
void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x,
SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException);
- sal_Int8* getLengthBuf (sal_Int32 index);
- sal_Int8* allocBindBuf ( sal_Int32 index, sal_Int32 bufLen);
+ SQLLEN* getLengthBuf (sal_Int32 index);
+ void* allocBindBuf ( sal_Int32 index, sal_Int32 bufLen);
void initBoundParam () throw(::com::sun::star::sdbc::SQLException);
- void setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData);
+ void setParameterPre(sal_Int32 parameterIndex);
+ template <typename T> void setScalarParameter(sal_Int32 parameterIndex, sal_Int32 _nType, SQLULEN _nColumnSize, const T i_Value);
+ void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, SQLULEN _nColumnSize, sal_Int32 _nScale, const void* _pData, SQLULEN _nDataLen, SQLLEN _nDataAllocLen);
+ void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, sal_Int32 _nColumnSize, sal_Int32 _nByteSize, void* _pData);
+ // Wrappers for special cases
+ void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, sal_Int16 _nScale, const ::rtl::OUString &_sData);
+ void setParameter(sal_Int32 parameterIndex, sal_Int32 _nType, const com::sun::star::uno::Sequence< sal_Int8 > &_Data);
sal_Bool isPrepared() const { return m_bPrepared;}
void prepareStatement();
void checkParameterIndex(sal_Int32 _parameterIndex);
- void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x );
/**
creates the driver specific resultset (factory)
diff --git a/connectivity/source/inc/odbc/OTools.hxx b/connectivity/source/inc/odbc/OTools.hxx
index 99339e23bf31..a971d4c8edaa 100644
--- a/connectivity/source/inc/odbc/OTools.hxx
+++ b/connectivity/source/inc/odbc/OTools.hxx
@@ -138,8 +138,8 @@ namespace connectivity
sal_Bool &_rValue,
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- static sal_Int32 MapOdbcType2Jdbc(sal_Int32 _nType);
- static sal_Int32 jdbcTypeToOdbc(sal_Int32 jdbcType);
+ static sal_Int32 MapOdbcType2Jdbc(SQLSMALLINT _nType);
+ static SQLSMALLINT jdbcTypeToOdbc(sal_Int32 jdbcType);
static DATE_STRUCT DateToOdbcDate(const ::com::sun::star::util::Date& x)
{
@@ -206,40 +206,6 @@ namespace connectivity
void* _pValue,
SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
- /**
- bindData copies data from pValue to pData
- @param _nOdbcType [in] the ODBC sql type
- @param _bUseWChar [in] true when Unicode should be used
- @param _pData [in/out] data copy destination
- @param pLen [out] buffer length of data written to _pData
- @param _pValue [in] contains the data to be copied
- @param _nTextEncoding [in] the text encoding
- @param _nColumnSize [out] columnSize of data written to _pData
- @param atExec [out] data was not copied, but setup for data-at-execution;
- caller is responsible for writing a token in _pData
- */
- static void bindData( SQLSMALLINT _nOdbcType,
- sal_Bool _bUseWChar,
- sal_Int8 *&_pData,
- SQLLEN*& pLen,
- const void* _pValue,
- rtl_TextEncoding _nTextEncoding,
- SQLULEN& _nColumnSize,
- bool &atExec);
-
- static void bindParameter( OConnection* _pConnection,
- SQLHANDLE _hStmt,
- sal_Int32 nPos,
- sal_Int8*& pDataBuffer,
- sal_Int8* pLenBuffer,
- SQLSMALLINT _nJDBCtype,
- sal_Bool _bUseWChar,
- sal_Bool _bUseOldTimeDate,
- const void* _pValue,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
- rtl_TextEncoding _nTextEncoding)
- throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
-
static void bindValue( OConnection* _pConnection,
SQLHANDLE _aStatementHandle,
sal_Int32 columnIndex,
diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index 743d38a35e8d..7f2d8fb30c2c 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -35,6 +35,7 @@
#include <osl/diagnose.h>
#include <algorithm>
+#include <iterator>
#include <o3tl/compat_functional.hxx>
diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx
index f9523c98fcac..7649044bd168 100644
--- a/connectivity/source/parse/PColumn.cxx
+++ b/connectivity/source/parse/PColumn.cxx
@@ -25,6 +25,8 @@
#include <comphelper/types.hxx>
#include <tools/diagnose_ex.h>
+#include <bitset>
+
using namespace ::comphelper;
using namespace connectivity;
using namespace dbtools;
@@ -48,6 +50,9 @@ OParseColumn::OParseColumn(const Reference<XPropertySet>& _xColumn,sal_Bool
, sal_False
, getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
, _bCase
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)))
+ , getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME)))
)
, m_bFunction(sal_False)
, m_bDbasePrecisionChanged(sal_False)
@@ -68,7 +73,10 @@ OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
sal_Int32 _Type,
sal_Bool _IsAutoIncrement,
sal_Bool _IsCurrency,
- sal_Bool _bCase
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName
) : connectivity::sdbcx::OColumn(_Name,
_TypeName,
_DefaultValue,
@@ -80,7 +88,10 @@ OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
_IsAutoIncrement,
sal_False,
_IsCurrency,
- _bCase)
+ _bCase,
+ _CatalogName,
+ _SchemaName,
+ _TableName)
, m_bFunction(sal_False)
, m_bDbasePrecisionChanged(sal_False)
, m_bAggregateFunction(sal_False)
@@ -116,7 +127,7 @@ OParseColumn::OParseColumn( const ::rtl::OUString& _Name,
// -------------------------------------------------------------------------
OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSetMetaData >& _rxResMetaData,
- const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos,StringMap& _rColumns )
+ const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos, StringMap& _rColumns )
{
::rtl::OUString sLabel = _rxResMetaData->getColumnLabel( _nColumnPos );
// retrieve the name of the column
@@ -143,17 +154,11 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe
_rxResMetaData->getColumnType( _nColumnPos ),
_rxResMetaData->isAutoIncrement( _nColumnPos ),
_rxResMetaData->isCurrency( _nColumnPos ),
- _rxDBMetaData->supportsMixedCaseQuotedIdentifiers()
+ _rxDBMetaData->supportsMixedCaseQuotedIdentifiers(),
+ _rxResMetaData->getCatalogName( _nColumnPos ),
+ _rxResMetaData->getSchemaName( _nColumnPos ),
+ _rxResMetaData->getTableName( _nColumnPos )
);
- const ::rtl::OUString sTableName = _rxResMetaData->getTableName( _nColumnPos );
- if ( !sTableName.isEmpty() )
- pColumn->setTableName( ::dbtools::composeTableName( _rxDBMetaData,
- _rxResMetaData->getCatalogName( _nColumnPos ),
- _rxResMetaData->getSchemaName( _nColumnPos ),
- sTableName,
- sal_False,
- eComplete
- ) );
pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) );
pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos ));
pColumn->setLabel(sLabel);
@@ -167,13 +172,12 @@ OParseColumn::~OParseColumn()
// -------------------------------------------------------------------------
void OParseColumn::construct()
{
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION), PROPERTY_ID_FUNCTION, 0, &m_bFunction, ::getCppuType(static_cast< sal_Bool*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION), PROPERTY_ID_AGGREGATEFUNCTION, 0, &m_bAggregateFunction, ::getCppuType(static_cast< sal_Bool*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, 0, &m_aTableName, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, 0, &m_aRealName, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, 0, &m_bDbasePrecisionChanged, ::getCppuType(static_cast<sal_Bool*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSEARCHABLE), PROPERTY_ID_ISSEARCHABLE, 0, &m_bIsSearchable, ::getCppuType(static_cast< sal_Bool*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL), PROPERTY_ID_LABEL, 0, &m_sLabel, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION), PROPERTY_ID_FUNCTION, 0, &m_bFunction, ::getCppuType(&m_bFunction));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AGGREGATEFUNCTION), PROPERTY_ID_AGGREGATEFUNCTION, 0, &m_bAggregateFunction, ::getCppuType(&m_bAggregateFunction));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME), PROPERTY_ID_REALNAME, 0, &m_aRealName, ::getCppuType(&m_aRealName));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DBASEPRECISIONCHANGED), PROPERTY_ID_DBASEPRECISIONCHANGED, 0, &m_bDbasePrecisionChanged, ::getCppuType(&m_bDbasePrecisionChanged));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISSEARCHABLE), PROPERTY_ID_ISSEARCHABLE, 0, &m_bIsSearchable, ::getCppuType(&m_bIsSearchable));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_LABEL), PROPERTY_ID_LABEL, 0, &m_sLabel, ::getCppuType(&m_sLabel));
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OParseColumn::createArrayHelper() const
@@ -188,24 +192,6 @@ void OParseColumn::construct()
}
// -----------------------------------------------------------------------------
-namespace
-{
- ::rtl::OUString lcl_getColumnTableName( const Reference< XPropertySet >& i_parseColumn )
- {
- ::rtl::OUString sColumnTableName;
- try
- {
- OSL_VERIFY( i_parseColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TABLENAME ) ) >>= sColumnTableName );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- return sColumnTableName;
- }
-}
-
-// -----------------------------------------------------------------------------
OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn, const ::rtl::OUString& i_rOriginatingTableName,
sal_Bool _bCase, sal_Bool _bAscending )
: connectivity::sdbcx::OColumn(
@@ -220,12 +206,17 @@ OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn, const ::rtl
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))),
sal_False,
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))),
- _bCase
+ _bCase,
+ getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME))),
+ getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME))),
+ i_rOriginatingTableName
)
,m_bAscending(_bAscending)
- ,m_sTableName( i_rOriginatingTableName )
{
construct();
+ OSL_ENSURE( getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME))).isEmpty() ||
+ i_rOriginatingTableName == getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME)) ),
+ "dbaccess::OOrderColumn::OOrderColumn: forced originating table name != underlying column table name" );
}
// -----------------------------------------------------------------------------
@@ -242,10 +233,12 @@ OOrderColumn::OOrderColumn( const Reference<XPropertySet>& _xColumn, sal_Bool _b
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))),
sal_False,
getBOOL(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))),
- _bCase
+ _bCase,
+ getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME))),
+ getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME))),
+ getString(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME)))
)
,m_bAscending(_bAscending)
- ,m_sTableName( lcl_getColumnTableName( _xColumn ) )
{
construct();
}
@@ -259,9 +252,7 @@ OOrderColumn::~OOrderColumn()
void OOrderColumn::construct()
{
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING), PROPERTY_ID_ISASCENDING,
- PropertyAttribute::READONLY, const_cast< sal_Bool* >( &m_bAscending ), ::getCppuType( static_cast< sal_Bool* >( 0 ) ) );
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME,
- PropertyAttribute::READONLY, const_cast< ::rtl::OUString* >( &m_sTableName ), ::getCppuType(static_cast< ::rtl::OUString*>(0)));
+ PropertyAttribute::READONLY, const_cast< sal_Bool* >( &m_bAscending ), ::getCppuType( &m_bAscending ) );
}
// -----------------------------------------------------------------------------
::cppu::IPropertyArrayHelper* OOrderColumn::createArrayHelper() const
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index f30aca2fe41f..7d91655b6394 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -40,6 +40,9 @@
#include "diagnose_ex.h"
#include <rtl/logfile.hxx>
+
+#include <iterator>
+
using namespace ::comphelper;
using namespace ::connectivity;
using namespace ::connectivity::sdbcx;
@@ -896,7 +899,8 @@ void OSQLParseTreeIterator::traverseCreateColumns(const OSQLParseNode* pSelectNo
{
//TODO:Create a new class for create statement to handle field length
OParseColumn* pColumn = new OParseColumn(aColumnName,aTypeName,::rtl::OUString(),::rtl::OUString(),
- ColumnValue::NULLABLE_UNKNOWN,0,0,nType,sal_False,sal_False,isCaseSensitive());
+ ColumnValue::NULLABLE_UNKNOWN,0,0,nType,sal_False,sal_False,isCaseSensitive(),
+ ::rtl::OUString(),::rtl::OUString(),::rtl::OUString());
pColumn->setFunction(sal_False);
pColumn->setRealName(aColumnName);
@@ -1497,7 +1501,10 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode
nType,
sal_False,
sal_False,
- isCaseSensitive());
+ isCaseSensitive(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString());
pColumn->setFunction(sal_True);
pColumn->setAggregateFunction(sal_True);
pColumn->setRealName(sFunctionName);
@@ -1561,7 +1568,10 @@ void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode
nType,
sal_False,
sal_False,
- isCaseSensitive() );
+ isCaseSensitive(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString());
pColumn->setName(aNewColName);
pColumn->setRealName(sParameterName);
m_aParameters->get().push_back(pColumn);
@@ -1704,7 +1714,10 @@ void OSQLParseTreeIterator::appendColumns(::rtl::Reference<OSQLColumns>& _rColum
, getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
, getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)))
, getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))
- , isCaseSensitive() );
+ , isCaseSensitive()
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME)))
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)))
+ , getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME))));
pColumn->setTableName(_rTableAlias);
pColumn->setRealName(*pBegin);
@@ -1782,7 +1795,10 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns>& _
_nType,
sal_False,
sal_False,
- isCaseSensitive()
+ isCaseSensitive(),
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ::rtl::OUString()
);
xNewColumn = pColumn;
@@ -1796,7 +1812,8 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns>& _
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
- ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
+ ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive(),
+ ::rtl::OUString(),::rtl::OUString(),::rtl::OUString());
pColumn->setFunction(sal_True);
pColumn->setAggregateFunction(bAggFkt);
pColumn->setRealName(rColumnName);
@@ -1817,7 +1834,8 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns>& _
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
- ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
+ ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive(),
+ ::rtl::OUString(),::rtl::OUString(),::rtl::OUString());
pColumn->setFunction(sal_True);
pColumn->setAggregateFunction(bAggFkt);
pColumn->setRealName(rColumnName);
@@ -1854,7 +1872,8 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns>& _
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),
- ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,isCaseSensitive());
+ ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,isCaseSensitive(),
+ ::rtl::OUString(),::rtl::OUString(),::rtl::OUString());
pColumn->setFunction(sal_True);
pColumn->setAggregateFunction(bAggFkt);
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index daf8ff5e768a..73fd5101c7cb 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/util/NumberFormat.hpp>
#include <com/sun/star/i18n/KParseType.hpp>
#include <com/sun/star/i18n/KParseTokens.hpp>
+#include <com/sun/star/i18n/CharacterClassification.hpp>
#include "connectivity/dbconversion.hxx"
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/Time.hpp>
@@ -1068,8 +1069,8 @@ OSQLParseNode* OSQLParser::buildNode_STR_NUM(OSQLParseNode*& _pLiteral)
{
::rtl::OUString aValue;
if(!m_xCharClass.is())
- m_xCharClass = Reference<XCharacterClassification>(m_xServiceFactory->createInstance(::rtl::OUString("com.sun.star.i18n.CharacterClassification")),UNO_QUERY);
- if(m_xCharClass.is() && s_xLocaleData.is())
+ m_xCharClass = CharacterClassification::create( m_xContext );
+ if( s_xLocaleData.is() )
{
try
{
@@ -1259,13 +1260,13 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const :
//=============================================================================
//-----------------------------------------------------------------------------
-OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory,const IParseContext* _pContext)
+OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const IParseContext* _pContext)
:m_pContext(_pContext)
,m_pParseTree(NULL)
- ,m_pData( new OSQLParser_Data( _xServiceFactory ) )
+ ,m_pData( new OSQLParser_Data( uno::Reference<lang::XMultiServiceFactory>(rxContext->getServiceManager(), uno::UNO_QUERY_THROW) ) )
,m_nFormatKey(0)
,m_nDateFormatKey(0)
- ,m_xServiceFactory(_xServiceFactory)
+ ,m_xContext(rxContext)
{
@@ -1286,7 +1287,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
s_pGarbageCollector = new OSQLParseNodesGarbageCollector();
if(!s_xLocaleData.is())
- s_xLocaleData = LocaleData::create(comphelper::getComponentContext(m_xServiceFactory));
+ s_xLocaleData = LocaleData::create(m_xContext);
// reset to 0
memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs[0]) * (OSQLParseNode::rule_count+1));
diff --git a/connectivity/source/sdbcx/VColumn.cxx b/connectivity/source/sdbcx/VColumn.cxx
index f69cb5e7ae85..8de64c8ff189 100644
--- a/connectivity/source/sdbcx/VColumn.cxx
+++ b/connectivity/source/sdbcx/VColumn.cxx
@@ -87,7 +87,10 @@ OColumn::OColumn( const ::rtl::OUString& _Name,
sal_Bool _IsAutoIncrement,
sal_Bool _IsRowVersion,
sal_Bool _IsCurrency,
- sal_Bool _bCase)
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName)
:OColumnDescriptor_BASE(m_aMutex)
,ODescriptor(OColumnDescriptor_BASE::rBHelper,_bCase)
,m_TypeName(_TypeName)
@@ -100,6 +103,9 @@ OColumn::OColumn( const ::rtl::OUString& _Name,
,m_IsAutoIncrement(_IsAutoIncrement)
,m_IsRowVersion(_IsRowVersion)
,m_IsCurrency(_IsCurrency)
+ ,m_CatalogName(_CatalogName)
+ ,m_SchemaName(_SchemaName)
+ ,m_TableName(_TableName)
{
m_Name = _Name;
@@ -157,16 +163,19 @@ void OColumn::construct()
sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib,&m_TypeName, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib,&m_Description, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib,&m_DefaultValue, ::getCppuType(static_cast< ::rtl::OUString*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib,&m_Precision, ::getCppuType(static_cast<sal_Int32*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(static_cast<sal_Int32*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib,&m_Scale, ::getCppuType(static_cast<sal_Int32*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib,&m_IsNullable, ::getCppuType(static_cast<sal_Int32*>(0)));
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib,&m_IsAutoIncrement, ::getBooleanCppuType());
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib,&m_IsRowVersion, ::getBooleanCppuType());
- registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib,&m_IsCurrency, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME), PROPERTY_ID_TYPENAME, nAttrib, &m_TypeName, ::getCppuType(&m_TypeName));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION, nAttrib, &m_Description, ::getCppuType(&m_Description));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE), PROPERTY_ID_DEFAULTVALUE, nAttrib, &m_DefaultValue, ::getCppuType(&m_DefaultValue));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION), PROPERTY_ID_PRECISION, nAttrib, &m_Precision, ::getCppuType(&m_Precision));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib, &m_Type, ::getCppuType(&m_Type));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE), PROPERTY_ID_SCALE, nAttrib, &m_Scale, ::getCppuType(&m_Scale));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE), PROPERTY_ID_ISNULLABLE, nAttrib, &m_IsNullable, ::getCppuType(&m_IsNullable));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT), PROPERTY_ID_ISAUTOINCREMENT, nAttrib, &m_IsAutoIncrement, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISROWVERSION), PROPERTY_ID_ISROWVERSION, nAttrib, &m_IsRowVersion, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY), PROPERTY_ID_ISCURRENCY, nAttrib, &m_IsCurrency, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME, nAttrib, &m_CatalogName, ::getCppuType(&m_CatalogName));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib, &m_SchemaName, ::getCppuType(&m_SchemaName));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TABLENAME), PROPERTY_ID_TABLENAME, nAttrib, &m_TableName, ::getCppuType(&m_TableName));
}
// -------------------------------------------------------------------------
void OColumn::disposing(void)
@@ -195,7 +204,10 @@ Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor( ) throw(Runti
m_IsAutoIncrement,
m_IsRowVersion,
m_IsCurrency,
- isCaseSensitive());
+ isCaseSensitive(),
+ m_CatalogName,
+ m_SchemaName,
+ m_TableName);
pNewColumn->setNew(sal_True);
return pNewColumn;
}
diff --git a/connectivity/source/sdbcx/VIndexColumn.cxx b/connectivity/source/sdbcx/VIndexColumn.cxx
index be5fd014ff72..15a20a2dec59 100644
--- a/connectivity/source/sdbcx/VIndexColumn.cxx
+++ b/connectivity/source/sdbcx/VIndexColumn.cxx
@@ -71,7 +71,10 @@ OIndexColumn::OIndexColumn( sal_Bool _IsAscending,
sal_Bool _IsAutoIncrement,
sal_Bool _IsRowVersion,
sal_Bool _IsCurrency,
- sal_Bool _bCase
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName
) : OColumn(_Name,
_TypeName,
_DefaultValue,
@@ -83,7 +86,10 @@ OIndexColumn::OIndexColumn( sal_Bool _IsAscending,
_IsAutoIncrement,
_IsRowVersion,
_IsCurrency,
- _bCase)
+ _bCase,
+ _CatalogName,
+ _SchemaName,
+ _TableName)
, m_IsAscending(_IsAscending)
{
construct();
diff --git a/connectivity/source/sdbcx/VKeyColumn.cxx b/connectivity/source/sdbcx/VKeyColumn.cxx
index edb052277d2b..48e1df5154f3 100644
--- a/connectivity/source/sdbcx/VKeyColumn.cxx
+++ b/connectivity/source/sdbcx/VKeyColumn.cxx
@@ -71,7 +71,10 @@ OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn,
sal_Bool _IsAutoIncrement,
sal_Bool _IsRowVersion,
sal_Bool _IsCurrency,
- sal_Bool _bCase
+ sal_Bool _bCase,
+ const ::rtl::OUString& _CatalogName,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _TableName
) : OColumn(_Name,
_TypeName,
_DefaultValue,
@@ -83,7 +86,10 @@ OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn,
_IsAutoIncrement,
_IsRowVersion,
_IsCurrency,
- _bCase)
+ _bCase,
+ _CatalogName,
+ _SchemaName,
+ _TableName)
, m_ReferencedColumn(_ReferencedColumn)
{
construct();
diff --git a/connectivity/source/simpledbt/dbtfactory.cxx b/connectivity/source/simpledbt/dbtfactory.cxx
index 616a7fa6dded..29d000423ed0 100644
--- a/connectivity/source/simpledbt/dbtfactory.cxx
+++ b/connectivity/source/simpledbt/dbtfactory.cxx
@@ -94,9 +94,9 @@ namespace connectivity
SAL_WNODEPRECATED_DECLARATIONS_POP
//----------------------------------------------------------------
- ::rtl::Reference< simple::ISQLParser > ODataAccessToolsFactory::createSQLParser(const Reference< XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext) const
+ ::rtl::Reference< simple::ISQLParser > ODataAccessToolsFactory::createSQLParser(const Reference< XComponentContext >& rxContext, const IParseContext* _pContext) const
{
- return new OSimpleSQLParser(_rxServiceFactory,_pContext);
+ return new OSimpleSQLParser(rxContext, _pContext);
}
//........................................................................
diff --git a/connectivity/source/simpledbt/dbtfactory.hxx b/connectivity/source/simpledbt/dbtfactory.hxx
index ba9d9c7e532f..40005ecbdd9f 100644
--- a/connectivity/source/simpledbt/dbtfactory.hxx
+++ b/connectivity/source/simpledbt/dbtfactory.hxx
@@ -44,7 +44,7 @@ namespace connectivity
// IDataAccessToolsFactory
virtual ::rtl::Reference< simple::ISQLParser > createSQLParser(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const IParseContext* _pContext
) const;
diff --git a/connectivity/source/simpledbt/parser_s.cxx b/connectivity/source/simpledbt/parser_s.cxx
index 302099d53622..b49c4bfe9a49 100644
--- a/connectivity/source/simpledbt/parser_s.cxx
+++ b/connectivity/source/simpledbt/parser_s.cxx
@@ -35,8 +35,8 @@ namespace connectivity
//= OSimpleSQLParser
//================================================================
//----------------------------------------------------------------
- OSimpleSQLParser::OSimpleSQLParser(const Reference< XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext)
- :m_aFullParser(_rxServiceFactory,_pContext)
+ OSimpleSQLParser::OSimpleSQLParser(const Reference< XComponentContext >& rxContext, const IParseContext* _pContext)
+ :m_aFullParser(rxContext, _pContext)
{
}
diff --git a/connectivity/source/simpledbt/parser_s.hxx b/connectivity/source/simpledbt/parser_s.hxx
index 6d2555e7b099..155ef739b233 100644
--- a/connectivity/source/simpledbt/parser_s.hxx
+++ b/connectivity/source/simpledbt/parser_s.hxx
@@ -40,7 +40,7 @@ namespace connectivity
OSQLParser m_aFullParser;
public:
- OSimpleSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceFactory,const IParseContext* _pContext);
+ OSimpleSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, const IParseContext* _pContext);
// ISQLParser
virtual ::rtl::Reference< simple::ISQLParseNode > predicateTree(
diff --git a/connectivity/workben/postgresql/ddl.py b/connectivity/workben/postgresql/ddl.py
deleted file mode 100644
index 151f0b8c1fe1..000000000000
--- a/connectivity/workben/postgresql/ddl.py
+++ /dev/null
@@ -1,179 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Ralph Thomas
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Ralph Thomas, Joerg Budischewski
-#
-#*************************************************************************
-from com.sun.star.sdbc import SQLException
-import sys
-
-def dumpResultSet( rs ):
- meta = rs.getMetaData()
- for i in range(1, meta.getColumnCount()+1):
- sys.stdout.write(meta.getColumnName( i ) + "\t")
- sys.stdout.write( "\n" )
- while rs.next():
- for i in range( 1, meta.getColumnCount()+1):
- sys.stdout.write( rs.getString( i ) + "\t" )
- sys.stdout.write( "\n" )
- rs.beforeFirst()
-
-
-
-def executeIgnoringException( stmt, sql ):
- try:
- stmt.executeUpdate(sql)
- except SQLException:
- pass
-
-def cleanGroupsAndUsers( stmt ):
- rs = stmt.executeQuery("SELECT groname FROM pg_group WHERE groname LIKE 'pqsdbc_%'" )
- stmt2 = stmt.getConnection().createStatement()
- while rs.next():
- stmt2.executeUpdate("DROP GROUP " + rs.getString(1) )
-
- rs.close()
- rs = stmt.executeQuery( "SELECT usename FROM pg_user WHERE usename LIKE 'pqsdbc_%'" )
- while rs.next():
- stmt2.executeUpdate( "DROP USER " + rs.getString(1) )
-
-
-
-
-def executeDDLs( connection ):
-
- stmt = connection.createStatement()
-
-
- executeIgnoringException( stmt, "DROP VIEW customer2" )
- executeIgnoringException( stmt, "DROP TABLE orderpos" )
- executeIgnoringException( stmt, "DROP TABLE ordertab" )
- executeIgnoringException( stmt, "DROP TABLE product" )
- executeIgnoringException( stmt, "DROP TABLE customer" )
- executeIgnoringException( stmt, "DROP TABLE blub" )
- executeIgnoringException( stmt, "DROP TABLE foo" )
- executeIgnoringException( stmt, "DROP TABLE nooid" )
- executeIgnoringException( stmt, "DROP TABLE nooid2" )
- cleanGroupsAndUsers( stmt )
- executeIgnoringException( stmt, "DROP DOMAIN pqsdbc_short" )
- executeIgnoringException( stmt, "DROP DOMAIN pqsdbc_amount" )
- executeIgnoringException( stmt, "DROP SCHEMA pqsdbc_test" )
-
- ddls = (
- "BEGIN",
- "CREATE DOMAIN pqsdbc_short AS int2",
- "CREATE DOMAIN pqsdbc_amount AS integer",
- "CREATE USER pqsdbc_joe",
- "CREATE USER pqsdbc_susy",
- "CREATE USER pqsdbc_boss",
- "CREATE USER pqsdbc_customer", # technical user (e.g. a webfrontend)
- "CREATE GROUP pqsdbc_employees WITH USER pqsdbc_joe,pqsdbc_susy",
- "CREATE GROUP pqsdbc_admin WITH USER pqsdbc_susy,pqsdbc_boss",
- "CREATE SCHEMA pqsdbc_test",
- "CREATE TABLE customer ( "+
- "id char(8) UNIQUE PRIMARY KEY, "+
- "name text, " +
- "dummySerial serial UNIQUE) WITH OIDS",
- "COMMENT ON TABLE customer IS 'contains customer attributes'",
- "COMMENT ON COLUMN customer.id IS 'unique id'",
- "CREATE TABLE product ("+
- "id char(8) UNIQUE PRIMARY KEY,"+
- "name text,"+
- "price numeric(10,2),"+
- "image bytea) WITH OIDS",
-
- "CREATE TABLE ordertab ( "+
- "id char(8) UNIQUE PRIMARY KEY,"+
- "customerid char(8) CONSTRAINT cust REFERENCES customer(id) ON DELETE CASCADE ON UPDATE RESTRICT,"+
- "orderdate char(8),"+
- "delivered boolean ) WITH OIDS",
- "CREATE TABLE orderpos ( "+
- "orderid char(8) REFERENCES ordertab(id),"+
- "id char(3),"+
- "productid char(8) REFERENCES product(id),"+
- "amount pqsdbc_amount,"+
- "shortamount pqsdbc_short,"+
- "PRIMARY KEY (orderid,id)) WITH OIDS",
- "CREATE TABLE nooid ("+
- "id char(8) UNIQUE PRIMARY KEY,"+
- "name text) "+
- "WITHOUT OIDS",
- "CREATE TABLE nooid2 ("+
- "id serial UNIQUE PRIMARY KEY,"+
- "name text) "+
- "WITHOUT OIDS",
- "CREATE VIEW customer2 AS SELECT id,name FROM customer",
- "GRANT SELECT ON TABLE customer,product,orderpos,ordertab TO pqsdbc_customer",
- "GRANT SELECT ON TABLE product TO GROUP pqsdbc_employees",
- "GRANT SELECT,UPDATE, INSERT ON TABLE customer TO GROUP pqsdbc_employees",
- "GRANT ALL ON TABLE orderpos,ordertab TO GROUP pqsdbc_employees, GROUP pqsdbc_admin",
- "GRANT ALL ON TABLE customer TO GROUP pqsdbc_admin", # the admin is allowed to delete customers
- "GRANT ALL ON TABLE product TO pqsdbc_boss", # only the boss may change the product table
- "INSERT INTO public.customer VALUES ('C1','John Doe')",
- "INSERT INTO \"public\" . \"customer\" VALUES ('C2','Bruce Springsteen')",
-
- "INSERT INTO \"public\".product VALUES ('PZZ2','Pizza Mista',6.95,'\\003foo\\005')",
- "INSERT INTO product VALUES ('PZZ5','Pizza Funghi',5.95,'\\001foo\\005')",
- "INSERT INTO product VALUES ('PAS1','Lasagne',5.49,NULL)",
-
- "INSERT INTO ordertab VALUES ( '1', 'C2', '20030403','true')",
- "INSERT INTO ordertab VALUES ( '2', 'C1', '20030402','false')",
-
- "INSERT INTO orderpos VALUES ( '1','001', 'PZZ2',2,0)",
- "INSERT INTO orderpos VALUES ( '1','002', 'PZZ5',3,-1)",
- "INSERT INTO orderpos VALUES ( '2','001', 'PAS1',5,1)",
- "INSERT INTO orderpos VALUES ( '2','002', 'PZZ2',3,2)",
- "COMMIT" )
- for i in ddls:
- stmt.executeUpdate(i)
-
- connection.getTables() # force refresh of metadata
-
- stmt.close()
diff --git a/connectivity/workben/postgresql/main.py b/connectivity/workben/postgresql/main.py
deleted file mode 100644
index 71c803799e31..000000000000
--- a/connectivity/workben/postgresql/main.py
+++ /dev/null
@@ -1,84 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Joerg Budischewski
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Joerg Budischewski
-#
-#
-#
-#*************************************************************************
-import uno
-import unohelper
-import unittest
-import statement
-import preparedstatement
-import metadata
-import sdbcx
-import sys
-import os
-
-ctx = uno.getComponentContext()
-
-# needed for the tests
-unohelper.addComponentsToContext(
- ctx,ctx,
- ("postgresql-sdbc.uno","postgresql-sdbc-impl.uno","typeconverter.uno"),
- "com.sun.star.loader.SharedLibrary")
-
-runner = unittest.TextTestRunner(sys.stderr,1,2)
-dburl = sys.argv[1] # os.environ['USER'] + "_pqtest"
-print "dburl=" + dburl
-
-suite = unittest.TestSuite()
-suite.addTest(statement.suite(ctx,dburl))
-suite.addTest(preparedstatement.suite(ctx,dburl))
-suite.addTest(metadata.suite(ctx,dburl))
-suite.addTest(sdbcx.suite(ctx,dburl))
-
-runner.run(suite)
diff --git a/connectivity/workben/postgresql/makefile.mk b/connectivity/workben/postgresql/makefile.mk
deleted file mode 100644
index bc7b9c2697aa..000000000000
--- a/connectivity/workben/postgresql/makefile.mk
+++ /dev/null
@@ -1,97 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): _______________________________________
-#
-#
-#
-#*************************************************************************
-
-PRJ=..$/..
-
-PRJNAME=connectivity
-TARGET=postgresql-test
-LIBTARGET=NO
-TARGETTYPE=CUI
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : sv.mk
-# --- Files --------------------------------------------------------
-
-
-PYFILES = \
- $(DLLDEST)$/statement.py \
- $(DLLDEST)$/preparedstatement.py \
- $(DLLDEST)$/main.py \
- $(DLLDEST)$/ddl.py \
- $(DLLDEST)$/sdbcx.py \
- $(DLLDEST)$/metadata.py
-
-ALL : \
- $(PYFILES) \
- doc
-
-.INCLUDE : target.mk
-
-$(DLLDEST)$/%.py: %.py
- +cp $? $@
-
-
-.PHONY doc:
- @echo "start test with dmake runtest dburl=your-url"
- @echo " e.g. dmake runtest dburl=sdbc:postgresql:dbname=pqtest"
- @echo " MUST: Create a separate datbases before (here pqtest),"
- @echo " (SOME TABLES GET DROPPED)"
-
-runtest : ALL
- +cd $(DLLDEST) && python main.py "$(dburl)"
diff --git a/connectivity/workben/postgresql/metadata.py b/connectivity/workben/postgresql/metadata.py
deleted file mode 100644
index 90764d557768..000000000000
--- a/connectivity/workben/postgresql/metadata.py
+++ /dev/null
@@ -1,145 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Ralph Thomas
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Ralph Thomas, Joerg Budischewski
-#
-#*************************************************************************
-import unittest
-import sys
-import ddl
-
-from com.sun.star.sdbc.DataType import SMALLINT, INTEGER, BIGINT , DATE, TIME, TIMESTAMP, NUMERIC
-
-def dumpResultSet( rs , count ):
-# for i in range(1, count):
-# sys.stdout.write(meta.getColumnName( i ) + "\t")
- sys.stdout.write( "\n" )
- while rs.next():
- for i in range( 1, count+1):
- sys.stdout.write( rs.getString( i ) + "\t" )
- sys.stdout.write( "\n" )
- rs.beforeFirst()
-
-
-
-
-def suite(ctx,dburl):
- suite = unittest.TestSuite()
- suite.addTest(TestCase("testDatabaseMetaData",ctx,dburl))
- suite.addTest(TestCase("testTypeGuess",ctx,dburl))
- return suite
-
-class TestCase(unittest.TestCase):
- def __init__(self,method,ctx,dburl):
- unittest.TestCase.__init__(self,method)
- self.ctx = ctx
- self.dburl = dburl
-
-
- def setUp( self ):
- self.driver = self.ctx.ServiceManager.createInstanceWithContext(
- 'org.openoffice.comp.connectivity.pq.Driver.noext' , self.ctx )
- self.connection = self.driver.connect( self.dburl, () )
- ddl.executeDDLs( self.connection )
-
- def tearDown( self ):
- self.connection.close()
-
- def testDatabaseMetaData( self ):
- meta = self.connection.getMetaData()
-
- rs = meta.getTables( None, "public", "%", () )
-# dumpResultSet( rs, 5)
-
- rs = meta.getColumns( None, "%", "customer", "%" )
-# dumpResultSet( rs, 18 )
-
- rs = meta.getPrimaryKeys( None, "public" , "%" )
-# dumpResultSet( rs , 6 )
- rs = meta.getTablePrivileges( None, "public" , "%" )
-# dumpResultSet( rs , 7 )
- rs = meta.getColumns( None, "public" , "customer", "%" )
-# dumpResultSet( rs , 18 )
- rs = meta.getTypeInfo()
-# dumpResultSet(rs, 18)
- while rs.next():
- if rs.getString(1) == "pqsdbc_short":
- self.failUnless( rs.getInt(2) == SMALLINT )
- break
- self.failUnless( not rs.isAfterLast() ) # domain type cannot be found
-
-
- rs = meta.getIndexInfo( None, "public" , "customer", False, False )
-# dumpResultSet( rs, 13 )
-
- def testTypeGuess( self ):
- stmt = self.connection.createStatement()
- rs = stmt.executeQuery( "SELECT sum(amount) FROM orderpos" )
- meta = rs.getMetaData()
- self.failUnless( meta.getColumnType(1) == BIGINT )
-
- stmt = self.connection.createStatement()
- rs = stmt.executeQuery( "SELECT sum(price) FROM product" )
- meta = rs.getMetaData()
- self.failUnless( meta.getColumnType(1) == NUMERIC )
-
- rs = stmt.executeQuery( "SELECT max(ttime) FROM firsttable" )
- meta = rs.getMetaData()
- self.failUnless( meta.getColumnType(1) == TIME )
-
- rs = stmt.executeQuery( "SELECT max(tdate) FROM firsttable" )
- meta = rs.getMetaData()
- self.failUnless( meta.getColumnType(1) == DATE )
-
- rs = stmt.executeQuery( "SELECT max(ttimestamp) FROM firsttable" )
- meta = rs.getMetaData()
- self.failUnless( meta.getColumnType(1) == TIMESTAMP )
-# rs.next()
-# print rs.getString( 1 )
diff --git a/connectivity/workben/postgresql/preparedstatement.py b/connectivity/workben/postgresql/preparedstatement.py
deleted file mode 100644
index a44f2ae55472..000000000000
--- a/connectivity/workben/postgresql/preparedstatement.py
+++ /dev/null
@@ -1,222 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Ralph Thomas
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Ralph Thomas, Joerg Budischewski
-#
-#*************************************************************************
-import unittest
-import sys
-import ddl
-from uno import ByteSequence
-from com.sun.star.sdbc import SQLException
-from com.sun.star.sdbc.ResultSetConcurrency import UPDATABLE
-from com.sun.star.sdbc.DataType import NUMERIC,VARCHAR
-
-def suite(ctx,dburl):
- suite = unittest.TestSuite()
- suite.addTest(TestCase("testQuery",ctx,dburl))
- suite.addTest(TestCase("testGeneratedResultSet",ctx,dburl))
- suite.addTest(TestCase("testUpdateableResultSet",ctx,dburl))
- suite.addTest(TestCase("testQuoteQuote",ctx,dburl))
- return suite
-
-def realEquals( a,b,eps ):
- val = a - b
- if val < 0:
- val = -1. * val
- return val < eps
-
-class TestCase(unittest.TestCase):
- def __init__(self,method,ctx,dburl):
- unittest.TestCase.__init__(self,method)
- self.ctx = ctx
- self.dburl = dburl
-
- def setUp(self):
- self.driver = self.ctx.ServiceManager.createInstanceWithContext(
- 'org.openoffice.comp.connectivity.pq.Driver.noext', self.ctx )
- self.connection = self.driver.connect( self.dburl, () )
- ddl.executeDDLs( self.connection )
-
- def testDown( self ):
- self.connection.close()
-
- def testQuery( self ):
-
- stmts = "SELECT product.id FROM product WHERE product.price > :lowprice AND product.price < :upprice", \
- "SELECT product.id FROM product WHERE product.price > ? AND product.price < ?" , \
- "SELECT \"product\".\"id\" FROM product WHERE \"product\".\"price\" > :lowprice AND \"product\".\"price\" < :upprice"
-
-
- for stmt in stmts:
- prepstmt = self.connection.prepareStatement( stmt )
- prepstmt.setDouble( 1, 5.80 )
- prepstmt.setObjectWithInfo( 2, 7. , NUMERIC, 2)
- prepstmt.setObjectWithInfo( 2, "7.0000", NUMERIC, 2 )
- rs = prepstmt.executeQuery( )
- self.failUnless( rs.getMetaData().getColumnCount() == 1 )
- self.failUnless( rs.getMetaData().getColumnName(1) == "id")
- self.failUnless( prepstmt.getMetaData().getColumnCount() == 1 )
- self.failUnless( prepstmt.getMetaData().getColumnName(1) == "id" )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ).strip() == "PZZ2" )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ).strip() == "PZZ5" )
- self.failUnless( rs.isLast() )
-
- prepstmt = self.connection.prepareStatement(
- "SELECT name FROM product WHERE id = ?" )
- prepstmt.setString( 1, 'PZZ2' )
- rs = prepstmt.executeQuery()
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ) == "Pizza Mista" )
- self.failUnless( rs.isLast() )
-
- prepstmt = self.connection.prepareStatement(
- "SELECT name FROM product WHERE image = ?" )
- prepstmt.setBytes( 1, ByteSequence( "\001foo\005" ) )
- rs = prepstmt.executeQuery()
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ) == "Pizza Funghi" )
- self.failUnless( rs.isLast() )
-
- prepstmt = self.connection.prepareStatement(
- "SELECT * FROM ordertab WHERE delivered = ?" )
- prepstmt.setBoolean( 1 , False )
- rs = prepstmt.executeQuery()
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ).strip() == "2" )
- self.failUnless( rs.isLast() )
-
- stmt = self.connection.createStatement()
- rs = stmt.executeQuery( "SELECT * FROM \"public\".\"customer\"" )
-
- stmt.executeUpdate( "DELETE FROM product where id='PAS5'" )
- prepstmt =self.connection.prepareStatement(
- "INSERT INTO product VALUES(?,'Ravioli',?,NULL)" );
- prepstmt.setObjectWithInfo( 1, "PAS5" ,VARCHAR,0)
- prepstmt.setObjectWithInfo( 2, "9.223" ,NUMERIC,2)
- prepstmt.executeUpdate()
- rs= stmt.executeQuery( "SELECT price FROM product WHERE id = 'PAS5'" )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ).strip() == "9.22" )
-
- stmt.executeUpdate( "DELETE FROM product where id='PAS5'" )
- prepstmt =self.connection.prepareStatement(
- "INSERT INTO product VALUES('PAS5','Ravioli',?,NULL)" );
- prepstmt.setObjectWithInfo( 1, 9.223,NUMERIC,2 )
- prepstmt.executeUpdate()
- rs= stmt.executeQuery( "SELECT price FROM product WHERE id = 'PAS5'" )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString( 1 ).strip() == "9.22" )
-
- def testGeneratedResultSet( self ):
- prepstmt = self.connection.prepareStatement(
- "INSERT INTO customer VALUES( ?, ? )" )
- prepstmt.setString( 1, "C3" )
- prepstmt.setString( 2, "Norah Jones" )
- prepstmt.executeUpdate()
- rs = prepstmt.getGeneratedValues()
- self.failUnless( rs.next() )
- self.failUnless( rs.getInt( 3 ) == 3 )
-
- prepstmt = self.connection.prepareStatement(
- "INSERT INTO public.nooid (id,name) VALUES( ?, ? )" )
- prepstmt.setString( 1, "C3" )
- prepstmt.setString( 2, "Norah Jones" )
- prepstmt.executeUpdate()
- rs = prepstmt.getGeneratedValues()
- self.failUnless( rs.next() )
- self.failUnless( rs.getString(1).rstrip() == "C3" )
-
- prepstmt = self.connection.prepareStatement(
- "INSERT INTO public.nooid2 (name) VALUES( ? )" )
- prepstmt.setString( 1, "Norah Jones" )
- prepstmt.executeUpdate()
- rs = prepstmt.getGeneratedValues()
- self.failUnless( rs )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString(2) == "Norah Jones" )
- self.failUnless( rs.getString(1) == "1" )
-
- def testUpdateableResultSet( self ):
- stmt = self.connection.createStatement()
- stmt.ResultSetConcurrency = UPDATABLE
- rs = stmt.executeQuery( "SELECT * FROM orderpos" )
-# ddl.dumpResultSet( rs )
- rs.next()
- rs.deleteRow()
- rs.next()
- rs.updateInt( 4 , 32 )
- rs.updateRow()
-
- rs.moveToInsertRow()
- rs.updateString( 1 , '2' )
- rs.updateString( 2, '003' )
- rs.updateString( 3, 'PZZ5' )
- rs.updateInt( 4, 22 )
- rs.insertRow()
-
- rs = stmt.executeQuery( "SELECT * FROM orderpos" )
- rs = stmt.executeQuery( "SELECT * FROM \"public\".\"orderpos\"" )
-# ddl.dumpResultSet( rs )
-
- def testQuoteQuote( self ):
- stmt = self.connection.prepareStatement( "select 'foo''l'" )
- rs = stmt.executeQuery()
- self.failUnless( rs )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString(1) == "foo'l" )
-
- stmt = self.connection.prepareStatement( "select 'foo''''l'" )
- rs = stmt.executeQuery()
- self.failUnless( rs )
- self.failUnless( rs.next() )
- self.failUnless( rs.getString(1) == "foo''l" )
diff --git a/connectivity/workben/postgresql/sdbcx.py b/connectivity/workben/postgresql/sdbcx.py
deleted file mode 100644
index 7c5e97136544..000000000000
--- a/connectivity/workben/postgresql/sdbcx.py
+++ /dev/null
@@ -1,300 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Joerg Budischewski
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Joerg Budischewski
-#
-#
-#
-#*************************************************************************
-import unittest
-import ddl
-import unohelper
-import sys
-from com.sun.star.sdbc import SQLException
-from com.sun.star.sdbc.DataType import VARCHAR, CHAR, DECIMAL, DOUBLE, BIGINT, NUMERIC
-from com.sun.star.sdbc.ColumnValue import NO_NULLS, NULLABLE
-from com.sun.star.sdbcx.KeyType import PRIMARY, FOREIGN, UNIQUE
-from com.sun.star.sdbc.KeyRule import RESTRICT, CASCADE, NO_ACTION
-
-def suite(ctx,dburl):
- suite = unittest.TestSuite()
- suite.addTest(TestCase("testTables",ctx,dburl))
- suite.addTest(TestCase("testViews",ctx,dburl))
- suite.addTest(TestCase("testKeys",ctx,dburl))
- suite.addTest(TestCase("testUsers",ctx,dburl))
- suite.addTest(TestCase("testIndexes",ctx,dburl))
- return suite
-
-def nullable2Str( v ):
- if v == NO_NULLS:
- return "NOT NULL"
- return ""
-
-def autoIncremtent2Str( v ):
- if v:
- return "auto increment"
- return ""
-
-def dumpColumns( columns ):
- n = columns.getCount()
- print "Name\t type\t prec\t scale\t"
- for i in range( 0, n ):
- col = columns.getByIndex( i )
- print col.Name + "\t "+col.TypeName + "\t " + str(col.Precision) + "\t " + str(col.Scale) + "\t "+\
- str( col.DefaultValue ) + "\t " + str( col.Description ) + "\t " +\
- autoIncremtent2Str( col.IsAutoIncrement ) + "\t " + \
- nullable2Str( col.IsNullable )
-
-
-class TestCase(unittest.TestCase):
- def __init__(self,method,ctx,dburl):
- unittest.TestCase.__init__(self,method)
- self.ctx = ctx
- self.dburl = dburl
-
- def setUp( self ):
- self.driver = self.ctx.ServiceManager.createInstanceWithContext(
- 'org.openoffice.comp.connectivity.pq.Driver.noext' , self.ctx )
- self.connection = self.driver.connect( self.dburl, () )
- ddl.executeDDLs( self.connection )
-
- def tearDown( self ):
- self.connection.close()
-
- def checkDescriptor( self, descriptor, name, typeName, type, prec, scale, defaultValue, desc ):
- self.failUnless( descriptor.Name == name )
- self.failUnless( descriptor.TypeName == typeName )
- self.failUnless( descriptor.Type == type )
- self.failUnless( descriptor.Precision == prec )
- self.failUnless( descriptor.Scale == scale )
-# print descriptor.DefaultValue + " == " + defaultValue
-# self.failUnless( descriptor.DefaultValue == defaultValue )
- self.failUnless( descriptor.Description == desc )
-
-
- def testKeys( self ):
- dd = self.driver.getDataDefinitionByConnection( self.connection )
- tables = dd.getTables()
- t = tables.getByName( "public.ordertab" )
- keys = t.getKeys()
- key = keys.getByName( "cust" )
- self.failUnless( key.Name == "cust" )
- self.failUnless( key.Type == FOREIGN )
- self.failUnless( key.ReferencedTable == "public.customer" )
- self.failUnless( key.UpdateRule == RESTRICT )
- self.failUnless( key.DeleteRule == CASCADE )
-
- keycolumns = keys.getByName( "ordertab_pkey" ).getColumns()
- self.failUnless( keycolumns.getElementNames() == (u"id",) )
-
- key = keys.getByName( "ordertab_pkey" )
- self.failUnless( key.Name == "ordertab_pkey" )
- self.failUnless( key.Type == PRIMARY )
- self.failUnless( key.UpdateRule == NO_ACTION )
- self.failUnless( key.DeleteRule == NO_ACTION )
-
- keys = tables.getByName( "public.customer" ).getKeys()
- key = keys.getByName( "customer_dummyserial_key" )
- self.failUnless( key.Name == "customer_dummyserial_key" )
- self.failUnless( key.Type == UNIQUE )
- self.failUnless( key.UpdateRule == NO_ACTION )
- self.failUnless( key.DeleteRule == NO_ACTION )
-
- keys = tables.getByName( "public.orderpos" ).getKeys()
- keyEnum = keys.createEnumeration()
- while keyEnum.hasMoreElements():
- key = keyEnum.nextElement()
- cols = key.getColumns()
- colEnum = cols.createEnumeration()
- while colEnum.hasMoreElements():
- col = colEnum.nextElement()
-
- def testViews( self ):
- dd = self.driver.getDataDefinitionByConnection( self.connection )
- views = dd.getViews()
-
- v = views.getByName( "public.customer2" )
- self.failUnless( v.Name == "customer2" )
- self.failUnless( v.SchemaName == "public" )
- self.failUnless( v.Command != "" )
-
- def testIndexes( self ):
- dd = self.driver.getDataDefinitionByConnection( self.connection )
- tables = dd.getTables()
- t = tables.getByName( "public.ordertab" )
- indexes = t.getIndexes()
- index = indexes.getByName( "ordertab_pkey" )
-
- self.failUnless( index.Name == "ordertab_pkey" )
- self.failUnless( index.IsPrimaryKeyIndex )
- self.failUnless( index.IsUnique )
- self.failUnless( not index.IsClustered )
-
- columns = index.getColumns()
- self.failUnless( columns.hasByName( "id" ) )
-
- self.failUnless( columns.getByIndex(0).Name == "id" )
-
- def checkRenameTable( self, t , tables):
- t.rename( "foo" )
- self.failUnless( tables.hasByName( "public.foo" ) )
-
- t.rename( "public.foo2" )
- self.failUnless( tables.hasByName( "public.foo2" ) )
-
- try:
- t.rename( "pqsdbc_test.foo2" )
- self.failUnless( tables.hasByName( "pqsdbc_test.foo2" ) )
- print "looks like a server 8.1 or later (changing a schema succeeded)"
- t.rename( "pqsdbc_test.foo" )
- self.failUnless( tables.hasByName( "pqsdbc_test.foo" ) )
- t.rename( "public.foo2" )
- self.failUnless( tables.hasByName( "public.foo2" ) )
- except SQLException,e:
- if e.Message.find( "support changing" ) >= 0:
- print "looks like a server prior to 8.1 (changing schema failed with Message [" + e.Message.replace("\n", " ") + "])"
- else:
- raise e
- tables.dropByName( "public.foo2" )
-
- def testTables( self ):
- dd = self.driver.getDataDefinitionByConnection( self.connection )
- tables = dd.getTables()
- t = tables.getByName( "public.customer" )
- self.failUnless( t.Name == "customer" )
- self.failUnless( t.SchemaName == "public" )
- self.failUnless( t.Type == "TABLE" )
-
- cols = t.getColumns()
- self.failUnless( cols.hasByName( 'name' ) )
- self.failUnless( cols.hasByName( 'id' ) )
- col = cols.getByName( "dummyserial" )
-# dumpColumns( cols )
- self.checkDescriptor( cols.getByName( "id" ), "id", "bpchar", CHAR, 8, 0, "", "unique id" )
- self.checkDescriptor( cols.getByName( "name" ), "name", "text", VARCHAR, 0, 0, "", "" )
-
- dd = cols.createDataDescriptor()
- dd.Name = "foo"
- dd.TypeName = "CHAR"
- dd.Type = CHAR
- dd.Precision = 25
- dd.IsNullable = NULLABLE
- cols.appendByDescriptor( dd )
-
- dd.Name = "foo2"
- dd.TypeName = "DECIMAL"
- dd.Type = DECIMAL
- dd.Precision = 12
- dd.Scale = 5
- dd.DefaultValue = "2.3423"
- dd.Description = "foo2 description"
- cols.appendByDescriptor( dd )
-
- dd.Name = "cash"
- dd.TypeName = "MONEY"
- dd.Type = DOUBLE
-# dd.IsNullable = NO_NULLS
- dd.DefaultValue = "'2.42'"
- cols.appendByDescriptor( dd )
-
- cols.refresh()
-
- self.checkDescriptor( cols.getByName( "foo"), "foo", "bpchar", CHAR, 25,0,"","")
- self.checkDescriptor(
- cols.getByName( "foo2"), "foo2", "numeric", NUMERIC, 12,5,"2.3423","foo2 description")
-# dumpColumns( cols )
-
- datadesc = tables.createDataDescriptor()
- datadesc.SchemaName = "public"
- datadesc.Name = "blub"
- datadesc.Description = "This describes blub"
-
- tables.appendByDescriptor( datadesc )
-
- # make the appended descriptors known
- tables.refresh()
-
- t = tables.getByName( "public.blub" )
- self.failUnless( t.Name == "blub" )
- self.failUnless( t.SchemaName == "public" )
- self.failUnless( t.Description == "This describes blub" )
-
- cols = t.getColumns()
- dd = cols.createDataDescriptor()
- dd.Name = "mytext"
- dd.TypeName = "text"
- dd.Type = VARCHAR
- dd.IsNullable = NO_NULLS
- cols.appendByDescriptor( dd )
-
- cols.refresh()
-
- dd.DefaultValue = "'myDefault'"
- dd.Name = "mytext2"
- dd.IsNullable = NULLABLE
- dd.Description = "mytext-Description"
- t.alterColumnByName( "mytext" , dd )
-
- cols.refresh()
-
- self.checkDescriptor( cols.getByName( "mytext2" ), "mytext2", "text", VARCHAR, 0,0,"'myDefault'","mytext-Description" )
-
- t = tables.getByName( "public.customer2" )
- self.checkRenameTable( t,tables )
-
- t = tables.getByName( "public.blub" )
- self.checkRenameTable( t,tables )
-
-
-
- def testUsers( self ):
- dd = self.driver.getDataDefinitionByConnection( self.connection )
- users = dd.getUsers()
- self.failUnless( "pqsdbc_joe" in users.getElementNames() )
diff --git a/connectivity/workben/postgresql/statement.py b/connectivity/workben/postgresql/statement.py
deleted file mode 100644
index 1e752e81bbae..000000000000
--- a/connectivity/workben/postgresql/statement.py
+++ /dev/null
@@ -1,271 +0,0 @@
-#*************************************************************************
-#
-# The Contents of this file are made available subject to the terms of
-# either of the following licenses
-#
-# - GNU Lesser General Public License Version 2.1
-# - Sun Industry Standards Source License Version 1.1
-#
-# Sun Microsystems Inc., October, 2000
-#
-# GNU Lesser General Public License Version 2.1
-# =============================================
-# Copyright 2000 by Sun Microsystems, Inc.
-# 901 San Antonio Road, Palo Alto, CA 94303, USA
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1, as published by the Free Software Foundation.
-#
-# This library 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 for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-#
-# Sun Industry Standards Source License Version 1.1
-# =================================================
-# The contents of this file are subject to the Sun Industry Standards
-# Source License Version 1.1 (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.openoffice.org/license.html.
-#
-# Software provided under this License is provided on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
-# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
-# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
-# See the License for the specific provisions governing your rights and
-# obligations concerning the Software.
-#
-# The Initial Developer of the Original Code is: Joerg Budischewski
-#
-# Copyright: 2000 by Sun Microsystems, Inc.
-#
-# All Rights Reserved.
-#
-# Contributor(s): Joerg Budischewski
-#
-#
-#
-#*************************************************************************
-import unohelper
-import unittest
-import ddl
-from com.sun.star.sdbc import SQLException, XArray
-from com.sun.star.sdbc.DataType import VARCHAR
-from com.sun.star.util import Date
-from com.sun.star.util import Time
-from com.sun.star.util import DateTime
-
-# todo
-class MyArray( unohelper.Base, XArray ):
- def __init__( self, data ):
- self.data = data
- def getBaseType( self ):
- return VARCHAR
- def getBaseTypeName( self ):
- return "varchar"
- def getArray( self, foo ):
- return self.data
- def getArrayAtIndex( self, startIndex, count, foo ):
- return self.data[startIndex:startIndex+count-1]
- def getResultSet( self, foo):
- return None
- def getResultSetAtIndex( self, startIndex, count, foo ):
- return None
-
-def suite(ctx,dburl):
- suite = unittest.TestSuite()
- suite.addTest(TestCase("testRobustness",ctx,dburl))
- suite.addTest(TestCase("testRow",ctx,dburl))
- suite.addTest(TestCase("testNavigation",ctx,dburl))
- suite.addTest(TestCase("testDatabaseMetaData",ctx,dburl))
- suite.addTest(TestCase("testGeneratedResultSet",ctx,dburl))
- suite.addTest(TestCase("testResultSetMetaData",ctx,dburl))
- suite.addTest(TestCase("testArray",ctx,dburl))
- return suite
-
-def realEquals( a,b,eps ):
- val = a - b
- if val < 0:
- val = -1. * val
- return val < eps
-
-class TestCase(unittest.TestCase):
- def __init__(self,method,ctx,dburl):
- unittest.TestCase.__init__(self,method)
- self.ctx = ctx
- self.dburl = dburl
-
- def setUp(self):
- self.driver = self.ctx.ServiceManager.createInstanceWithContext(
- 'org.openoffice.comp.connectivity.pq.Driver.noext' , self.ctx )
- self.connection = self.driver.connect( self.dburl, () )
- self.stmt = self.connection.createStatement()
- try:
- self.stmt.executeUpdate( "DROP TABLE firsttable" )
- except SQLException,e:
- pass
-
- ddls = (
- "BEGIN",
- "CREATE TABLE firsttable (tString text,tInteger integer,tShort smallint,tLong bigint,tFloat real,"+
- "tDouble double precision,tByteSeq bytea,tBool boolean, tDate date, tTime time, tTimestamp timestamp, tIntArray integer[], tStringArray text[], tSerial serial ) WITH OIDS",
- "INSERT INTO firsttable VALUES ( 'foo', 70000, 12000, 70001, 2.4, 2.45, 'huhu', 'true', '1999-01-08','04:05:06','1999-01-08 04:05:06', '{2,3,4}', '{\"huhu\",\"hi\"}')",
- "INSERT INTO firsttable VALUES ( 'foo2', 69999, 12001, 70002, -2.4, 2.55, 'huhu', 'false', '1999-01-08','04:05:06','1999-01-08 04:05:06', NULL , '{\"bla\"}' )",
- "INSERT INTO firsttable VALUES ( 'foo2', 69999, 12001, 70002, -2.4, 2.55, 'huhu', null, '1999-01-08', '04:05:06','1999-01-08 04:05:06', '{}' , '{\"bl ubs\",\"bl\\\\\\\\a}}b\\\\\"a\",\"blub\"}' )",
- "COMMIT" )
- for i in ddls:
- self.stmt.executeUpdate(i)
-
- def tearDown(self):
- self.stmt.close()
- self.connection.close()
-
- def testRow(self):
- row = ("foo",70000,12000,70001,2.4,2.45, "huhu", True ,
- Date(8,1,1999), Time(0,6,5,4),DateTime(0,6,5,4,8,1,1999) )
- row2 = ("foo2",69999,12001,70002,-2.4,2.55, "huhu", False )
-
- rs = self.stmt.executeQuery( "SELECT * from firsttable" )
- self.failUnless( rs.next() )
-
- self.failUnless( rs.getString(1) == row[0] )
- self.failUnless( rs.getInt(2) == row[1] )
- self.failUnless( rs.getShort(3) == row[2] )
- self.failUnless( rs.getLong(4) == row[3] )
- self.failUnless( realEquals(rs.getFloat(5), row[4], 0.001))
- self.failUnless( realEquals(rs.getDouble(6), row[5], 0.00001))
- self.failUnless( rs.getBytes(7) == row[6] )
- self.failUnless( rs.getBoolean(8) == row[7] )
- self.failUnless( rs.getDate(9) == row[8] )
- self.failUnless( rs.getTime(10) == row[9] )
- self.failUnless( rs.getTimestamp(11) == row[10] )
-
- a = rs.getArray(12)
- data = a.getArray( None )
- self.failUnless( len( data ) == 3 )
- self.failUnless( int(data[0] ) == 2 )
- self.failUnless( int(data[1] ) == 3 )
- self.failUnless( int(data[2] ) == 4 )
-
- self.failUnless( rs.next() )
-
- self.failUnless( rs.next() )
- data = rs.getArray(13).getArray(None)
- self.failUnless( data[0] == "bl ubs" )
- self.failUnless( data[1] == "bl\\a}}b\"a" ) # check special keys
- self.failUnless( data[2] == "blub" )
-
- rs.getString(8)
- self.failUnless( rs.wasNull() )
- rs.getString(7)
- self.failUnless( not rs.wasNull() )
-
- self.failUnless( rs.findColumn( "tShort" ) == 3 )
- rs.close()
-
- def testNavigation( self ):
- rs = self.stmt.executeQuery( "SELECT * from firsttable" )
- self.failUnless( rs.isBeforeFirst() )
- self.failUnless( not rs.isAfterLast() )
- self.failUnless( rs.isBeforeFirst() )
-
- self.failUnless( rs.next() )
- self.failUnless( rs.isFirst() )
- self.failUnless( not rs.isLast() )
- self.failUnless( not rs.isBeforeFirst() )
-
- self.failUnless( rs.next() )
- self.failUnless( rs.next() )
- self.failUnless( not rs.next() )
- self.failUnless( rs.isAfterLast() )
-
- rs.absolute( 1 )
- self.failUnless( rs.isFirst() )
-
- rs.absolute( 3 )
- self.failUnless( rs.isLast() )
-
- rs.relative( -1 )
- self.failUnless( rs.getRow() == 2 )
-
- rs.relative( 1 )
- self.failUnless( rs.getRow() == 3 )
-
- rs.close()
-
- def testRobustness( self ):
- rs = self.stmt.executeQuery( "SELECT * from firsttable" )
-
- self.failUnlessRaises( SQLException, rs.getString , 1 )
-
- rs.next()
- self.failUnlessRaises( SQLException, rs.getString , 24 )
- self.failUnlessRaises( SQLException, rs.getString , 0 )
-
- self.connection.close()
- self.failUnlessRaises( SQLException, rs.getString , 1 )
- self.failUnlessRaises( SQLException, self.stmt.executeQuery, "SELECT * from firsttable" )
- rs.close()
-
-
- def testDatabaseMetaData( self ):
- meta = self.connection.getMetaData()
-
- self.failUnless( not meta.isReadOnly() )
-
- def testGeneratedResultSet( self ):
- self.stmt.executeUpdate(
- "INSERT INTO firsttable VALUES ( 'foo3', 69998, 12001, 70002, -2.4, 2.55, 'huhu2')" )
- #ddl.dumpResultSet( self.stmt.getGeneratedValues() )
- rs = self.stmt.getGeneratedValues()
- self.failUnless( rs.next() )
- self.failUnless( rs.getInt( 14 ) == 4 )
-
- def testResultSetMetaData( self ):
- rs = self.stmt.executeQuery( "SELECT * from firsttable" )
-
- # just check, if we get results !
- meta = rs.getMetaData()
-
- count = meta.getColumnCount()
- for i in range( 1, count+1):
- meta.isNullable( i )
- meta.isCurrency( i )
- meta.isCaseSensitive( i )
- meta.isSearchable( i )
- meta.isSigned( i )
- meta.getColumnDisplaySize( i )
- meta.getColumnName( i )
- meta.getColumnLabel( i )
- meta.getSchemaName( i )
- meta.getPrecision( i )
- meta.getScale( i )
- meta.getTableName( i )
- meta.getColumnTypeName( i )
- meta.getColumnType( i )
- meta.isReadOnly( i )
- meta.isWritable( i )
- meta.isDefinitelyWritable( i )
- meta.getColumnServiceName( i )
-
- def testArray( self ):
- stmt = self.connection.prepareStatement(
- "INSERT INTO firsttable VALUES ( 'insertedArray', 70000, 12000, 70001, 2.4, 2.45, 'huhu', 'true', '1999-01-08','04:05:06','1999-01-08 04:05:06', '{2,3,4}', ? )" )
- myarray = ( "a", "\"c", "}d{" )
- stmt.setArray( 1, MyArray( myarray ) )
- stmt.executeUpdate()
-
- stmt = self.connection.createStatement()
- rs = stmt.executeQuery( "SELECT tStringArray FROM firsttable WHERE tString = 'insertedArray'" )
- rs.next()
- data = rs.getArray(1).getArray(None)
- self.failUnless( data[0] == myarray[0] )
- self.failUnless( data[1] == myarray[1] )
- self.failUnless( data[2] == myarray[2] )