diff options
author | David Ostrovsky <david@ostrovsky.org> | 2012-08-03 00:10:17 +0200 |
---|---|---|
committer | David Ostrovsky <david@ostrovsky.org> | 2012-08-03 00:10:17 +0200 |
commit | cf0c13c5f7e81a9b2afdd0a5e085b2964cc59ef8 (patch) | |
tree | a9e306296942310cfe58a61960a25624456382ae | |
parent | fc3f784f488bfac06ab943b852e32a0e8f42dd6e (diff) |
mork driver: commenting out OSQLParser in MStatement
Change-Id: I28abadac8844996b6823239894a5eb2177020548
4 files changed, 137 insertions, 13 deletions
diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx index 8dedf5e680b3..9345d87b04ba 100644 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ b/connectivity/source/drivers/mork/MConnection.cxx @@ -156,9 +156,9 @@ Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLExcep // create a statement // the statement can only be executed once - // Reference< XStatement > xReturn = new OStatement(this); - // m_aStatements.push_back(WeakReferenceHelper(xReturn)); - return NULL; + Reference< XStatement > xReturn = new OStatement(this); + m_aStatements.push_back(WeakReferenceHelper(xReturn)); + return xReturn; } // -------------------------------------------------------------------------------- Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException) @@ -178,8 +178,7 @@ Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const :: pPrepared->lateInit(); m_aStatements.push_back(WeakReferenceHelper(xReturn)); - - return NULL; + return xReturn; } // -------------------------------------------------------------------------------- Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/mork/MResultSetMetaData.hxx b/connectivity/source/drivers/mork/MResultSetMetaData.hxx new file mode 100644 index 000000000000..89b50cf6fa1b --- /dev/null +++ b/connectivity/source/drivers/mork/MResultSetMetaData.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef CONNECTIVITY_SRESULSETMETADATA_HXX +#define CONNECTIVITY_SRESULSETMETADATA_HXX + +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> +#include <cppuhelper/implbase1.hxx> +#include <vector> +#include <rtl/ref.hxx> +#include "MConnection.hxx" +#include "MTable.hxx" + +namespace connectivity +{ + namespace mork + { + //************************************************************** + //************ Class: ResultSetMetaData + //************************************************************** + typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE; + + class OResultSetMetaData : public OResultSetMetaData_BASE + { + ::rtl::OUString m_aTableName; + ::rtl::Reference<connectivity::OSQLColumns> m_xColumns; + OTable* m_pTable; + sal_Bool m_bReadOnly; + + protected: + virtual ~OResultSetMetaData(); + public: + // a constructor that is needed to return the object: + // OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){} + OResultSetMetaData(const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns, + const ::rtl::OUString& _aTableName,OTable* _pTable,sal_Bool aReadOnly + ) + :m_aTableName(_aTableName) + ,m_xColumns(_rxColumns) + ,m_pTable(_pTable) + ,m_bReadOnly(aReadOnly) + {} + + + /// Avoid ambigous cast error from the compiler. + inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw() + { return this; } + + void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; + } +} + +#endif // CONNECTIVITY_SRESULSETMETADATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MStatement.cxx b/connectivity/source/drivers/mork/MStatement.cxx index dbbb78bc36bd..669121fb8585 100644 --- a/connectivity/source/drivers/mork/MStatement.cxx +++ b/connectivity/source/drivers/mork/MStatement.cxx @@ -64,22 +64,32 @@ using namespace com::sun::star::container; using namespace com::sun::star::io; using namespace com::sun::star::util; //------------------------------------------------------------------------------ + +OStatement::OStatement( OConnection* _pConnection) : OCommonStatement( _pConnection) +{ + SAL_INFO("connectivity.mork", "=> OStatement::OStatement()" ); +} + OCommonStatement::OCommonStatement(OConnection* _pConnection ) :OCommonStatement_IBASE(m_aMutex) ,OPropertySetHelper(OCommonStatement_IBASE::rBHelper) ,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this) - ,m_xDBMetaData(_pConnection->getMetaData()) ,m_pTable(NULL) ,m_pConnection(_pConnection) - ,m_aParser(NULL)//_pConnection->getDriver()->getMSFactory()) +// ,m_aParser(NULL)//_pConnection->getDriver()->getMSFactory()) // TODO - ,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, NULL/*_pConnection->createCatalog()->getTables()*/, m_aParser, NULL ) ) - ,m_pParseTree(NULL) ,rBHelper(OCommonStatement_IBASE::rBHelper) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::OCommonStatement()" ); + m_xDBMetaData = _pConnection->getMetaData(); + + m_pParseTree = NULL; + + //m_pSQLIterator = ( new OSQLParseTreeIterator( _pConnection, _pConnection->getMorkDriver()->getTables(), m_aParser, NULL ) ) + m_pConnection->acquire(); - OSL_TRACE("In/Out: OCommonStatement::OCommonStatement" ); } + // ----------------------------------------------------------------------------- OCommonStatement::~OCommonStatement() { @@ -133,6 +143,8 @@ void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException) // ------------------------------------------------------------------------- void OCommonStatement::createTable( ) throw ( SQLException, RuntimeException ) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::createTable()" ); + /* if(m_pParseTree) { @@ -181,9 +193,12 @@ void OCommonStatement::createTable( ) throw ( SQLException, RuntimeException ) OCommonStatement::StatementType OCommonStatement::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted) throw ( SQLException, RuntimeException ) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::parseSql()" ); + SAL_WARN("connectivity.mork", "m_aParser is not set!"); + ::rtl::OUString aErr; - m_pParseTree = m_aParser.parseTree(aErr,sql); + m_pParseTree = NULL;//m_aParser.parseTree(aErr,sql); #if OSL_DEBUG_LEVEL > 0 { @@ -257,6 +272,8 @@ OCommonStatement::StatementType OCommonStatement::parseSql( const ::rtl::OUStrin // ------------------------------------------------------------------------- Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery() { + SAL_INFO("connectivity.mork", "=> OCommonStatement::impl_executeCurrentQuery()" ); + clearCachedResultSet(); ::rtl::Reference< OResultSet > pResult( new OResultSet( this, m_pSQLIterator ) ); @@ -272,6 +289,8 @@ Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery() // ------------------------------------------------------------------------- void OCommonStatement::initializeResultSet( OResultSet* _pResult ) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::initializeResultSet()" ); + ENSURE_OR_THROW( _pResult, "invalid result set" ); _pResult->setColumnMapping(m_aColMapping); @@ -284,6 +303,8 @@ void OCommonStatement::initializeResultSet( OResultSet* _pResult ) // ------------------------------------------------------------------------- void OCommonStatement::clearCachedResultSet() { + SAL_INFO("connectivity.mork", "=> OCommonStatement::clearCachedResultSet()" ); + Reference< XResultSet > xResultSet( m_xResultSet.get(), UNO_QUERY ); if ( !xResultSet.is() ) return; @@ -311,6 +332,8 @@ void OCommonStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pR // ------------------------------------------------------------------------- sal_Bool SAL_CALL OCommonStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::execute()" ); + ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); @@ -324,6 +347,8 @@ sal_Bool SAL_CALL OCommonStatement::execute( const ::rtl::OUString& sql ) throw( Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::executeQuery()" ); + ::osl::MutexGuard aGuard( m_ThreadMutex ); checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); @@ -340,6 +365,8 @@ Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const ::rtl::OU Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLException, RuntimeException) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::getConnection()" ); + ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed); @@ -349,6 +376,8 @@ Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLE // ----------------------------------------------------------------------------- Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::queryInterface()" ); + Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this)); if(!aRet.hasValue()) aRet = OCommonStatement::queryInterface(rType); @@ -483,6 +512,8 @@ Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCommonStatement // ----------------------------------------------------------------------------- void OCommonStatement::createColumnMapping() { + SAL_INFO("connectivity.mork", "=> OCommonStatement::createColumnMapping()" ); + size_t i; // initialize the column index map (mapping select columns to table columns) @@ -533,6 +564,8 @@ void OCommonStatement::analyseSQL() void OCommonStatement::setOrderbyColumn( OSQLParseNode* pColumnRef, OSQLParseNode* pAscendingDescending) { + SAL_INFO("connectivity.mork", "=> OCommonStatement::setOrderbyColumn()" ); + ::rtl::OUString aColumnName; if (pColumnRef->count() == 1) aColumnName = pColumnRef->getChild(0)->getTokenValue(); diff --git a/connectivity/source/drivers/mork/MStatement.hxx b/connectivity/source/drivers/mork/MStatement.hxx index c89cecfd52db..212b8e1c8b3d 100644 --- a/connectivity/source/drivers/mork/MStatement.hxx +++ b/connectivity/source/drivers/mork/MStatement.hxx @@ -82,7 +82,7 @@ namespace connectivity OValueRow m_aRow; - connectivity::OSQLParser m_aParser; +// connectivity::OSQLParser m_aParser; ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator > m_pSQLIterator; @@ -188,7 +188,7 @@ namespace connectivity ~OStatement(){} public: // a constructor, for when the object needs to be returned: - OStatement( OConnection* _pConnection) : OCommonStatement( _pConnection){} + OStatement( OConnection* _pConnection); DECLARE_SERVICE_INFO(); virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); |