You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2010/07/02 16:09:41 UTC
svn commit: r959991 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/tests/lang/
Author: rhillegas
Date: Fri Jul 2 14:09:40 2010
New Revision: 959991
URL: http://svn.apache.org/viewvc?rev=959991&view=rev
Log:
DERBY-4720: Allow complicated BOOLEAN-valued expressions in SELECT lists, VALUES constructors, routine arguments, and as source values for SET clauses.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/aggregate.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/logop.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/schemas.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery2.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/logop.sql
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/schemas.sql
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery2.sql
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Jul 2 14:09:40 2010
@@ -3578,7 +3578,7 @@ bareCallStatement() throws StandardExcep
ResultSetNode resultSetNode;
}
{
- <CALL> value = primaryExpression( true )
+ <CALL> value = primaryExpression()
{
if (! (value instanceof JavaToSQLValueNode) ||
! (((JavaToSQLValueNode) value).getJavaValueNode() instanceof MethodCallNode))
@@ -3646,11 +3646,8 @@ bareCallStatement() throws StandardExcep
/*
* <A NAME="primaryExpression">primaryExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
-ValueNode primaryExpression( boolean inSelectClause ) throws StandardException :
+ValueNode primaryExpression() throws StandardException :
{
ValueNode value = null;
}
@@ -3666,7 +3663,7 @@ ValueNode primaryExpression( boolean inS
return value;
}
|
- value = primaryExpressionXX( inSelectClause )
+ value = primaryExpressionXX()
{
return value;
}
@@ -5256,9 +5253,7 @@ derivedColumn(ResultColumnList resultCol
String columnName = null;
}
{
- //true to additiveExpression ensures that for the derived columns, we will not allow boolean values inside (),
- //eg (2 > 1) should be disallowed in the select clause
- columnExpression = additiveExpression(null, 0, true)
+ columnExpression = orExpression( null )
[ columnName = asClause() ]
{
/*
@@ -5297,18 +5292,15 @@ asClause() throws StandardException :
/*
* <A NAME="valueExpression">valueExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-valueExpression( boolean inSelectClause ) throws StandardException :
+valueExpression() throws StandardException :
{
ValueNode leftOperand;
}
{
- leftOperand = orExpression(null, inSelectClause)
- (<OR> leftOperand = orExpression(leftOperand, inSelectClause) ) *
+ leftOperand = orExpression(null)
+ (<OR> leftOperand = orExpression(leftOperand) ) *
{
return leftOperand;
@@ -5317,18 +5309,15 @@ valueExpression( boolean inSelectClause
/*
* <A NAME="orExpression">orExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-orExpression(ValueNode farLeftOperand, boolean inSelectClause) throws StandardException :
+orExpression(ValueNode farLeftOperand) throws StandardException :
{
ValueNode leftOperand;
}
{
- leftOperand = andExpression(null, inSelectClause)
- (<AND> leftOperand = andExpression(leftOperand, inSelectClause)) *
+ leftOperand = andExpression(null)
+ (<AND> leftOperand = andExpression(leftOperand)) *
{
if (farLeftOperand == null)
{
@@ -5347,12 +5336,9 @@ orExpression(ValueNode farLeftOperand, b
/*
* <A NAME="andExpression">andExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-andExpression(ValueNode farLeftOperand, boolean inSelectClause) throws StandardException :
+andExpression(ValueNode farLeftOperand) throws StandardException :
{
Token tok = null;
ValueNode test;
@@ -5360,7 +5346,7 @@ andExpression(ValueNode farLeftOperand,
{
//LOOKAHEAD required to tell that NOT is not part of a class name
[ LOOKAHEAD({getToken(1).kind == NOT && !(getToken(2).kind == PERIOD ||
- getToken(2).kind == DOUBLE_COLON)}) tok = <NOT> ] test = isSearchCondition(inSelectClause)
+ getToken(2).kind == DOUBLE_COLON)}) tok = <NOT> ] test = isSearchCondition()
{
/* Put the NOT on top of test */
if (tok != null)
@@ -5385,12 +5371,9 @@ andExpression(ValueNode farLeftOperand,
/*
* <A NAME="isSearchCondition">isSearchCondition</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-isSearchCondition( boolean inSelectClause ) throws StandardException :
+isSearchCondition() throws StandardException :
{
ValueNode result;
ValueNode booleanPrimary;
@@ -5399,7 +5382,7 @@ isSearchCondition( boolean inSelectClaus
Token truthValue = null;
}
{
- booleanPrimary = booleanPrimary(inSelectClause)
+ booleanPrimary = booleanPrimary()
[
isToken = <IS> [ notToken = <NOT> ] <NULL>
]
@@ -5428,18 +5411,15 @@ isSearchCondition( boolean inSelectClaus
/*
* <A NAME="booleanPrimary">booleanPrimary</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-booleanPrimary(boolean inSelectClause) throws StandardException :
+booleanPrimary() throws StandardException :
{
ValueNode primary;
ValueNode searchCondition;
}
{
- primary = predicate(inSelectClause)
+ primary = predicate()
{
return primary;
}
@@ -5447,18 +5427,15 @@ booleanPrimary(boolean inSelectClause) t
/*
* <A NAME="predicate">predicate</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-predicate( boolean inSelectClause ) throws StandardException :
+predicate() throws StandardException :
{
ValueNode value;
}
{
(
- value = additiveExpression(null, 0, inSelectClause) |
+ value = additiveExpression(null, 0) |
value = existsExpression()
)
(
@@ -5466,7 +5443,7 @@ predicate( boolean inSelectClause ) thro
// start with NOT, and what follows a predicate() can also start
// with NOT
LOOKAHEAD( { remainingPredicateFollows() } )
- value = remainingPredicate(value, inSelectClause)
+ value = remainingPredicate(value)
)*
{
return value;
@@ -5488,22 +5465,19 @@ predicate( boolean inSelectClause ) thro
/*
* <A NAME="remainingPredicates">remainingPredicates</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-remainingPredicate(ValueNode value, boolean inSelectClause) throws StandardException :
+remainingPredicate(ValueNode value) throws StandardException :
{
Token tok = null;
}
{
- value = remainingNonNegatablePredicate(value, inSelectClause)
+ value = remainingNonNegatablePredicate(value)
{
return value;
}
|
- [ tok = <NOT> ] value = remainingNegatablePredicate(value, inSelectClause)
+ [ tok = <NOT> ] value = remainingNegatablePredicate(value)
{
/* Put the NOT on top of the tree */
if (tok != null)
@@ -5520,12 +5494,9 @@ remainingPredicate(ValueNode value, bool
/*
* <A NAME="remainingNonNegatablePredicate">remainingNonNegatablePredicate</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-remainingNonNegatablePredicate(ValueNode leftOperand, boolean inSelectClause) throws StandardException :
+remainingNonNegatablePredicate(ValueNode leftOperand) throws StandardException :
{
int operator;
String javaClassName;
@@ -5550,7 +5521,7 @@ remainingNonNegatablePredicate(ValueNode
)
|
(
- leftOperand = additiveExpression(leftOperand, operator, inSelectClause)
+ leftOperand = additiveExpression(leftOperand, operator)
)
)
{
@@ -5560,12 +5531,9 @@ remainingNonNegatablePredicate(ValueNode
/*
* <A NAME="remainingNegatablePredicate">remainingNegatablePredicate</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-remainingNegatablePredicate(ValueNode leftOperand, boolean inSelectClause) throws StandardException :
+remainingNegatablePredicate(ValueNode leftOperand) throws StandardException :
{
ValueNode tree = null;
ValueNode likePattern;
@@ -5579,10 +5547,10 @@ remainingNegatablePredicate(ValueNode le
return tree;
}
|
- <LIKE> likePattern = additiveExpression(null, 0, inSelectClause)
+ <LIKE> likePattern = additiveExpression(null, 0)
[
- <ESCAPE> escapeValue = additiveExpression(null, 0, inSelectClause) |
- <LEFT_BRACE> <ESCAPE> escapeValue = additiveExpression(null, 0, inSelectClause) <RIGHT_BRACE>
+ <ESCAPE> escapeValue = additiveExpression(null, 0) |
+ <LEFT_BRACE> <ESCAPE> escapeValue = additiveExpression(null, 0) <RIGHT_BRACE>
]
{
tree = (ValueNode) nodeFactory.getNode(
@@ -5595,8 +5563,8 @@ remainingNegatablePredicate(ValueNode le
return tree;
}
|
- <BETWEEN> betweenLeft = additiveExpression(null, 0, inSelectClause) <AND>
- betweenRight = additiveExpression(null, 0, inSelectClause)
+ <BETWEEN> betweenLeft = additiveExpression(null, 0) <AND>
+ betweenRight = additiveExpression(null, 0)
{
ValueNodeList betweenList = (ValueNodeList) nodeFactory.getNode(
C_NodeTypes.VALUE_NODE_LIST,
@@ -5658,21 +5626,18 @@ compOp() throws StandardException :
/*
* <A NAME="additiveExpression">additiveExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-additiveExpression(ValueNode farLeftOperand, int compOp, boolean inSelectClause) throws StandardException :
+additiveExpression(ValueNode farLeftOperand, int compOp) throws StandardException :
{
ValueNode leftOperand;
int operator;
int nodeType;
}
{
- leftOperand = multiplicativeExpression(null, 0, inSelectClause)
+ leftOperand = multiplicativeExpression(null, 0)
(operator = additiveOperator()
- leftOperand = multiplicativeExpression(leftOperand, operator, inSelectClause) )*
+ leftOperand = multiplicativeExpression(leftOperand, operator) )*
{
if (farLeftOperand == null)
return leftOperand;
@@ -5739,20 +5704,17 @@ additiveOperator() throws StandardExcept
/*
* <A NAME="multiplicativeExpression">multiplicativeExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-multiplicativeExpression(ValueNode farLeftOperand, int additiveOperator, boolean inSelectClause) throws StandardException :
+multiplicativeExpression(ValueNode farLeftOperand, int additiveOperator) throws StandardException :
{
ValueNode leftOperand;
int multOp;
}
{
- leftOperand = unaryExpression(null, 0, inSelectClause)
+ leftOperand = unaryExpression(null, 0)
(multOp = multiplicativeOperator()
- leftOperand = unaryExpression(leftOperand, multOp, inSelectClause) )*
+ leftOperand = unaryExpression(leftOperand, multOp) )*
{
if (farLeftOperand == null)
return leftOperand;
@@ -5808,12 +5770,9 @@ multiplicativeOperator() throws Standard
/*
* <A NAME="unaryExpression">unaryExpression</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-unaryExpression(ValueNode farLeftOperand, int multiplicativeOperator, boolean inSelectClause) throws StandardException :
+unaryExpression(ValueNode farLeftOperand, int multiplicativeOperator) throws StandardException :
{
ValueNode value;
String sign = null;
@@ -5836,7 +5795,7 @@ unaryExpression(ValueNode farLeftOperand
} )
sign = sign()
]
- value = primaryExpression(inSelectClause)
+ value = primaryExpression()
{
if ("-".equals(sign))
{
@@ -5889,17 +5848,14 @@ sign() :
/*
* <A NAME="primaryExpressionXX">primaryExpressionXX</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-primaryExpressionXX( boolean inSelectClause ) throws StandardException :
+primaryExpressionXX() throws StandardException :
{
ValueNode value;
}
{
- value = primary(inSelectClause)
+ value = primary()
( value = nonStaticMethodCallOrFieldAccess(value)) *
{
return value;
@@ -6052,7 +6008,7 @@ methodParameter(Vector parameterList) th
ValueNode parameter;
}
{
- parameter = additiveExpression(null,0, false)
+ parameter = orExpression(null)
{
parameterList.addElement(parameter);
}
@@ -6066,12 +6022,9 @@ methodParameter(Vector parameterList) th
/*
* <A NAME="primary">primary</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-primary(boolean inSelectClause) throws StandardException :
+primary() throws StandardException :
{
String javaClassName;
ValueNode value;
@@ -6085,7 +6038,7 @@ primary(boolean inSelectClause) throws S
return value;
}
|
- value = valueExpressionPrimary(inSelectClause)
+ value = valueExpressionPrimary()
{
return value;
}
@@ -6202,7 +6155,7 @@ escapedValueFunction() throws StandardEx
}
|
/* Escaped function substring() */
- <SUBSTRING> <LEFT_PAREN> value = additiveExpression(null, 0, false) <COMMA> startPosition = additiveExpression(null, 0, false) [ <COMMA> length = additiveExpression(null, 0, false) ] <RIGHT_PAREN>
+ <SUBSTRING> <LEFT_PAREN> value = additiveExpression(null, 0) <COMMA> startPosition = additiveExpression(null, 0) [ <COMMA> length = additiveExpression(null, 0) ] <RIGHT_PAREN>
{
return getSubstringNode(value, startPosition, length, Boolean.FALSE);
}
@@ -6230,8 +6183,8 @@ escapedValueFunction() throws StandardEx
/* CONCAT( string1, string2 )
* CONCAT is not a reserved word.
*/
- <CONCAT> <LEFT_PAREN> str1 = additiveExpression(null,0, false) <COMMA>
- str2 = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <CONCAT> <LEFT_PAREN> str1 = additiveExpression(null,0) <COMMA>
+ str2 = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.CONCATENATION_OPERATOR_NODE,
@@ -6320,8 +6273,8 @@ timestampArithmeticFuncion() throws Stan
}
{
<TIMESTAMPADD> <LEFT_PAREN> intervalType = jdbcIntervalType() <COMMA>
- count = additiveExpression(null,0,false) <COMMA>
- tstamp1 = additiveExpression(null,0,false) <RIGHT_PAREN>
+ count = additiveExpression(null,0) <COMMA>
+ tstamp1 = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode( C_NodeTypes.TIMESTAMP_ADD_FN_NODE,
tstamp1,
@@ -6333,8 +6286,8 @@ timestampArithmeticFuncion() throws Stan
}
|
<TIMESTAMPDIFF> <LEFT_PAREN> intervalType = jdbcIntervalType() <COMMA>
- tstamp1 = additiveExpression(null,0,false) <COMMA>
- tstamp2 = additiveExpression(null,0,false) <RIGHT_PAREN>
+ tstamp1 = additiveExpression(null,0) <COMMA>
+ tstamp2 = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode( C_NodeTypes.TIMESTAMP_DIFF_FN_NODE,
tstamp2,
@@ -6424,7 +6377,7 @@ numericValueFunction() throws StandardEx
return value;
}
|
- <SQRT> <LEFT_PAREN> value = additiveExpression(null,0,false) <RIGHT_PAREN>
+ <SQRT> <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode)nodeFactory.getNode(
C_NodeTypes.SQRT_OPERATOR_NODE,
@@ -6480,7 +6433,7 @@ coalesceExpression(ValueNodeList express
ValueNode expression;
}
{
- expression = additiveExpression(null,0,false)
+ expression = additiveExpression(null,0)
{
expressionList.addElement(expression);
}
@@ -6495,7 +6448,7 @@ absFunction() throws StandardException :
ValueNode value;
}
{
- <LEFT_PAREN> value = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode)nodeFactory.getNode(
C_NodeTypes.ABSOLUTE_OPERATOR_NODE,
@@ -6513,8 +6466,8 @@ modFunction() throws StandardException :
ValueNode int2;
}
{
- <LEFT_PAREN> int1 = additiveExpression(null,0,false) <COMMA>
- int2 = additiveExpression(null,0,false) <RIGHT_PAREN>
+ <LEFT_PAREN> int1 = additiveExpression(null,0) <COMMA>
+ int2 = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode)nodeFactory.getNode(
C_NodeTypes.MOD_OPERATOR_NODE,
@@ -6556,12 +6509,12 @@ characterValueFunction() throws Standard
ValueNode length = null;
}
{
- <SUBSTR> <LEFT_PAREN> value = additiveExpression(null,0,false) <COMMA> startPosition = additiveExpression(null,0,false) [ <COMMA> length = additiveExpression(null,0,false) ] <RIGHT_PAREN>
+ <SUBSTR> <LEFT_PAREN> value = additiveExpression(null,0) <COMMA> startPosition = additiveExpression(null,0) [ <COMMA> length = additiveExpression(null,0) ] <RIGHT_PAREN>
{
return getSubstringNode( value, startPosition, length, Boolean.FALSE );
}
|
- ( upperTok = <UPPER> | lowerTok = <LOWER> ) <LEFT_PAREN> value = additiveExpression(null,0,false) <RIGHT_PAREN>
+ ( upperTok = <UPPER> | lowerTok = <LOWER> ) <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.SIMPLE_STRING_OPERATOR_NODE,
@@ -6570,7 +6523,7 @@ characterValueFunction() throws Standard
getContextManager());
}
|
- ( upperTok = <UCASE> | lowerTok = <LCASE> ) <LEFT_PAREN> value = additiveExpression(null,0,false) <RIGHT_PAREN>
+ ( upperTok = <UCASE> | lowerTok = <LCASE> ) <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.SIMPLE_STRING_OPERATOR_NODE,
@@ -6587,9 +6540,9 @@ characterValueFunction() throws Standard
/* LOCATE( string1, string2[, start] )
* LOCATE is a SQLJ reserved word.
*/
- <LOCATE> <LEFT_PAREN> str1 = additiveExpression(null,0,false) <COMMA>
- str2 = additiveExpression(null,0,false)
- [ <COMMA> value = additiveExpression(null,0,false) ]
+ <LOCATE> <LEFT_PAREN> str1 = additiveExpression(null,0) <COMMA>
+ str2 = additiveExpression(null,0)
+ [ <COMMA> value = additiveExpression(null,0) ]
<RIGHT_PAREN>
{
// if start is missing, start is equal to 1
@@ -6617,7 +6570,7 @@ trimFunction() throws StandardException
ValueNode ansiTrimNode;
}
{
- trimType = trimType() <LEFT_PAREN> source = additiveExpression(null,0,false) <RIGHT_PAREN>
+ trimType = trimType() <LEFT_PAREN> source = additiveExpression(null,0) <RIGHT_PAREN>
{
return getTrimOperatorNode(trimType, null, source, null);
}
@@ -6643,22 +6596,22 @@ ansiTrim() throws StandardException :
(
// LEADING FROM <source>
LOOKAHEAD(<FROM>)
- <FROM> trimSource = additiveExpression(null,0,false) <RIGHT_PAREN>
+ <FROM> trimSource = additiveExpression(null,0) <RIGHT_PAREN>
{
return getTrimOperatorNode(trimSpec, trimChar, trimSource, null);
}
|
// LEADING <char> FROM <source>
- trimChar = additiveExpression(null,0,false) <FROM> trimSource = additiveExpression(null,0,false) <RIGHT_PAREN>
+ trimChar = additiveExpression(null,0) <FROM> trimSource = additiveExpression(null,0) <RIGHT_PAREN>
{
return getTrimOperatorNode(trimSpec, trimChar, trimSource, null);
}
)
|
LOOKAHEAD ({!ansiTrimSpecFollows()})
- <LEFT_PAREN> trimChar = additiveExpression(null,0,false)
+ <LEFT_PAREN> trimChar = additiveExpression(null,0)
(
- <FROM> trimSource = additiveExpression(null,0,false) <RIGHT_PAREN>
+ <FROM> trimSource = additiveExpression(null,0) <RIGHT_PAREN>
{
return getTrimOperatorNode(trimSpec, trimChar, trimSource, null);
}
@@ -6711,12 +6664,9 @@ trimType() :
/*
* <A NAME="valueExpressionPrimary">valueExpressionPrimary</A>
- *
- * @param inSelectClause will be true if this method got called while parsing the select or values clause
- * If in select or values clause, we do not want to allow boolean values.
*/
ValueNode
-valueExpressionPrimary(boolean inSelectClause) throws StandardException :
+valueExpressionPrimary() throws StandardException :
{
ValueNode value;
int tokKind;
@@ -6804,11 +6754,7 @@ valueExpressionPrimary(boolean inSelectC
** valueExpression() here is a MINUS operator if the intervalQualifier
** is supplied.
*/
- // without the following check, select/values (c1>c2) will not be caught
- LOOKAHEAD({inSelectClause})
- value = additiveExpression(null,0, inSelectClause)
- | //following will happen if we are not coming here for select/values clause
- value = valueExpression(inSelectClause)
+ value = valueExpression()
)
<RIGHT_PAREN>
{
@@ -6960,7 +6906,7 @@ miscBuiltinsCore( boolean isJDBCEscape)
return value;
}
|
- <LENGTH> <LEFT_PAREN> value = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <LENGTH> <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
ContextManager localCM = getContextManager();
if( isJDBCEscape)
@@ -7005,7 +6951,7 @@ ValueNode
return value;
}
|
- dts = numericFunctionType() <LEFT_PAREN> operand = additiveExpression(null,0, false) <RIGHT_PAREN>
+ dts = numericFunctionType() <LEFT_PAREN> operand = additiveExpression(null,0) <RIGHT_PAREN>
{
value = (ValueNode) nodeFactory.getNode(
C_NodeTypes.CAST_NODE,
@@ -7017,7 +6963,7 @@ ValueNode
return value;
}
- | charType = charOrVarchar() <LEFT_PAREN> operand = additiveExpression(null,0, false) [ <COMMA> length = length() ] <RIGHT_PAREN>
+ | charType = charOrVarchar() <LEFT_PAREN> operand = additiveExpression(null,0) [ <COMMA> length = length() ] <RIGHT_PAREN>
{
// Always check db2 limits for this function. It's new
checkTypeLimits(charType,length);
@@ -7108,7 +7054,7 @@ ValueNode
boolean wsOption;
}
{
- value = additiveExpression(null,0,false) wsOption = xmlPreserveWhitespace() {
+ value = additiveExpression(null,0) wsOption = xmlPreserveWhitespace() {
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.XML_PARSE_OPERATOR_NODE,
value,
@@ -7173,7 +7119,7 @@ ValueNode
DataTypeDescriptor targetType;
}
{
- value = additiveExpression(null,0,false)
+ value = additiveExpression(null,0)
targetType = xmlSerializeTargetType()
{
return (ValueNode) nodeFactory.getNode(
@@ -7271,7 +7217,7 @@ ValueNode
short defaultPassingMech = -1;
}
{
- xqueryExpr = additiveExpression(null, 0, false)
+ xqueryExpr = additiveExpression(null, 0)
<PASSING> defaultPassingMech = xmlPassingMechanism()
xmlValue = xqVarList()
(
@@ -7356,7 +7302,7 @@ void xqVariable(ValueNode [] xmlVal) thr
short passingMech = -1;
}
{
- curVal = additiveExpression(null,0, false)
+ curVal = additiveExpression(null,0)
[
LOOKAHEAD( { getToken(1).kind == AS } )
<AS> varName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
@@ -7576,7 +7522,7 @@ dateTimeScalarFunction() throws Standard
* NOTE: If you add a new rule here, you must add the appropriate
* LOOKAHEAD rule to miscBuiltins().
*/
- <TIME> <LEFT_PAREN> value = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <TIME> <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
ValueNode castValue = (ValueNode) nodeFactory.getNode(
C_NodeTypes.CAST_NODE,
@@ -7587,7 +7533,7 @@ dateTimeScalarFunction() throws Standard
return castValue;
}
|
- <DATE> <LEFT_PAREN> value = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <DATE> <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.UNARY_DATE_TIMESTAMP_OPERATOR_NODE,
@@ -7596,12 +7542,12 @@ dateTimeScalarFunction() throws Standard
getContextManager());
}
|
- <TIMESTAMP> <LEFT_PAREN> value = additiveExpression(null,0, false) timestampNode = timestampFunctionCompletion( value)
+ <TIMESTAMP> <LEFT_PAREN> value = additiveExpression(null,0) timestampNode = timestampFunctionCompletion( value)
{
return timestampNode;
}
|
- field = datetimeField() <LEFT_PAREN> value = additiveExpression(null,0, false) <RIGHT_PAREN>
+ field = datetimeField() <LEFT_PAREN> value = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.EXTRACT_OPERATOR_NODE,
@@ -7630,7 +7576,7 @@ timestampFunctionCompletion( ValueNode f
getContextManager());
}
|
- <COMMA> timeValue = additiveExpression(null,0, false) <RIGHT_PAREN>
+ <COMMA> timeValue = additiveExpression(null,0) <RIGHT_PAREN>
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.TIMESTAMP_OPERATOR_NODE,
@@ -8219,7 +8165,7 @@ sortKey() throws StandardException :
ValueNode columnExpression;
}
{
- columnExpression = additiveExpression(null,0,true)
+ columnExpression = additiveExpression(null,0)
{
return (OrderByColumn) nodeFactory.getNode(
C_NodeTypes.ORDER_BY_COLUMN,
@@ -8425,7 +8371,7 @@ updateSource(String columnName) throws S
ValueNode valueNode;
}
{
- valueNode = additiveExpression(null,0, false)
+ valueNode = orExpression(null)
{
return valueNode;
}
@@ -8676,7 +8622,7 @@ rowValueConstructorElement(ResultColumnL
ValueNode value;
}
{
- value = additiveExpression(null, 0, true)
+ value = orExpression(null)
{
resultColumns.addResultColumn(
(ResultColumn) nodeFactory.getNode(
@@ -8834,7 +8780,7 @@ inElement(ValueNodeList inList) throws S
ValueNode valueNode;
}
{
- valueNode = additiveExpression(null, 0, false)
+ valueNode = additiveExpression(null, 0)
{
inList.addElement(valueNode);
}
@@ -9528,7 +9474,7 @@ joinCondition() throws StandardException
}
{
/* valueExpression() was searchCondition() */
- <ON> joinClause = valueExpression(false)
+ <ON> joinClause = valueExpression()
{
return joinClause;
}
@@ -9750,7 +9696,7 @@ aggregateExpression(String aggName, Clas
ValueNode value;
}
{
- [ distinct = setQuantifier() ] value = additiveExpression(null, 0, false)
+ [ distinct = setQuantifier() ] value = additiveExpression(null, 0)
{
return (ValueNode) nodeFactory.getNode(
C_NodeTypes.AGGREGATE_NODE,
@@ -9890,7 +9836,7 @@ castOperand() throws StandardException :
ValueNode value;
}
{
- value = additiveExpression(null, 0, false)
+ value = additiveExpression(null, 0)
{
return value;
}
@@ -9928,7 +9874,7 @@ whereClause(Token beginToken) throws Sta
}
{
/* valueExpression() was searchCondition() */
- value = valueExpression(false)
+ value = valueExpression()
{
endToken = getToken(0);
@@ -9982,7 +9928,7 @@ groupingColumnReference(GroupByList grou
ValueNode columnExpression;
}
{
- columnExpression = additiveExpression(null, 0, false)
+ columnExpression = additiveExpression(null, 0)
{
/* Aggregates not allowed in group by */
HasNodeVisitor visitor =
@@ -10011,7 +9957,7 @@ havingClause() throws StandardException
}
{
/* valueExpression() was searchCondition() */
- <HAVING> value = valueExpression(false)
+ <HAVING> value = valueExpression()
{
return value;
}
@@ -11386,7 +11332,7 @@ generationClause() throws StandardExcept
Token endToken = null;
}
{
- <AS> beginToken = <LEFT_PAREN> value = valueExpression( false ) endToken = <RIGHT_PAREN>
+ <AS> beginToken = <LEFT_PAREN> value = valueExpression() endToken = <RIGHT_PAREN>
{
checkVersion(DataDictionary.DD_VERSION_DERBY_10_5, "GENERATED COLUMN");
@@ -11930,7 +11876,7 @@ checkConstraintDefinition(TableName cons
{
/* valueExpression() was searchCondition() */
<CHECK> beginToken =
- <LEFT_PAREN> value = valueExpression(false) endToken = <RIGHT_PAREN>
+ <LEFT_PAREN> value = valueExpression() endToken = <RIGHT_PAREN>
{
if (columnName != null)
{
@@ -12468,7 +12414,7 @@ valueSpecification() throws StandardExce
return value;
}
|
- <NULLIF> <LEFT_PAREN> leftExpression = additiveExpression(null, 0, false) <COMMA> rightExpression = additiveExpression(null, 0, false) <RIGHT_PAREN>
+ <NULLIF> <LEFT_PAREN> leftExpression = additiveExpression(null, 0) <COMMA> rightExpression = additiveExpression(null, 0) <RIGHT_PAREN>
{
// "NULLIF(L, R)" is the same as "L=R ? untyped NULL : L"
// An impl assumption here is that Derby can promote CHAR to any comparable datatypes such as numeric
@@ -12543,8 +12489,8 @@ whenThenExpression() throws StandardExce
ValueNode elseExpr;
}
{
- <WHEN> expr = orExpression(null, false)
- (<OR> expr = orExpression(expr, false) )*
+ <WHEN> expr = orExpression(null)
+ (<OR> expr = orExpression(expr) )*
<THEN> thenExpr = thenElseExpression()
elseExpr = caseExpression()
{
@@ -12583,7 +12529,7 @@ thenElseExpression() throws StandardExce
return value;
}
|
- expr = additiveExpression(null, 0, false)
+ expr = additiveExpression(null, 0)
{
return expr;
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/aggregate.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/aggregate.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/aggregate.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/aggregate.out Fri Jul 2 14:09:40 2010
@@ -232,10 +232,14 @@ WARNING 01003: Null values were eliminat
WARNING 01003: Null values were eliminated from the argument of a column function.
ij> -- binary list operator
select (1 in (1,2)), count(c1) from t1 group by c1;
-ERROR 42X01: Syntax error: Encountered "in" at line 2, column 11.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1 |2
+-----------------
+true |1
+true |1
+true |1
+true |1
+true |0
+WARNING 01003: Null values were eliminated from the argument of a column function.
ij> select count((1 in (1,2))) from t1 group by c1;
1
-----------
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/logop.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/logop.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/logop.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/logop.out Fri Jul 2 14:09:40 2010
@@ -272,30 +272,25 @@ ij> select x from s where not ( (1 = 2)
X
-----------
1
-ij> -- following NOTs in select clause won't work because it results in a transient boolean datatype
-select ( not ( (1 = 1) or (2 = 2) ) and (3 = 4) ) from s;
-ERROR 42X01: Syntax error: Encountered "not" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ij> select ( not ( (1 = 1) or (2 = 2) ) and (3 = 4) ) from s;
+1
+-----
+false
ij> --
select ( not ( ( (1 = 1) or (2 = 2) ) and (3 = 4) ) ) from s;
-ERROR 42X01: Syntax error: Encountered "not" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> --
select ( (1 = 2) and not ( (3 = 3) or (4 = 4) ) ) from s;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 13.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
ij> --
select ( not ( (1 = 2) and ( (3 = 3) or (4 = 4) ) ) ) from s;
-ERROR 42X01: Syntax error: Encountered "not" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- Ands under ands under ands ...
select * from s where not ( ( ( ((1=1) and (1=1)) and ((1=1) and (1=1)) ) and
( ((1=1) and (1=1)) and ((1=1) and (1=1)) ) ) and
@@ -395,12 +390,10 @@ ij> -- nots on nots
select * from s where not ( not ( not ((1=2) or (1=1))) or (not ((1=2) or (1=2)) ) );
X
-----------
-ij> -- following nots on nots won't work because they result in transient boolean datatype in the select clause
-select not ( not ( not ((1=2) or (1=1))) or (not ((1=2) or (1=2)) ) ) from s;
-ERROR 42X01: Syntax error: Encountered "not" at line 2, column 8.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ij> select not ( not ( not ((1=2) or (1=1))) or (not ((1=2) or (1=2)) ) ) from s;
+1
+-----
+false
ij> -- negative testing
-- non boolean where clauses
select * from s where 1;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/schemas.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/schemas.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/schemas.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/schemas.out Fri Jul 2 14:09:40 2010
@@ -767,16 +767,16 @@ I |S |C
--------------------------------------------------------------------------------
ij> -- correlated subqueries
--- exists disallowed in select clause
select (exists (select * from test.ttt
where iii = (select 11 from test.tt where ii = i and ii <> 1)) )
a
from test.s
order by a;
-ERROR 42X01: Syntax error: Encountered "exists" at line 4, column 9.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+A
+-----
+true
+NULL
+NULL
ij> -- negative tests
-- multiple matches at parent level
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out Fri Jul 2 14:09:40 2010
@@ -480,20 +480,23 @@ I |S |C
-----------------------------------------------------------------------------------------------------
ij> -- select list
select ( i in (select i from t) ) a from s order by a;
-ERROR 42X01: Syntax error: Encountered "in" at line 2, column 12.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+A
+-----
+false
+true
+true
ij> select ( i in (select i from t where 1 = 0) ) a from s order by a;
-ERROR 42X01: Syntax error: Encountered "in" at line 1, column 12.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+A
+-----
+false
+false
+false
ij> select ( (i in (select i from t where 1 = 0)) is null ) a from s order by a;
-ERROR 42X01: Syntax error: Encountered "in" at line 1, column 13.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+A
+-----
+false
+false
+false
ij> -- subquery under an or
select i from s where i = -1 or i in (select i from t);
I
@@ -719,13 +722,14 @@ ij> ----------------------------------
-- on table expressions (remapColumnReferencesToExpressions()
-- binary list node
select i in (1,2) from (select i from s) as tmp(i);
-ERROR 42X01: Syntax error: Encountered "in" at line 6, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+NULL
+false
+true
ij> -- conditional expression
select i = 1 ? 1 : i from (select i from s) as tmp(i);
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 10.
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 14.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
@@ -802,10 +806,7 @@ NULL |NULL |NULL
1 |1 |1 |1 |1
ij> update u set b = exists (select b from t)
where vc <> (select vc from s where vc = '1');
-ERROR 42X01: Syntax error: Encountered "exists" at line 1, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ERROR 42821: Columns of type 'BIGINT' cannot hold values of type 'BOOLEAN'.
ij> select * from u;
I |S |C |VC |B
-----------------------------------------------------------------------------------------------------
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery2.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery2.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery2.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery2.out Fri Jul 2 14:09:40 2010
@@ -989,13 +989,9 @@ I |S |C
NULL |NULL |NULL |NULL |NULL
0 |0 |0 |0 |0
1 |1 |1 |1 |1
-ij> -- exists returns a boolean value and hence it can not be used to set a value. Exists can only be used in where clause
-update u set b = exists (select * from t)
+ij> update u set b = exists (select * from t)
where vc < ANY (select vc from s);
-ERROR 42X01: Syntax error: Encountered "exists" at line 2, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ERROR 42821: Columns of type 'BIGINT' cannot hold values of type 'BOOLEAN'.
ij> select * from u;
I |S |C |VC |B
-----------------------------------------------------------------------------------------------------
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/valuesclause.out Fri Jul 2 14:09:40 2010
@@ -185,40 +185,34 @@ NULL |0 |def
ij> remove v2;
ij> -- type precedence tests. tinyint not supported by DB2 Cloudscape
values (1 = 1.2);
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 11.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (1.2 = 1);
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 13.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (1 = cast(1 as bigint));
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 11.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (1 = cast(1 as smallint));
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 11.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (cast(1 as bigint) = 1);
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 27.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (cast(1 as smallint) = 1);
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 29.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- inserts
create table insert_test1 (c1 int);
0 rows inserted/updated/deleted
@@ -454,163 +448,120 @@ ij> drop table sub;
0 rows inserted/updated/deleted
ij> drop table target;
0 rows inserted/updated/deleted
-ij> -- negative tests
-create table t1 (c1 int);
+ij> create table t1 (c1 int, c11 boolean);
0 rows inserted/updated/deleted
-ij> insert into t1 values 1;
+ij> insert into t1( c1, c11 ) values ( 1, true );
1 row inserted/updated/deleted
-ij> -- boolean expression IS disallowed in values or select clause
-select nullif(c1, 1) is null from t1;
-ERROR 42X01: Syntax error: Encountered "is" at line 2, column 22.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ij> select nullif(c1, 1) is null from t1;
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 1 is null;
-ERROR 42X01: Syntax error: Encountered "is" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
-ij> -- boolean expression =, >, >=, <, <= disallowed in values or select clause
-values 1 = 1;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
+ij> values 1 = 1;
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 1 = 1 from t1;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (nullif('abc','a') = 'abc');
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 27.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select (nullif('abc','a') = 'abc') from t1;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 27.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select c11 = any (select c11 from t1) from t1;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 12.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 2 > 1;
-ERROR 42X01: Syntax error: Encountered ">" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 2 > 1 from t1;
-ERROR 42X01: Syntax error: Encountered ">" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 2 >= 1;
-ERROR 42X01: Syntax error: Encountered ">=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 2 >= 1 from t1;
-ERROR 42X01: Syntax error: Encountered ">=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 1 < 2;
-ERROR 42X01: Syntax error: Encountered "<" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 1 < 2 from t1;
-ERROR 42X01: Syntax error: Encountered "<" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 1 <= 2;
-ERROR 42X01: Syntax error: Encountered "<=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 1 <= 2 from t1;
-ERROR 42X01: Syntax error: Encountered "<=" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (1>1);
-ERROR 42X01: Syntax error: Encountered ">" at line 2, column 10.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select (c1 < 2) from t1;
-ERROR 42X01: Syntax error: Encountered "<" at line 2, column 12.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values (1 between 2 and 5);
-ERROR 42X01: Syntax error: Encountered "between" at line 2, column 11.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+false
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select (c1 between 1 and 3) from t1;
-ERROR 42X01: Syntax error: Encountered "between" at line 2, column 12.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
-ij> -- boolean expression LIKE disallowed in values and select clause
-prepare ll1 as 'values ''asdf'' like ?';
-ERROR 42X01: Syntax error: Encountered "like" at line 1, column 15.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
+ij> prepare ll1 as 'values ''asdf'' like ?';
ij> prepare ll1 as 'select ''asdf'' like ? from t1';
-ERROR 42X01: Syntax error: Encountered "like" at line 1, column 15.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> prepare ll15 as 'values ''%foobar'' like ''Z%foobar'' escape ?';
-ERROR 42X01: Syntax error: Encountered "like" at line 1, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> prepare ll15 as 'select ''%foobar'' like ''Z%foobar'' escape ? from t1';
-ERROR 42X01: Syntax error: Encountered "like" at line 1, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values '%foobar' like '%%foobar' escape '%';
-ERROR 42X01: Syntax error: Encountered "like" at line 2, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select '_foobar' like '__foobar' escape '_' from t1;
-ERROR 42X01: Syntax error: Encountered "like" at line 2, column 18.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+1
+-----
+true
ij> prepare ll4 as 'values org.apache.derbyTesting.functionTests.tests.lang.CharUTF8::getMaxDefinedCharAsString() like ?';
-ERROR 42X01: Syntax error: Encountered "like" at line 1, column 95.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ERROR 42X51: The class 'org.apache.derbyTesting.functionTests.tests.lang.CharUTF8' does not exist or is inaccessible. This can happen if the class is not public.
+ERROR XJ001: Java exception: 'org.apache.derbyTesting.functionTests.tests.lang.CharUTF8: java.lang.ClassNotFoundException'.
ij> -- boolean expression INSTANCEOF disallowed in values and select clause
values 1 instanceof int;
ERROR 42X01: Syntax error: Encountered "instanceof" at line 2, column 10.
@@ -623,26 +574,25 @@ ERROR 42X01: Syntax error: Encountered "
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
-ij> -- boolean expression EXISTS disallowed in values and select clause
-select exists (values 1) from t1;
-ERROR 42X01: Syntax error: Encountered "exists" at line 2, column 8.
-Issue the 'help' command for general information on IJ command syntax.
-Any unrecognized commands are treated as potential SQL commands and executed directly.
-Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
+ij> select exists (values 1) from t1;
+1
+-----
+true
ij> values exists (values 2);
-ERROR 42X80: VALUES clause must contain at least one element. Empty elements are not allowed.
-ij> -- boolean expression EXISTS diallowed in update set clause too
-update t1 set c11 = exists(values 1);
-ERROR 42X01: Syntax error: Encountered "exists" at line 2, column 21.
+1
+-----
+true
+ij> update t1 set c11 = exists(values 1);
+1 row inserted/updated/deleted
+ij> -- ?: not supported anymore
+values not true ? false : true;
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 17.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
-ij> -- ?: not supported anymore
-values not true ? false : true;
-ERROR 42X80: VALUES clause must contain at least one element. Empty elements are not allowed.
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select not true ? false : true from t1;
-ERROR 42X01: Syntax error: Encountered "not" at line 2, column 8.
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 17.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
@@ -654,19 +604,19 @@ Any unrecognized commands are treated as
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select c1 is null ? true : false from t1;
-ERROR 42X01: Syntax error: Encountered "is" at line 2, column 11.
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 19.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select new java.lang.Integer(c1 is null ? 0 : c1) from t1;
-ERROR 42X01: Syntax error: Encountered "is" at line 2, column 33.
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 41.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
ij> -- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select c1, (c1=1? cast(null as int) : c1) is null from t1;
-ERROR 42X01: Syntax error: Encountered "=" at line 2, column 15.
+ERROR 42X01: Syntax error: Encountered "?" at line 2, column 17.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java Fri Jul 2 14:09:40 2010
@@ -1120,6 +1120,38 @@ public class BooleanValuesTest extends
expectCompilationError( BAD_DEFAULT, "create table badDefault( a int, b boolean default X'DE' )" );
}
+ /**
+ * <p>
+ * Verify that you can have boolean expressions in the SELECT list.
+ * </p>
+ */
+ public void test_15_selectList() throws Exception
+ {
+ Connection conn = getConnection();
+
+ assertResults
+ (
+ conn,
+ "select columnnumber > 0 from sys.syscolumns where columnname = 'TABLENAME'",
+ new String[][]
+ {
+ { "true" }
+ },
+ false
+ );
+
+ assertResults
+ (
+ conn,
+ "values 3 > 10",
+ new String[][]
+ {
+ { "false" }
+ },
+ false
+ );
+ }
+
///////////////////////////////////////////////////////////////////////////////////
//
// SQL ROUTINES
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/logop.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/logop.sql?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/logop.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/logop.sql Fri Jul 2 14:09:40 2010
@@ -172,7 +172,6 @@ select x from s where not ( (1 = 1) or (
select x from s where not ( ( (1 = 1) or (2 = 2) ) and (3 = 4) );
select x from s where (1 = 2) and not ( (3 = 3) or (4 = 4) );
select x from s where not ( (1 = 2) and ( (3 = 3) or (4 = 4) ) );
--- following NOTs in select clause won't work because it results in a transient boolean datatype
select ( not ( (1 = 1) or (2 = 2) ) and (3 = 4) ) from s;
--
select ( not ( ( (1 = 1) or (2 = 2) ) and (3 = 4) ) ) from s;
@@ -255,7 +254,6 @@ select * from s where not ( ( ( ( ( (1=2
-- nots on nots
select * from s where not ( not ( not ((1=2) or (1=1))) or (not ((1=2) or (1=2)) ) );
--- following nots on nots won't work because they result in transient boolean datatype in the select clause
select not ( not ( not ((1=2) or (1=1))) or (not ((1=2) or (1=2)) ) ) from s;
-- negative testing
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/schemas.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/schemas.sql?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/schemas.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/schemas.sql Fri Jul 2 14:09:40 2010
@@ -446,7 +446,6 @@ select * from test.s t1
where i = (select i from test.t t2 where s = (select i from test.t t3 where s = 2));
-- correlated subqueries
--- exists disallowed in select clause
select (exists (select * from test.ttt
where iii = (select 11 from test.tt where ii = i and ii <> 1)) )
a
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery2.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery2.sql?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery2.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subquery2.sql Fri Jul 2 14:09:40 2010
@@ -323,7 +323,6 @@ create table u (i int, s smallint, c cha
insert into u select * from s;
select * from u;
--- exists returns a boolean value and hence it can not be used to set a value. Exists can only be used in where clause
update u set b = exists (select * from t)
where vc < ANY (select vc from s);
select * from u;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql?rev=959991&r1=959990&r2=959991&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/valuesclause.sql Fri Jul 2 14:09:40 2010
@@ -233,16 +233,13 @@ drop table sub;
drop table target;
--- negative tests
-create table t1 (c1 int);
-insert into t1 values 1;
+create table t1 (c1 int, c11 boolean);
+insert into t1( c1, c11 ) values ( 1, true );
--- boolean expression IS disallowed in values or select clause
select nullif(c1, 1) is null from t1;
-- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 1 is null;
--- boolean expression =, >, >=, <, <= disallowed in values or select clause
values 1 = 1;
-- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select 1 = 1 from t1;
@@ -277,7 +274,6 @@ values (1 between 2 and 5);
-- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
select (c1 between 1 and 3) from t1;
--- boolean expression LIKE disallowed in values and select clause
prepare ll1 as 'values ''asdf'' like ?';
prepare ll1 as 'select ''asdf'' like ? from t1';
prepare ll15 as 'values ''%foobar'' like ''Z%foobar'' escape ?';
@@ -293,11 +289,9 @@ values 1 instanceof int;
-- this test runs in SPS mode too, hence adding a comment line before the sql, so we get correct column number in error message in both SPS and non-SPS mode
values 1 instanceof java.lang.Integer between false and true;
--- boolean expression EXISTS disallowed in values and select clause
select exists (values 1) from t1;
values exists (values 2);
--- boolean expression EXISTS diallowed in update set clause too
update t1 set c11 = exists(values 1);
-- ?: not supported anymore