[ 
https://issues.apache.org/jira/browse/DERBY-5750?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13397463#comment-13397463
 ] 

Knut Anders Hatlen commented on DERBY-5750:
-------------------------------------------

The String.isEmpty() method was introduced in Java 6, so the patch won't 
compile in my environment:

compile_catalog:
    [javac] Compiling 1 source file to /code/derby/trunk/classes
    [javac] 
/code/derby/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java:747:
 error: cannot find symbol
    [javac]         if (!StringUtil.trimTrailing(schemaname).isEmpty())
    [javac]                                                 ^
    [javac]   symbol:   method isEmpty()
    [javac]   location: class String
    [javac] 
/code/derby/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java:750:
 error: cannot find symbol
    [javac]         if (!StringUtil.trimTrailing(tablename).isEmpty())
    [javac]                                                ^
    [javac]   symbol:   method isEmpty()
    [javac]   location: class String
(...)
    [javac] 8 errors

BUILD FAILED
/code/derby/trunk/build.xml:603: The following error occurred while executing 
this line:
/code/derby/trunk/java/engine/build.xml:67: The following error occurred while 
executing this line:
/code/derby/trunk/java/engine/org/apache/derby/catalog/build.xml:51: Compile 
failed; see the compiler error output for details.

I couldn't test the patch because of this, but this check looks wrong to me:

+        if (!StringUtil.trimTrailing(schemaname).isEmpty())
+               query.append(IdUtil.normalToDelimited(schemaname) + ".");

I think the intention here is to check if the schema name is empty, whereas it 
actually checks if it's free for non-whitespace characters. So I suspect 
statements like these might stop working:

ij> create table "   "."   " (x int);
0 rows inserted/updated/deleted
ij> call syscs_util.syscs_compress_table('   ', '   ', 1);
0 rows inserted/updated/deleted

Also, I think skipping the schema name in the internal ALTER TABLE statement if 
it's empty, will make the following statement compress the table T2 in the 
current schema instead of failing, which I believe is not the intention of the 
patch:

    call syscs_util.syscs_compress_table('', 'T2', 1)
                
> Sending an empty string as table name to compress table procedure or empty 
> string as index name to update statistics procedure makes the parser throw an 
> exception.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-5750
>                 URL: https://issues.apache.org/jira/browse/DERBY-5750
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.9.1.0
>            Reporter: Mamta A. Satoor
>            Assignee: Mamta A. Satoor
>            Priority: Minor
>         Attachments: DERBY5750_patch1_diff.txt
>
>
> When empty string is passed for the index name to the update statistics 
> procedure, it throws following exception(passing an empty string for table to 
> compress table procedure also gives simiar exception). The new stored 
> procedure being created through DERBY-4115 for dropping the statistics also 
> gave similar exception
> java -Dij.exceptionTrace=true org.apache.derby.tools.ij
> connect 'jdbc:derby:db1;create=true'; 
> create table t1(c11 int, statistics int not null);
> call syscs_util.SYSCS_UPDATE_STATISTICS( 'APP', 'T1', '' );
> ERROR 38000: The exception 'java.sql.SQLException: Syntax error: Encountered 
> "\"" at line 1, column 42.' was thrown while evaluating an expression.
> java.sql.SQLException: The exception 'java.sql.SQLException: Syntax error: 
> Encountered "\"" at line 1, column 42.' was thrown while evaluating an 
> expression.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:98)
>         at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:142)
>         at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:278)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:431)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2360)
>         at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1334)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:630)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:559)
>         at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:367)
>         at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:527)
>         at 
> org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:369)
>         at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
>         at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
>         at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
>         at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
>         at org.apache.derby.tools.ij.main(ij.java:59)
> Caused by: java.sql.SQLException: The exception 'java.sql.SQLException: 
> Syntax error: Encountered "\"" at line 1, column 42.' was thrown while 
> evaluating an expression.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:122)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71)
>         ... 17 more
> Caused by: java.sql.SQLException: Syntax error: Encountered "\"" at line 1, 
> column 42.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:122)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71)
>         at 
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:424)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2360)
>         at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:153)
>         at 
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Driver40.java:107)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1685)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1513)
>         at 
> org.apache.derby.catalog.SystemProcedures.SYSCS_UPDATE_STATISTICS(SystemProcedures.java:753)
>         at 
> org.apache.derby.exe.acace4c0a3x0137x2f19xcc22x00000013e5704.g0(Unknown 
> Source)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>         at java.lang.reflect.Method.invoke(Method.java:611)
>         at 
> org.apache.derby.impl.services.reflect.ReflectMethod.invoke(ReflectMethod.java:46)
>         at 
> org.apache.derby.impl.sql.execute.CallStatementResultSet.open(CallStatementResultSet.java:75)
>         at 
> org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:443)
>         at 
> org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:324)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1242)
>         ... 10 more
> Caused by: ERROR 42X01: Syntax error: Encountered "\"" at line 1, column 42.
>         at 
> org.apache.derby.iapi.error.StandardException.newException(StandardException.java:278)
>         at 
> org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(ParserImpl.java:153)
>         at 
> org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:357)
>         at 
> org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
>         at 
> org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1103)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:134)
>         ... 24 more
> ERROR 42X01: Syntax error: Encountered "\"" at line 1, column 42.
> java.sql.SQLSyntaxErrorException: Syntax error: Encountered "\"" at line 1, 
> column 42.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:92)
>         at 
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:256)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:424)
>         at 
> org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2360)
>         at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:82)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:153)
>         at 
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Driver40.java:107)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1685)
>         at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1513)
>         at 
> org.apache.derby.catalog.SystemProcedures.SYSCS_UPDATE_STATISTICS(SystemProcedures.java:753)
>         at 
> org.apache.derby.exe.acace4c0a3x0137x2f19xcc22x00000013e5704.g0(Unknown 
> Source)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>         at java.lang.reflect.Method.invoke(Method.java:611)
>         at 
> org.apache.derby.impl.services.reflect.ReflectMethod.invoke(ReflectMethod.java:46)
>         at 
> org.apache.derby.impl.sql.execute.CallStatementResultSet.open(CallStatementResultSet.java:75)
>         at 
> org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:443)
>         at 
> org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:324)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1242)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:630)
>         at 
> org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:559)
>         at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:367)
>         at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:527)
>         at 
> org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:369)
>         at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
>         at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
>         at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
>         at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
>         at org.apache.derby.tools.ij.main(ij.java:59)
> Caused by: java.sql.SQLException: Syntax error: Encountered "\"" at line 1, 
> column 42.
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:122)
>         at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71)
>         ... 30 more
> Caused by: ERROR 42X01: Syntax error: Encountered "\"" at line 1, column 42.
>         at 
> org.apache.derby.iapi.error.StandardException.newException(StandardException.java:278)
>         at 
> org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(ParserImpl.java:153)
>         at 
> org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:357)
>         at 
> org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:99)
>         at 
> org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:1103)
>         at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:134)
>         ... 24 more
> 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 message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to