[ http://issues.apache.org/jira/browse/DERBY-183?page=all ]
James F. Adams updated DERBY-183:
---------------------------------
Attachment: Derby183.patch2.txt
I have attached an updated patch (Derby183.patch2.txt) that modifies the
following files:
java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java
java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
java/testing/org/apache/derbyTesting/functionTests/tests/lang/procedure.java
java/testing/org/apache/derbyTesting/functionTests/master/procedure.out
java/testing/org/apache/derbyTesting/functionTests/util/ProcedureTest.java
java/testing/org/apache/derbyTesting/functionTests/tests/lang/functions.sql
java/testing/org/apache/derbyTesting/functionTests/master/functions.out
Tests have been added to lang/functions.sql and lang/procedure.java.
I added a comment to sqlgrammar.jj to explain the need for the LOOKAHEAD(2).
The parameter name is made optional by surrounding its production with [].
This changes the grammar from:
parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
typeDescriptor = dataTypeDDL()
to:
[ parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true) ]
typeDescriptor = dataTypeDDL()
This results in a choice conflict because certain tokens satisfy both
identifier() and dataTypeDDL(). An additional token of lookahead resolves this
conflict. This results in:
[ LOOKAHEAD(2) parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH,
true) ]
typeDescriptor = dataTypeDDL()
Expressing this in an alternate form such as:
(
parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
typeDescriptor = dataTypeDDL()
) | typeDescriptor = dataTypeDDL()
still results in a choice conflict so I opted for the more compact form.
> Parameter names required in CREATE FUNCTION
> -------------------------------------------
>
> Key: DERBY-183
> URL: http://issues.apache.org/jira/browse/DERBY-183
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.0
> Reporter: Jack Klebanoff
> Assigned To: James F. Adams
> Priority: Minor
> Attachments: Derby183.patch.txt, Derby183.patch2.txt
>
>
> A statement like
> create function s2.f2( char(8), integer) returns int
> language java parameter style java external name 'myclass.mymethod'
> fails with the message
> ERROR 42X01: Syntax error: Encountered "char" at line 1, column 24
> However
> create function s2.f2( p1 char(8), p2 integer) returns int
> language java parameter style java external name 'myclass.mymethod'
> is accepted.
> The Derby documentation (at
> http://incubator.apache.org/derby/manuals/reference/sqlj27.html#CREATE+PROCEDURE+Statement),
> the SQL2003 standard, and DB2 all agree that the parameter name is optional.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira