parser changed for table names

This commit is contained in:
Ocke Janssen
2001-01-09 12:11:07 +00:00
parent e724c719ba
commit f970ce8e0d
5 changed files with 188 additions and 76 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: sqliterator.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: oj $ $Date: 2000-11-03 13:25:37 $
* last change: $Author: oj $ $Date: 2001-01-09 13:11:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -319,6 +319,9 @@ namespace connectivity
// Ermittelt fuer eine Funktion, Spalten den zugehoeren TableRange,
// wenn nicht eindeutig, dann leer
sal_Bool getColumnTableRange(const OSQLParseNode* pNode, ::rtl::OUString &rTableRange) const;
// return true when the tableNode is a rule like catalog_name, schema_name or table_name
sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const;
};
}

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: sqlnode.hxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: svesik $ $Date: 2000-11-22 16:47:35 $
* last change: $Author: oj $ $Date: 2001-01-09 13:11:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -162,6 +162,8 @@ namespace connectivity
table_exp,
table_ref_commalist,
table_ref,
catalog_name,
schema_name,
table_name,
opt_column_commalist,
column_commalist,
@@ -356,6 +358,12 @@ namespace connectivity
// makes the logic formula a little more smaller
static void compress(OSQLParseNode*& pSearchCondition);
// return the catalog, schema and tablename form this node
// _pTableNode must be a rule of that above or a SQL_TOKEN_NAME
static sal_Bool getTableComponents(const OSQLParseNode* _pTableNode,
::com::sun::star::uno::Any &_rCatalog,
::rtl::OUString &_rSchema,
::rtl::OUString &_rTable);
protected:
// ParseNodeToStr konkateniert alle Token (Blaetter) des ParseNodes

View File

