@@ -547,36 +547,41 @@ class SQLGrammar
547547 return retval;
548548 }
549549
550+ /**
551+ * Check that an opening parenthese AND Subquery are the next tokens.
552+ *
553+ * Identical to subqueryFollows(), but the function can't be used
554+ * because we don't want to discard the left paren before hand.
555+ *
556+ */
550557 private boolean leftParenAndSubqueryFollows()
551558 {
552- boolean retval = false;
553559 int i = 1;
554560 if (getToken(i).kind != LEFT_PAREN)
555561 return false;
556562
557563 for( ; true; ++i)
558564 {
559565 int tokKind = getToken(i).kind;
560- if (tokKind == LEFT_PAREN) {
566+ if (tokKind == LEFT_PAREN)
567+ {
561568 // A subquery can start with an arbitrary number of left
562569 // parentheses.
563570 continue;
564571 }
565- else if (tokKind == SELECT || tokKind == VALUES) {
572+ else if (tokKind == SELECT || tokKind == VALUES)
573+ {
566574 // If the first token we find after all the left parentheses
567575 // is SELECT or VALUES, it's a subquery.
568- retval = true;
569- break;
576+ return true;
570577 }
571- else {
578+ else
579+ {
572580 // If the first token we find after all the left parentheses
573581 // is neither SELECT nor VALUES, it's not a subquery.
574- break ;
582+ return false ;
575583 }
576584 }
577-
578- return retval;
579-
580585 }
581586
582587 /**
@@ -690,42 +695,6 @@ class SQLGrammar
690695 return retval;
691696 }
692697
693- /**
694- * Checking nested tupples.
695- * Identical to rowValueConstructorListFollows() except this keeps the count
696- * of parens for later use (that is, to discard un-needed parens)
697- *
698- *
699- */
700- private boolean nestedTupplesFollow(int count[])
701- {
702- boolean ret = false;
703- if (getToken(1).kind == LEFT_PAREN)
704- {
705- count[0] = 1; // saw one left paren so far
706-
707- for (int i = 2; true; ++i)
708- {
709- int toKind = getToken(i).kind;
710-
711- // only looks for COMMA
712- //
713- if (toKind == COMMA)
714- ret = true;
715-
716- if (toKind == EOF)
717- break;
718-
719- if (toKind == LEFT_PAREN)
720- ++count[0];
721- else if (toKind == RIGHT_PAREN)
722- break;
723- }
724- }
725-
726- return ret;
727- }
728-
729698
730699 /**
731700 * Determine whether the next token is the beginning of a propertyList().
@@ -5258,7 +5227,7 @@ remainingNegatablePredicate(ValueNode leftOperand) throws StandardException :
52585227 ValueNode escapeValue = null;
52595228}
52605229{
5261- <DUMMY> tree = rowCtor(0 )
5230+ <DUMMY> tree = rowCtor()
52625231 {
52635232 return tree;
52645233 }
@@ -8246,7 +8215,6 @@ ValueNode
82468215inPredicateValue(ValueNode leftOperand) throws StandardException :
82478216{
82488217 ValueNode retval;
8249- int tokKind;
82508218}
82518219{
82528220 LOOKAHEAD( {leftParenAndSubqueryFollows()} )
@@ -8255,7 +8223,7 @@ inPredicateValue(ValueNode leftOperand) throws StandardException :
82558223 return retval;
82568224 }
82578225|
8258- retval = rowCtor(0 )
8226+ retval = rowCtor()
82598227 {
82608228 return (ValueNode)nodeFactory.getNode(NodeTypes.IN_LIST_OPERATOR_NODE,
82618229 leftOperand,
@@ -8295,15 +8263,15 @@ inElement(ValueNodeList inList) throws StandardException :
82958263
82968264
82978265ValueNode
8298- rowCtor(int count ) throws StandardException:
8266+ rowCtor() throws StandardException:
82998267{
83008268 ValueNodeList list = (ValueNodeList)nodeFactory.getNode(NodeTypes.VALUE_NODE_LIST,
83018269 parserContext);
83028270}
83038271{
83048272 <LEFT_PAREN>
83058273 getRow(list)
8306- discardRightParen(count) <RIGHT_PAREN>
8274+ <RIGHT_PAREN>
83078275 {
83088276 return (ValueNode)nodeFactory.getNode(NodeTypes.ROW_CTOR_NODE,
83098277 list,
@@ -8324,39 +8292,15 @@ getRow(ValueNodeList rowList) throws StandardException:
83248292 }
83258293}
83268294
8327- void
8328- discardLeftParen(int count) throws StandardException:
8329- {
8330- }
8331- {
8332- LOOKAHEAD( {count > 0 && getToken(1).kind == LEFT_PAREN} )
8333- <LEFT_PAREN>
8334- {
8335- discardLeftParen(count - 1);
8336- }
8337- }
8338-
8339- void
8340- discardRightParen(int count) throws StandardException:
8341- {
8342- }
8343- {
8344- LOOKAHEAD( {count >= 0 && getToken(1).kind == RIGHT_PAREN} )
8345- <RIGHT_PAREN>
8346- {
8347- discardRightParen(count - 1);
8348- }
8349- }
8350-
83518295void
83528296rowElement(ValueNodeList list) throws StandardException:
83538297{
83548298 ValueNode element = null;
83558299 int count[] = new int[]{0};
83568300}
83578301{
8358- LOOKAHEAD( {nestedTupplesFollow(count )} )
8359- discardLeftParen(count[0] - 1) element = rowCtor(count[0] - 1) // discard (count -1) parens
8302+ LOOKAHEAD( {rowValueConstructorListFollows( )} )
8303+ element = rowCtor()
83608304 {
83618305 list.addValueNode(element);
83628306 }
0 commit comments