|
From: <asf...@us...> - 2015-05-15 16:10:41
|
Revision: 61551
http://sourceforge.net/p/firebird/code/61551
Author: asfernandes
Date: 2015-05-15 16:10:39 +0000 (Fri, 15 May 2015)
Log Message:
-----------
1) Improvement CORE-4791 - Make INSERTING/UPDATING/DELETING reserved words to fix ambiguity with boolean expresions.
2) Fixed CORE-4735 - Expression 'where bool_field IS true | false' should also use index as 'where bool_field = true | false' (if such index exists).
Modified Paths:
--------------
firebird/trunk/doc/sql.extensions/README.data_types
firebird/trunk/doc/sql.extensions/README.keywords
firebird/trunk/src/dsql/BoolNodes.cpp
firebird/trunk/src/dsql/BoolNodes.h
firebird/trunk/src/dsql/Parser.h
firebird/trunk/src/dsql/parse.y
Modified: firebird/trunk/doc/sql.extensions/README.data_types
===================================================================
--- firebird/trunk/doc/sql.extensions/README.data_types 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/doc/sql.extensions/README.data_types 2015-05-15 16:10:39 UTC (rev 61551)
@@ -74,9 +74,3 @@
5. It's allowed to test booleans without compare with TRUE or FALSE. For example,
"field1 OR field2" and "NOT field1" are valid expressions. It's also allowed to compare with
others operators, including the new IS operator: "field1 IS FALSE".
-
- 6. For compatibility reasons, the names INSERTING, UPDATING and DELETING (which aren't keywords)
- work (like in 2.5 and previous) as boolean expressions and work as values (column or
- variable) in non-booleans expressions. For example, in:
- SELECT INSERTING, NOT INSERTING FROM TEST WHERE INSERTING AND INSERTING IS TRUE
- the INSERTING's are respectively recognized as value, keyword, keyword and value.
Modified: firebird/trunk/doc/sql.extensions/README.keywords
===================================================================
--- firebird/trunk/doc/sql.extensions/README.keywords 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/doc/sql.extensions/README.keywords 2015-05-15 16:10:39 UTC (rev 61551)
@@ -221,8 +221,10 @@
Added as reserved words:
BOOLEAN
+ DELETING *
DETERMINISTIC
FALSE
+ INSERTING *
OVER
RDB$RECORD_VERSION
RETURN
@@ -230,6 +232,7 @@
SQLSTATE
TRUE
UNKNOWN
+ UPDATING *
Added as non-reserved words:
Modified: firebird/trunk/src/dsql/BoolNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/BoolNodes.cpp 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/src/dsql/BoolNodes.cpp 2015-05-15 16:10:39 UTC (rev 61551)
@@ -343,7 +343,6 @@
: TypedNode<BoolExprNode, ExprNode::TYPE_COMPARATIVE_BOOL>(pool),
blrOp(aBlrOp),
dsqlFlag(DFLAG_NONE),
- dsqlWasValue(false),
arg1(aArg1),
arg2(aArg2),
arg3(aArg3),
@@ -390,27 +389,6 @@
NestConst<ValueExprNode> procArg3 = arg3;
FieldNode* fieldNode1;
- // Make INSERTING/UPDATING/DELETING in booleans to read the trigger action.
-
- if (dsqlWasValue && (fieldNode1 = procArg1->as<FieldNode>()))
- {
- static const char* const NAMES[] = {
- "INSERTING",
- "UPDATING",
- "DELETING"
- };
-
- for (int i = 0; i < FB_NELEM(NAMES); ++i)
- {
- if (fieldNode1->dsqlName == NAMES[i])
- {
- procArg1 = FB_NEW(getPool()) InternalInfoNode(getPool(),
- MAKE_const_slong(INFO_TYPE_TRIGGER_ACTION));
- procArg2 = MAKE_const_slong(i + 1);
- }
- }
- }
-
if (dsqlSpecialArg)
{
ValueListNode* listNode = dsqlSpecialArg->as<ValueListNode>();
@@ -1571,7 +1549,6 @@
ComparativeBoolNode* node = FB_NEW(getPool()) ComparativeBoolNode(
getPool(), newBlrOp, cmpArg->arg1, cmpArg->arg2);
- node->dsqlWasValue = cmpArg->dsqlWasValue;
node->dsqlSpecialArg = cmpArg->dsqlSpecialArg;
if (cmpArg->dsqlFlag == ComparativeBoolNode::DFLAG_ANSI_ANY)
Modified: firebird/trunk/src/dsql/BoolNodes.h
===================================================================
--- firebird/trunk/src/dsql/BoolNodes.h 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/src/dsql/BoolNodes.h 2015-05-15 16:10:39 UTC (rev 61551)
@@ -103,7 +103,6 @@
public:
UCHAR blrOp;
DsqlFlag dsqlFlag;
- bool dsqlWasValue;
NestConst<ValueExprNode> arg1;
NestConst<ValueExprNode> arg2;
NestConst<ValueExprNode> arg3;
Modified: firebird/trunk/src/dsql/Parser.h
===================================================================
--- firebird/trunk/src/dsql/Parser.h 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/src/dsql/Parser.h 2015-05-15 16:10:39 UTC (rev 61551)
@@ -213,7 +213,6 @@
ComparativeBoolNode* cmpNode = newNode<ComparativeBoolNode>(
blr_eql, value, MAKE_constant("1", CONSTANT_BOOLEAN));
- cmpNode->dsqlWasValue = true;
return cmpNode;
}
Modified: firebird/trunk/src/dsql/parse.y
===================================================================
--- firebird/trunk/src/dsql/parse.y 2015-05-15 16:08:31 UTC (rev 61550)
+++ firebird/trunk/src/dsql/parse.y 2015-05-15 16:10:39 UTC (rev 61551)
@@ -3829,8 +3829,10 @@
| CORR
| COVAR_POP
| COVAR_SAMP
+ | DELETING
| DETERMINISTIC
| KW_FALSE
+ | INSERTING
| OFFSET
| OVER
| REGR_AVGX
@@ -3851,6 +3853,7 @@
| STDDEV_POP
| KW_TRUE
| UNKNOWN
+ | UPDATING
| VAR_SAMP
| VAR_POP
;
@@ -5941,13 +5944,9 @@
| '(' boolean_value_expression ')'
{ $$ = $2; }
| value IS boolean_literal
- { $$ = newNode<ComparativeBoolNode>(blr_equiv, newNode<BoolAsValueNode>(valueToBool($1)), $3); }
+ { $$ = newNode<ComparativeBoolNode>(blr_eql, $1, $3); }
| value IS NOT boolean_literal
- {
- ComparativeBoolNode* node = newNode<ComparativeBoolNode>(blr_equiv,
- newNode<BoolAsValueNode>(valueToBool($1)), $4);
- $$ = newNode<NotBoolNode>(node);
- }
+ { $$ = newNode<NotBoolNode>(newNode<ComparativeBoolNode>(blr_eql, $1, $4)); }
;
%type <boolExprNode> predicate
@@ -5962,6 +5961,7 @@
| quantified_predicate
| exists_predicate
| singular_predicate
+ | trigger_action_predicate
;
@@ -6116,6 +6116,28 @@
{ $$ = newNode<RseBoolNode>(blr_unique, $3); }
;
+%type <boolExprNode> trigger_action_predicate
+trigger_action_predicate
+ : INSERTING
+ {
+ $$ = newNode<ComparativeBoolNode>(blr_eql,
+ newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_TRIGGER_ACTION)),
+ MAKE_const_slong(1));
+ }
+ | UPDATING
+ {
+ $$ = newNode<ComparativeBoolNode>(blr_eql,
+ newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_TRIGGER_ACTION)),
+ MAKE_const_slong(2));
+ }
+ | DELETING
+ {
+ $$ = newNode<ComparativeBoolNode>(blr_eql,
+ newNode<InternalInfoNode>(MAKE_const_slong(INFO_TYPE_TRIGGER_ACTION)),
+ MAKE_const_slong(3));
+ }
+ ;
+
%type <boolExprNode> null_predicate
null_predicate
: value IS KW_NULL
@@ -7502,9 +7524,6 @@
| NULLIF
| NULLS
| STATEMENT
- | INSERTING
- | UPDATING
- | DELETING
| FIRST
| SKIP
| BLOCK // added in FB 2.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|