Files
libreoffice/connectivity/source/drivers/file/fcomp.cxx

897 lines
33 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-06-12 22:04:38 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-10-05 07:39:29 +00:00
#include "file/fcomp.hxx"
#include <tools/debug.hxx>
2001-05-14 10:42:44 +00:00
#include "TConnection.hxx"
#include <connectivity/sqlparse.hxx>
2000-10-05 07:39:29 +00:00
#include "file/fanalyzer.hxx"
#include <com/sun/star/sdbc/XColumnLocate.hpp>
2001-08-09 11:54:45 +00:00
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/Time.hpp>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbconversion.hxx>
#include <com/sun/star/sdb/SQLFilterOperator.hpp>
2008-10-01 12:28:29 +00:00
#include "resource/file_res.hrc"
#include "file/FStringFunctions.hxx"
#include "file/FDateFunctions.hxx"
#include "file/FNumericFunctions.hxx"
2008-10-01 12:28:29 +00:00
#include "file/FConnection.hxx"
#include "sqlbison.hxx"
2000-10-05 07:39:29 +00:00
using namespace connectivity;
using namespace connectivity::file;
using namespace com::sun::star::uno;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdb;
2000-10-05 07:39:29 +00:00
using namespace ::com::sun::star::container;
using namespace com::sun::star;
2000-10-05 07:39:29 +00:00
OPredicateCompiler::OPredicateCompiler(OSQLAnalyzer* pAnalyzer)//,OCursor& rCurs)
: m_pAnalyzer(pAnalyzer)
2001-04-10 07:51:30 +00:00
, m_nParamCounter(0)
, m_bORCondition(false)
2000-10-05 07:39:29 +00:00
{
}
2000-10-05 07:39:29 +00:00
OPredicateCompiler::~OPredicateCompiler()
{
Clean();
}
2000-11-03 13:21:22 +00:00
void OPredicateCompiler::dispose()
{
Clean();
m_orgColumns = nullptr;
m_xIndexes.clear();
2000-11-03 13:21:22 +00:00
}
2011-02-18 19:35:44 -05:00
2000-10-05 07:39:29 +00:00
void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode)
{
if (!pSQLParseNode)
return;
2001-04-10 07:51:30 +00:00
m_nParamCounter = 0;
2011-02-18 21:46:25 +01:00
// analyse Parse Tree (depending on Statement-type)
// and set pointer on WHERE-clause:
OSQLParseNode * pWhereClause = nullptr;
2000-10-05 07:39:29 +00:00
if (SQL_ISRULE(pSQLParseNode,select_statement))
{
OSQLParseNode * pOrderbyClause = nullptr;
2000-10-05 07:39:29 +00:00
DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
OSQLParseNode * pTableExp = pSQLParseNode->getChild(3);
DBG_ASSERT(pTableExp != nullptr,"Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Fehler im Parse Tree");
DBG_ASSERT(pTableExp->count() == TABLE_EXPRESSION_CHILD_COUNT,"Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
// check that we don't use anything other than count(*) as function
OSQLParseNode* pSelection = pSQLParseNode->getChild(2);
if ( SQL_ISRULE(pSelection,scalar_exp_commalist) )
{
for (size_t i = 0; i < pSelection->count(); i++)
{
OSQLParseNode *pColumnRef = pSelection->getChild(i)->getChild(0);
if ( SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->count() != 4 )
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_COMPLEX_COUNT,nullptr);
}
}
}
2000-10-05 07:39:29 +00:00
pWhereClause = pTableExp->getChild(1);
pOrderbyClause = pTableExp->getChild(ORDER_BY_CHILD_POS);
2011-02-03 13:17:05 +00:00
(void)pOrderbyClause;
2000-10-05 07:39:29 +00:00
}
else if (SQL_ISRULE(pSQLParseNode,update_statement_searched))
{
DBG_ASSERT(pSQLParseNode->count() == 5,"OFILECursor: Fehler im Parse Tree");
pWhereClause = pSQLParseNode->getChild(4);
}
else if (SQL_ISRULE(pSQLParseNode,delete_statement_searched))
{
DBG_ASSERT(pSQLParseNode->count() == 4,"Fehler im Parse Tree");
pWhereClause = pSQLParseNode->getChild(3);
}
else
2011-02-18 21:46:25 +01:00
// Other Statement. no selection-criteria
2000-10-05 07:39:29 +00:00
return;
if (SQL_ISRULE(pWhereClause,where_clause))
{
2011-02-18 21:46:25 +01:00
// a where-clause is not allowed to be empty:
2000-10-05 07:39:29 +00:00
DBG_ASSERT(pWhereClause->count() == 2,"OFILECursor: Fehler im Parse Tree");
OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1);
DBG_ASSERT(pComparisonPredicate != nullptr,"OFILECursor: Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
execute( pComparisonPredicate );
2000-10-05 07:39:29 +00:00
}
else
{
2011-02-18 21:46:25 +01:00
// The where-clause is optionally in the majority of cases, i.e. it might be an "optional-where-clause".
2001-04-30 09:16:19 +00:00
DBG_ASSERT(SQL_ISRULE(pWhereClause,opt_where_clause),"OPredicateCompiler: Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
}
}
2000-10-05 07:39:29 +00:00
OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode)
{
OOperand* pOperand = nullptr;
2011-02-18 21:46:25 +01:00
if (pPredicateNode->count() == 3 && // Expression is bracketed
2000-10-05 07:39:29 +00:00
SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"(") &&
SQL_ISPUNCTUATION(pPredicateNode->getChild(2),")"))
{
execute(pPredicateNode->getChild(1));
}
else if ((SQL_ISRULE(pPredicateNode,search_condition) || (SQL_ISRULE(pPredicateNode,boolean_term)))
2011-02-18 21:46:25 +01:00
&& // AND/OR-linkage:
CWS-TOOLING: integrate CWS dba32e 2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected 2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte 2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name 2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard 2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus 2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up 2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up 2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct 2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0 2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected 2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string 2009-07-20 11:40:39 +0200 fs r274117 : removed unused include 2009-07-20 11:40:01 +0200 fs r274116 : class name corrected 2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path 2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst 2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar 2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well 2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths 2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality 2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52) 2009-07-01 21:41:50 +0200 fs r273614 : #i10000# 2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents 2009-07-01 12:10:31 +0200 fs r273562 : updated 2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names 2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays 2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder 2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb 2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d 2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions 2009-06-29 10:01:13 +0200 fs r273453 : #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-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays 2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899# 2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes 2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes 2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log 2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts 2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string 2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime 2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata 2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge 2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved 2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set 2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge 2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge 2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing 2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d 2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries? 2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed 2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix 2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section 2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox 2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop 2009-06-19 13:18:26 +0200 oj r273157 : remove unused param 2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50) 2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e 2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e 2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e 2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50 2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text 2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any 2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid 2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ... 2009-06-10 09:53:20 +0200 oj r272797 : add lic text 2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618 2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed 2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property 2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases 2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases 2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases 2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid 2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing 2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType 2009-06-08 13:51:20 +0200 oj r272730 : add tests 2009-06-05 14:38:01 +0200 oj r272686 : add dep 2009-06-05 14:35:00 +0200 oj r272684 : add new tests 2009-06-05 13:41:18 +0200 oj r272681 : code clean ups 2009-06-05 12:40:51 +0200 oj r272678 : code cleanup 2009-06-05 12:02:57 +0200 oj r272677 : code cleanup 2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML 2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard 2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
pPredicateNode->count() == 3)
2000-10-05 07:39:29 +00:00
{
2011-02-18 21:46:25 +01:00
execute(pPredicateNode->getChild(0)); // process the left branch
execute(pPredicateNode->getChild(2)); // process the right branch
2000-10-05 07:39:29 +00:00
if (SQL_ISTOKEN(pPredicateNode->getChild(1),OR)) // OR-Operator
{
m_aCodeList.push_back(new OOp_OR());
m_bORCondition = true;
2000-10-05 07:39:29 +00:00
}
else if (SQL_ISTOKEN(pPredicateNode->getChild(1),AND)) // AND-Operator
m_aCodeList.push_back(new OOp_AND());
else
{
2011-03-01 19:07:44 +01:00
OSL_FAIL("OPredicateCompiler: Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
}
}
CWS-TOOLING: integrate CWS dba32e 2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected 2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte 2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name 2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard 2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus 2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up 2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up 2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct 2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0 2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected 2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string 2009-07-20 11:40:39 +0200 fs r274117 : removed unused include 2009-07-20 11:40:01 +0200 fs r274116 : class name corrected 2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path 2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst 2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar 2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well 2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths 2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality 2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52) 2009-07-01 21:41:50 +0200 fs r273614 : #i10000# 2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents 2009-07-01 12:10:31 +0200 fs r273562 : updated 2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names 2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays 2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder 2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb 2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d 2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions 2009-06-29 10:01:13 +0200 fs r273453 : #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-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays 2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899# 2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes 2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes 2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log 2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts 2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string 2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime 2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata 2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge 2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved 2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set 2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge 2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge 2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing 2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d 2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries? 2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed 2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix 2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section 2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox 2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop 2009-06-19 13:18:26 +0200 oj r273157 : remove unused param 2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50) 2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e 2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e 2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e 2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50 2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text 2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any 2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid 2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ... 2009-06-10 09:53:20 +0200 oj r272797 : add lic text 2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618 2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed 2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property 2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases 2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases 2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases 2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid 2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing 2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType 2009-06-08 13:51:20 +0200 oj r272730 : add tests 2009-06-05 14:38:01 +0200 oj r272686 : add dep 2009-06-05 14:35:00 +0200 oj r272684 : add new tests 2009-06-05 13:41:18 +0200 oj r272681 : code clean ups 2009-06-05 12:40:51 +0200 oj r272678 : code cleanup 2009-06-05 12:02:57 +0200 oj r272677 : code cleanup 2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML 2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard 2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
else if (SQL_ISRULE(pPredicateNode,boolean_factor))
{
execute(pPredicateNode->getChild(1));
m_aCodeList.push_back(new OOp_NOT());
}
2000-10-05 07:39:29 +00:00
else if (SQL_ISRULE(pPredicateNode,comparison_predicate))
{
execute_COMPARE(pPredicateNode);
}
else if (SQL_ISRULE(pPredicateNode,like_predicate))
{
execute_LIKE(pPredicateNode);
}
else if (SQL_ISRULE(pPredicateNode,between_predicate))
{
execute_BETWEEN(pPredicateNode);
}
2000-10-05 07:39:29 +00:00
else if (SQL_ISRULE(pPredicateNode,test_for_null))
{
execute_ISNULL(pPredicateNode);
}
2001-04-30 09:16:19 +00:00
else if(SQL_ISRULE(pPredicateNode,num_value_exp))
{
2011-02-18 21:46:25 +01:00
execute(pPredicateNode->getChild(0)); // process the left branch
execute(pPredicateNode->getChild(2)); // process the right branch
2001-04-30 09:16:19 +00:00
if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"+"))
{
m_aCodeList.push_back(new OOp_ADD());
}
else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"-"))
m_aCodeList.push_back(new OOp_SUB());
else
{
2011-03-01 19:07:44 +01:00
OSL_FAIL("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
2001-04-30 09:16:19 +00:00
}
}
else if(SQL_ISRULE(pPredicateNode,term))
{
2011-02-18 21:46:25 +01:00
execute(pPredicateNode->getChild(0)); // process the left branch
execute(pPredicateNode->getChild(2)); // process the right branch
2001-04-30 09:16:19 +00:00
if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"*"))
{
m_aCodeList.push_back(new OOp_MUL());
}
else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"/"))
m_aCodeList.push_back(new OOp_DIV());
else
{
2011-03-01 19:07:44 +01:00
OSL_FAIL("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
2001-04-30 09:16:19 +00:00
}
}
2000-10-05 07:39:29 +00:00
else
2011-02-18 21:46:25 +01:00
pOperand = execute_Operand(pPredicateNode); // now only simple operands will be processed
2000-10-05 07:39:29 +00:00
return pOperand;
}
void OPredicateCompiler::execute_COMPARE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
2000-10-05 07:39:29 +00:00
{
DBG_ASSERT(pPredicateNode->count() == 3,"OFILECursor: Fehler im Parse Tree");
if ( !(SQL_ISRULE(pPredicateNode->getChild(0),column_ref) ||
pPredicateNode->getChild(2)->getNodeType() == SQLNodeType::String ||
pPredicateNode->getChild(2)->getNodeType() == SQLNodeType::IntNum ||
pPredicateNode->getChild(2)->getNodeType() == SQLNodeType::ApproxNum ||
SQL_ISTOKEN(pPredicateNode->getChild(2),TRUE) ||
SQL_ISTOKEN(pPredicateNode->getChild(2),FALSE) ||
SQL_ISRULE(pPredicateNode->getChild(2),parameter) ||
2000-10-05 07:39:29 +00:00
// odbc date
SQL_ISRULE(pPredicateNode->getChild(2),set_fct_spec) ||
SQL_ISRULE(pPredicateNode->getChild(2),position_exp) ||
SQL_ISRULE(pPredicateNode->getChild(2),char_substring_fct) ||
// upper, lower etc.
SQL_ISRULE(pPredicateNode->getChild(2),fold)) )
2000-10-05 07:39:29 +00:00
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,nullptr);
return;
2000-10-05 07:39:29 +00:00
}
sal_Int32 ePredicateType( SQLFilterOperator::EQUAL );
2000-10-05 07:39:29 +00:00
OSQLParseNode *pPrec = pPredicateNode->getChild(1);
if (pPrec->getNodeType() == SQLNodeType::Equal)
ePredicateType = SQLFilterOperator::EQUAL;
else if (pPrec->getNodeType() == SQLNodeType::NotEqual)
ePredicateType = SQLFilterOperator::NOT_EQUAL;
else if (pPrec->getNodeType() == SQLNodeType::Less)
ePredicateType = SQLFilterOperator::LESS;
else if (pPrec->getNodeType() == SQLNodeType::LessEq)
ePredicateType = SQLFilterOperator::LESS_EQUAL;
else if (pPrec->getNodeType() == SQLNodeType::GreatEq)
ePredicateType = SQLFilterOperator::GREATER_EQUAL;
else if (pPrec->getNodeType() == SQLNodeType::Great)
ePredicateType = SQLFilterOperator::GREATER;
else
OSL_FAIL( "OPredicateCompiler::execute_COMPARE: unexpected node type!" );
2000-10-05 07:39:29 +00:00
execute(pPredicateNode->getChild(0));
execute(pPredicateNode->getChild(2));
m_aCodeList.push_back( new OOp_COMPARE(ePredicateType) );
2000-10-05 07:39:29 +00:00
}
void OPredicateCompiler::execute_LIKE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
2000-10-05 07:39:29 +00:00
{
DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
2000-10-05 07:39:29 +00:00
sal_Unicode cEscape = L'\0';
const bool bNotLike = pPart2->getChild(0)->isToken();
2000-10-05 07:39:29 +00:00
2010-05-27 08:38:58 +02:00
OSQLParseNode* pAtom = pPart2->getChild(pPart2->count()-2);
OSQLParseNode* pOptEscape = pPart2->getChild(pPart2->count()-1);
2000-10-05 07:39:29 +00:00
if (!(pAtom->getNodeType() == SQLNodeType::String ||
SQL_ISRULE(pAtom,parameter) ||
// odbc date
SQL_ISRULE(pAtom,set_fct_spec) ||
SQL_ISRULE(pAtom,position_exp) ||
SQL_ISRULE(pAtom,char_substring_fct) ||
// upper, lower etc.
SQL_ISRULE(pAtom,fold)) )
2000-10-05 07:39:29 +00:00
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,nullptr);
return;
2000-10-05 07:39:29 +00:00
}
2000-10-05 07:39:29 +00:00
if (pOptEscape->count() != 0)
{
if (pOptEscape->count() != 2)
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,nullptr);
2000-10-05 07:39:29 +00:00
}
OSQLParseNode *pEscNode = pOptEscape->getChild(1);
if (pEscNode->getNodeType() != SQLNodeType::String)
2000-10-05 07:39:29 +00:00
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,nullptr);
2000-10-05 07:39:29 +00:00
}
else
2000-10-19 10:56:36 +00:00
cEscape = pEscNode->getTokenValue().toChar();
2000-10-05 07:39:29 +00:00
}
execute(pPredicateNode->getChild(0));
execute(pAtom);
OBoolOperator* pOperator = bNotLike
? new OOp_NOTLIKE(cEscape)
: new OOp_LIKE(cEscape);
2000-10-05 07:39:29 +00:00
m_aCodeList.push_back(pOperator);
}
void OPredicateCompiler::execute_BETWEEN(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
{
DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
OSQLParseNode* pColumn = pPredicateNode->getChild(0);
const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
2010-05-28 11:37:27 +02:00
OSQLParseNode* p1stValue = pPart2->getChild(2);
OSQLParseNode* p2ndtValue = pPart2->getChild(4);
if (
!(p1stValue->getNodeType() == SQLNodeType::String || SQL_ISRULE(p1stValue,parameter))
&& !(p2ndtValue->getNodeType() == SQLNodeType::String || SQL_ISRULE(p2ndtValue,parameter))
)
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_BETWEEN,nullptr);
}
bool bNot = SQL_ISTOKEN(pPart2->getChild(0),NOT);
OOperand* pColumnOp = execute(pColumn);
OOperand* pOb1 = execute(p1stValue);
OBoolOperator* pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::LESS_EQUAL : SQLFilterOperator::GREATER);
m_aCodeList.push_back(pOperator);
execute(pColumn);
OOperand* pOb2 = execute(p2ndtValue);
pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::GREATER_EQUAL : SQLFilterOperator::LESS);
m_aCodeList.push_back(pOperator);
if ( pColumnOp && pOb1 && pOb2 )
{
switch(pColumnOp->getDBType())
{
case DataType::CHAR:
case DataType::VARCHAR:
case DataType::LONGVARCHAR:
pOb1->setValue(pOb1->getValue().getString());
pOb2->setValue(pOb2->getValue().getString());
break;
case DataType::DECIMAL:
case DataType::NUMERIC:
pOb1->setValue((double)pOb1->getValue());
pOb2->setValue((double)pOb2->getValue());
break;
case DataType::FLOAT:
pOb1->setValue((float)pOb1->getValue());
pOb2->setValue((float)pOb2->getValue());
break;
case DataType::DOUBLE:
case DataType::REAL:
pOb1->setValue((double)pOb1->getValue());
pOb2->setValue((double)pOb2->getValue());
break;
case DataType::DATE:
pOb1->setValue(static_cast<util::Date>(pOb1->getValue()));
pOb2->setValue(static_cast<util::Date>(pOb2->getValue()));
break;
case DataType::TIME:
pOb1->setValue(static_cast<util::Time>(pOb1->getValue()));
pOb2->setValue(static_cast<util::Time>(pOb2->getValue()));
break;
case DataType::TIMESTAMP:
pOb1->setValue(static_cast<util::DateTime>(pOb1->getValue()));
pOb2->setValue(static_cast<util::DateTime>(pOb2->getValue()));
break;
}
}
OBoolOperator* pBoolOp = nullptr;
if ( bNot )
pBoolOp = new OOp_OR();
else
pBoolOp = new OOp_AND();
m_aCodeList.push_back(pBoolOp);
}
void OPredicateCompiler::execute_ISNULL(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
2000-10-05 07:39:29 +00:00
{
DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
DBG_ASSERT(SQL_ISTOKEN(pPart2->getChild(0),IS),"OFILECursor: Fehler im Parse Tree");
2000-10-05 07:39:29 +00:00
sal_Int32 ePredicateType;
if (SQL_ISTOKEN(pPart2->getChild(1),NOT))
ePredicateType = SQLFilterOperator::NOT_SQLNULL;
2000-10-05 07:39:29 +00:00
else
ePredicateType = SQLFilterOperator::SQLNULL;
2000-10-05 07:39:29 +00:00
execute(pPredicateNode->getChild(0));
OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::SQLNULL) ?
2000-10-05 07:39:29 +00:00
new OOp_ISNULL() : new OOp_ISNOTNULL();
m_aCodeList.push_back(pOperator);
}
OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
2000-10-05 07:39:29 +00:00
{
OOperand* pOperand = nullptr;
2000-10-05 07:39:29 +00:00
if (SQL_ISRULE(pPredicateNode,column_ref))
{
OUString aColumnName;
2000-10-05 07:39:29 +00:00
if (pPredicateNode->count() == 1)
{
aColumnName = pPredicateNode->getChild(0)->getTokenValue();
}
else if (pPredicateNode->count() == 3)
{
2001-02-12 09:49:13 +00:00
if(SQL_ISRULE(pPredicateNode->getChild(2),column_val))
aColumnName = pPredicateNode->getChild(2)->getChild(0)->getTokenValue();
else
aColumnName = pPredicateNode->getChild(2)->getTokenValue();
2000-10-05 07:39:29 +00:00
}
2001-04-10 07:03:36 +00:00
if(!m_orgColumns->hasByName(aColumnName))
{
const OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
2008-10-01 12:28:29 +00:00
STR_INVALID_COLUMNNAME,
"$columnname$", aColumnName
) );
::dbtools::throwGenericSQLException( sError, nullptr );
2001-04-10 07:03:36 +00:00
}
css::uno::Reference< css::beans::XPropertySet> xCol;
2000-10-05 07:39:29 +00:00
try
{
if (m_orgColumns->getByName(aColumnName) >>= xCol)
2000-10-05 07:39:29 +00:00
{
pOperand = OSQLAnalyzer::createOperandAttr(Reference< XColumnLocate>(m_orgColumns,UNO_QUERY)->findColumn(aColumnName),xCol,m_xIndexes);
}
else
2011-02-18 21:46:25 +01:00
{// Column doesn't exist in the Result-set
const OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
2008-10-01 12:28:29 +00:00
STR_INVALID_COLUMNNAME,
"$columnname$", aColumnName
) );
::dbtools::throwGenericSQLException( sError, nullptr );
2000-10-05 07:39:29 +00:00
}
}
catch(Exception &)
2000-10-05 07:39:29 +00:00
{
OSL_FAIL("OPredicateCompiler::execute_Operand Exception");
2000-10-05 07:39:29 +00:00
}
}
else if (SQL_ISRULE(pPredicateNode,parameter))
{
2001-04-10 07:51:30 +00:00
pOperand = new OOperandParam(pPredicateNode, ++m_nParamCounter);
2000-10-05 07:39:29 +00:00
}
else if (pPredicateNode->getNodeType() == SQLNodeType::String ||
pPredicateNode->getNodeType() == SQLNodeType::IntNum ||
pPredicateNode->getNodeType() == SQLNodeType::ApproxNum ||
pPredicateNode->getNodeType() == SQLNodeType::Name ||
2000-10-05 07:39:29 +00:00
SQL_ISTOKEN(pPredicateNode,TRUE) ||
SQL_ISTOKEN(pPredicateNode,FALSE) ||
SQL_ISRULE(pPredicateNode,parameter))
{
pOperand = new OOperandConst(*pPredicateNode, pPredicateNode->getTokenValue());
}
else if((pPredicateNode->count() == 2) &&
(SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"+") || SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"-")) &&
pPredicateNode->getChild(1)->getNodeType() == SQLNodeType::IntNum)
2011-02-18 21:46:25 +01:00
{ // if -1 or +1 is there
OUString aValue = pPredicateNode->getChild(0)->getTokenValue() + pPredicateNode->getChild(1)->getTokenValue();
2000-10-05 07:39:29 +00:00
pOperand = new OOperandConst(*pPredicateNode->getChild(1), aValue);
}
else if( SQL_ISRULE(pPredicateNode,set_fct_spec) && SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"{") )
2000-10-05 07:39:29 +00:00
{
const OSQLParseNode* pODBCNode = pPredicateNode->getChild(1);
const OSQLParseNode* pODBCNodeChild = pODBCNode->getChild(0);
// Odbc Date or time
if (pODBCNodeChild->getNodeType() == SQLNodeType::Keyword && (
2000-10-05 07:39:29 +00:00
SQL_ISTOKEN(pODBCNodeChild,D) ||
SQL_ISTOKEN(pODBCNodeChild,T) ||
SQL_ISTOKEN(pODBCNodeChild,TS) ))
{
OUString sDateTime = pODBCNode->getChild(1)->getTokenValue();
2001-08-09 11:54:45 +00:00
pOperand = new OOperandConst(*pODBCNode->getChild(1), sDateTime);
if(SQL_ISTOKEN(pODBCNodeChild,D))
{
2002-07-04 05:39:26 +00:00
pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(sDateTime)));
2001-08-09 11:54:45 +00:00
}
else if(SQL_ISTOKEN(pODBCNodeChild,T))
{
2002-07-04 05:39:26 +00:00
pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(sDateTime)));
2001-08-09 11:54:45 +00:00
}
else if(SQL_ISTOKEN(pODBCNodeChild,TS))
{
2002-07-04 05:39:26 +00:00
pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(sDateTime)));
2001-08-09 11:54:45 +00:00
}
2000-10-05 07:39:29 +00:00
}
else
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,nullptr);
}
else if( SQL_ISRULE(pPredicateNode,fold) )
{
execute_Fold(pPredicateNode);
}
else if( SQL_ISRULE(pPredicateNode,set_fct_spec)
|| SQL_ISRULE(pPredicateNode,position_exp)
|| SQL_ISRULE(pPredicateNode,char_substring_fct)
)
{
executeFunction(pPredicateNode);
}
else if( SQL_ISRULE(pPredicateNode,length_exp) )
{
executeFunction(pPredicateNode->getChild(0));
2000-10-05 07:39:29 +00:00
}
else
{
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,nullptr);
2000-10-05 07:39:29 +00:00
}
if (pOperand)
m_aCodeList.push_back(pOperand);
return pOperand;
}
bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
2000-10-05 07:39:29 +00:00
{
static bool bResult;
2000-10-05 07:39:29 +00:00
OCodeList::iterator aIter = rCodeList.begin();
if (!(*aIter))
return true; // no Predicate
2000-10-05 07:39:29 +00:00
for(;aIter != rCodeList.end();++aIter)
{
OOperand* pOperand = dynamic_cast<OOperand* >(*aIter);
2000-10-05 07:39:29 +00:00
if (pOperand)
m_aStack.push(pOperand);
else
static_cast<OOperator *>(*aIter)->Exec(m_aStack);
2000-10-05 07:39:29 +00:00
}
OOperand* pOperand = m_aStack.top();
m_aStack.pop();
2012-02-19 16:59:40 +04:00
DBG_ASSERT(m_aStack.empty(), "StackFehler");
2000-10-05 07:39:29 +00:00
DBG_ASSERT(pOperand, "StackFehler");
bResult = pOperand->isValid();
if (typeid(OOperandResult) == typeid(*pOperand))
2000-10-05 07:39:29 +00:00
delete pOperand;
return bResult;
}
void OPredicateInterpreter::evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal)
{
OCodeList::iterator aIter = rCodeList.begin();
if (!(*aIter))
2011-02-18 21:46:25 +01:00
return ; // no Predicate
for(;aIter != rCodeList.end();++aIter)
{
OOperand* pOperand = dynamic_cast<OOperand* >(*aIter);
if (pOperand)
m_aStack.push(pOperand);
else
static_cast<OOperator *>(*aIter)->Exec(m_aStack);
}
OOperand* pOperand = m_aStack.top();
m_aStack.pop();
2012-02-19 16:59:40 +04:00
DBG_ASSERT(m_aStack.empty(), "StackFehler");
DBG_ASSERT(pOperand, "StackFehler");
(*_rVal) = pOperand->getValue();
if (typeid(OOperandResult) == typeid(*pOperand))
delete pOperand;
}
void OPredicateCompiler::execute_Fold(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
{
DBG_ASSERT(pPredicateNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
bool bUpper = SQL_ISTOKEN(pPredicateNode->getChild(0),UPPER);
execute(pPredicateNode->getChild(2));
OOperator* pOperator = nullptr;
if ( bUpper )
pOperator = new OOp_Upper();
else
pOperator = new OOp_Lower();
m_aCodeList.push_back(pOperator);
}
void OPredicateCompiler::executeFunction(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
{
OOperator* pOperator = nullptr;
OSL_ENSURE(pPredicateNode->getChild(0)->isToken(),"The first one must be the name of the function!");
sal_Int32 nTokenId = pPredicateNode->getChild(0)->getTokenID();
switch ( nTokenId )
{
case SQL_TOKEN_CHAR_LENGTH:
case SQL_TOKEN_LENGTH:
case SQL_TOKEN_OCTET_LENGTH:
case SQL_TOKEN_ASCII:
case SQL_TOKEN_LCASE:
case SQL_TOKEN_LTRIM:
case SQL_TOKEN_RTRIM:
case SQL_TOKEN_SPACE:
case SQL_TOKEN_UCASE:
case SQL_TOKEN_ABS:
case SQL_TOKEN_ACOS:
case SQL_TOKEN_ASIN:
case SQL_TOKEN_ATAN:
case SQL_TOKEN_CEILING:
case SQL_TOKEN_COS:
case SQL_TOKEN_DEGREES:
case SQL_TOKEN_EXP:
case SQL_TOKEN_FLOOR:
case SQL_TOKEN_LOG10:
case SQL_TOKEN_LN:
case SQL_TOKEN_RADIANS:
case SQL_TOKEN_SIGN:
case SQL_TOKEN_SIN:
case SQL_TOKEN_SQRT:
case SQL_TOKEN_TAN:
case SQL_TOKEN_DAYNAME:
case SQL_TOKEN_DAYOFMONTH:
case SQL_TOKEN_DAYOFWEEK:
case SQL_TOKEN_DAYOFYEAR:
case SQL_TOKEN_HOUR:
case SQL_TOKEN_MINUTE:
case SQL_TOKEN_MONTH:
case SQL_TOKEN_MONTHNAME:
case SQL_TOKEN_QUARTER:
case SQL_TOKEN_SECOND:
case SQL_TOKEN_YEAR:
execute(pPredicateNode->getChild(2));
switch( nTokenId )
{
case SQL_TOKEN_CHAR_LENGTH:
case SQL_TOKEN_LENGTH:
case SQL_TOKEN_OCTET_LENGTH:
pOperator = new OOp_CharLength();
break;
case SQL_TOKEN_ASCII:
pOperator = new OOp_Ascii();
break;
case SQL_TOKEN_LCASE:
pOperator = new OOp_Lower();
break;
case SQL_TOKEN_LTRIM:
pOperator = new OOp_LTrim();
break;
case SQL_TOKEN_RTRIM:
pOperator = new OOp_RTrim();
break;
case SQL_TOKEN_SPACE:
pOperator = new OOp_Space();
break;
case SQL_TOKEN_UCASE:
pOperator = new OOp_Upper();
break;
case SQL_TOKEN_ABS:
pOperator = new OOp_Abs();
break;
case SQL_TOKEN_ACOS:
pOperator = new OOp_ACos();
break;
case SQL_TOKEN_ASIN:
pOperator = new OOp_ASin();
break;
case SQL_TOKEN_ATAN:
pOperator = new OOp_ATan();
break;
case SQL_TOKEN_CEILING:
pOperator = new OOp_Ceiling();
break;
case SQL_TOKEN_COS:
pOperator = new OOp_Cos();
break;
case SQL_TOKEN_DEGREES:
pOperator = new OOp_Degrees();
break;
case SQL_TOKEN_EXP:
pOperator = new OOp_Exp();
break;
case SQL_TOKEN_FLOOR:
pOperator = new OOp_Floor();
break;
case SQL_TOKEN_LOG10:
pOperator = new OOp_Log10();
break;
case SQL_TOKEN_LN:
pOperator = new OOp_Ln();
break;
case SQL_TOKEN_RADIANS:
pOperator = new OOp_Radians();
break;
case SQL_TOKEN_SIGN:
pOperator = new OOp_Sign();
break;
case SQL_TOKEN_SIN:
pOperator = new OOp_Sin();
break;
case SQL_TOKEN_SQRT:
pOperator = new OOp_Sqrt();
break;
case SQL_TOKEN_TAN:
pOperator = new OOp_Tan();
break;
case SQL_TOKEN_DAYOFWEEK:
pOperator = new OOp_DayOfWeek();
break;
case SQL_TOKEN_DAYOFMONTH:
pOperator = new OOp_DayOfMonth();
break;
case SQL_TOKEN_DAYOFYEAR:
pOperator = new OOp_DayOfYear();
break;
case SQL_TOKEN_MONTH:
pOperator = new OOp_Month();
break;
case SQL_TOKEN_DAYNAME:
pOperator = new OOp_DayName();
break;
case SQL_TOKEN_MONTHNAME:
pOperator = new OOp_MonthName();
break;
case SQL_TOKEN_QUARTER:
pOperator = new OOp_Quarter();
break;
case SQL_TOKEN_YEAR:
pOperator = new OOp_Year();
break;
case SQL_TOKEN_HOUR:
pOperator = new OOp_Hour();
break;
case SQL_TOKEN_MINUTE:
pOperator = new OOp_Minute();
break;
case SQL_TOKEN_SECOND:
pOperator = new OOp_Second();
break;
default:
OSL_FAIL("Error in switch!");
}
break;
case SQL_TOKEN_CHAR:
case SQL_TOKEN_CONCAT:
case SQL_TOKEN_INSERT:
case SQL_TOKEN_LEFT:
case SQL_TOKEN_LOCATE:
case SQL_TOKEN_LOCATE_2:
case SQL_TOKEN_REPEAT:
case SQL_TOKEN_REPLACE:
case SQL_TOKEN_RIGHT:
case SQL_TOKEN_MOD:
case SQL_TOKEN_ROUND:
case SQL_TOKEN_LOGF:
case SQL_TOKEN_LOG:
case SQL_TOKEN_POWER:
case SQL_TOKEN_ATAN2:
case SQL_TOKEN_PI:
case SQL_TOKEN_CURDATE:
case SQL_TOKEN_CURTIME:
case SQL_TOKEN_NOW:
case SQL_TOKEN_WEEK:
{
m_aCodeList.push_back(new OStopOperand);
OSQLParseNode* pList = pPredicateNode->getChild(2);
for (size_t i=0; i < pList->count(); ++i)
execute(pList->getChild(i));
switch( nTokenId )
{
case SQL_TOKEN_CHAR:
pOperator = new OOp_Char();
break;
case SQL_TOKEN_CONCAT:
pOperator = new OOp_Concat();
break;
case SQL_TOKEN_INSERT:
pOperator = new OOp_Insert();
break;
case SQL_TOKEN_LEFT:
pOperator = new OOp_Left();
break;
case SQL_TOKEN_LOCATE:
case SQL_TOKEN_LOCATE_2:
pOperator = new OOp_Locate();
break;
case SQL_TOKEN_REPEAT:
pOperator = new OOp_Repeat();
break;
case SQL_TOKEN_REPLACE:
pOperator = new OOp_Replace();
break;
case SQL_TOKEN_RIGHT:
pOperator = new OOp_Right();
break;
case SQL_TOKEN_MOD:
pOperator = new OOp_Mod();
break;
case SQL_TOKEN_ROUND:
pOperator = new OOp_Round();
break;
case SQL_TOKEN_LOGF:
case SQL_TOKEN_LOG:
pOperator = new OOp_Log();
break;
case SQL_TOKEN_POWER:
pOperator = new OOp_Pow();
break;
case SQL_TOKEN_ATAN2:
pOperator = new OOp_ATan2();
break;
case SQL_TOKEN_PI:
pOperator = new OOp_Pi();
break;
case SQL_TOKEN_CURDATE:
pOperator = new OOp_CurDate();
break;
case SQL_TOKEN_CURTIME:
pOperator = new OOp_CurTime();
break;
case SQL_TOKEN_NOW:
pOperator = new OOp_Now();
break;
case SQL_TOKEN_WEEK:
pOperator = new OOp_Week();
break;
default:
OSL_FAIL("Error in switch!");
}
}
break;
case SQL_TOKEN_SUBSTRING:
m_aCodeList.push_back(new OStopOperand);
if ( pPredicateNode->count() == 4 ) //char_substring_fct
{
OSQLParseNode* pList = pPredicateNode->getChild(2);
for (size_t i=0; i < pList->count(); ++i)
execute(pList->getChild(i));
}
else
{
execute(pPredicateNode->getChild(2));
execute(pPredicateNode->getChild(4));
execute(pPredicateNode->getChild(5)->getChild(1));
}
pOperator = new OOp_SubString();
break;
case SQL_TOKEN_POSITION:
m_aCodeList.push_back(new OStopOperand);
if ( pPredicateNode->count() == 4 ) //position_exp
{
OSQLParseNode* pList = pPredicateNode->getChild(2);
for (size_t i=0; i < pList->count(); ++i)
execute(pList->getChild(i));
}
else
{
execute(pPredicateNode->getChild(2));
execute(pPredicateNode->getChild(4));
}
pOperator = new OOp_Locate();
break;
default:
m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_FUNCTION_NOT_SUPPORTED,nullptr);
}
m_aCodeList.push_back(pOperator);
}
2000-11-10 10:04:52 +00:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */