fdo#72267 boolean_test is subsumed by general case "foo IS [NOT] bar"
Change-Id: Ie9666b1c8878dd26593629b4b64d74b7448f98c1
This commit is contained in:
@@ -222,7 +222,7 @@ using namespace connectivity;
|
||||
%type <pParseNode> non_join_query_term non_join_query_primary simple_table
|
||||
%type <pParseNode> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
|
||||
%type <pParseNode> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
|
||||
%type <pParseNode> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec
|
||||
%type <pParseNode> boolean_factor boolean_primary named_columns_join join_spec
|
||||
%type <pParseNode> cast_operand cast_target factor datetime_value_exp /*interval_value_exp*/ datetime_term datetime_factor
|
||||
%type <pParseNode> datetime_primary datetime_value_fct time_zone time_zone_specifier /*interval_term*/ interval_qualifier
|
||||
%type <pParseNode> start_field non_second_datetime_field end_field single_datetime_field extract_field datetime_field time_zone_field
|
||||
@@ -1081,12 +1081,6 @@ opt_having_clause:
|
||||
;
|
||||
|
||||
/* search conditions */
|
||||
truth_value:
|
||||
SQL_TOKEN_TRUE
|
||||
| SQL_TOKEN_FALSE
|
||||
| SQL_TOKEN_UNKNOWN
|
||||
| SQL_TOKEN_NULL
|
||||
;
|
||||
boolean_primary:
|
||||
predicate
|
||||
| '(' search_condition ')'
|
||||
@@ -1130,20 +1124,9 @@ parenthesized_boolean_value_expression:
|
||||
$$->append(newNode(")", SQL_NODE_PUNCTUATION));
|
||||
}
|
||||
;
|
||||
boolean_test:
|
||||
boolean_primary
|
||||
| boolean_primary SQL_TOKEN_IS sql_not truth_value
|
||||
{
|
||||
$$ = SQL_NEW_RULE;
|
||||
$$->append($1);
|
||||
$$->append($2);
|
||||
$$->append($3);
|
||||
$$->append($4);
|
||||
}
|
||||
;
|
||||
boolean_factor:
|
||||
boolean_test
|
||||
| SQL_TOKEN_NOT boolean_test
|
||||
boolean_primary
|
||||
| SQL_TOKEN_NOT boolean_primary
|
||||
{ // boolean_factor: rule 1
|
||||
$$ = SQL_NEW_RULE;
|
||||
$$->append($1);
|
||||
@@ -1171,12 +1154,12 @@ search_condition:
|
||||
}
|
||||
;
|
||||
predicate:
|
||||
comparison_predicate
|
||||
comparison_predicate %dprec 2
|
||||
| between_predicate
|
||||
| all_or_any_predicate
|
||||
| existence_test
|
||||
| unique_test
|
||||
| test_for_null
|
||||
| test_for_null %dprec 1
|
||||
| in_predicate
|
||||
| like_predicate
|
||||
;
|
||||
@@ -1391,6 +1374,13 @@ null_predicate_part_2:
|
||||
$$->append($2);
|
||||
$$->append($3);
|
||||
}
|
||||
| SQL_TOKEN_IS sql_not SQL_TOKEN_UNKNOWN
|
||||
{
|
||||
$$ = SQL_NEW_RULE; // test_for_null: rule 1
|
||||
$$->append($1);
|
||||
$$->append($2);
|
||||
$$->append($3);
|
||||
}
|
||||
;
|
||||
test_for_null:
|
||||
row_value_constructor null_predicate_part_2
|
||||
@@ -3959,11 +3949,11 @@ when_operand_list:
|
||||
;
|
||||
when_operand:
|
||||
row_value_constructor_elem
|
||||
| comparison_predicate_part_2
|
||||
| comparison_predicate_part_2 %dprec 2
|
||||
| between_predicate_part_2
|
||||
| in_predicate_part_2
|
||||
| character_like_predicate_part_2
|
||||
| null_predicate_part_2
|
||||
| null_predicate_part_2 %dprec 1
|
||||
;
|
||||
searched_when_clause_list:
|
||||
searched_when_clause
|
||||
|
@@ -619,7 +619,6 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const
|
||||
case unique_test:
|
||||
case all_or_any_predicate:
|
||||
case join_condition:
|
||||
case boolean_test:
|
||||
case comparison_predicate_part_2:
|
||||
case parenthesized_boolean_value_expression:
|
||||
case other_like_predicate_part_2:
|
||||
@@ -1384,6 +1383,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
|
||||
{ OSQLParseNode::where_clause, "where_clause" },
|
||||
{ OSQLParseNode::opt_where_clause, "opt_where_clause" },
|
||||
{ OSQLParseNode::search_condition, "search_condition" },
|
||||
{ OSQLParseNode::comparison, "comparison" },
|
||||
{ OSQLParseNode::comparison_predicate, "comparison_predicate" },
|
||||
{ OSQLParseNode::between_predicate, "between_predicate" },
|
||||
{ OSQLParseNode::like_predicate, "like_predicate" },
|
||||
@@ -1431,7 +1431,6 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
|
||||
{ OSQLParseNode::joined_table, "joined_table" },
|
||||
{ OSQLParseNode::boolean_factor, "boolean_factor" },
|
||||
{ OSQLParseNode::sql_not, "sql_not" },
|
||||
{ OSQLParseNode::boolean_test, "boolean_test" },
|
||||
{ OSQLParseNode::manipulative_statement, "manipulative_statement" },
|
||||
{ OSQLParseNode::subquery, "subquery" },
|
||||
{ OSQLParseNode::value_exp_commalist, "value_exp_commalist" },
|
||||
@@ -1966,7 +1965,7 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
||||
negateSearchCondition(pLeft,bNegate);
|
||||
negateSearchCondition(pRight,bNegate);
|
||||
}
|
||||
// SQL_TOKEN_NOT ( boolean_test )
|
||||
// SQL_TOKEN_NOT ( boolean_primary )
|
||||
else if (SQL_ISRULE(pSearchCondition,boolean_factor))
|
||||
{
|
||||
OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0);
|
||||
@@ -1982,8 +1981,29 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
||||
// row_value_constructor comparison any_all_some subquery
|
||||
else if(bNegate && (SQL_ISRULE(pSearchCondition,comparison_predicate) || SQL_ISRULE(pSearchCondition,all_or_any_predicate)))
|
||||
{
|
||||
assert(pSearchCondition->count() == 3);
|
||||
OSQLParseNode* pComparison = pSearchCondition->getChild(1);
|
||||
OSQLParseNode* pNewComparison = NULL;
|
||||
if(SQL_ISRULE(pComparison, comparison))
|
||||
{
|
||||
assert(pComparison->count() == 2 ||
|
||||
pComparison->count() == 4);
|
||||
assert(SQL_ISTOKEN(pComparison->getChild(0), IS));
|
||||
|
||||
OSQLParseNode* pNot = pComparison->getChild(1);
|
||||
OSQLParseNode* pNotNot = NULL;
|
||||
if(pNot->isRule()) // no NOT token (empty rule)
|
||||
pNotNot = new OSQLParseNode(OUString("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT);
|
||||
else
|
||||
{
|
||||
assert(SQL_ISTOKEN(pNot,NOT));
|
||||
pNotNot = new OSQLParseNode(OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
|
||||
}
|
||||
pComparison->replace(pNot, pNotNot);
|
||||
delete pNot;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(pComparison->getNodeType())
|
||||
{
|
||||
case SQL_NODE_EQUAL:
|
||||
@@ -2008,28 +2028,29 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
||||
SAL_WARN( "connectivity.parse", "OSQLParseNode::negateSearchCondition: unexpected node type!" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
pSearchCondition->replace(pComparison, pNewComparison);
|
||||
delete pComparison;
|
||||
}
|
||||
|
||||
else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) || SQL_ISRULE(pSearchCondition,in_predicate) ||
|
||||
SQL_ISRULE(pSearchCondition,between_predicate) || SQL_ISRULE(pSearchCondition,boolean_test) ))
|
||||
else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) ||
|
||||
SQL_ISRULE(pSearchCondition,in_predicate) ||
|
||||
SQL_ISRULE(pSearchCondition,between_predicate) ))
|
||||
{
|
||||
OSQLParseNode* pPart2 = pSearchCondition;
|
||||
if ( !SQL_ISRULE(pSearchCondition,boolean_test) )
|
||||
pPart2 = pSearchCondition->getChild(1);
|
||||
OSQLParseNode* pPart2 = pSearchCondition->getChild(1);
|
||||
sal_uInt32 nNotPos = 0;
|
||||
if ( SQL_ISRULE( pSearchCondition, test_for_null ) )
|
||||
nNotPos = 1;
|
||||
else if ( SQL_ISRULE( pSearchCondition, boolean_test ) )
|
||||
nNotPos = 2;
|
||||
|
||||
OSQLParseNode* pNot = pPart2->getChild(nNotPos);
|
||||
OSQLParseNode* pNotNot = NULL;
|
||||
if(pNot->isRule())
|
||||
if(pNot->isRule()) // no NOT token (empty rule)
|
||||
pNotNot = new OSQLParseNode(OUString("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT);
|
||||
else
|
||||
{
|
||||
assert(SQL_ISTOKEN(pNot,NOT));
|
||||
pNotNot = new OSQLParseNode(OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
|
||||
}
|
||||
pPart2->replace(pNot, pNotNot);
|
||||
delete pNot;
|
||||
}
|
||||
|
@@ -3345,6 +3345,7 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p
|
||||
case OSQLParseNode::op_column_commalist:
|
||||
case OSQLParseNode::table_primary_as_range_column:
|
||||
case OSQLParseNode::character_string_type:
|
||||
case OSQLParseNode::comparison:
|
||||
OSL_FAIL("Unexpected SQL RuleID");
|
||||
break;
|
||||
case OSQLParseNode::column:
|
||||
@@ -3373,7 +3374,6 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p
|
||||
case OSQLParseNode::all_or_any_predicate:
|
||||
case OSQLParseNode::join_condition:
|
||||
case OSQLParseNode::boolean_factor:
|
||||
case OSQLParseNode::boolean_test:
|
||||
case OSQLParseNode::comparison_predicate_part_2:
|
||||
case OSQLParseNode::parenthesized_boolean_value_expression:
|
||||
case OSQLParseNode::other_like_predicate_part_2:
|
||||
|
@@ -149,6 +149,7 @@ namespace connectivity
|
||||
where_clause,
|
||||
opt_where_clause,
|
||||
search_condition,
|
||||
comparison,
|
||||
comparison_predicate,
|
||||
between_predicate,
|
||||
like_predicate,
|
||||
@@ -196,7 +197,6 @@ namespace connectivity
|
||||
joined_table,
|
||||
boolean_factor,
|
||||
sql_not,
|
||||
boolean_test,
|
||||
manipulative_statement,
|
||||
subquery,
|
||||
value_exp_commalist,
|
||||
|
Reference in New Issue
Block a user