2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* $RCSfile: sqliterator.cxx,v $
|
2008-08-19 08:17:46 +00:00
|
|
|
* $Revision: 1.60 $
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 10:52:50 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 02:09:24 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_connectivity.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "connectivity/sqliterator.hxx"
|
2004-06-25 17:34:59 +00:00
|
|
|
#include "connectivity/sdbcx/VTable.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <connectivity/sqlparse.hxx>
|
2001-01-04 09:59:52 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
2007-11-21 14:09:21 +00:00
|
|
|
#include <connectivity/sqlerror.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <com/sun/star/sdbc/ColumnValue.hpp>
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XRow.hpp>
|
2006-07-10 13:38:34 +00:00
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
2007-11-21 14:09:21 +00:00
|
|
|
#include <com/sun/star/sdb/ErrorCondition.hpp>
|
2000-09-18 15:18:56 +00:00
|
|
|
#ifdef SQL_TEST_PARSETREEITERATOR
|
2003-04-28 15:59:08 +00:00
|
|
|
#include <iostream>
|
2000-09-18 15:18:56 +00:00
|
|
|
#endif
|
|
|
|
#include "connectivity/PColumn.hxx"
|
2001-02-01 12:10:17 +00:00
|
|
|
#include "connectivity/dbtools.hxx"
|
2006-07-10 13:38:34 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2001-05-14 10:42:44 +00:00
|
|
|
#include "TConnection.hxx"
|
2001-05-18 07:33:49 +00:00
|
|
|
#include <comphelper/types.hxx>
|
2006-07-10 13:38:34 +00:00
|
|
|
#include <connectivity/dbmetadata.hxx>
|
2004-03-15 11:49:26 +00:00
|
|
|
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
|
2006-06-20 01:08:52 +00:00
|
|
|
#include "diagnose_ex.h"
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-05-18 07:33:49 +00:00
|
|
|
using namespace ::comphelper;
|
2001-02-01 12:10:17 +00:00
|
|
|
using namespace ::connectivity;
|
2004-06-25 17:34:59 +00:00
|
|
|
using namespace ::connectivity::sdbcx;
|
2001-01-04 09:59:52 +00:00
|
|
|
using namespace ::dbtools;
|
2001-02-01 12:10:17 +00:00
|
|
|
using namespace ::connectivity::parse;
|
2007-11-21 14:09:21 +00:00
|
|
|
using namespace ::com::sun::star;
|
2000-09-18 15:18:56 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
2004-03-15 11:49:26 +00:00
|
|
|
using namespace ::com::sun::star::sdb;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2004-09-09 08:04:16 +00:00
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
struct OSQLParseTreeIteratorImpl
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
Reference< XConnection > m_xConnection;
|
|
|
|
Reference< XDatabaseMetaData > m_xDatabaseMetaData;
|
|
|
|
Reference< XNameAccess > m_xTableContainer;
|
|
|
|
Reference< XNameAccess > m_xQueryContainer;
|
|
|
|
|
|
|
|
::boost::shared_ptr< OSQLTables > m_pTables; /// all tables which participate in the SQL statement
|
|
|
|
::boost::shared_ptr< OSQLTables > m_pSubTables; /// all tables from sub queries not the tables from the select tables
|
|
|
|
::boost::shared_ptr< QueryNameSet > m_pForbiddenQueryNames;
|
|
|
|
|
|
|
|
sal_uInt32 m_nIncludeMask;
|
|
|
|
|
|
|
|
bool m_bIsCaseSensitive;
|
|
|
|
|
|
|
|
OSQLParseTreeIteratorImpl( const Reference< XConnection >& _rxConnection, const Reference< XNameAccess >& _rxTables )
|
|
|
|
:m_xConnection( _rxConnection )
|
|
|
|
,m_nIncludeMask( OSQLParseTreeIterator::All )
|
|
|
|
,m_bIsCaseSensitive( true )
|
|
|
|
{
|
|
|
|
OSL_PRECOND( m_xConnection.is(), "OSQLParseTreeIteratorImpl::OSQLParseTreeIteratorImpl: invalid connection!" );
|
|
|
|
m_xDatabaseMetaData = m_xConnection->getMetaData();
|
|
|
|
|
|
|
|
m_bIsCaseSensitive = m_xDatabaseMetaData.is() && m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers();
|
|
|
|
m_pTables.reset( new OSQLTables( m_bIsCaseSensitive ) );
|
|
|
|
m_pSubTables.reset( new OSQLTables( m_bIsCaseSensitive ) );
|
|
|
|
|
|
|
|
m_xTableContainer = _rxTables;
|
|
|
|
|
|
|
|
DatabaseMetaData aMetaData( m_xConnection );
|
|
|
|
if ( aMetaData.supportsSubqueriesInFrom() )
|
|
|
|
{
|
|
|
|
// connections might support the XQueriesSupplier interface, if they implement the css.sdb.Connection
|
|
|
|
// service
|
|
|
|
Reference< XQueriesSupplier > xSuppQueries( m_xConnection, UNO_QUERY );
|
|
|
|
if ( xSuppQueries.is() )
|
|
|
|
m_xQueryContainer = xSuppQueries->getQueries();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline bool isQueryAllowed( const ::rtl::OUString& _rQueryName )
|
|
|
|
{
|
|
|
|
if ( !m_pForbiddenQueryNames.get() )
|
|
|
|
return true;
|
|
|
|
if ( m_pForbiddenQueryNames->find( _rQueryName ) == m_pForbiddenQueryNames->end() )
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/** helper class for temporarily adding a query name to a list of forbidden query names
|
|
|
|
*/
|
|
|
|
class ForbidQueryName
|
|
|
|
{
|
|
|
|
::boost::shared_ptr< QueryNameSet >& m_rpAllForbiddenNames;
|
|
|
|
::rtl::OUString m_sForbiddenQueryName;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ForbidQueryName( OSQLParseTreeIteratorImpl& _rIteratorImpl, const ::rtl::OUString _rForbiddenQueryName )
|
|
|
|
:m_rpAllForbiddenNames( _rIteratorImpl.m_pForbiddenQueryNames )
|
|
|
|
,m_sForbiddenQueryName( _rForbiddenQueryName )
|
|
|
|
{
|
|
|
|
if ( !m_rpAllForbiddenNames.get() )
|
|
|
|
m_rpAllForbiddenNames.reset( new QueryNameSet );
|
|
|
|
m_rpAllForbiddenNames->insert( m_sForbiddenQueryName );
|
|
|
|
}
|
2004-09-09 08:04:16 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
~ForbidQueryName()
|
|
|
|
{
|
|
|
|
m_rpAllForbiddenNames->erase( m_sForbiddenQueryName );
|
|
|
|
}
|
2004-09-09 08:04:16 +00:00
|
|
|
};
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
OSQLParseTreeIterator::OSQLParseTreeIterator(const Reference< XConnection >& _rxConnection,
|
|
|
|
const Reference< XNameAccess >& _rxTables,
|
|
|
|
const OSQLParser& _rParser,
|
|
|
|
const OSQLParseNode* pRoot )
|
|
|
|
:m_rParser( _rParser )
|
|
|
|
,m_pImpl( new OSQLParseTreeIteratorImpl( _rxConnection, _rxTables ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::OSQLParseTreeIterator" );
|
2000-09-18 15:18:56 +00:00
|
|
|
setParseTree(pRoot);
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
OSQLParseTreeIterator::OSQLParseTreeIterator( const OSQLParseTreeIterator& _rParentIterator, const OSQLParser& _rParser, const OSQLParseNode* pRoot )
|
|
|
|
:m_rParser( _rParser )
|
|
|
|
,m_pImpl( new OSQLParseTreeIteratorImpl( _rParentIterator.m_pImpl->m_xConnection, _rParentIterator.m_pImpl->m_xTableContainer ) )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::OSQLParseTreeIterator" );
|
2006-07-10 13:38:34 +00:00
|
|
|
m_pImpl->m_pForbiddenQueryNames = _rParentIterator.m_pImpl->m_pForbiddenQueryNames;
|
|
|
|
setParseTree( pRoot );
|
|
|
|
}
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
OSQLParseTreeIterator::~OSQLParseTreeIterator()
|
|
|
|
{
|
2003-12-16 11:29:20 +00:00
|
|
|
dispose();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const OSQLTables& OSQLParseTreeIterator::getTables() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getTables" );
|
2006-07-10 13:38:34 +00:00
|
|
|
return *m_pImpl->m_pTables;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
bool OSQLParseTreeIterator::isCaseSensitive() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::isCaseSensitive" );
|
2006-07-10 13:38:34 +00:00
|
|
|
return m_pImpl->m_bIsCaseSensitive;
|
|
|
|
}
|
|
|
|
|
2000-11-03 12:31:35 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::dispose()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::dispose" );
|
2001-05-07 09:37:54 +00:00
|
|
|
m_aSelectColumns = NULL;
|
2003-12-16 11:29:20 +00:00
|
|
|
m_aGroupColumns = NULL;
|
|
|
|
m_aOrderColumns = NULL;
|
2001-05-07 09:37:54 +00:00
|
|
|
m_aParameters = NULL;
|
2006-07-10 13:38:34 +00:00
|
|
|
m_pImpl->m_xTableContainer = NULL;
|
|
|
|
m_pImpl->m_xDatabaseMetaData = NULL;
|
2004-06-25 17:34:59 +00:00
|
|
|
m_aCreateColumns = NULL;
|
2006-07-10 13:38:34 +00:00
|
|
|
m_pImpl->m_pTables->clear();
|
|
|
|
m_pImpl->m_pSubTables->clear();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::setParseTree(const OSQLParseNode * pNewParseTree)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setParseTree" );
|
2006-07-10 13:38:34 +00:00
|
|
|
m_pImpl->m_pTables->clear();
|
|
|
|
m_pImpl->m_pSubTables->clear();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-05-07 09:37:54 +00:00
|
|
|
m_aSelectColumns = new OSQLColumns();
|
2003-12-16 11:29:20 +00:00
|
|
|
m_aGroupColumns = new OSQLColumns();
|
|
|
|
m_aOrderColumns = new OSQLColumns();
|
2001-05-07 09:37:54 +00:00
|
|
|
m_aParameters = new OSQLColumns();
|
2004-06-25 17:34:59 +00:00
|
|
|
m_aCreateColumns = new OSQLColumns();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
m_pParseTree = pNewParseTree;
|
|
|
|
if (!m_pParseTree)
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_UNKNOWN;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// falls m_pParseTree aber keine Connection, dann Fehler
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !m_pImpl->m_xTableContainer.is() )
|
2000-09-18 15:18:56 +00:00
|
|
|
return;
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
m_aErrors = SQLException();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Statement-Typ ermitteln ...
|
|
|
|
if (SQL_ISRULE(m_pParseTree,select_statement) || SQL_ISRULE(m_pParseTree,union_statement) )
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_SELECT;
|
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(m_pParseTree,insert_statement))
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_INSERT;
|
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(m_pParseTree,update_statement_searched))
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_UPDATE;
|
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(m_pParseTree,delete_statement_searched))
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_DELETE;
|
|
|
|
}
|
|
|
|
else if (m_pParseTree->count() == 3 && SQL_ISRULE(m_pParseTree->getChild(1),odbc_call_spec))
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_ODBC_CALL;
|
|
|
|
}
|
2004-06-25 17:34:59 +00:00
|
|
|
else if (SQL_ISRULE(m_pParseTree->getChild(0),base_table_def))
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_CREATE_TABLE;
|
|
|
|
m_pParseTree = m_pParseTree->getChild(0);
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_eStatementType = SQL_STATEMENT_UNKNOWN;
|
|
|
|
//aIteratorStatus.setInvalidStatement();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
namespace
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
//.........................................................................
|
|
|
|
static void impl_getRowString( const Reference< XRow >& _rxRow, const sal_Int32 _nColumnIndex, ::rtl::OUString& _out_rString )
|
|
|
|
{
|
|
|
|
_out_rString = _rxRow->getString( _nColumnIndex );
|
|
|
|
if ( _rxRow->wasNull() )
|
|
|
|
_out_rString= ::rtl::OUString();
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
//.........................................................................
|
|
|
|
static ::rtl::OUString lcl_findTableInMetaData(
|
|
|
|
const Reference< XDatabaseMetaData >& _rxDBMeta, const ::rtl::OUString& _rCatalog,
|
|
|
|
const ::rtl::OUString& _rSchema, const ::rtl::OUString& _rTableName )
|
|
|
|
{
|
|
|
|
::rtl::OUString sComposedName;
|
|
|
|
|
|
|
|
static const ::rtl::OUString s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
|
|
|
|
static const ::rtl::OUString s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
|
|
|
|
static const ::rtl::OUString s_sWildcard = ::rtl::OUString::createFromAscii("%");
|
|
|
|
|
|
|
|
// we want all catalogues, all schemas, all tables
|
|
|
|
Sequence< ::rtl::OUString > sTableTypes(3);
|
|
|
|
sTableTypes[0] = s_sTableTypeView;
|
|
|
|
sTableTypes[1] = s_sTableTypeTable;
|
|
|
|
sTableTypes[2] = s_sWildcard; // just to be sure to include anything else ....
|
|
|
|
|
|
|
|
if ( _rxDBMeta.is() )
|
|
|
|
{
|
|
|
|
sComposedName = ::rtl::OUString();
|
|
|
|
|
|
|
|
Reference< XResultSet> xRes = _rxDBMeta->getTables(
|
|
|
|
_rCatalog.getLength() ? makeAny( _rCatalog ) : Any(), _rSchema.getLength() ? _rSchema : s_sWildcard, _rTableName, sTableTypes );
|
|
|
|
|
|
|
|
Reference< XRow > xCurrentRow( xRes, UNO_QUERY );
|
|
|
|
if ( xCurrentRow.is() && xRes->next() )
|
|
|
|
{
|
|
|
|
::rtl::OUString sCatalog, sSchema, sName;
|
|
|
|
|
|
|
|
impl_getRowString( xCurrentRow, 1, sCatalog );
|
|
|
|
impl_getRowString( xCurrentRow, 2, sSchema );
|
|
|
|
impl_getRowString( xCurrentRow, 3, sName );
|
|
|
|
|
|
|
|
sComposedName = ::dbtools::composeTableName(
|
|
|
|
_rxDBMeta,
|
|
|
|
sCatalog,
|
|
|
|
sSchema,
|
|
|
|
sName,
|
|
|
|
sal_False,
|
|
|
|
::dbtools::eInDataManipulation
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sComposedName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::impl_getQueryParameterColumns( const OSQLTable& _rQuery )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_getQueryParameterColumns" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( ( m_pImpl->m_nIncludeMask & Parameters ) != Parameters )
|
|
|
|
// parameters not to be included in the traversal
|
|
|
|
return;
|
|
|
|
|
|
|
|
::vos::ORef< OSQLColumns > pSubQueryParameterColumns( new OSQLColumns() );
|
|
|
|
|
|
|
|
// get the command and the EscapeProcessing properties from the sub query
|
|
|
|
::rtl::OUString sSubQueryCommand;
|
|
|
|
sal_Bool bEscapeProcessing = sal_False;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xQueryProperties( _rQuery, UNO_QUERY_THROW );
|
|
|
|
OSL_VERIFY( xQueryProperties->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_COMMAND ) ) >>= sSubQueryCommand );
|
|
|
|
OSL_VERIFY( xQueryProperties->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_ESCAPEPROCESSING ) ) >>= bEscapeProcessing );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse the sub query
|
|
|
|
do {
|
|
|
|
|
|
|
|
if ( !bEscapeProcessing || ( sSubQueryCommand.getLength() == 0 ) )
|
|
|
|
break;
|
|
|
|
|
|
|
|
::rtl::OUString sError;
|
|
|
|
::std::auto_ptr< OSQLParseNode > pSubQueryNode( const_cast< OSQLParser& >( m_rParser ).parseTree( sError, sSubQueryCommand, sal_False ) );
|
|
|
|
if ( !pSubQueryNode.get() )
|
|
|
|
break;
|
|
|
|
|
|
|
|
OSQLParseTreeIterator aSubQueryIterator( *this, m_rParser, pSubQueryNode.get() );
|
2007-07-31 12:39:08 +00:00
|
|
|
aSubQueryIterator.traverseSome( Parameters | SelectColumns );
|
|
|
|
// SelectColumns might also contain parameters
|
|
|
|
// #i77635# - 2007-07-23 / frank.schoenheit@sun.com
|
2006-07-10 13:38:34 +00:00
|
|
|
pSubQueryParameterColumns = aSubQueryIterator.getParameters();
|
|
|
|
aSubQueryIterator.dispose();
|
|
|
|
|
|
|
|
} while ( false );
|
|
|
|
|
|
|
|
// copy the parameters of the sub query to our own parameter array
|
2008-12-30 13:32:01 +00:00
|
|
|
::std::copy( pSubQueryParameterColumns->get().begin(), pSubQueryParameterColumns->get().end(),
|
|
|
|
::std::insert_iterator< OSQLColumns::Vector >( m_aParameters->get(), m_aParameters->get().end() ) );
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
OSQLTable OSQLParseTreeIterator::impl_locateRecordSource( const ::rtl::OUString& _rComposedName )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_locateRecordSource" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !_rComposedName.getLength() )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( false, "OSQLParseTreeIterator::impl_locateRecordSource: no object name at all?" );
|
|
|
|
return OSQLTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
OSQLTable aReturn;
|
|
|
|
::rtl::OUString sComposedName( _rComposedName );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::rtl::OUString sCatalog, sSchema, sName;
|
|
|
|
qualifiedNameComponents( m_pImpl->m_xDatabaseMetaData, sComposedName, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
|
|
|
|
|
|
|
|
// check whether there is a query with the given name
|
|
|
|
bool bQueryDoesExist = m_pImpl->m_xQueryContainer.is() && m_pImpl->m_xQueryContainer->hasByName( sComposedName );
|
|
|
|
|
|
|
|
// check whether the table container contains an object with the given name
|
|
|
|
if ( !bQueryDoesExist && !m_pImpl->m_xTableContainer->hasByName( sComposedName ) )
|
|
|
|
sComposedName = lcl_findTableInMetaData( m_pImpl->m_xDatabaseMetaData, sCatalog, sSchema, sName );
|
|
|
|
bool bTableDoesExist = m_pImpl->m_xTableContainer->hasByName( sComposedName );
|
|
|
|
|
|
|
|
// now obtain the object
|
|
|
|
|
|
|
|
// if we're creating a table, and there already is a table or query with the same name,
|
|
|
|
// this is worth an error
|
|
|
|
if ( SQL_STATEMENT_CREATE_TABLE == m_eStatementType )
|
|
|
|
{
|
|
|
|
if ( bQueryDoesExist )
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_QUERY_EXIST, &sName );
|
|
|
|
else if ( bTableDoesExist )
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_TABLE_EXIST, &sName );
|
|
|
|
else
|
|
|
|
aReturn = impl_createTableObject( sName, sCatalog, sSchema );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// queries win over tables, so if there's a query with this name, take this, no matter if
|
|
|
|
// there's a table, too
|
|
|
|
if ( bQueryDoesExist )
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->isQueryAllowed( sComposedName ) )
|
|
|
|
{
|
2007-11-21 14:09:21 +00:00
|
|
|
impl_appendError( m_rParser.getErrorHelper().getSQLException( sdb::ErrorCondition::PARSER_CYCLIC_SUB_QUERIES, NULL ) );
|
2006-07-10 13:38:34 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pImpl->m_xQueryContainer->getByName( sComposedName ) >>= aReturn;
|
|
|
|
|
|
|
|
// collect the parameters from the sub query
|
|
|
|
ForbidQueryName aForbidName( *m_pImpl, sComposedName );
|
|
|
|
impl_getQueryParameterColumns( aReturn );
|
|
|
|
}
|
|
|
|
else if ( bTableDoesExist )
|
|
|
|
m_pImpl->m_xTableContainer->getByName( sComposedName ) >>= aReturn;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( m_pImpl->m_xQueryContainer.is() )
|
|
|
|
// the connection on which we're working supports sub queries in from (else
|
|
|
|
// m_xQueryContainer would not have been set), so emit a better error message
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_TABLE_OR_QUERY, &sName );
|
|
|
|
else
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_TABLE, &sName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_TABLE, &sComposedName );
|
|
|
|
}
|
|
|
|
|
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseOneTableName( OSQLTables& _rTables,const OSQLParseNode * pTableName, const ::rtl::OUString & rTableRange )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOneTableName" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( ( m_pImpl->m_nIncludeMask & TableNames ) != TableNames )
|
|
|
|
// tables should not be included in the traversal
|
|
|
|
return;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-03-21 12:52:43 +00:00
|
|
|
OSL_ENSURE(pTableName != NULL,"OSQLParseTreeIterator::traverseOneTableName: pTableName == NULL");
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2001-01-09 12:11:07 +00:00
|
|
|
Any aCatalog;
|
|
|
|
::rtl::OUString aSchema,aTableName,aComposedName;
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aTableRange(rTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Tabellenname abholen
|
2009-09-08 09:50:48 +00:00
|
|
|
OSQLParseNode::getTableComponents(pTableName,aCatalog,aSchema,aTableName,m_pImpl->m_xDatabaseMetaData);
|
2001-01-09 12:11:07 +00:00
|
|
|
|
|
|
|
// create the composed name like DOMAIN.USER.TABLE1
|
2006-07-10 13:38:34 +00:00
|
|
|
aComposedName = ::dbtools::composeTableName(m_pImpl->m_xDatabaseMetaData,
|
2001-01-09 12:11:07 +00:00
|
|
|
aCatalog.hasValue() ? ::comphelper::getString(aCatalog) : ::rtl::OUString(),
|
|
|
|
aSchema,
|
|
|
|
aTableName,
|
2002-10-07 12:09:48 +00:00
|
|
|
sal_False,
|
|
|
|
::dbtools::eInDataManipulation);
|
2006-07-10 13:38:34 +00:00
|
|
|
|
2001-01-09 12:11:07 +00:00
|
|
|
// if there is no alias for the table name assign the orignal name to it
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !aTableRange.getLength() )
|
2001-01-09 12:11:07 +00:00
|
|
|
aTableRange = aComposedName;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
// get the object representing this table/query
|
|
|
|
OSQLTable aTable = impl_locateRecordSource( aComposedName );
|
|
|
|
if ( aTable.is() )
|
|
|
|
_rTables[ aTableRange ] = aTable;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
void OSQLParseTreeIterator::getQualified_join( OSQLTables& _rTables, const OSQLParseNode *pTableRef, ::rtl::OUString& aTableRange )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getQualified_join" );
|
2008-06-16 11:11:56 +00:00
|
|
|
OSL_PRECOND( SQL_ISRULE( pTableRef, cross_union ) || SQL_ISRULE( pTableRef, qualified_join ) ,
|
2006-07-10 13:38:34 +00:00
|
|
|
"OSQLParseTreeIterator::getQualified_join: illegal node!" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
|
|
|
aTableRange = ::rtl::OUString();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
const OSQLParseNode* pNode = getTableNode(_rTables,pTableRef->getChild(0),aTableRange);
|
|
|
|
if ( isTableNode( pNode ) )
|
|
|
|
traverseOneTableName( _rTables, pNode, aTableRange );
|
2001-07-19 08:29:22 +00:00
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
sal_uInt32 nPos = 4;
|
2000-09-18 15:18:56 +00:00
|
|
|
if(SQL_ISRULE(pTableRef,cross_union) || pTableRef->getChild(1)->getTokenID() != SQL_TOKEN_NATURAL)
|
|
|
|
nPos = 3;
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
pNode = getTableNode(_rTables,pTableRef->getChild(nPos),aTableRange);
|
|
|
|
if ( isTableNode( pNode ) )
|
|
|
|
traverseOneTableName( _rTables, pNode, aTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-08-04 12:50:09 +00:00
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getTableNode( OSQLTables& _rTables, const OSQLParseNode *pTableRef,::rtl::OUString& rTableRange )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getTableNode" );
|
2008-07-25 06:41:44 +00:00
|
|
|
OSL_PRECOND( SQL_ISRULE( pTableRef, table_ref ) || SQL_ISRULE( pTableRef, joined_table )
|
|
|
|
|| SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( pTableRef, cross_union ),
|
2006-07-10 13:38:34 +00:00
|
|
|
"OSQLParseTreeIterator::getTableNode: only to be called for table_ref nodes!" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
const OSQLParseNode* pTableNameNode = NULL;
|
|
|
|
|
2008-07-25 06:41:44 +00:00
|
|
|
if ( SQL_ISRULE( pTableRef, joined_table ) )
|
|
|
|
{
|
|
|
|
getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
|
|
|
|
}
|
2008-06-16 11:11:56 +00:00
|
|
|
if ( SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( pTableRef, cross_union ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-08-04 12:50:09 +00:00
|
|
|
getQualified_join( _rTables, pTableRef, rTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
else
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2008-06-16 11:11:56 +00:00
|
|
|
rTableRange = OSQLParseNode::getTableRange(pTableRef);
|
2008-07-25 06:41:44 +00:00
|
|
|
if ( ( pTableRef->count() == 4 ) // '{' SQL_TOKEN_OJ joined_table '}'
|
|
|
|
|| ( pTableRef->count() == 5 ) // '(' joined_table ')' range_variable op_column_commalist
|
|
|
|
)
|
2006-07-10 13:38:34 +00:00
|
|
|
{
|
2008-06-16 11:11:56 +00:00
|
|
|
getQualified_join( _rTables, pTableRef->getChild(6 - pTableRef->count()), rTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2008-11-19 17:43:08 +00:00
|
|
|
else if ( pTableRef->count() == 3 ) // subquery range_variable op_column_commalist || '(' joined_table ')'
|
2008-07-25 06:41:44 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
const OSQLParseNode* pSubQuery = pTableRef->getChild(0);
|
2008-11-19 17:43:08 +00:00
|
|
|
if ( pSubQuery->isToken() )
|
2006-07-10 13:38:34 +00:00
|
|
|
{
|
2008-11-19 17:43:08 +00:00
|
|
|
getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-19 17:43:08 +00:00
|
|
|
OSL_ENSURE( pSubQuery->count() == 3, "sub queries should have 3 children!" );
|
|
|
|
const OSQLParseNode* pQueryExpression = pSubQuery->getChild(1);
|
|
|
|
if ( SQL_ISRULE( pQueryExpression, select_statement ) )
|
|
|
|
{
|
|
|
|
getSelect_statement( *m_pImpl->m_pSubTables, pQueryExpression );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: subquery which is no select_statement: not yet implemented!" );
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-25 06:41:44 +00:00
|
|
|
else if ( pTableRef->count() == 2 ) // table_node table_primary_as_range_column
|
2006-08-04 12:50:09 +00:00
|
|
|
{
|
|
|
|
pTableNameNode = pTableRef->getChild(0);
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: unhandled case!" );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
return pTableNameNode;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
void OSQLParseTreeIterator::getSelect_statement(OSQLTables& _rTables,const OSQLParseNode* pSelect)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSelect_statement" );
|
2000-09-18 15:18:56 +00:00
|
|
|
if(SQL_ISRULE(pSelect,union_statement))
|
|
|
|
{
|
2004-09-09 08:04:16 +00:00
|
|
|
getSelect_statement(_rTables,pSelect->getChild(0));
|
2000-09-18 15:18:56 +00:00
|
|
|
//getSelect_statement(pSelect->getChild(3));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
OSQLParseNode * pTableRefCommalist = pSelect->getChild(3)->getChild(0)->getChild(1);
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableRefCommalist != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableRefCommalist,table_ref_commalist),"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
const OSQLParseNode* pTableName = NULL;
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aTableRange;
|
|
|
|
for (sal_uInt32 i = 0; i < pTableRefCommalist->count(); i++)
|
2000-09-18 15:18:56 +00:00
|
|
|
{ // from clause durchlaufen
|
2000-10-19 10:47:14 +00:00
|
|
|
aTableRange = ::rtl::OUString();
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
const OSQLParseNode* pTableListElement = pTableRefCommalist->getChild(i);
|
|
|
|
if ( isTableNode( pTableListElement ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOneTableName( _rTables, pTableListElement, aTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
else if ( SQL_ISRULE( pTableListElement, table_ref ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
// Tabellenreferenz kann aus Tabellennamen, Tabellennamen (+),'('joined_table')'(+) bestehen
|
2006-07-10 13:38:34 +00:00
|
|
|
pTableName = pTableListElement->getChild(0);
|
|
|
|
if( isTableNode( pTableName ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{ // Tabellennamen gefunden
|
2008-06-16 11:11:56 +00:00
|
|
|
aTableRange = OSQLParseNode::getTableRange(pTableListElement);
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOneTableName( _rTables, pTableName, aTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else if(SQL_ISPUNCTUATION(pTableName,"{"))
|
2006-07-10 13:38:34 +00:00
|
|
|
{ // '{' SQL_TOKEN_OJ joined_table '}'
|
|
|
|
getQualified_join( _rTables, pTableListElement->getChild(2), aTableRange );
|
|
|
|
}
|
|
|
|
else
|
2008-06-16 11:11:56 +00:00
|
|
|
{ // '(' joined_table ')' range_variable op_column_commalist
|
2006-07-10 13:38:34 +00:00
|
|
|
getTableNode( _rTables, pTableListElement, aTableRange );
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
else if (SQL_ISRULE( pTableListElement, qualified_join ) || SQL_ISRULE( pTableListElement, cross_union ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
getQualified_join( _rTables, pTableListElement, aTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2008-07-25 06:41:44 +00:00
|
|
|
else if ( SQL_ISRULE( pTableListElement, joined_table ) )
|
|
|
|
{
|
|
|
|
getQualified_join( _rTables, pTableListElement->getChild(1), aTableRange );
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
bool OSQLParseTreeIterator::traverseTableNames(OSQLTables& _rTables)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseTableNames" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( m_pParseTree == NULL )
|
|
|
|
return false;
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OSQLParseNode* pTableName = NULL;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
switch ( m_eStatementType )
|
|
|
|
{
|
|
|
|
case SQL_STATEMENT_SELECT:
|
|
|
|
getSelect_statement( _rTables, m_pParseTree );
|
|
|
|
break;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
case SQL_STATEMENT_CREATE_TABLE:
|
|
|
|
case SQL_STATEMENT_INSERT:
|
|
|
|
case SQL_STATEMENT_DELETE:
|
|
|
|
pTableName = m_pParseTree->getChild(2);
|
|
|
|
break;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
case SQL_STATEMENT_UPDATE:
|
|
|
|
pTableName = m_pParseTree->getChild(1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-06-25 17:34:59 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
if ( pTableName )
|
2004-06-25 17:34:59 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString sTableRange;
|
|
|
|
traverseOneTableName( _rTables, pTableName, sTableRange );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
return !hasErrors();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2002-07-15 11:34:56 +00:00
|
|
|
::rtl::OUString OSQLParseTreeIterator::getColumnAlias(const OSQLParseNode* _pDerivedColumn)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnAlias" );
|
2002-07-15 11:34:56 +00:00
|
|
|
OSL_ENSURE(SQL_ISRULE(_pDerivedColumn,derived_column),"No derived column!");
|
|
|
|
::rtl::OUString sColumnAlias;
|
|
|
|
if(_pDerivedColumn->getChild(1)->count() == 2)
|
|
|
|
sColumnAlias = _pDerivedColumn->getChild(1)->getChild(1)->getTokenValue();
|
|
|
|
else if(!_pDerivedColumn->getChild(1)->isRule())
|
|
|
|
sColumnAlias = _pDerivedColumn->getChild(1)->getTokenValue();
|
|
|
|
return sColumnAlias;
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
2006-12-13 15:24:48 +00:00
|
|
|
void lcl_getColumnRange( const OSQLParseNode* _pColumnRef, const Reference< XConnection >& _rxConnection,
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString& _out_rColumnName, ::rtl::OUString& _out_rTableRange,
|
|
|
|
const OSQLColumns* _pSelectColumns, ::rtl::OUString& _out_rColumnAliasIfPresent )
|
|
|
|
{
|
|
|
|
_out_rColumnName = _out_rTableRange = _out_rColumnAliasIfPresent = ::rtl::OUString();
|
|
|
|
if ( SQL_ISRULE( _pColumnRef, column_ref ) )
|
|
|
|
{
|
|
|
|
if( _pColumnRef->count() > 1 )
|
|
|
|
{
|
|
|
|
for ( sal_Int32 i=0; i<((sal_Int32)_pColumnRef->count())-2; ++i )
|
2006-12-13 15:24:48 +00:00
|
|
|
_pColumnRef->getChild(i)->parseNodeToStr( _out_rTableRange, _rxConnection, NULL, sal_False, sal_False );
|
2006-07-10 13:38:34 +00:00
|
|
|
_out_rColumnName = _pColumnRef->getChild( _pColumnRef->count()-1 )->getChild(0)->getTokenValue();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_out_rColumnName = _pColumnRef->getChild(0)->getTokenValue();
|
|
|
|
|
|
|
|
// look up the column in the select column, to find an possible alias
|
|
|
|
if ( _pSelectColumns )
|
|
|
|
{
|
2008-12-30 13:32:01 +00:00
|
|
|
for ( OSQLColumns::Vector::const_iterator lookupColumn = _pSelectColumns->get().begin();
|
|
|
|
lookupColumn != _pSelectColumns->get().end();
|
2006-07-10 13:38:34 +00:00
|
|
|
++lookupColumn
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xColumn( *lookupColumn );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
::rtl::OUString sName, sTableName;
|
|
|
|
xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_REALNAME ) ) >>= sName;
|
|
|
|
xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TABLENAME ) ) >>= sTableName;
|
|
|
|
if ( sName == _out_rColumnName && sTableName == _out_rTableRange )
|
|
|
|
xColumn->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= _out_rColumnAliasIfPresent;
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec))
|
|
|
|
{ // Funktion
|
2006-12-13 15:24:48 +00:00
|
|
|
_pColumnRef->parseNodeToStr( _out_rColumnName, _rxConnection );
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
else if(_pColumnRef->getNodeType() == SQL_NODE_NAME)
|
|
|
|
_out_rColumnName = _pColumnRef->getTokenValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-15 11:34:56 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString& _rColumnName,
|
2002-07-15 11:34:56 +00:00
|
|
|
::rtl::OUString& _rTableRange) const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString sDummy;
|
2006-12-13 15:24:48 +00:00
|
|
|
lcl_getColumnRange( _pColumnRef, m_pImpl->m_xConnection, _rColumnName, _rTableRange, NULL, sDummy );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
|
|
|
|
::rtl::OUString& _rColumnName,
|
|
|
|
::rtl::OUString& _rTableRange,
|
|
|
|
::rtl::OUString& _out_rColumnAliasIfPresent ) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
|
2006-12-13 15:24:48 +00:00
|
|
|
lcl_getColumnRange( _pColumnRef, m_pImpl->m_xConnection, _rColumnName, _rTableRange, &*m_aSelectColumns, _out_rColumnAliasIfPresent );
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::getColumnRange( const OSQLParseNode* _pColumnRef,
|
2006-12-13 15:24:48 +00:00
|
|
|
const Reference< XConnection >& _rxConnection, ::rtl::OUString& _out_rColumnName, ::rtl::OUString& _out_rTableRange )
|
2006-07-10 13:38:34 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnRange" );
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString sDummy;
|
2006-12-13 15:24:48 +00:00
|
|
|
lcl_getColumnRange( _pColumnRef, _rxConnection, _out_rColumnName, _out_rTableRange, NULL, sDummy );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2000-10-19 10:47:14 +00:00
|
|
|
sal_Bool OSQLParseTreeIterator::getColumnTableRange(const OSQLParseNode* pNode, ::rtl::OUString &rTableRange) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getColumnTableRange" );
|
2000-09-18 15:18:56 +00:00
|
|
|
// Ermitteln ob alle Spalten zu einer Tabelle gehoeren
|
|
|
|
if (SQL_ISRULE(pNode,column_ref))
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aColName, aTableRange;
|
2000-09-18 15:18:56 +00:00
|
|
|
getColumnRange(pNode, aColName, aTableRange);
|
2000-10-19 10:47:14 +00:00
|
|
|
if (!aTableRange.getLength()) // keinen gefunden
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
// dann die Spalte in den Tabellen suchen
|
2006-07-10 13:38:34 +00:00
|
|
|
for (ConstOSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end(); ++aIter)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if (aIter->second.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference< XNameAccess > xColumns = aIter->second->getColumns();
|
2001-01-04 09:59:52 +00:00
|
|
|
if(xColumns->hasByName(aColName))
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2001-01-04 09:59:52 +00:00
|
|
|
Reference< XPropertySet > xColumn;
|
|
|
|
if (xColumns->getByName(aColName) >>= xColumn)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!");
|
|
|
|
aTableRange = aIter->first;
|
|
|
|
break;
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
2000-11-29 09:39:47 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-10-19 10:47:14 +00:00
|
|
|
if (!aTableRange.getLength())
|
|
|
|
return sal_False;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
if (!rTableRange.getLength())
|
2000-09-18 15:18:56 +00:00
|
|
|
rTableRange = aTableRange;
|
|
|
|
else if (rTableRange != aTableRange)
|
2000-10-19 10:47:14 +00:00
|
|
|
return sal_False;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
for (sal_uInt32 i = 0, ncount = pNode->count(); i < ncount; i++)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if (!getColumnTableRange(pNode->getChild(i), rTableRange))
|
2000-10-19 10:47:14 +00:00
|
|
|
return sal_False;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
2000-10-19 10:47:14 +00:00
|
|
|
return sal_True;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 17:34:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseCreateColumns(const OSQLParseNode* pSelectNode)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseCreateColumns" );
|
2004-06-25 17:34:59 +00:00
|
|
|
// aIteratorStatus.Clear();
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
if (!pSelectNode || m_eStatementType != SQL_STATEMENT_CREATE_TABLE || m_pImpl->m_pTables->empty())
|
2004-06-25 17:34:59 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
impl_appendError( IParseContext::ERROR_GENERAL );
|
2004-06-25 17:34:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!SQL_ISRULE(pSelectNode,base_table_element_commalist))
|
|
|
|
return ;
|
|
|
|
|
|
|
|
for (sal_uInt32 i = 0; i < pSelectNode->count(); i++)
|
|
|
|
{
|
|
|
|
OSQLParseNode *pColumnRef = pSelectNode->getChild(i);
|
|
|
|
|
|
|
|
if (SQL_ISRULE(pColumnRef,column_def))
|
|
|
|
{
|
|
|
|
::rtl::OUString aColumnName;
|
|
|
|
::rtl::OUString aTypeName;
|
|
|
|
::rtl::OUString aTableRange;
|
|
|
|
sal_Int32 nType = DataType::VARCHAR;
|
|
|
|
sal_Int32 nLen = 0;
|
|
|
|
aColumnName = pColumnRef->getChild(0)->getTokenValue();
|
|
|
|
|
|
|
|
OSQLParseNode *pDatatype = pColumnRef->getChild(1);
|
|
|
|
if (pDatatype && SQL_ISRULE(pDatatype,data_type))
|
|
|
|
{
|
|
|
|
//data type
|
|
|
|
// 0 | 1| 2 |3
|
|
|
|
//char ( 20 )
|
|
|
|
aTypeName = pDatatype->getChild(0)->getTokenValue();
|
|
|
|
if (pDatatype->count() == 4
|
|
|
|
&& SQL_ISPUNCTUATION(pDatatype->getChild(1), "(")
|
|
|
|
&& SQL_ISPUNCTUATION(pDatatype->getChild(3) , ")") )
|
|
|
|
{
|
|
|
|
nLen = pDatatype->getChild(2)->getTokenValue().toInt32();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(pDatatype && pDatatype->getNodeType() == SQL_NODE_KEYWORD)
|
|
|
|
{
|
|
|
|
aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTypeName.getLength())
|
|
|
|
{
|
|
|
|
//TO DO:Create a new class for create statement to handle field length
|
|
|
|
OParseColumn* pColumn = new OParseColumn(aColumnName,aTypeName,::rtl::OUString(),
|
2006-07-10 13:38:34 +00:00
|
|
|
ColumnValue::NULLABLE_UNKNOWN,0,0,nType,sal_False,sal_False,isCaseSensitive());
|
2004-06-25 17:34:59 +00:00
|
|
|
pColumn->setFunction(sal_False);
|
|
|
|
pColumn->setRealName(aColumnName);
|
|
|
|
|
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aCreateColumns->get().push_back(xCol);
|
2004-06-25 17:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSelectNode)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSelectColumnNames" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( ( m_pImpl->m_nIncludeMask & SelectColumns ) != SelectColumns )
|
|
|
|
return true;
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
if (!pSelectNode || m_eStatementType != SQL_STATEMENT_SELECT || m_pImpl->m_pTables->empty())
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
impl_appendError( IParseContext::ERROR_GENERAL );
|
|
|
|
return false;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(SQL_ISRULE(pSelectNode,union_statement))
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
return traverseSelectColumnNames( pSelectNode->getChild( 0 ) )
|
|
|
|
/*&& traverseSelectColumnNames( pSelectNode->getChild( 3 ) )*/;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2008-08-19 08:17:46 +00:00
|
|
|
static ::rtl::OUString aEmptyString;
|
2000-09-18 15:18:56 +00:00
|
|
|
// nyi: mehr Pruefung auf korrekte Struktur!
|
|
|
|
if (pSelectNode->getChild(2)->isRule() && SQL_ISPUNCTUATION(pSelectNode->getChild(2)->getChild(0),"*"))
|
|
|
|
{
|
|
|
|
// SELECT * ...
|
2003-12-16 11:29:20 +00:00
|
|
|
setSelectColumnName(m_aSelectColumns,::rtl::OUString::createFromAscii("*"), aEmptyString,aEmptyString);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(pSelectNode->getChild(2),scalar_exp_commalist))
|
|
|
|
{
|
2001-01-09 12:11:07 +00:00
|
|
|
// SELECT column[,column] oder SELECT COUNT(*) ...
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pSelection = pSelectNode->getChild(2);
|
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
for (sal_uInt32 i = 0; i < pSelection->count(); i++)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
OSQLParseNode *pColumnRef = pSelection->getChild(i);
|
|
|
|
|
2001-01-09 12:11:07 +00:00
|
|
|
//if (SQL_ISRULE(pColumnRef,select_sublist))
|
|
|
|
if (SQL_ISRULE(pColumnRef,derived_column) &&
|
|
|
|
SQL_ISRULE(pColumnRef->getChild(0),column_ref) &&
|
|
|
|
pColumnRef->getChild(0)->count() == 3 &&
|
|
|
|
SQL_ISPUNCTUATION(pColumnRef->getChild(0)->getChild(2),"*"))
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
// alle Spalten der Tabelle
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aTableRange;
|
2006-12-13 15:24:48 +00:00
|
|
|
pColumnRef->getChild(0)->parseNodeToStr( aTableRange, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2003-12-16 11:29:20 +00:00
|
|
|
setSelectColumnName(m_aSelectColumns,::rtl::OUString::createFromAscii("*"), aEmptyString,aTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
continue;
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(pColumnRef,derived_column))
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aColumnAlias(getColumnAlias(pColumnRef)); // kann leer sein
|
2005-12-21 12:18:40 +00:00
|
|
|
::rtl::OUString sColumnName;
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aTableRange;
|
2003-09-04 07:29:48 +00:00
|
|
|
sal_Int32 nType = DataType::VARCHAR;
|
2000-10-19 10:47:14 +00:00
|
|
|
sal_Bool bFkt(sal_False);
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumnRef = pColumnRef->getChild(0);
|
2004-08-02 16:16:44 +00:00
|
|
|
if (
|
|
|
|
pColumnRef->count() == 3 &&
|
|
|
|
SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
|
|
|
|
SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
|
|
|
|
)
|
|
|
|
pColumnRef = pColumnRef->getChild(1);
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
if (SQL_ISRULE(pColumnRef,column_ref))
|
|
|
|
{
|
2005-12-21 12:18:40 +00:00
|
|
|
getColumnRange(pColumnRef,sColumnName,aTableRange);
|
|
|
|
OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein");
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else /*if (SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec) ||
|
|
|
|
SQL_ISRULE(pColumnRef,position_exp) || SQL_ISRULE(pColumnRef,extract_exp) ||
|
|
|
|
SQL_ISRULE(pColumnRef,length_exp) || SQL_ISRULE(pColumnRef,char_value_fct)||
|
|
|
|
SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term))*/
|
|
|
|
{
|
|
|
|
/* Funktionsaufruf vorhanden */
|
2006-12-13 15:24:48 +00:00
|
|
|
pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_True );
|
2005-12-21 12:18:40 +00:00
|
|
|
::rtl::OUString sTableRange;
|
|
|
|
// check if the column is also a parameter
|
|
|
|
traverseORCriteria(pColumnRef); // num_value_exp
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// gehoeren alle beteiligten Spalten der Funktion zu einer Tabelle
|
2006-07-10 13:38:34 +00:00
|
|
|
if (m_pImpl->m_pTables->size() == 1)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
aTableRange = m_pImpl->m_pTables->begin()->first;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
getColumnTableRange(pColumnRef,aTableRange);
|
|
|
|
}
|
2003-09-04 07:29:48 +00:00
|
|
|
if ( pColumnRef->isRule() )
|
|
|
|
{
|
|
|
|
bFkt = sal_True;
|
|
|
|
if ( SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term) || SQL_ISRULE(pColumnRef,factor) )
|
|
|
|
{
|
|
|
|
nType = DataType::DOUBLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::rtl::OUString sFunctionName;
|
|
|
|
if ( SQL_ISRULE(pColumnRef,length_exp) )
|
2006-07-10 13:38:34 +00:00
|
|
|
pColumnRef->getChild(0)->getChild(0)->parseNodeToStr(
|
2006-12-13 15:24:48 +00:00
|
|
|
sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2003-09-04 07:29:48 +00:00
|
|
|
else
|
2006-07-10 13:38:34 +00:00
|
|
|
pColumnRef->getChild(0)->parseNodeToStr(
|
2006-12-13 15:24:48 +00:00
|
|
|
sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2006-07-10 13:38:34 +00:00
|
|
|
nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
|
2003-09-04 07:29:48 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aIteratorStatus.setStatementTooComplex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
2000-10-19 10:47:14 +00:00
|
|
|
if(!aColumnAlias.getLength())
|
2005-12-21 12:18:40 +00:00
|
|
|
aColumnAlias = sColumnName;
|
|
|
|
setSelectColumnName(m_aSelectColumns,sColumnName,aColumnAlias,aTableRange,bFkt,nType,SQL_ISRULE(pColumnRef,general_set_fct) || SQL_ISRULE(pColumnRef,set_fct_spec));
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
return !hasErrors();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
bool OSQLParseTreeIterator::traverseOrderByColumnNames(const OSQLParseNode* pSelectNode)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOrderByColumnNames" );
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseByColumnNames( pSelectNode, sal_True );
|
|
|
|
return !hasErrors();
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseByColumnNames(const OSQLParseNode* pSelectNode,sal_Bool _bOrder)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseByColumnNames" );
|
2000-09-18 15:18:56 +00:00
|
|
|
// aIteratorStatus.Clear();
|
|
|
|
|
|
|
|
if (pSelectNode == NULL)
|
|
|
|
{
|
|
|
|
//aIteratorStatus.setInvalidStatement();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_eStatementType != SQL_STATEMENT_SELECT)
|
|
|
|
{
|
|
|
|
//aIteratorStatus.setInvalidStatement();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SQL_ISRULE(pSelectNode,union_statement))
|
|
|
|
{
|
2003-12-16 11:29:20 +00:00
|
|
|
traverseByColumnNames(pSelectNode->getChild(0),_bOrder);
|
2000-09-18 15:18:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OSQLParseNode * pTableExp = pSelectNode->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator:table_exp error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
sal_uInt32 nPos = ( _bOrder ? 4 : 2 );
|
|
|
|
|
|
|
|
OSQLParseNode * pOptByClause = pTableExp->getChild(nPos);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pOptByClause != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( pOptByClause->count() == 0 )
|
2000-09-18 15:18:56 +00:00
|
|
|
return;
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pOptByClause->count() == 3,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
OSQLParseNode * pOrderingSpecCommalist = pOptByClause->getChild(2);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pOrderingSpecCommalist != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(!_bOrder || SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OSQLParseTreeIterator:ordering_spec_commalist error in parse tree!");
|
|
|
|
OSL_ENSURE(pOrderingSpecCommalist->count() > 0,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2005-12-21 12:18:40 +00:00
|
|
|
::rtl::OUString sColumnName,aColumnAlias;
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aTableRange;
|
2003-12-16 11:29:20 +00:00
|
|
|
sal_uInt32 nCount = pOrderingSpecCommalist->count();
|
|
|
|
for (sal_uInt32 i = 0; i < nCount; ++i)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2003-12-16 11:29:20 +00:00
|
|
|
OSQLParseNode* pColumnRef = pOrderingSpecCommalist->getChild(i);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pColumnRef != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( _bOrder )
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(SQL_ISRULE(pColumnRef,ordering_spec),"OSQLParseTreeIterator:ordering_spec error in parse tree!");
|
|
|
|
OSL_ENSURE(pColumnRef->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
pColumnRef = pColumnRef->getChild(0);
|
|
|
|
}
|
2000-10-19 10:47:14 +00:00
|
|
|
aTableRange = ::rtl::OUString();
|
2005-12-21 12:18:40 +00:00
|
|
|
sColumnName = ::rtl::OUString();
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( SQL_ISRULE(pColumnRef,column_ref) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
// Column-Name (und TableRange):
|
|
|
|
if(SQL_ISRULE(pColumnRef,column_ref))
|
2005-12-21 12:18:40 +00:00
|
|
|
getColumnRange(pColumnRef,sColumnName,aTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
else // eine Expression
|
2006-12-13 15:24:48 +00:00
|
|
|
pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2005-12-21 12:18:40 +00:00
|
|
|
OSL_ENSURE(sColumnName.getLength(),"sColumnName darf nicht leer sein");
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // here I found a predicate
|
2006-12-13 15:24:48 +00:00
|
|
|
pColumnRef->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pColumnRef != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( _bOrder )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2003-12-16 11:29:20 +00:00
|
|
|
// Ascending/Descending
|
|
|
|
OSQLParseNode * pOptAscDesc = pColumnRef->getParent()->getChild(1);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pOptAscDesc != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
sal_Bool bAscending = pOptAscDesc && SQL_ISTOKEN(pOptAscDesc,ASC);
|
2005-12-21 12:18:40 +00:00
|
|
|
setOrderByColumnName(sColumnName, aTableRange,bAscending);
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
|
|
|
else
|
2005-12-21 12:18:40 +00:00
|
|
|
setGroupByColumnName(sColumnName, aTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-16 11:29:20 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
bool OSQLParseTreeIterator::traverseGroupByColumnNames(const OSQLParseNode* pSelectNode)
|
2003-12-16 11:29:20 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseGroupByColumnNames" );
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseByColumnNames( pSelectNode, sal_False );
|
|
|
|
return !hasErrors();
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
2009-02-18 07:15:37 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
::rtl::OUString lcl_generateParameterName( const OSQLParseNode& _rParentNode, const OSQLParseNode& _rParamNode )
|
|
|
|
{
|
|
|
|
::rtl::OUString sColumnName( RTL_CONSTASCII_USTRINGPARAM( "param" ) );
|
|
|
|
const sal_Int32 nCount = (sal_Int32)_rParentNode.count();
|
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i )
|
|
|
|
{
|
|
|
|
if ( _rParentNode.getChild(i) == &_rParamNode )
|
|
|
|
{
|
|
|
|
sColumnName += ::rtl::OUString::valueOf( i+1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sColumnName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-19 08:17:46 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseParameters(const OSQLParseNode* _pNode)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseParameters" );
|
2008-08-19 08:17:46 +00:00
|
|
|
if ( _pNode == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
::rtl::OUString sColumnName, sTableRange, aColumnAlias;
|
|
|
|
const OSQLParseNode* pParent = _pNode->getParent();
|
|
|
|
if ( pParent != NULL )
|
|
|
|
{
|
|
|
|
if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X
|
|
|
|
{
|
|
|
|
sal_uInt32 nPos = 0;
|
|
|
|
if ( pParent->getChild(nPos) == _pNode )
|
|
|
|
nPos = 2;
|
2009-02-18 07:15:37 +00:00
|
|
|
const OSQLParseNode* pOther = pParent->getChild(nPos);
|
|
|
|
if ( SQL_ISRULE( pOther, column_ref ) )
|
|
|
|
getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
|
|
|
|
else
|
|
|
|
pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2008-08-19 08:17:46 +00:00
|
|
|
} // if ( SQL_ISRULE(pParent,comparison_predicate) ) // x = X
|
|
|
|
else if ( SQL_ISRULE(pParent,like_predicate) )
|
|
|
|
{
|
2009-02-18 07:15:37 +00:00
|
|
|
const OSQLParseNode* pOther = pParent->getChild(0);
|
|
|
|
if ( SQL_ISRULE( pOther, column_ref ) )
|
|
|
|
getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
|
|
|
|
else
|
|
|
|
pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2008-08-19 08:17:46 +00:00
|
|
|
}
|
|
|
|
else if ( SQL_ISRULE(pParent,between_predicate) )
|
|
|
|
{
|
2009-02-18 07:15:37 +00:00
|
|
|
const OSQLParseNode* pOther = pParent->getChild(0);
|
|
|
|
if ( SQL_ISRULE( pOther, column_ref ) )
|
|
|
|
getColumnRange( pOther, sColumnName, sTableRange, aColumnAlias);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pOther->parseNodeToStr( sColumnName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
|
|
|
lcl_generateParameterName( *pParent, *_pNode );
|
|
|
|
}
|
2008-08-19 08:17:46 +00:00
|
|
|
}
|
|
|
|
else if ( pParent->getNodeType() == SQL_NODE_COMMALISTRULE )
|
|
|
|
{
|
2009-02-18 07:15:37 +00:00
|
|
|
lcl_generateParameterName( *pParent, *_pNode );
|
2008-08-19 08:17:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
traverseParameter( _pNode, pParent, sColumnName, sTableRange, aColumnAlias );
|
|
|
|
const sal_uInt32 nCount = _pNode->count();
|
|
|
|
for (sal_uInt32 i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
const OSQLParseNode* pChild = _pNode->getChild(i);
|
|
|
|
traverseParameters( pChild );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
bool OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSelectNode)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSelectionCriteria" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( pSelectNode == NULL )
|
|
|
|
return false;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Parse Tree analysieren (je nach Statement-Typ)
|
|
|
|
// und Zeiger auf WHERE-Klausel setzen:
|
|
|
|
OSQLParseNode * pWhereClause = NULL;
|
|
|
|
|
|
|
|
if (m_eStatementType == SQL_STATEMENT_SELECT)
|
|
|
|
{
|
|
|
|
if(SQL_ISRULE(pSelectNode,union_statement))
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
return traverseSelectionCriteria( pSelectNode->getChild( 0 ) )
|
|
|
|
&& traverseSelectionCriteria( pSelectNode->getChild( 3 ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSelectNode->count() >= 4,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OSQLParseNode * pTableExp = pSelectNode->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
pWhereClause = pTableExp->getChild(1);
|
|
|
|
} else if (SQL_ISRULE(pSelectNode,update_statement_searched)) {
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSelectNode->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
pWhereClause = pSelectNode->getChild(4);
|
|
|
|
} else if (SQL_ISRULE(pSelectNode,delete_statement_searched)) {
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSelectNode->count() == 4,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
pWhereClause = pSelectNode->getChild(3);
|
|
|
|
} else if (SQL_ISRULE(pSelectNode,delete_statement_positioned)) {
|
|
|
|
// nyi
|
2000-10-19 10:47:14 +00:00
|
|
|
OSL_ASSERT("OSQLParseTreeIterator::getSelectionCriteria: positioned nyi");
|
2000-09-18 15:18:56 +00:00
|
|
|
} else {
|
|
|
|
// Anderes Statement. Keine Selektionskriterien.
|
2006-07-10 13:38:34 +00:00
|
|
|
return false;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (! SQL_ISRULE(pWhereClause,where_clause)) {
|
|
|
|
// Die Where Clause ist meistens optional, d. h. es koennte sich auch
|
|
|
|
// um "optional_where_clause" handeln.
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(SQL_ISRULE(pWhereClause,opt_where_clause),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
return false;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Wenn es aber eine where_clause ist, dann darf sie nicht leer sein:
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pWhereClause->count() == 2,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pComparisonPredicate != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Und nun die Vergleichskriterien abarbeiten (rekursiv, alles ist erstmal ein OR-Kriterium):
|
|
|
|
//
|
|
|
|
|
|
|
|
traverseORCriteria(pComparisonPredicate);
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
return !hasErrors();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseORCriteria(OSQLParseNode * pSearchCondition)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseORCriteria" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
pSearchCondition->count() == 3 &&
|
|
|
|
SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
|
|
|
|
SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Runde Klammern um den Ausdruck
|
|
|
|
traverseORCriteria(pSearchCondition->getChild(1));
|
|
|
|
} else if (SQL_ISRULE(pSearchCondition,search_condition) &&
|
|
|
|
pSearchCondition->count() == 3 &&
|
|
|
|
SQL_ISTOKEN(pSearchCondition->getChild(1),OR))
|
|
|
|
{
|
|
|
|
// OR-Verknuepfung:
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (i == 1) continue; // Schluesselwort OR ueberspringen
|
|
|
|
|
|
|
|
// Ist das erste Element wieder eine OR-Verknuepfung?
|
|
|
|
if (i == 0 &&
|
|
|
|
SQL_ISRULE(pSearchCondition->getChild(0),search_condition) &&
|
|
|
|
pSearchCondition->getChild(0)->count() == 3 &&
|
|
|
|
SQL_ISTOKEN(pSearchCondition->getChild(0)->getChild(1),OR))
|
|
|
|
{
|
|
|
|
// Dann rekursiv absteigen ...
|
|
|
|
traverseORCriteria(pSearchCondition->getChild(0));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// AND-Kriterien ...
|
|
|
|
traverseANDCriteria(pSearchCondition->getChild(i));
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Nur *ein* Kriterium oder eine AND-Verknuepfung von Kriterien.
|
|
|
|
// Direkt die AND-Kriterien behandeln.
|
|
|
|
traverseANDCriteria(pSearchCondition);
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fehler einfach weiterreichen.
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseANDCriteria(OSQLParseNode * pSearchCondition)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseANDCriteria" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
SQL_ISRULE(pSearchCondition,boolean_primary) &&
|
|
|
|
pSearchCondition->count() == 3 &&
|
|
|
|
SQL_ISPUNCTUATION(pSearchCondition->getChild(0),"(") &&
|
|
|
|
SQL_ISPUNCTUATION(pSearchCondition->getChild(2),")")
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Runde Klammern
|
|
|
|
traverseANDCriteria(pSearchCondition->getChild(1));
|
|
|
|
}
|
|
|
|
// Das erste Element ist eine OR-Verknuepfung
|
|
|
|
else if ( SQL_ISRULE(pSearchCondition,search_condition) && pSearchCondition->count() == 3 )
|
|
|
|
{
|
|
|
|
// Dann rekursiv absteigen (dieselbe Row benutzen) ...
|
|
|
|
traverseORCriteria(pSearchCondition->getChild(0));
|
|
|
|
// if (! aIteratorStatus.IsSuccessful())
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// Und mit dem rechten Child weitermachen:
|
|
|
|
traverseANDCriteria(pSearchCondition->getChild(2));
|
|
|
|
}
|
|
|
|
// Das erste Element ist (wieder) eine AND-Verknuepfung
|
|
|
|
else if ( SQL_ISRULE(pSearchCondition,boolean_term) && pSearchCondition->count() == 3 )
|
|
|
|
{
|
|
|
|
// Dann rekursiv absteigen (dieselbe Row benutzen) ...
|
|
|
|
traverseANDCriteria(pSearchCondition->getChild(0));
|
|
|
|
// if (! aIteratorStatus.IsSuccessful())
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// Und mit dem rechten Child weitermachen:
|
|
|
|
traverseANDCriteria(pSearchCondition->getChild(2));
|
|
|
|
}
|
|
|
|
// Sonst einzelne Suchkriterien wie =, !=, ..., LIKE, IS NULL usw. behandeln:
|
|
|
|
else if (SQL_ISRULE(pSearchCondition,comparison_predicate) )
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aValue;
|
2006-12-13 15:24:48 +00:00
|
|
|
pSearchCondition->getChild(2)->parseNodeToStr( aValue, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOnePredicate(pSearchCondition->getChild(0),aValue,pSearchCondition->getChild(2));
|
2000-09-18 15:18:56 +00:00
|
|
|
// if (! aIteratorStatus.IsSuccessful())
|
|
|
|
// return;
|
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(pSearchCondition,like_predicate) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/)
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSearchCondition->count() >= 4,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-09-29 14:13:06 +00:00
|
|
|
sal_Int32 nCurentPos = pSearchCondition->count()-2;
|
|
|
|
|
|
|
|
OSQLParseNode * pNum_value_exp = pSearchCondition->getChild(nCurentPos);
|
|
|
|
OSQLParseNode * pOptEscape = pSearchCondition->getChild(nCurentPos+1);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pNum_value_exp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pOptEscape != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
if (pOptEscape->count() != 0)
|
|
|
|
{
|
|
|
|
// aIteratorStatus.setStatementTooComplex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aValue;
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pParam = NULL;
|
|
|
|
if (SQL_ISRULE(pNum_value_exp,parameter))
|
|
|
|
pParam = pNum_value_exp;
|
|
|
|
else if(pNum_value_exp->isToken())
|
|
|
|
// Normaler Wert
|
|
|
|
aValue = pNum_value_exp->getTokenValue();
|
|
|
|
else
|
|
|
|
{
|
2006-12-13 15:24:48 +00:00
|
|
|
pNum_value_exp->parseNodeToStr( aValue, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2000-09-18 15:18:56 +00:00
|
|
|
pParam = pNum_value_exp;
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOnePredicate(pSearchCondition->getChild(0),aValue,pParam);
|
2000-09-18 15:18:56 +00:00
|
|
|
// if (! aIteratorStatus.IsSuccessful())
|
|
|
|
// return;
|
|
|
|
}
|
2004-08-02 16:16:44 +00:00
|
|
|
else if (SQL_ISRULE(pSearchCondition,in_predicate))
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSearchCondition->count() == 4,"OSQLParseTreeIterator: error in parse tree!");
|
2004-08-02 16:16:44 +00:00
|
|
|
|
|
|
|
traverseORCriteria(pSearchCondition->getChild(0));
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) return;
|
|
|
|
|
|
|
|
OSQLParseNode* pChild = pSearchCondition->getChild(3);
|
|
|
|
if ( SQL_ISRULE(pChild->getChild(0),subquery) )
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseTableNames( *m_pImpl->m_pSubTables );
|
2004-08-02 16:16:44 +00:00
|
|
|
traverseSelectionCriteria(pChild->getChild(0)->getChild(1));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // '(' value_exp_commalist ')'
|
|
|
|
pChild = pChild->getChild(1);
|
|
|
|
sal_Int32 nCount = pChild->count();
|
|
|
|
for (sal_Int32 i=0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
traverseANDCriteria(pChild->getChild(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
else if (SQL_ISRULE(pSearchCondition,test_for_null) /*&& SQL_ISRULE(pSearchCondition->getChild(0),column_ref)*/)
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pSearchCondition->count() >= 3,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISTOKEN(pSearchCondition->getChild(1),IS),"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aString;
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOnePredicate(pSearchCondition->getChild(0),aString,NULL);
|
2000-09-18 15:18:56 +00:00
|
|
|
// if (! aIteratorStatus.IsSuccessful()) return;
|
2001-04-30 08:59:56 +00:00
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(pSearchCondition,num_value_exp) || SQL_ISRULE(pSearchCondition,term))
|
|
|
|
{
|
|
|
|
::rtl::OUString aString;
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseOnePredicate(pSearchCondition->getChild(0),aString,pSearchCondition->getChild(0));
|
|
|
|
traverseOnePredicate(pSearchCondition->getChild(2),aString,pSearchCondition->getChild(2));
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// Fehler einfach weiterreichen.
|
|
|
|
}
|
2005-12-21 12:18:40 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2008-08-19 08:17:46 +00:00
|
|
|
void OSQLParseTreeIterator::traverseParameter(const OSQLParseNode* _pParseNode
|
|
|
|
,const OSQLParseNode* _pColumnRef
|
2005-12-21 12:18:40 +00:00
|
|
|
,const ::rtl::OUString& _aColumnName
|
2006-07-10 13:38:34 +00:00
|
|
|
,const ::rtl::OUString& _aTableRange
|
|
|
|
,const ::rtl::OUString& _rColumnAlias)
|
2005-12-21 12:18:40 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseParameter" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !SQL_ISRULE( _pParseNode, parameter ) )
|
|
|
|
return;
|
2005-12-21 12:18:40 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( ( m_pImpl->m_nIncludeMask & Parameters ) != Parameters )
|
|
|
|
// parameters not to be included in the traversal
|
|
|
|
return;
|
|
|
|
|
|
|
|
OSL_ENSURE(_pParseNode->count() > 0,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSQLParseNode * pMark = _pParseNode->getChild(0);
|
|
|
|
::rtl::OUString sParameterName;
|
|
|
|
|
|
|
|
if (SQL_ISPUNCTUATION(pMark,"?"))
|
|
|
|
{
|
|
|
|
sParameterName = _rColumnAlias.getLength()
|
|
|
|
? _rColumnAlias
|
|
|
|
: _aColumnName.getLength()
|
|
|
|
? _aColumnName
|
|
|
|
: ::rtl::OUString::createFromAscii("?");
|
|
|
|
}
|
|
|
|
else if (SQL_ISPUNCTUATION(pMark,":"))
|
|
|
|
{
|
|
|
|
sParameterName = _pParseNode->getChild(1)->getTokenValue();
|
|
|
|
}
|
|
|
|
else if (SQL_ISPUNCTUATION(pMark,"["))
|
|
|
|
{
|
|
|
|
sParameterName = _pParseNode->getChild(1)->getTokenValue();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSL_ASSERT("OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
}
|
|
|
|
|
|
|
|
// found a parameter
|
|
|
|
if ( _pColumnRef && (SQL_ISRULE(_pColumnRef,general_set_fct) || SQL_ISRULE(_pColumnRef,set_fct_spec)) )
|
|
|
|
{// found a function as column_ref
|
|
|
|
::rtl::OUString sFunctionName;
|
2006-12-13 15:24:48 +00:00
|
|
|
_pColumnRef->getChild(0)->parseNodeToStr( sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False );
|
2006-07-10 13:38:34 +00:00
|
|
|
sal_Int32 nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() );
|
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn( sParameterName,
|
|
|
|
::rtl::OUString(),
|
|
|
|
::rtl::OUString(),
|
|
|
|
ColumnValue::NULLABLE_UNKNOWN,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
nType,
|
|
|
|
sal_False,
|
|
|
|
sal_False,
|
|
|
|
isCaseSensitive());
|
|
|
|
pColumn->setFunction(sal_True);
|
|
|
|
pColumn->setAggregateFunction(sal_True);
|
|
|
|
pColumn->setRealName(sFunctionName);
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aParameters->get().push_back(pColumn);
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Bool bNotFound = sal_True;
|
2008-12-30 13:32:01 +00:00
|
|
|
OSQLColumns::Vector::const_iterator aIter = ::connectivity::find(
|
|
|
|
m_aSelectColumns->get().begin(),
|
|
|
|
m_aSelectColumns->get().end(),
|
2006-07-10 13:38:34 +00:00
|
|
|
_aColumnName,::comphelper::UStringMixEqual( isCaseSensitive() )
|
|
|
|
);
|
2008-12-30 13:32:01 +00:00
|
|
|
if(aIter != m_aSelectColumns->get().end())
|
2005-12-21 12:18:40 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OParseColumn* pNewColumn = new OParseColumn(*aIter,isCaseSensitive());
|
|
|
|
pNewColumn->setName(sParameterName);
|
|
|
|
pNewColumn->setRealName(_aColumnName);
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aParameters->get().push_back(pNewColumn);
|
2006-07-10 13:38:34 +00:00
|
|
|
bNotFound = sal_False;
|
2005-12-21 12:18:40 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
else if(_aColumnName.getLength())// search in the tables for the right one
|
2005-12-21 12:18:40 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
Reference<XPropertySet> xColumn = findColumn( _aColumnName, _aTableRange, true );
|
|
|
|
|
|
|
|
if ( xColumn.is() )
|
2005-12-21 12:18:40 +00:00
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OParseColumn* pNewColumn = new OParseColumn(xColumn,isCaseSensitive());
|
|
|
|
pNewColumn->setName(sParameterName);
|
2005-12-21 12:18:40 +00:00
|
|
|
pNewColumn->setRealName(_aColumnName);
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aParameters->get().push_back(pNewColumn);
|
2005-12-21 12:18:40 +00:00
|
|
|
bNotFound = sal_False;
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
if ( bNotFound )
|
|
|
|
{
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
sal_Int32 nType = DataType::VARCHAR;
|
|
|
|
OSQLParseNode* pParent = _pColumnRef ? _pColumnRef->getParent() : NULL;
|
|
|
|
if ( pParent && (SQL_ISRULE(pParent,general_set_fct) || SQL_ISRULE(pParent,set_fct_spec)) )
|
|
|
|
{
|
|
|
|
const sal_uInt32 nCount = _pColumnRef->count();
|
|
|
|
sal_uInt32 i = 0;
|
|
|
|
for(; i < nCount;++i)
|
|
|
|
{
|
|
|
|
if ( _pColumnRef->getChild(i) == _pParseNode )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nType = ::connectivity::OSQLParser::getFunctionParameterType( pParent->getChild(0)->getTokenID(), i+1);
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString aNewColName( getUniqueColumnName( sParameterName ) );
|
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn(aNewColName,
|
|
|
|
::rtl::OUString(),
|
|
|
|
::rtl::OUString(),
|
|
|
|
ColumnValue::NULLABLE_UNKNOWN,
|
|
|
|
0,
|
|
|
|
0,
|
CWS-TOOLING: integrate CWS dba32c
2009-06-29 20:53:25 +0200 fs r273484 : #i103138# Rectangle conversion
2009-06-29 20:51:50 +0200 fs r273483 : #i103138# yet more refactoring, now also setting the proper zoom level at the proper point in time
2009-06-29 13:40:26 +0200 fs r273470 : added svn:ignore to ignore output paths
2009-06-29 10:08:54 +0200 fs r273455 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-25 13:41:35 +0200 msc r273380 : #100000# the tabs changed die to new properties
2009-06-24 12:42:40 +0200 msc r273330 : #102082# remove issue warning
2009-06-22 10:43:14 +0200 fs r273201 : createPrimitive2DSequence: care for being disposed
2009-06-18 12:35:13 +0200 oj r273109 : #i102305# make nooptfiles for gcc
2009-06-17 12:14:37 +0200 oj r273056 : #i102305# fix for linux
2009-06-17 07:20:22 +0200 oj r273046 : #i102305# move ValueTransfer into the for loop to avoid a crash under Linux
2009-06-17 07:17:28 +0200 oj r273045 : #i102305# use varchar
2009-06-15 14:11:27 +0200 fs r272983 : added since tag
2009-06-15 12:11:39 +0200 oj r272973 : #i102305# SAL_DLLPUBLIC_EXPORT inserted
2009-06-15 11:08:53 +0200 fs r272969 : #i10000#
2009-06-15 09:25:13 +0200 fs r272963 : merging fix for P1 issue #i102701#
2009-06-11 11:31:24 +0200 fs r272858 : #i10000# copied the fix which before the rebase was done in ../dialog/macropg.src
2009-06-11 09:38:14 +0200 fs r272846 : CWS-TOOLING: rebase CWS dba32c to trunk@272827 (milestone: DEV300:m50)
2009-06-02 09:53:10 +0200 fs r272483 : #i10000#
2009-05-29 15:55:03 +0200 fs r272465 : #i100818#
2009-05-29 12:58:43 +0200 fs r272452 : don't apply comphelper::getString on possibly VOID any
2009-05-29 10:38:35 +0200 oj r272437 : #i101519# handle where condition
2009-05-29 09:53:39 +0200 fs r272434 : #i100818# call into releaseStubs /without/ locked GlobalMutex
2009-05-28 07:53:44 +0200 oj r272375 : #i101369# parse tree changed
2009-05-27 14:53:36 +0200 fs r272347 : #i10000#
2009-05-27 09:29:15 +0200 oj r272327 : #i101626# check for double before hard cast
2009-05-27 09:13:58 +0200 oj r272326 : #i101626# handle void correctly
2009-05-27 08:04:39 +0200 oj r272321 : #i102256# wrong method signature used
2009-05-27 07:55:52 +0200 oj r272320 : #i101519# look up parameter typ if used in function
2009-05-27 06:49:07 +0200 oj r272319 : #i101519# set parameter from rowset as well
2009-05-26 13:30:56 +0200 oj r272297 : #i101987# impl XBatchExecution
2009-05-26 12:44:34 +0200 oj r272293 : #i101700# check if group is not set
2009-05-26 12:16:53 +0200 oj r272290 : #i101369# resolved some reduce7reduce problems with boolean_term and search_condition
2009-05-26 12:12:42 +0200 oj r272289 : #i101369# fix for or on one line criteria
2009-05-25 16:02:25 +0200 fs r272257 : #i999704# +PROPERTY_MOUSE_WHEEL_BEHAVIOR
2009-05-25 16:01:55 +0200 fs r272256 : merging the changes from CWS dba32b herein
2009-05-25 15:49:57 +0200 fs r272254 : #i999704#
2009-05-25 15:32:57 +0200 fs r272252 : #i99704# grid columns also to respect the MouseWheelBehavior property
2009-05-25 15:23:43 +0200 fs r272251 : don't pass empty Anys to ::comphelper::getString
2009-05-25 14:48:43 +0200 fs r272248 : merged changes from CWS dba32b herein
2009-05-25 14:44:40 +0200 fs r272247 : #i99704# support new MouseWheelBehavior property
2009-05-25 14:43:18 +0200 fs r272246 : #i99704# WheelWithoutFocus (peer property) superseded by MouseWheelBehavior (model property)
2009-05-25 14:41:03 +0200 fs r272245 : #i99704# no need to set the mouse wheel behavior at the peer, this is now a model property, having the right default
2009-05-25 14:39:31 +0200 fs r272243 : removed dead import
2009-05-25 14:35:36 +0200 fs r272242 : the new EnableVisible doesn't make sense for grid columns
2009-05-25 14:34:33 +0200 fs r272241 : #i99704# +MouseWheelBehavior - allow to enable/disable the mouse wheel for the control, or make it focus-dependent
2009-05-25 14:26:11 +0200 fs r272240 : #i99704# change MouseSettings wheel flag (NoWheelActionWithoutFocus) to a three-state option, allowing to completely ignore the mouse wheel
2009-05-23 21:35:59 +0200 fs r272213 : localize 'sub component opened/closed' event
2009-05-22 21:42:47 +0200 fs r272211 : #i102003#
2009-05-22 21:42:20 +0200 fs r272210 : grammar
2009-05-22 21:36:10 +0200 fs r272209 : #i102140# load only once, not twice, and show error messages during loading (and during any form action, that is) asynchronously
2009-05-22 21:35:11 +0200 fs r272208 : #i102140# +clear
2009-05-22 14:50:30 +0200 fs r272194 : #i102139# for newly created DB docs, set the MacroExecutionMode to USE_CONFIG
2009-05-22 12:03:42 +0200 fs r272180 : #i88878#
provided by noel.power@novell.com
implement a visibility property (EnableVisible) for toolkit controls, and usage in forms and UNO dialogs
2009-05-15 15:37:31 +0200 fs r271942 : #i100671# corrected some @since tags, so autodoc has better chances of correctly reading them
2009-05-15 15:33:11 +0200 fs r271940 : don't call comphelper::getFOO for VOID values
2009-05-15 15:08:31 +0200 fs r271937 : includes
2009-05-15 13:39:22 +0200 fs r271934 : #i101398# createPrimitive2DSequence: when we already have a control, use the old code. In particular, call positionControlForPaint
2009-05-15 12:33:48 +0200 fs r271933 : make the geometry a part of the ControlPrimitive2D's identity
2009-05-15 10:15:44 +0200 fs r271928 : #i10000#
2009-05-14 20:55:38 +0200 fs r271921 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:55:31 +0200 fs r271920 : #i101398# don't reuse the name PRIMITIVE_ID_CONTROLPRIMITIVE2D, make the name of our own ControlPrimitive2D unique
2009-05-14 20:23:23 +0200 fs r271919 : #i101622#
2009-05-14 16:04:38 +0200 fs r271898 : don't use comphelper::getInt32 on voids
2009-05-14 16:04:12 +0200 fs r271897 : merge fix for issue whose number just slipped my memory ... (originally fixed in CWS dba32b)
2009-05-14 15:36:55 +0200 fs r271895 : merging changes from DEV300:m48
2009-05-07 14:43:19 +0200 fs r271670 : #i101477#
2009-05-07 14:37:30 +0200 fs r271668 : #i101477#
2009-05-07 09:27:30 +0200 oj r271628 : #i101343# remove pch
2009-05-06 09:36:02 +0200 fs r271568 : getFoo: diagnostics
2009-05-04 09:23:06 +0200 oj r271438 : CWS-TOOLING: rebase CWS dba32c to trunk@271427 (milestone: DEV300:m47)
2009-04-29 23:18:13 +0200 fs r271394 : #i101398# use a dedicated 2DPrimitive for UNO Controls, which is able to provide the B2DRange *without* actually creating the control
2009-04-29 13:52:25 +0200 fs r271366 : #i101308#
2009-07-03 14:21:50 +00:00
|
|
|
nType,
|
2006-07-10 13:38:34 +00:00
|
|
|
sal_False,
|
|
|
|
sal_False,
|
|
|
|
isCaseSensitive() );
|
|
|
|
pColumn->setName(aNewColName);
|
|
|
|
pColumn->setRealName(sParameterName);
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aParameters->get().push_back(pColumn);
|
2005-12-21 12:18:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseOnePredicate(
|
|
|
|
OSQLParseNode * pColumnRef,
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString& rValue,
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pParseNode)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseOnePredicate" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !pParseNode )
|
|
|
|
return;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Column-Name (und TableRange):
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString aColumnName, aTableRange, sColumnAlias;
|
|
|
|
getColumnRange( pColumnRef, aColumnName, aTableRange, sColumnAlias);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aName;
|
2001-04-30 08:59:56 +00:00
|
|
|
|
2008-08-19 08:17:46 +00:00
|
|
|
/*if (SQL_ISRULE(pParseNode,parameter))
|
2006-07-10 13:38:34 +00:00
|
|
|
traverseParameter( pParseNode, pColumnRef, aColumnName, aTableRange, sColumnAlias );
|
2008-08-19 08:17:46 +00:00
|
|
|
else */if (SQL_ISRULE(pParseNode,column_ref))// Column-Name (und TableRange):
|
2006-07-10 13:38:34 +00:00
|
|
|
getColumnRange(pParseNode,aName,rValue);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
traverseORCriteria(pParseNode);
|
|
|
|
// if (! aIteratorStatus.IsSuccessful()) return;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
void OSQLParseTreeIterator::traverseSome( sal_uInt32 _nIncludeMask )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseSome" );
|
2006-07-10 13:38:34 +00:00
|
|
|
impl_traverse( _nIncludeMask );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::traverseAll()
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::traverseAll" );
|
2006-07-10 13:38:34 +00:00
|
|
|
impl_traverse( All );
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_traverse" );
|
2006-07-10 13:38:34 +00:00
|
|
|
impl_resetErrors();
|
|
|
|
m_pImpl->m_nIncludeMask = _nIncludeMask;
|
|
|
|
|
|
|
|
if ( !traverseTableNames( *m_pImpl->m_pTables ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch ( m_eStatementType )
|
|
|
|
{
|
|
|
|
case SQL_STATEMENT_SELECT:
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
const OSQLParseNode* pSelectNode = m_pParseTree;
|
2008-08-19 08:17:46 +00:00
|
|
|
traverseParameters( pSelectNode );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( !traverseSelectColumnNames( pSelectNode )
|
|
|
|
|| !traverseOrderByColumnNames( pSelectNode )
|
|
|
|
|| !traverseGroupByColumnNames( pSelectNode )
|
|
|
|
|| !traverseSelectionCriteria( pSelectNode )
|
|
|
|
)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SQL_STATEMENT_CREATE_TABLE:
|
|
|
|
{
|
2004-06-25 17:34:59 +00:00
|
|
|
//0 | 1 | 2 |3| 4 |5
|
|
|
|
//create table sc.foo ( a char(20), b char )
|
|
|
|
const OSQLParseNode* pCreateNode = m_pParseTree->getChild(4);
|
|
|
|
traverseCreateColumns(pCreateNode);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
break;
|
2007-09-26 13:31:52 +00:00
|
|
|
case SQL_STATEMENT_INSERT:
|
|
|
|
break;
|
2006-07-10 13:38:34 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy-Implementationen:
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
OSQLTable OSQLParseTreeIterator::impl_createTableObject( const ::rtl::OUString& rTableName,
|
|
|
|
const ::rtl::OUString& rCatalogName, const ::rtl::OUString& rSchemaName )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_createTableObject" );
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_PRECOND( m_eStatementType == SQL_STATEMENT_CREATE_TABLE,
|
|
|
|
"OSQLParseTreeIterator::impl_createTableObject: only to be called for CREATE TABLE statements!" );
|
|
|
|
// (in all other cases, m_pTables is to contain the table objects as obtained from the tables
|
|
|
|
// container of the connection (m_xTablesContainer)
|
|
|
|
|
|
|
|
OSQLTable aReturnTable = new OTable(
|
|
|
|
NULL,
|
|
|
|
sal_False,
|
|
|
|
rTableName,
|
|
|
|
::rtl::OUString::createFromAscii("Table"),
|
|
|
|
::rtl::OUString::createFromAscii("New Created Table"),
|
|
|
|
rSchemaName,
|
|
|
|
rCatalogName
|
|
|
|
);
|
|
|
|
return aReturnTable;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2003-12-16 11:29:20 +00:00
|
|
|
void OSQLParseTreeIterator::appendColumns(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString& _rTableAlias,const OSQLTable& _rTable)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::appendColumns" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
if (!_rTable.is())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Reference<XNameAccess> xColumns = _rTable->getColumns();
|
2003-08-18 13:47:14 +00:00
|
|
|
if ( !xColumns.is() )
|
|
|
|
return;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
Sequence< ::rtl::OUString > aColNames = xColumns->getElementNames();
|
|
|
|
const ::rtl::OUString* pBegin = aColNames.getConstArray();
|
|
|
|
const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
|
|
|
|
|
|
|
|
for(;pBegin != pEnd;++pBegin)
|
|
|
|
{
|
2001-02-01 12:10:17 +00:00
|
|
|
|
|
|
|
::rtl::OUString aName(getUniqueColumnName(*pBegin));
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet > xColumn;
|
2001-01-04 09:59:52 +00:00
|
|
|
if(xColumns->hasByName(*pBegin) && (xColumns->getByName(*pBegin) >>= xColumn) && xColumn.is())
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2001-02-01 12:10:17 +00:00
|
|
|
OParseColumn* pColumn = new OParseColumn(aName
|
2001-05-14 10:42:44 +00:00
|
|
|
, getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
|
|
|
|
, getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))
|
|
|
|
, getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
|
|
|
|
, getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
|
|
|
|
, getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
|
|
|
|
, 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)))
|
2006-07-10 13:38:34 +00:00
|
|
|
, isCaseSensitive() );
|
2001-02-01 12:10:17 +00:00
|
|
|
|
|
|
|
pColumn->setTableName(_rTableAlias);
|
|
|
|
pColumn->setRealName(*pBegin);
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back(xCol);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
else
|
|
|
|
impl_appendError( IParseContext::ERROR_INVALID_COLUMN, pBegin, &_rTableAlias );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-10-22 07:45:49 +00:00
|
|
|
void OSQLParseTreeIterator::setSelectColumnName(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString & rColumnName,const ::rtl::OUString & rColumnAlias, const ::rtl::OUString & rTableRange,sal_Bool bFkt,sal_Int32 _nType,sal_Bool bAggFkt)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setSelectColumnName" );
|
2000-10-19 10:47:14 +00:00
|
|
|
if(rColumnName.toChar() == '*' && !rTableRange.getLength())
|
2006-08-22 11:51:42 +00:00
|
|
|
{ // SELECT * ...
|
2003-12-16 11:29:20 +00:00
|
|
|
OSL_ENSURE(_rColumns == m_aSelectColumns,"Invalid columns used here!");
|
2006-07-10 13:38:34 +00:00
|
|
|
for(ConstOSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end();++aIter)
|
2003-12-16 11:29:20 +00:00
|
|
|
appendColumns(_rColumns,aIter->first,aIter->second);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-08-22 11:51:42 +00:00
|
|
|
else if( rColumnName.toChar() == '*' && rTableRange.getLength() )
|
|
|
|
{ // SELECT <table>.*
|
2003-12-16 11:29:20 +00:00
|
|
|
OSL_ENSURE(_rColumns == m_aSelectColumns,"Invalid columns used here!");
|
2006-07-10 13:38:34 +00:00
|
|
|
ConstOSQLTablesIterator aFind = m_pImpl->m_pTables->find(rTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2009-09-08 09:50:48 +00:00
|
|
|
if(aFind != m_pImpl->m_pTables->end())
|
2003-12-16 11:29:20 +00:00
|
|
|
appendColumns(_rColumns,rTableRange,aFind->second);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-08-22 11:51:42 +00:00
|
|
|
else if ( !rTableRange.getLength() )
|
|
|
|
{ // SELECT <something> ...
|
|
|
|
// without table specified
|
|
|
|
if ( !bFkt )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-08-22 11:51:42 +00:00
|
|
|
Reference< XPropertySet> xNewColumn;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-08-22 11:51:42 +00:00
|
|
|
for ( OSQLTablesIterator aIter = m_pImpl->m_pTables->begin(); aIter != m_pImpl->m_pTables->end(); ++aIter )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-08-22 11:51:42 +00:00
|
|
|
if ( !aIter->second.is() )
|
|
|
|
continue;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-08-22 11:51:42 +00:00
|
|
|
Reference<XNameAccess> xColumns = aIter->second->getColumns();
|
|
|
|
Reference< XPropertySet > xColumn;
|
|
|
|
if ( !xColumns->hasByName( rColumnName )
|
|
|
|
|| !( xColumns->getByName( rColumnName ) >>= xColumn )
|
|
|
|
)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
|
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn(xColumn,isCaseSensitive());
|
|
|
|
xNewColumn = pColumn;
|
|
|
|
pColumn->setTableName(aIter->first);
|
|
|
|
pColumn->setName(aNewColName);
|
|
|
|
pColumn->setRealName(rColumnName);
|
|
|
|
|
|
|
|
break;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-08-22 11:51:42 +00:00
|
|
|
|
|
|
|
if ( !xNewColumn.is() )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-08-22 11:51:42 +00:00
|
|
|
// no function (due to the above !bFkt), no existing column
|
|
|
|
// => assume an expression
|
|
|
|
::rtl::OUString aNewColName( getUniqueColumnName( rColumnAlias ) );
|
|
|
|
// did not find a column with this name in any of the tables
|
|
|
|
OParseColumn* pColumn = new OParseColumn(
|
|
|
|
aNewColName,
|
|
|
|
::rtl::OUString::createFromAscii( "VARCHAR" ),
|
|
|
|
// TODO: does this match with _nType?
|
|
|
|
// Or should be fill this from the getTypeInfo of the connection?
|
|
|
|
::rtl::OUString(),
|
|
|
|
ColumnValue::NULLABLE_UNKNOWN,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
_nType,
|
|
|
|
sal_False,
|
|
|
|
sal_False,
|
|
|
|
isCaseSensitive()
|
|
|
|
);
|
|
|
|
|
|
|
|
xNewColumn = pColumn;
|
|
|
|
pColumn->setRealName( rColumnName );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2006-08-22 11:51:42 +00:00
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back( xNewColumn );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),
|
2006-07-10 13:38:34 +00:00
|
|
|
ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
|
2006-08-22 11:51:42 +00:00
|
|
|
pColumn->setFunction(sal_True);
|
2004-10-22 07:45:49 +00:00
|
|
|
pColumn->setAggregateFunction(bAggFkt);
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumn->setRealName(rColumnName);
|
|
|
|
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back(xCol);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // ColumnName und Tablename vorhanden
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
ConstOSQLTablesIterator aFind = m_pImpl->m_pTables->find(rTableRange);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-10-19 10:47:14 +00:00
|
|
|
sal_Bool bError = sal_False;
|
2006-07-10 13:38:34 +00:00
|
|
|
if (aFind != m_pImpl->m_pTables->end() && aFind->second.is())
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if (bFkt)
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),
|
2006-07-10 13:38:34 +00:00
|
|
|
ColumnValue::NULLABLE_UNKNOWN,0,0,_nType,sal_False,sal_False,isCaseSensitive());
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumn->setFunction(sal_True);
|
2004-10-22 07:45:49 +00:00
|
|
|
pColumn->setAggregateFunction(bAggFkt);
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumn->setRealName(rColumnName);
|
|
|
|
pColumn->setTableName(aFind->first);
|
|
|
|
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back(xCol);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet > xColumn;
|
2001-01-04 09:59:52 +00:00
|
|
|
if (aFind->second->getColumns()->hasByName(rColumnName) && (aFind->second->getColumns()->getByName(rColumnName) >>= xColumn))
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2006-07-10 13:38:34 +00:00
|
|
|
OParseColumn* pColumn = new OParseColumn(xColumn,isCaseSensitive());
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumn->setName(aNewColName);
|
|
|
|
pColumn->setRealName(rColumnName);
|
|
|
|
pColumn->setTableName(aFind->first);
|
|
|
|
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back(xCol);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
2000-10-19 10:47:14 +00:00
|
|
|
bError = sal_True;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2000-10-19 10:47:14 +00:00
|
|
|
bError = sal_True;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Tabelle existiert nicht oder Feld nicht vorhanden
|
|
|
|
if (bError)
|
|
|
|
{
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias));
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(),
|
2006-07-10 13:38:34 +00:00
|
|
|
ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,isCaseSensitive());
|
2000-09-18 15:18:56 +00:00
|
|
|
pColumn->setFunction(sal_True);
|
2004-10-22 07:45:49 +00:00
|
|
|
pColumn->setAggregateFunction(bAggFkt);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2000-10-30 06:47:10 +00:00
|
|
|
Reference< XPropertySet> xCol = pColumn;
|
2008-12-30 13:32:01 +00:00
|
|
|
_rColumns->get().push_back(xCol);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2000-10-19 10:47:14 +00:00
|
|
|
::rtl::OUString OSQLParseTreeIterator::getUniqueColumnName(const ::rtl::OUString & rColumnName) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getUniqueColumnName" );
|
2000-09-18 15:18:56 +00:00
|
|
|
::rtl::OUString aAlias(rColumnName);
|
|
|
|
|
2008-12-30 13:32:01 +00:00
|
|
|
OSQLColumns::Vector::const_iterator aIter = find(
|
|
|
|
m_aSelectColumns->get().begin(),
|
|
|
|
m_aSelectColumns->get().end(),
|
2006-07-10 13:38:34 +00:00
|
|
|
aAlias,
|
|
|
|
::comphelper::UStringMixEqual( isCaseSensitive() )
|
|
|
|
);
|
2000-09-18 15:18:56 +00:00
|
|
|
sal_Int32 i=1;
|
2008-12-30 13:32:01 +00:00
|
|
|
while(aIter != m_aSelectColumns->get().end())
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
(aAlias = rColumnName) += ::rtl::OUString::valueOf(i++);
|
2006-07-10 13:38:34 +00:00
|
|
|
aIter = find(
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aSelectColumns->get().begin(),
|
|
|
|
m_aSelectColumns->get().end(),
|
2006-07-10 13:38:34 +00:00
|
|
|
aAlias,
|
|
|
|
::comphelper::UStringMixEqual( isCaseSensitive() )
|
|
|
|
);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
return aAlias;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
2000-10-19 10:47:14 +00:00
|
|
|
void OSQLParseTreeIterator::setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange,sal_Bool bAscending)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setOrderByColumnName" );
|
2006-07-10 13:38:34 +00:00
|
|
|
Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false );
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( xColumn.is() )
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aOrderColumns->get().push_back(new OOrderColumn(xColumn,isCaseSensitive(),bAscending));
|
2003-12-16 11:29:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Int32 nId = rColumnName.toInt32();
|
2008-12-30 13:32:01 +00:00
|
|
|
if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->get().size()) )
|
|
|
|
m_aOrderColumns->get().push_back(new OOrderColumn((m_aSelectColumns->get())[nId-1],isCaseSensitive(),bAscending));
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
#ifdef SQL_TEST_PARSETREEITERATOR
|
|
|
|
cout << "OSQLParseTreeIterator::setOrderByColumnName: "
|
|
|
|
<< (const char *) rColumnName << ", "
|
|
|
|
<< (const char *) rTableRange << ", "
|
2000-10-19 10:47:14 +00:00
|
|
|
<< (bAscending ? "sal_True" : "sal_False")
|
2000-09-18 15:18:56 +00:00
|
|
|
<< "\n";
|
|
|
|
#endif
|
|
|
|
}
|
2003-12-16 11:29:20 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange)
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::setGroupByColumnName" );
|
2006-07-10 13:38:34 +00:00
|
|
|
Reference<XPropertySet> xColumn = findColumn( rColumnName, rTableRange, false );
|
2003-12-16 11:29:20 +00:00
|
|
|
if ( xColumn.is() )
|
2008-12-30 13:32:01 +00:00
|
|
|
m_aGroupColumns->get().push_back(new OParseColumn(xColumn,isCaseSensitive()));
|
2003-12-16 11:29:20 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Int32 nId = rColumnName.toInt32();
|
2008-12-30 13:32:01 +00:00
|
|
|
if ( nId > 0 && nId < static_cast<sal_Int32>(m_aSelectColumns->get().size()) )
|
|
|
|
m_aGroupColumns->get().push_back(new OParseColumn((m_aSelectColumns->get())[nId-1],isCaseSensitive()));
|
2003-12-16 11:29:20 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
#ifdef SQL_TEST_PARSETREEITERATOR
|
|
|
|
cout << "OSQLParseTreeIterator::setOrderByColumnName: "
|
|
|
|
<< (const char *) rColumnName << ", "
|
|
|
|
<< (const char *) rTableRange << ", "
|
|
|
|
<< (bAscending ? "sal_True" : "sal_False")
|
|
|
|
<< "\n";
|
|
|
|
#endif
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getWhereTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getWhereTree" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
if (!m_pParseTree)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Parse Tree analysieren (je nach Statement-Typ)
|
|
|
|
// und Zeiger auf WHERE-Klausel setzen:
|
|
|
|
OSQLParseNode * pWhereClause = NULL;
|
|
|
|
if(getStatementType() == SQL_STATEMENT_SELECT)
|
|
|
|
{
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
pWhereClause = pTableExp->getChild(1);
|
|
|
|
}
|
|
|
|
else if (SQL_ISRULE(m_pParseTree,update_statement_searched) ||
|
|
|
|
SQL_ISRULE(m_pParseTree,delete_statement_searched))
|
|
|
|
{
|
|
|
|
pWhereClause = m_pParseTree->getChild(m_pParseTree->count()-1);
|
|
|
|
}
|
|
|
|
if(pWhereClause->count() != 2)
|
|
|
|
pWhereClause = NULL;
|
|
|
|
return pWhereClause;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getOrderTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getOrderTree" );
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Parse Tree analysieren (je nach Statement-Typ)
|
|
|
|
// und Zeiger auf ORDER-Klausel setzen:
|
|
|
|
OSQLParseNode * pOrderClause = NULL;
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
pOrderClause = pTableExp->getChild(4);
|
|
|
|
// Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
|
|
|
|
if(pOrderClause->count() != 3)
|
|
|
|
pOrderClause = NULL;
|
|
|
|
return pOrderClause;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getGroupByTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getGroupByTree" );
|
2000-09-18 15:18:56 +00:00
|
|
|
if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Parse Tree analysieren (je nach Statement-Typ)
|
|
|
|
// und Zeiger auf ORDER-Klausel setzen:
|
|
|
|
OSQLParseNode * pGroupClause = NULL;
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2001-10-26 07:04:06 +00:00
|
|
|
pGroupClause = pTableExp->getChild(2);
|
2000-09-18 15:18:56 +00:00
|
|
|
// Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
|
|
|
|
if(pGroupClause->count() != 3)
|
|
|
|
pGroupClause = NULL;
|
|
|
|
return pGroupClause;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const
|
|
|
|
{
|
|
|
|
if (!m_pParseTree || getStatementType() != SQL_STATEMENT_SELECT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// Parse Tree analysieren (je nach Statement-Typ)
|
|
|
|
// und Zeiger auf ORDER-Klausel setzen:
|
|
|
|
OSQLParseNode * pHavingClause = NULL;
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(m_pParseTree->count() >= 4,"ParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
OSQLParseNode * pTableExp = m_pParseTree->getChild(3);
|
2006-07-10 13:38:34 +00:00
|
|
|
OSL_ENSURE(pTableExp != NULL,"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(SQL_ISRULE(pTableExp,table_exp),"OSQLParseTreeIterator: error in parse tree!");
|
|
|
|
OSL_ENSURE(pTableExp->count() == 5,"OSQLParseTreeIterator: error in parse tree!");
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
pHavingClause = pTableExp->getChild(3);
|
|
|
|
// Wenn es aber eine order_by ist, dann darf sie nicht leer sein:
|
|
|
|
if(pHavingClause->count() < 1)
|
|
|
|
pHavingClause = NULL;
|
|
|
|
return pHavingClause;
|
|
|
|
}
|
2001-01-09 12:11:07 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OSQLParseTreeIterator::isTableNode(const OSQLParseNode* _pTableNode) const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::isTableNode" );
|
2001-01-09 12:11:07 +00:00
|
|
|
return _pTableNode && (SQL_ISRULE(_pTableNode,catalog_name) ||
|
|
|
|
SQL_ISRULE(_pTableNode,schema_name) ||
|
|
|
|
SQL_ISRULE(_pTableNode,table_name));
|
|
|
|
}
|
2001-02-23 13:54:11 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2003-12-16 11:29:20 +00:00
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getSimpleWhereTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleWhereTree" );
|
2003-12-16 11:29:20 +00:00
|
|
|
const OSQLParseNode* pNode = getWhereTree();
|
|
|
|
return pNode ? pNode->getChild(1) : NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getSimpleOrderTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleOrderTree" );
|
2003-12-16 11:29:20 +00:00
|
|
|
const OSQLParseNode* pNode = getOrderTree();
|
|
|
|
return pNode ? pNode->getChild(2) : NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getSimpleGroupByTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleGroupByTree" );
|
2003-12-16 11:29:20 +00:00
|
|
|
const OSQLParseNode* pNode = getGroupByTree();
|
|
|
|
return pNode ? pNode->getChild(2) : NULL;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const OSQLParseNode* OSQLParseTreeIterator::getSimpleHavingTree() const
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::getSimpleHavingTree" );
|
2003-12-16 11:29:20 +00:00
|
|
|
const OSQLParseNode* pNode = getHavingTree();
|
|
|
|
return pNode ? pNode->getChild(1) : NULL;
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XPropertySet > OSQLParseTreeIterator::findColumn( const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" );
|
2006-07-10 13:38:34 +00:00
|
|
|
Reference< XPropertySet > xColumn = findColumn( *m_pImpl->m_pTables, rColumnName, rTableRange );
|
|
|
|
if ( !xColumn.is() && _bLookInSubTables )
|
|
|
|
xColumn = findColumn( *m_pImpl->m_pSubTables, rColumnName, rTableRange );
|
|
|
|
return xColumn;
|
|
|
|
}
|
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2004-09-09 08:04:16 +00:00
|
|
|
Reference< XPropertySet > OSQLParseTreeIterator::findColumn(const OSQLTables& _rTables,const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange)
|
2003-12-16 11:29:20 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::findColumn" );
|
2003-12-16 11:29:20 +00:00
|
|
|
Reference< XPropertySet > xColumn;
|
|
|
|
if ( rTableRange.getLength() )
|
|
|
|
{
|
2004-09-09 08:04:16 +00:00
|
|
|
ConstOSQLTablesIterator aFind = _rTables.find(rTableRange);
|
2000-10-19 10:47:14 +00:00
|
|
|
|
2004-09-09 08:04:16 +00:00
|
|
|
if ( aFind != _rTables.end()
|
2003-12-16 11:29:20 +00:00
|
|
|
&& aFind->second.is()
|
|
|
|
&& aFind->second->getColumns().is()
|
|
|
|
&& aFind->second->getColumns()->hasByName(rColumnName) )
|
|
|
|
aFind->second->getColumns()->getByName(rColumnName) >>= xColumn;
|
|
|
|
}
|
|
|
|
if ( !xColumn.is() )
|
|
|
|
{
|
2004-09-09 08:04:16 +00:00
|
|
|
OSQLTables::const_iterator aEnd = _rTables.end();
|
|
|
|
for(OSQLTables::const_iterator aIter = _rTables.begin(); aIter != aEnd; ++aIter)
|
2003-12-16 11:29:20 +00:00
|
|
|
{
|
|
|
|
if ( aIter->second.is() )
|
|
|
|
{
|
|
|
|
Reference<XNameAccess> xColumns = aIter->second->getColumns();
|
|
|
|
if( xColumns.is() && xColumns->hasByName(rColumnName) && (xColumns->getByName(rColumnName) >>= xColumn) )
|
|
|
|
{
|
|
|
|
OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!");
|
|
|
|
break; // diese Column darf nur einmal vorkommen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return xColumn;
|
|
|
|
}
|
2006-07-10 13:38:34 +00:00
|
|
|
|
2003-12-16 11:29:20 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2006-07-10 13:38:34 +00:00
|
|
|
void OSQLParseTreeIterator::impl_appendError( IParseContext::ErrorCode _eError, const ::rtl::OUString* _pReplaceToken1, const ::rtl::OUString* _pReplaceToken2 )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_appendError" );
|
2006-07-10 13:38:34 +00:00
|
|
|
::rtl::OUString sErrorMessage = m_rParser.getContext().getErrorMessage( _eError );
|
|
|
|
if ( _pReplaceToken1 )
|
|
|
|
{
|
2006-08-28 13:54:57 +00:00
|
|
|
bool bTwoTokens = ( _pReplaceToken2 != NULL );
|
|
|
|
const sal_Char* pPlaceHolder1 = bTwoTokens ? "#1" : "#";
|
|
|
|
const ::rtl::OUString sPlaceHolder1 = ::rtl::OUString::createFromAscii( pPlaceHolder1 );
|
|
|
|
|
|
|
|
sErrorMessage = sErrorMessage.replaceAt( sErrorMessage.indexOf( sPlaceHolder1 ), sPlaceHolder1.getLength(), *_pReplaceToken1 );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( _pReplaceToken2 )
|
2006-08-28 13:54:57 +00:00
|
|
|
sErrorMessage = sErrorMessage.replaceAt( sErrorMessage.indexOf( ::rtl::OUString::createFromAscii( "#2" ) ), 2, *_pReplaceToken2 );
|
2006-07-10 13:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl_appendError( SQLException(
|
|
|
|
sErrorMessage, NULL, getStandardSQLState( SQL_GENERAL_ERROR ), 1000, Any() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError )
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "parse", "Ocke.Janssen@sun.com", "OSQLParseTreeIterator::impl_appendError" );
|
2006-07-10 13:38:34 +00:00
|
|
|
if ( m_aErrors.Message.getLength() )
|
|
|
|
{
|
|
|
|
SQLException* pErrorChain = &m_aErrors;
|
|
|
|
while ( pErrorChain->NextException.hasValue() )
|
|
|
|
pErrorChain = static_cast< SQLException* >( pErrorChain->NextException.pData );
|
|
|
|
pErrorChain->NextException <<= _rError;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_aErrors = _rError;
|
|
|
|
}
|
2008-06-16 11:11:56 +00:00
|
|
|
// -----------------------------------------------------------------------------
|