diff options
Diffstat (limited to 'connectivity/source/parse')
-rw-r--r-- | connectivity/source/parse/PColumn.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/parse/internalnode.cxx | 5 | ||||
-rw-r--r-- | connectivity/source/parse/makefile.mk | 6 | ||||
-rw-r--r-- | connectivity/source/parse/sqlbison.y | 12 | ||||
-rw-r--r-- | connectivity/source/parse/sqlflex.l | 6 | ||||
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 103 | ||||
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 31 | ||||
-rw-r--r-- | connectivity/source/parse/wrap_sqlbison.cxx | 5 | ||||
-rw-r--r-- | connectivity/source/parse/wrap_sqlflex.cxx | 5 |
9 files changed, 113 insertions, 68 deletions
diff --git a/connectivity/source/parse/PColumn.cxx b/connectivity/source/parse/PColumn.cxx index d8372ca69167..21e78ec61fea 100644 --- a/connectivity/source/parse/PColumn.cxx +++ b/connectivity/source/parse/PColumn.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: PColumn.cxx,v $ - * $Revision: 1.16 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -116,7 +113,7 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe const Reference< XDatabaseMetaData >& _rxDBMetaData, sal_Int32 _nColumnPos ) { OParseColumn* pColumn = new OParseColumn( - _rxResMetaData->getColumnName( _nColumnPos ), + _rxResMetaData->getColumnLabel( _nColumnPos ), _rxResMetaData->getColumnTypeName( _nColumnPos ), ::rtl::OUString(), _rxResMetaData->isNullable( _nColumnPos ), @@ -135,6 +132,7 @@ OParseColumn* OParseColumn::createColumnForResultSet( const Reference< XResultSe eComplete ) ); pColumn->setIsSearchable( _rxResMetaData->isSearchable( _nColumnPos ) ); + pColumn->setRealName(_rxResMetaData->getColumnName( _nColumnPos )); return pColumn; } diff --git a/connectivity/source/parse/internalnode.cxx b/connectivity/source/parse/internalnode.cxx index 752211c423d2..39b4a4af3b48 100644 --- a/connectivity/source/parse/internalnode.cxx +++ b/connectivity/source/parse/internalnode.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: internalnode.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/connectivity/source/parse/makefile.mk b/connectivity/source/parse/makefile.mk index bd84092f9c7b..98eb4685903c 100644 --- a/connectivity/source/parse/makefile.mk +++ b/connectivity/source/parse/makefile.mk @@ -2,14 +2,10 @@ # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # -# Copyright 2008 by Sun Microsystems, Inc. +# Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite # -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.22 $ -# # This file is part of OpenOffice.org. # # OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 97875dfd4de0..4151314d36eb 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -3,14 +3,10 @@ // // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // -// Copyright 2008 by Sun Microsystems, Inc. +// Copyright 2000, 2010 Oracle and/or its affiliates. // // OpenOffice.org - a multi-platform office productivity suite // -// $RCSfile: sqlbison.y,v $ -// -// $Revision: 1.66.6.5 $ -// // This file is part of OpenOffice.org. // // OpenOffice.org is free software: you can redistribute it and/or modify @@ -107,7 +103,6 @@ static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID); } @@ -115,7 +110,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } @@ -123,7 +117,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } @@ -2043,7 +2036,8 @@ join_spec: | named_columns_join ; join_type: - SQL_TOKEN_INNER + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_INNER { $$ = SQL_NEW_RULE; $$->append($1); diff --git a/connectivity/source/parse/sqlflex.l b/connectivity/source/parse/sqlflex.l index e365fdec1eca..77544ece300a 100644 --- a/connectivity/source/parse/sqlflex.l +++ b/connectivity/source/parse/sqlflex.l @@ -4,14 +4,10 @@ // // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. // -// Copyright 2008 by Sun Microsystems, Inc. +// Copyright 2000, 2010 Oracle and/or its affiliates. // // OpenOffice.org - a multi-platform office productivity suite // -// $RCSfile: sqlflex.l,v $ -// -// $Revision: 1.35 $ -// // This file is part of OpenOffice.org. // // OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 26086495be89..feecc26a4052 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: sqliterator.cxx,v $ - * $Revision: 1.60 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -952,21 +949,7 @@ bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele 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) ) - pColumnRef->getChild(0)->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - else - pColumnRef->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); - } + nType = getFunctionReturnType(pColumnRef); } } /* @@ -1601,7 +1584,6 @@ void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask ) case SQL_STATEMENT_INSERT: break; default: - OSL_ENSURE( false, "OSQLParseTreeIterator::traverseAll: not yet implemented for this statement type!" ); break; } } @@ -2104,3 +2086,84 @@ void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError ) m_aErrors = _rError; } // ----------------------------------------------------------------------------- +sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode ) +{ + sal_Int32 nType = DataType::OTHER; + ::rtl::OUString sFunctionName; + if ( SQL_ISRULE(_pNode,length_exp) ) + { + _pNode->getChild(0)->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + else if ( SQL_ISRULE(_pNode,num_value_exp) || SQL_ISRULE(_pNode,term) || SQL_ISRULE(_pNode,factor) ) + { + nType = DataType::DOUBLE; + } + else + { + _pNode->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + + // MIN and MAX have another return type, we have to check the expression itself. + // @see http://qa.openoffice.org/issues/show_bug.cgi?id=99566 + if ( SQL_ISRULE(_pNode,general_set_fct) && (SQL_ISTOKEN(_pNode->getChild(0),MIN) || SQL_ISTOKEN(_pNode->getChild(0),MAX) )) + { + const OSQLParseNode* pValueExp = _pNode->getChild(3); + if (SQL_ISRULE(pValueExp,column_ref)) + { + ::rtl::OUString sColumnName; + ::rtl::OUString aTableRange; + getColumnRange(pValueExp,sColumnName,aTableRange); + OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein"); + Reference<XPropertySet> xColumn = findColumn( sColumnName, aTableRange, true ); + + if ( xColumn.is() ) + { + xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE)) >>= nType; + } + } + else + { + if ( SQL_ISRULE(pValueExp,num_value_exp) || SQL_ISRULE(pValueExp,term) || SQL_ISRULE(pValueExp,factor) ) + { + nType = DataType::DOUBLE; + } + else if ( SQL_ISRULE(pValueExp,datetime_primary) ) + { + switch(pValueExp->getChild(0)->getTokenID() ) + { + case SQL_TOKEN_CURRENT_DATE: + nType = DataType::DATE; + break; + case SQL_TOKEN_CURRENT_TIME: + nType = DataType::TIME; + break; + case SQL_TOKEN_CURRENT_TIMESTAMP: + nType = DataType::TIMESTAMP; + break; + } + } + else if ( SQL_ISRULE(pValueExp,value_exp_primary) ) + { + nType = getFunctionReturnType(pValueExp->getChild(1)); + } + else if ( SQL_ISRULE(pValueExp,concatenation) + || SQL_ISRULE(pValueExp,char_factor) + || SQL_ISRULE(pValueExp,bit_value_fct) + || SQL_ISRULE(pValueExp,char_value_fct) + || SQL_ISRULE(pValueExp,char_substring_fct) + || SQL_ISRULE(pValueExp,fold) + || SQL_ISTOKEN(pValueExp,STRING) ) + { + nType = DataType::VARCHAR; + } + } + if ( nType == DataType::OTHER ) + nType = DataType::DOUBLE; + } + else + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + + return nType; +} + diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 8d869c2dea0a..20b35b21a493 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: sqlnode.cxx,v $ - * $Revision: 1.57 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -813,8 +810,9 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) - pReturn = NULL; + case DataType::CLOB: + if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) + pReturn = NULL; default: break; } @@ -829,6 +827,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: break; case DataType::DATE: case DataType::TIME: @@ -872,12 +871,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; default: m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE); @@ -893,12 +893,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; case DataType::INTEGER: default: @@ -907,7 +908,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) } break; default: - OSL_ENSURE(0,"Not handled!"); + ; } } return pReturn; @@ -967,6 +968,7 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: if(pLiteral->isRule()) { pAppend->append(pLiteral); @@ -1228,6 +1230,7 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const : case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: s_pScanner->SetRule(s_pScanner->GetSTRINGRule()); break; default: @@ -1415,7 +1418,11 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::table_node, "table_node" }, { OSQLParseNode::as, "as" }, { OSQLParseNode::op_column_commalist, "op_column_commalist" }, - { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" } + { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" }, + { OSQLParseNode::datetime_primary, "datetime_primary" }, + { OSQLParseNode::concatenation, "concatenation" }, + { OSQLParseNode::char_factor, "char_factor" }, + { OSQLParseNode::bit_value_fct, "bit_value_fct" } }; size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" ); diff --git a/connectivity/source/parse/wrap_sqlbison.cxx b/connectivity/source/parse/wrap_sqlbison.cxx index afe7c3f3b6ca..17993a194bc5 100644 --- a/connectivity/source/parse/wrap_sqlbison.cxx +++ b/connectivity/source/parse/wrap_sqlbison.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: wrap_sqlbison.cxx,v $ - * $Revision: 1.5 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/connectivity/source/parse/wrap_sqlflex.cxx b/connectivity/source/parse/wrap_sqlflex.cxx index 55253a1bf79b..2cb5ad64ee5b 100644 --- a/connectivity/source/parse/wrap_sqlflex.cxx +++ b/connectivity/source/parse/wrap_sqlflex.cxx @@ -2,13 +2,10 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: wrap_sqlflex.cxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify |