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> 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> 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> 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> 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> 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
|
%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 */
|
/* search conditions */
|
||||||
truth_value:
|
|
||||||
SQL_TOKEN_TRUE
|
|
||||||
| SQL_TOKEN_FALSE
|
|
||||||
| SQL_TOKEN_UNKNOWN
|
|
||||||
| SQL_TOKEN_NULL
|
|
||||||
;
|
|
||||||
boolean_primary:
|
boolean_primary:
|
||||||
predicate
|
predicate
|
||||||
| '(' search_condition ')'
|
| '(' search_condition ')'
|
||||||
@@ -1130,20 +1124,9 @@ parenthesized_boolean_value_expression:
|
|||||||
$$->append(newNode(")", SQL_NODE_PUNCTUATION));
|
$$->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_factor:
|
||||||
boolean_test
|
boolean_primary
|
||||||
| SQL_TOKEN_NOT boolean_test
|
| SQL_TOKEN_NOT boolean_primary
|
||||||
{ // boolean_factor: rule 1
|
{ // boolean_factor: rule 1
|
||||||
$$ = SQL_NEW_RULE;
|
$$ = SQL_NEW_RULE;
|
||||||
$$->append($1);
|
$$->append($1);
|
||||||
@@ -1171,12 +1154,12 @@ search_condition:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
predicate:
|
predicate:
|
||||||
comparison_predicate
|
comparison_predicate %dprec 2
|
||||||
| between_predicate
|
| between_predicate
|
||||||
| all_or_any_predicate
|
| all_or_any_predicate
|
||||||
| existence_test
|
| existence_test
|
||||||
| unique_test
|
| unique_test
|
||||||
| test_for_null
|
| test_for_null %dprec 1
|
||||||
| in_predicate
|
| in_predicate
|
||||||
| like_predicate
|
| like_predicate
|
||||||
;
|
;
|
||||||
@@ -1384,13 +1367,20 @@ opt_escape:
|
|||||||
;
|
;
|
||||||
|
|
||||||
null_predicate_part_2:
|
null_predicate_part_2:
|
||||||
SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
|
SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
|
||||||
{
|
{
|
||||||
$$ = SQL_NEW_RULE; // test_for_null: rule 1
|
$$ = SQL_NEW_RULE; // test_for_null: rule 1
|
||||||
$$->append($1);
|
$$->append($1);
|
||||||
$$->append($2);
|
$$->append($2);
|
||||||
$$->append($3);
|
$$->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:
|
test_for_null:
|
||||||
row_value_constructor null_predicate_part_2
|
row_value_constructor null_predicate_part_2
|
||||||
@@ -3959,11 +3949,11 @@ when_operand_list:
|
|||||||
;
|
;
|
||||||
when_operand:
|
when_operand:
|
||||||
row_value_constructor_elem
|
row_value_constructor_elem
|
||||||
| comparison_predicate_part_2
|
| comparison_predicate_part_2 %dprec 2
|
||||||
| between_predicate_part_2
|
| between_predicate_part_2
|
||||||
| in_predicate_part_2
|
| in_predicate_part_2
|
||||||
| character_like_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_list:
|
||||||
searched_when_clause
|
searched_when_clause
|
||||||
|
@@ -619,7 +619,6 @@ void OSQLParseNode::impl_parseNodeToString_throw(OUStringBuffer& rString, const
|
|||||||
case unique_test:
|
case unique_test:
|
||||||
case all_or_any_predicate:
|
case all_or_any_predicate:
|
||||||
case join_condition:
|
case join_condition:
|
||||||
case boolean_test:
|
|
||||||
case comparison_predicate_part_2:
|
case comparison_predicate_part_2:
|
||||||
case parenthesized_boolean_value_expression:
|
case parenthesized_boolean_value_expression:
|
||||||
case other_like_predicate_part_2:
|
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::where_clause, "where_clause" },
|
||||||
{ OSQLParseNode::opt_where_clause, "opt_where_clause" },
|
{ OSQLParseNode::opt_where_clause, "opt_where_clause" },
|
||||||
{ OSQLParseNode::search_condition, "search_condition" },
|
{ OSQLParseNode::search_condition, "search_condition" },
|
||||||
|
{ OSQLParseNode::comparison, "comparison" },
|
||||||
{ OSQLParseNode::comparison_predicate, "comparison_predicate" },
|
{ OSQLParseNode::comparison_predicate, "comparison_predicate" },
|
||||||
{ OSQLParseNode::between_predicate, "between_predicate" },
|
{ OSQLParseNode::between_predicate, "between_predicate" },
|
||||||
{ OSQLParseNode::like_predicate, "like_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::joined_table, "joined_table" },
|
||||||
{ OSQLParseNode::boolean_factor, "boolean_factor" },
|
{ OSQLParseNode::boolean_factor, "boolean_factor" },
|
||||||
{ OSQLParseNode::sql_not, "sql_not" },
|
{ OSQLParseNode::sql_not, "sql_not" },
|
||||||
{ OSQLParseNode::boolean_test, "boolean_test" },
|
|
||||||
{ OSQLParseNode::manipulative_statement, "manipulative_statement" },
|
{ OSQLParseNode::manipulative_statement, "manipulative_statement" },
|
||||||
{ OSQLParseNode::subquery, "subquery" },
|
{ OSQLParseNode::subquery, "subquery" },
|
||||||
{ OSQLParseNode::value_exp_commalist, "value_exp_commalist" },
|
{ OSQLParseNode::value_exp_commalist, "value_exp_commalist" },
|
||||||
@@ -1966,7 +1965,7 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
|||||||
negateSearchCondition(pLeft,bNegate);
|
negateSearchCondition(pLeft,bNegate);
|
||||||
negateSearchCondition(pRight,bNegate);
|
negateSearchCondition(pRight,bNegate);
|
||||||
}
|
}
|
||||||
// SQL_TOKEN_NOT ( boolean_test )
|
// SQL_TOKEN_NOT ( boolean_primary )
|
||||||
else if (SQL_ISRULE(pSearchCondition,boolean_factor))
|
else if (SQL_ISRULE(pSearchCondition,boolean_factor))
|
||||||
{
|
{
|
||||||
OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0);
|
OSQLParseNode *pNot = pSearchCondition->removeAt((sal_uInt32)0);
|
||||||
@@ -1982,10 +1981,31 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
|||||||
// row_value_constructor comparison any_all_some subquery
|
// row_value_constructor comparison any_all_some subquery
|
||||||
else if(bNegate && (SQL_ISRULE(pSearchCondition,comparison_predicate) || SQL_ISRULE(pSearchCondition,all_or_any_predicate)))
|
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* pComparison = pSearchCondition->getChild(1);
|
||||||
OSQLParseNode* pNewComparison = NULL;
|
OSQLParseNode* pNewComparison = NULL;
|
||||||
switch(pComparison->getNodeType())
|
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:
|
case SQL_NODE_EQUAL:
|
||||||
pNewComparison = new OSQLParseNode(OUString("<>"),SQL_NODE_NOTEQUAL,SQL_NOTEQUAL);
|
pNewComparison = new OSQLParseNode(OUString("<>"),SQL_NODE_NOTEQUAL,SQL_NOTEQUAL);
|
||||||
break;
|
break;
|
||||||
@@ -2007,29 +2027,30 @@ void OSQLParseNode::negateSearchCondition(OSQLParseNode*& pSearchCondition, sal_
|
|||||||
default:
|
default:
|
||||||
SAL_WARN( "connectivity.parse", "OSQLParseNode::negateSearchCondition: unexpected node type!" );
|
SAL_WARN( "connectivity.parse", "OSQLParseNode::negateSearchCondition: unexpected node type!" );
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pSearchCondition->replace(pComparison, pNewComparison);
|
pSearchCondition->replace(pComparison, pNewComparison);
|
||||||
delete pComparison;
|
delete pComparison;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) || SQL_ISRULE(pSearchCondition,in_predicate) ||
|
else if(bNegate && (SQL_ISRULE(pSearchCondition,test_for_null) ||
|
||||||
SQL_ISRULE(pSearchCondition,between_predicate) || SQL_ISRULE(pSearchCondition,boolean_test) ))
|
SQL_ISRULE(pSearchCondition,in_predicate) ||
|
||||||
|
SQL_ISRULE(pSearchCondition,between_predicate) ))
|
||||||
{
|
{
|
||||||
OSQLParseNode* pPart2 = pSearchCondition;
|
OSQLParseNode* pPart2 = pSearchCondition->getChild(1);
|
||||||
if ( !SQL_ISRULE(pSearchCondition,boolean_test) )
|
|
||||||
pPart2 = pSearchCondition->getChild(1);
|
|
||||||
sal_uInt32 nNotPos = 0;
|
sal_uInt32 nNotPos = 0;
|
||||||
if ( SQL_ISRULE( pSearchCondition, test_for_null ) )
|
if ( SQL_ISRULE( pSearchCondition, test_for_null ) )
|
||||||
nNotPos = 1;
|
nNotPos = 1;
|
||||||
else if ( SQL_ISRULE( pSearchCondition, boolean_test ) )
|
|
||||||
nNotPos = 2;
|
|
||||||
|
|
||||||
OSQLParseNode* pNot = pPart2->getChild(nNotPos);
|
OSQLParseNode* pNot = pPart2->getChild(nNotPos);
|
||||||
OSQLParseNode* pNotNot = NULL;
|
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);
|
pNotNot = new OSQLParseNode(OUString("NOT"),SQL_NODE_KEYWORD,SQL_TOKEN_NOT);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
assert(SQL_ISTOKEN(pNot,NOT));
|
||||||
pNotNot = new OSQLParseNode(OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
|
pNotNot = new OSQLParseNode(OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::sql_not));
|
||||||
|
}
|
||||||
pPart2->replace(pNot, pNotNot);
|
pPart2->replace(pNot, pNotNot);
|
||||||
delete pNot;
|
delete pNot;
|
||||||
}
|
}
|
||||||
|
@@ -3345,6 +3345,7 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p
|
|||||||
case OSQLParseNode::op_column_commalist:
|
case OSQLParseNode::op_column_commalist:
|
||||||
case OSQLParseNode::table_primary_as_range_column:
|
case OSQLParseNode::table_primary_as_range_column:
|
||||||
case OSQLParseNode::character_string_type:
|
case OSQLParseNode::character_string_type:
|
||||||
|
case OSQLParseNode::comparison:
|
||||||
OSL_FAIL("Unexpected SQL RuleID");
|
OSL_FAIL("Unexpected SQL RuleID");
|
||||||
break;
|
break;
|
||||||
case OSQLParseNode::column:
|
case OSQLParseNode::column:
|
||||||
@@ -3373,7 +3374,6 @@ void OQueryDesignView::fillFunctionInfo( const ::connectivity::OSQLParseNode* p
|
|||||||
case OSQLParseNode::all_or_any_predicate:
|
case OSQLParseNode::all_or_any_predicate:
|
||||||
case OSQLParseNode::join_condition:
|
case OSQLParseNode::join_condition:
|
||||||
case OSQLParseNode::boolean_factor:
|
case OSQLParseNode::boolean_factor:
|
||||||
case OSQLParseNode::boolean_test:
|
|
||||||
case OSQLParseNode::comparison_predicate_part_2:
|
case OSQLParseNode::comparison_predicate_part_2:
|
||||||
case OSQLParseNode::parenthesized_boolean_value_expression:
|
case OSQLParseNode::parenthesized_boolean_value_expression:
|
||||||
case OSQLParseNode::other_like_predicate_part_2:
|
case OSQLParseNode::other_like_predicate_part_2:
|
||||||
|
@@ -149,6 +149,7 @@ namespace connectivity
|
|||||||
where_clause,
|
where_clause,
|
||||||
opt_where_clause,
|
opt_where_clause,
|
||||||
search_condition,
|
search_condition,
|
||||||
|
comparison,
|
||||||
comparison_predicate,
|
comparison_predicate,
|
||||||
between_predicate,
|
between_predicate,
|
||||||
like_predicate,
|
like_predicate,
|
||||||
@@ -196,7 +197,6 @@ namespace connectivity
|
|||||||
joined_table,
|
joined_table,
|
||||||
boolean_factor,
|
boolean_factor,
|
||||||
sql_not,
|
sql_not,
|
||||||
boolean_test,
|
|
||||||
manipulative_statement,
|
manipulative_statement,
|
||||||
subquery,
|
subquery,
|
||||||
value_exp_commalist,
|
value_exp_commalist,
|
||||||
|
Reference in New Issue
Block a user