@@ -1,7 +1,7 @@
%{
//--------------------------------------------------------------------------
//
// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlbison.y,v 1.8 2000-11-29 10:41:38 oj Exp $
// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlbison.y,v 1.9 2001-01-09 13:07:48 oj Exp $
//
// Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
//
@@ -9,7 +9,7 @@
// OJ
//
// Last change:
// $Author: oj $ $Date: 2000-11-29 10:41:38 $ $Revision: 1.8 $
// $Author: oj $ $Date: 2001-01-09 13:07:48 $ $Revision: 1.9 $
//
// Description:
//
@@ -228,7 +228,8 @@ using namespace connectivity;
%type <pParseNode> all query_primary as not for_length upper_lower comparison column_val cross_union /*opt_schema_element_list*/
%type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
%type <pParseNode> column_def odbc_fct_spec odbc_call_spec odbc_fct_type op_parameter union_statement
%type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter
%type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter
%type <pParseNode> catalog_name schema_name table_node
%%
/* Parse Tree an OSQLParser zurueckliefern
@@ -322,7 +323,7 @@ schema_element:
;
base_table_def:
SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_name '(' base_table_element_commalist ')'
SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node '(' base_table_element_commalist ')'
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -405,11 +406,11 @@ column_def_opt:
$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
$$->append($3);
$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
| SQL_TOKEN_REFERENCES table_name
| SQL_TOKEN_REFERENCES table_node
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);}
| SQL_TOKEN_REFERENCES table_name '(' column_commalist ')'
| SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -425,7 +426,7 @@ table_constraint_def:
$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
$$->append($3);
$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
| SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_name
| SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -434,7 +435,7 @@ table_constraint_def:
$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
$$->append($6);
$$->append($7);}
| SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_name '(' column_commalist ')'
| SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -472,7 +473,7 @@ column_commalist:
;
view_def:
SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_name opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -502,7 +503,7 @@ opt_column_commalist:
;
privilege_def:
SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_name SQL_TOKEN_TO grantee_commalist
SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
opt_with_grant_option
{$$ = SQL_NEW_RULE;
$$->append($1);
@@ -679,7 +680,7 @@ commit_statement:
;
/*
delete_statement_positioned:
SQL_TOKEN_DELETE SQL_TOKEN_FROM table_name SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -691,7 +692,7 @@ delete_statement_positioned:
;
*/
delete_statement_searched:
SQL_TOKEN_DELETE SQL_TOKEN_FROM table_name opt_where_clause
SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -709,7 +710,7 @@ fetch_statement:
;
insert_statement:
SQL_TOKEN_INSERT SQL_TOKEN_INTO table_name opt_column_commalist values_or_query_spec
SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist values_or_query_spec
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -791,7 +792,7 @@ opt_all_distinct:
;
/*
update_statement_positioned:
SQL_TOKEN_UPDATE table_name SQL_TOKEN_SET assignment_commalist
SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
{$$ = SQL_NEW_RULE;
$$->append($1);
@@ -826,7 +827,7 @@ update_source:
| SQL_TOKEN_DEFAULT
;
update_statement_searched:
SQL_TOKEN_UPDATE table_name SQL_TOKEN_SET assignment_commalist opt_where_clause
SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2);
@@ -925,12 +926,12 @@ as:
}
;
table_ref:
table_name
table_node
{
$$ = SQL_NEW_RULE;
$$->append($1);
}
| table_name as range_variable op_column_commalist
| table_node as range_variable op_column_commalist
{
$$ = SQL_NEW_RULE;
$$->append($1);
@@ -1506,14 +1507,15 @@ scalar_exp_commalist:
}
;
select_sublist:
table_name '.' '*'
/* table_node '.' '*'
{
$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
$$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
}
| derived_column
}
*/
derived_column
;
@@ -1777,7 +1779,7 @@ op_parameter:
}
;
odbc_call_spec:
op_parameter SQL_TOKEN_CALL table_name op_odbc_call_parameter
op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
{
$$ = SQL_NEW_RULE;
$$->append($1);
@@ -2027,7 +2029,7 @@ cast_operand:
| SQL_TOKEN_NULL
;
cast_target:
table_name
table_node
| data_type
;
cast_spec:
@@ -2441,7 +2443,7 @@ char_primary:
}
;
collate_clause:
SQL_TOKEN_COLLATE table_name
SQL_TOKEN_COLLATE table_node
{
$$ = SQL_NEW_RULE;
$$->append($1);
@@ -2597,7 +2599,7 @@ fold:
}
;
form_conversion:
SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_name ')'
SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_node ')'
{
$$ = SQL_NEW_RULE;
$$->append($1);
@@ -2609,7 +2611,7 @@ form_conversion:
}
;
char_translation:
SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_name ')'
SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_node ')'
{
$$ = SQL_NEW_RULE;
$$->append($1);
@@ -2662,12 +2664,43 @@ derived_column:
$$->append($2);
}
;
/* Tabellenname */
/* Tabellenname */
table_node:
catalog_name
| schema_name
| table_name
;
catalog_name:
SQL_TOKEN_NAME '.' schema_name
{
$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
$$->append($3);
}
| SQL_TOKEN_NAME ':' schema_name
{
$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(":", SQL_NODE_PUNCTUATION));
$$->append($3);
}
;
schema_name:
SQL_TOKEN_NAME '.' table_name
{
$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
$$->append($3);
}
;
table_name:
SQL_TOKEN_NAME
{$$ = SQL_NEW_RULE;
$$->append($1);}
| SQL_TOKEN_NAME '.' SQL_TOKEN_NAME %prec SQL_TOKEN_NAME
/* | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME %prec SQL_TOKEN_NAME
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
@@ -2693,17 +2726,18 @@ table_name:
$$->append($3);
$$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
$$->append($5);}
*/ ;
*/ ;
/* Columns */
column_ref:
column
{$$ = SQL_NEW_RULE;
$$->append($1);}
| SQL_TOKEN_NAME '.' column_val %prec '.'
| table_node '.' column_val %prec '.'
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
$$->append($3);}
| SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
/* | SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
{$$ = SQL_NEW_RULE;
$$->append($1);
$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
@@ -3294,9 +3328,8 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const :
// get the field type
m_xField->getPropertyValue(FIELD_STR_TYPE) >>= nType;
}
catch(Exception&)
{
OSL_ENSHURE(0,"OSQLParser::predicateTree throws an Exception!");
catch ( ... )
{
}
if (m_nFormatKey && m_xFormatter.is())
@@ -3462,7 +3495,11 @@ sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule)
case OSQLParseNode::table_exp:
s_nRuleIDs[eRule] = StrToRuleID("table_exp"); break;
case OSQLParseNode::table_ref:
s_nRuleIDs[eRule] = StrToRuleID("table_ref"); break;
s_nRuleIDs[eRule] = StrToRuleID("table_ref"); break;
case OSQLParseNode::catalog_name:
s_nRuleIDs[eRule] = StrToRuleID("catalog_name"); break;
case OSQLParseNode::schema_name:
s_nRuleIDs[eRule] = StrToRuleID("schema_name"); break;
case OSQLParseNode::table_name:
s_nRuleIDs[eRule] = StrToRuleID("table_name"); break;
case OSQLParseNode::opt_column_commalist:
@@ -3632,7 +3669,6 @@ sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule)
}
catch(Exception&)
{
OSL_ENSHURE(0,"OSQLParser::stringToDouble throws an Exception!");
}
}
return aValue;
@@ -3669,9 +3705,8 @@ sal_Int16 OSQLParser::buildNode_STR_NUM(OSQLParseNode*& pAppend,OSQLParseNode*&
m_nFormatKey, rtl::OUString::createFromAscii("Decimals"));
aValue >>= nScale;
}
catch(Exception&)
{
OSL_ENSHURE(0,"OSQLParser::buildNode_STR_NUM throws an Exception!");
catch ( ... )
{
}
pComp->append(new OSQLInternalNode(stringToDouble(pLiteral->getTokenValue(),nScale),SQL_NODE_STRING));
@@ -3764,7 +3799,7 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi
aValue >>= nType;
}
}
catch(Exception&)
catch ( ... )
{
return nErg;
}
@@ -3798,9 +3833,8 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi
m_nFormatKey, rtl::OUString::createFromAscii("Decimals"));
aValue >>= nScale;
}
catch(Exception&)
{
OSL_ENSHURE(0,"OSQLParser::SQL_NODE_APPROXNUM throws an Exception!");
catch ( ... )
{
}
pAppend->append(new OSQLInternalNode(stringToDouble(pLiteral->getTokenValue(),nScale),SQL_NODE_STRING));
@@ -3879,7 +3913,7 @@ sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode*
aValue >>= nType;
}
}
catch(Exception&)
catch ( ... )
{
return nErg;
}
@@ -3920,7 +3954,7 @@ sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode*
double fValue = m_xFormatter->convertStringToNumber(m_nFormatKey, pLiteral->getTokenValue().getStr());
nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare);
}
catch(Exception&)
catch ( ... )
{
try
{
@@ -3940,7 +3974,7 @@ sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode*
}
}
catch(Exception&)
catch ( ... )
{
nErg = -1;
m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE);
@@ -3969,7 +4003,7 @@ sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode*
double fValue = m_xFormatter->convertStringToNumber(m_nFormatKey, pLiteral->getTokenValue().getStr());
nErg = buildNode_Date(fValue, nType, pAppend,pLiteral,pCompare);
}
catch(Exception&)
catch ( ... )
{
try
{
@@ -3988,7 +4022,7 @@ sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode*
m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE);
}
}
catch(Exception&)
catch ( ... )
{
nErg = -1;
m_sErrorMessage = m_pContext->getErrorMessage(OParseContext::ERROR_INVALID_DATE_COMPARE);

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: sqliterator.cxx,v $
*
* $Revision: 1.11 $
* $Revision: 1.12 $
*
* last change: $Author: oj $ $Date: 2001-01-04 10:59:52 $
* last change: $Author: oj $ $Date: 2001-01-09 13:07:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -209,26 +209,37 @@ void OSQLParseTreeIterator::traverseOneTableName(const OSQLParseNode * pTableNam
OSL_ENSHURE(pTableName != NULL,"OSQLParseTreeIterator::traverseOneTableName: pTableName == NULL");
::rtl::OUString aTableName;
Any aCatalog;
::rtl::OUString aSchema,aTableName,aComposedName;
::rtl::OUString aTableRange(rTableRange);
// Tabellenname abholen
pTableName->parseNodeToStr(aTableName,m_xDatabaseMetaData,NULL,sal_False,sal_False);
// Wenn keine Range Variable angegeben, dann den Tabellennamen verwenden.
if (!aTableRange.getLength())
aTableRange = aTableName;
OSQLParseNode::getTableComponents(pTableName,aCatalog,aSchema,aTableName);
if(aTableName.getLength())
// create the composed name like DOMAIN.USER.TABLE1
::dbtools::composeTableName(m_xDatabaseMetaData,
aCatalog.hasValue() ? ::comphelper::getString(aCatalog) : ::rtl::OUString(),
aSchema,
aTableName,
aComposedName,
sal_False);
// if there is no alias for the table name assign the orignal name to it
if (!aTableRange.getLength())
aTableRange = aComposedName;
if(aComposedName.getLength())
{
try
{
if(!m_xTables->hasByName(aTableName)) // name not in XNameAccess
if(!m_xTables->hasByName(aComposedName)) // name not in XNameAccess
{
// exists the name in the metadata ?!
if(!aSchema.getLength())
aSchema = ::rtl::OUString::createFromAscii("%");
const ::rtl::OUString sAll = ::rtl::OUString::createFromAscii("%");
Sequence< ::rtl::OUString > aSeq;
Reference< XResultSet> xRes = m_xDatabaseMetaData->getTables(Any(),sAll,aTableName,aSeq);
aTableName = ::rtl::OUString(); // now clear the name to avoid reassignment
Reference< XResultSet> xRes = m_xDatabaseMetaData->getTables(aCatalog,aSchema,aTableName,aSeq);
aComposedName = ::rtl::OUString(); // now clear the name to avoid reassignment
if(xRes.is() && xRes->next())
{
::rtl::OUString sCatalog, sSchema, sName;
@@ -236,12 +247,12 @@ void OSQLParseTreeIterator::traverseOneTableName(const OSQLParseNode * pTableNam
::dbtools::composeTableName(m_xDatabaseMetaData, xCurrentRow->getString(1),
xCurrentRow->getString(2),
xCurrentRow->getString(3),
aTableName,
aComposedName,
sal_False);
}
}
if(m_xTables->hasByName(aTableName)) // the name can be changed before
m_xTables->getByName(aTableName) >>= m_aTables[aTableRange];
if(m_xTables->hasByName(aComposedName)) // the name can be changed before
m_xTables->getByName(aComposedName) >>= m_aTables[aTableRange];
}
catch(Exception&)
@@ -258,16 +269,20 @@ OSQLParseNode * OSQLParseTreeIterator::getQualified_join(OSQLParseNode *pTableRe
aTableRange = ::rtl::OUString();
OSQLParseNode *pNode = getTableRef(pTableRef->getChild(0),aTableRange);
if(pNode)
if(isTableNode(pNode))
traverseOneTableName(pNode,aTableRange);
else
OSL_ENSURE(0,"To tableNode found!");
sal_uInt32 nPos = 4;
if(SQL_ISRULE(pTableRef,cross_union) || pTableRef->getChild(1)->getTokenID() != SQL_TOKEN_NATURAL)
nPos = 3;
pNode = getTableRef(pTableRef->getChild(nPos),aTableRange);
if(pNode)
if(isTableNode(pNode))
traverseOneTableName(pNode,aTableRange);
else
OSL_ENSURE(0,"To tableNode found!");
return pNode;
}
//-----------------------------------------------------------------------------
@@ -285,7 +300,7 @@ OSQLParseNode * OSQLParseTreeIterator::getTableRef(OSQLParseNode *pTableRef,::rt
else
{
// Tabellennamen gefunden
if(!SQL_ISRULE(pTableName,table_name))
if(!isTableNode(pTableName))
pTableName = pTableRef->getChild(0);
aTableRange = ::rtl::OUString();
if(pTableRef->count() == 4)
@@ -340,16 +355,16 @@ void OSQLParseTreeIterator::getSelect_statement(OSQLParseNode *pSelect)
{ // from clause durchlaufen
aTableRange = ::rtl::OUString();
if (SQL_ISRULE(pTableRefCommalist->getChild(i),table_name))
if (isTableNode(pTableRefCommalist->getChild(i)))
{
pTableName = pTableRefCommalist->getChild(i);
traverseOneTableName(pTableName,aTableRange);// Keine Range Variable
traverseOneTableName(pTableName,aTableRange);// aTableRange will be set inside to the tablename
}
else if (SQL_ISRULE(pTableRefCommalist->getChild(i),table_ref))
{
// Tabellenreferenz kann aus Tabellennamen, Tabellennamen (+),'('joined_table')'(+) bestehen
pTableName = pTableRefCommalist->getChild(i)->getChild(0);
if (SQL_ISRULE(pTableName,table_name))
if(isTableNode(pTableName))
{ // Tabellennamen gefunden
if(pTableRefCommalist->getChild(i)->count() == 4) // Tabellenrange an Pos 2
aTableRange = pTableRefCommalist->getChild(i)->getChild(2)->getTokenValue();
@@ -534,14 +549,18 @@ void OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele
}
else if (SQL_ISRULE(pSelectNode->getChild(2),scalar_exp_commalist))
{
// SELECT column(,column) oder SELECT COUNT(*) ...
// SELECT column[,column] oder SELECT COUNT(*) ...
OSQLParseNode * pSelection = pSelectNode->getChild(2);
for (sal_uInt32 i = 0; i < pSelection->count(); i++)
{
OSQLParseNode *pColumnRef = pSelection->getChild(i);
if (SQL_ISRULE(pColumnRef,select_sublist))
//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),"*"))
{
// alle Spalten der Tabelle
::rtl::OUString aTableRange;
@@ -1448,5 +1467,12 @@ const OSQLParseNode* OSQLParseTreeIterator::getHavingTree() const
pHavingClause = NULL;
return pHavingClause;
}
// -----------------------------------------------------------------------------
sal_Bool OSQLParseTreeIterator::isTableNode(const OSQLParseNode* _pTableNode) const
{
return _pTableNode && (SQL_ISRULE(_pTableNode,catalog_name) ||
SQL_ISRULE(_pTableNode,schema_name) ||
SQL_ISRULE(_pTableNode,table_name));
}

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: sqlnode.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: svesik $ $Date: 2000-11-22 16:51:52 $
* last change: $Author: oj $ $Date: 2001-01-09 13:07:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1399,5 +1399,46 @@ OSQLParseNode* OSQLParseNode::replace (OSQLParseNode* pOldSubNode, OSQLParseNode
::std::replace(m_aChilds.begin(), m_aChilds.end(), pOldSubNode, pNewSubNode);
return pOldSubNode;
}
// -----------------------------------------------------------------------------
sal_Bool OSQLParseNode::getTableComponents(const OSQLParseNode* _pTableNode,
::com::sun::star::uno::Any &_rCatalog,
::rtl::OUString &_rSchema,
::rtl::OUString &_rTable)
{
OSL_ENSURE(_pTableNode,"Wrong use of getTableComponents! _pTableNode is not allowed to be null!");
if(_pTableNode)
{
const OSQLParseNode* pTableNode = _pTableNode;
// clear the parameter given
_rCatalog = Any();
_rSchema = _rTable = ::rtl::OUString();
// see rule catalog_name: in sqlbison.y
if (SQL_ISRULE(pTableNode,catalog_name))
{
OSL_ENSURE(pTableNode->getChild(0) && pTableNode->getChild(0)->isToken(),"Invalid parsenode!");
_rCatalog <<= pTableNode->getChild(0)->getTokenValue();
pTableNode = pTableNode->getChild(2);
}
// check if we have schema_name rule
if(SQL_ISRULE(pTableNode,schema_name))
{
_rSchema = pTableNode->getChild(0)->getTokenValue();
pTableNode = pTableNode->getChild(2);
}
// check if we have table_name rule
if(SQL_ISRULE(pTableNode,table_name))
{
_rTable = pTableNode->getChild(0)->getTokenValue();
}
else
{
OSL_ENSURE(0,"Error in parse tree!");
}
}
return _rTable.getLength() != 0;
}
// -----------------------------------------------------------------------------