Derby
  1. Derby
  2. DERBY-5750

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.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.9.1.0
    • Fix Version/s: 10.8.3.3, 10.9.2.2, 10.10.1.1
    • Component/s: SQL
    • Labels:
      None
    • Issue & fix info:
      Repro attached

      Description

      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>

      1. DERBY5750_patch1_diff.txt
        9 kB
        Mamta A. Satoor
      2. DERBY5750_patch2_diff.txt
        12 kB
        Mamta A. Satoor

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        54d 23h 42m 1 Mamta A. Satoor 03/Jul/12 04:39
        Resolved Resolved Closed Closed
        792d 4h 52m 1 Knut Anders Hatlen 03/Sep/14 09:31
        Knut Anders Hatlen made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Knut Anders Hatlen added a comment -

        [bulk update] Close all resolved issues that haven't been updated for more than one year.

        Show
        Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.
        Mamta A. Satoor made changes -
        Fix Version/s 10.8.3.1 [ 12323475 ]
        Hide
        ASF subversion and git services added a comment -

        Commit 1509814 from Mamta A. Satoor in branch 'code/branches/10.8'
        [ https://svn.apache.org/r1509814 ]

        DERBY-5750(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.)

        Backporting to 10.8

        Show
        ASF subversion and git services added a comment - Commit 1509814 from Mamta A. Satoor in branch 'code/branches/10.8' [ https://svn.apache.org/r1509814 ] DERBY-5750 (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.) Backporting to 10.8
        Mamta A. Satoor made changes -
        Fix Version/s 10.9.2.2 [ 12323562 ]
        Hide
        ASF subversion and git services added a comment -

        Commit 1508273 from Mamta A. Satoor in branch 'code/branches/10.9'
        [ https://svn.apache.org/r1508273 ]

        DERBY-5750(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.)

        Backporting to 10.9

        Show
        ASF subversion and git services added a comment - Commit 1508273 from Mamta A. Satoor in branch 'code/branches/10.9' [ https://svn.apache.org/r1508273 ] DERBY-5750 (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.) Backporting to 10.9
        Hide
        Mamta A. Satoor added a comment - - edited

        I am working on backporting this jira to 10.9 and 10.8

        Show
        Mamta A. Satoor added a comment - - edited I am working on backporting this jira to 10.9 and 10.8
        Gavin made changes -
        Workflow jira [ 12666517 ] Default workflow, editable Closed status [ 12797015 ]
        Mamta A. Satoor made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mamta A. Satoor made changes -
        Fix Version/s 10.10.0.0 [ 12321550 ]
        Hide
        Mamta A. Satoor added a comment -

        Knut, I just committed a patch for this jira after taking care of of your comments.

        The commit comments are as follows
        *********************************
        DERBY-5750 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.

        Committing changes for DERBY-5750 which will provide following functionality
        a)if schema name is provided as an empty string, we will throw SQLState.LANG_SCHEMA_DOES_NOT_EXIST
        b)if table name is provided as an empty string, we will throw SQLState.LANG_TABLE_NOT_FOUND
        c)if index name is provided as an empty string(this is for update and drop statistics procedures), we will throw
        SQLState.LANG_INDEX_NOT_FOUND
        d)if schema name is null, we will use current schema to resolve the table name
        e)if table name is null, we will throw SQLState.LANG_TABLE_NOT_FOUND
        f)if index name is null, we will drop/update statisitcs for all the indexes for the given table.

        I have added few test cases for each of these procedures.
        *********************************

        Show
        Mamta A. Satoor added a comment - Knut, I just committed a patch for this jira after taking care of of your comments. The commit comments are as follows ********************************* DERBY-5750 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. Committing changes for DERBY-5750 which will provide following functionality a)if schema name is provided as an empty string, we will throw SQLState.LANG_SCHEMA_DOES_NOT_EXIST b)if table name is provided as an empty string, we will throw SQLState.LANG_TABLE_NOT_FOUND c)if index name is provided as an empty string(this is for update and drop statistics procedures), we will throw SQLState.LANG_INDEX_NOT_FOUND d)if schema name is null, we will use current schema to resolve the table name e)if table name is null, we will throw SQLState.LANG_TABLE_NOT_FOUND f)if index name is null, we will drop/update statisitcs for all the indexes for the given table. I have added few test cases for each of these procedures. *********************************
        Hide
        Knut Anders Hatlen added a comment -

        Empty index name seems to be translated to all indexes in the latest patch. I think I'd prefer to keep it consistent with table and schema name and raise an error in that case too.

        Some small nits:

        • indentation seems to be a mix of tabs and spaces
        • method name "basic_schema_table_validation" should be camel-cased for consistency
        • javadoc for basic_schema_table_validation() has empty descriptions in @param and @throws
        • maybe use curly braces in the if/else statements for clarity
        • typos in comments (UpdateStatisticsTest.java): indedx, stiatistics
        • use of IdUtil.mkQualifiedName() would allow simplification of basic_schema_table_validation() (could eliminate the StringBuffer, the second "if" statement and the "else" branch of the last "if" statement)
        Show
        Knut Anders Hatlen added a comment - Empty index name seems to be translated to all indexes in the latest patch. I think I'd prefer to keep it consistent with table and schema name and raise an error in that case too. Some small nits: indentation seems to be a mix of tabs and spaces method name "basic_schema_table_validation" should be camel-cased for consistency javadoc for basic_schema_table_validation() has empty descriptions in @param and @throws maybe use curly braces in the if/else statements for clarity typos in comments (UpdateStatisticsTest.java): indedx, stiatistics use of IdUtil.mkQualifiedName() would allow simplification of basic_schema_table_validation() (could eliminate the StringBuffer, the second "if" statement and the "else" branch of the last "if" statement)
        Mamta A. Satoor made changes -
        Attachment DERBY5750_patch2_diff.txt [ 12533386 ]
        Hide
        Mamta A. Satoor added a comment -

        Attaching patch#2 (DERBY5750_patch2_diff.txt). This patch will provide following functionality
        a)if schema name is provided as an empty string, we will throw SQLState.LANG_SCHEMA_DOES_NOT_EXIST
        b)if table name is provided as an empty string, we will throw SQLState.LANG_TABLE_NOT_FOUND
        c)if schema name is null, we will use current schema to resolve the table name
        d)if table name is null, we will throw SQLState.LANG_TABLE_NOT_FOUND

        I have added few test cases for each of these procedures.

        Show
        Mamta A. Satoor added a comment - Attaching patch#2 (DERBY5750_patch2_diff.txt). This patch will provide following functionality a)if schema name is provided as an empty string, we will throw SQLState.LANG_SCHEMA_DOES_NOT_EXIST b)if table name is provided as an empty string, we will throw SQLState.LANG_TABLE_NOT_FOUND c)if schema name is null, we will use current schema to resolve the table name d)if table name is null, we will throw SQLState.LANG_TABLE_NOT_FOUND I have added few test cases for each of these procedures.
        Hide
        Knut Anders Hatlen added a comment -

        I'd prefer some kind of error if an empty name is specified, since one way to specify current schema (NULL) is enough. Although a parse error isn't very helpful, I agree. The proposed patch introduces checks for empty names and changes the internal SQL based on that check. Couldn't these checks be changed to raise an error with a proper error message instead? I see that empty table names still cause parse errors with the patch.

        Show
        Knut Anders Hatlen added a comment - I'd prefer some kind of error if an empty name is specified, since one way to specify current schema (NULL) is enough. Although a parse error isn't very helpful, I agree. The proposed patch introduces checks for empty names and changes the internal SQL based on that check. Couldn't these checks be changed to raise an error with a proper error message instead? I see that empty table names still cause parse errors with the patch.
        Hide
        Mamta A. Satoor added a comment -

        Knut, thanks for reviewing the patch. Thanks for catching the isEmpty() usage. I have changed that in my codeline to instead use length() to determine if we are dealing with empty name.

        As for schema name, I did intentionally make the change to use the current schema, but we can determine if that is the right thing to do or not. While going through existing procedures, I have found that we have 2 flavors of procedures when it comes to dealing with empty or null schema name.

        For instance, when '' is passed for the schema name, SYSCS_UTIL.SYSCS_EXPORT_TABLE uses curent schema, syscs_util.SYSCS_INPLACE_COMPRESS_TABLE gives error schema '' does not exist. Top of the trunk(without my changes in the patch attached here) syscs_util.SYSCS_UPDATE_STATISTICS gives parser error(because we pass the schema name as '').
        – uses current schema
        call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('', 'T1' , 't11.del' , null, null, null);
        – gives parser error - Caused by: java.sql.SQLException: Syntax error: Encountered "\"" at line 1, column 13.
        call syscs_util.SYSCS_UPDATE_STATISTICS( '', 'T1', '' );
        – Caused by: ERROR 42Y07: Schema '' does not exist
        call syscs_util.SYSCS_INPLACE_COMPRESS_TABLE( '', 'T1', 1,1,1 );

        When null is passed for the schema name, SYSCS_UTIL.SYSCS_EXPORT_TABLE uses curent schema, syscs_util.SYSCS_INPLACE_COMPRESS_TABLE gives error schema null doesn't exist, and top of the trunk, syscs_util.SYSCS_UPDATE_STATISTICS gives null pointer exception
        – uses current schema
        call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'T1' , 't111.del' , null, null, null);
        – gives null pointer exception
        call syscs_util.SYSCS_UPDATE_STATISTICS( null, 'T1', '' );
        – schema null doesn't exist - Caused by: ERROR 42Y07: Schema 'null' does not exist
        call syscs_util.SYSCS_INPLACE_COMPRESS_TABLE( null, 'T1', 1,1,1 );

        So, we can have either of the two behaviors for SYSCS_UTIL.SYSCS_EXPORT_TABLE and '' or null for schema name
        1)Use current schema or
        2)Give parsing error (we internally generate ALTER TABLE sql here and parser will throw error before ALTER TABLE can throw exception for invalid schema name)

        No matter what we decide, we definitely need to take care of null pointer exception when null is passed for schema name.

        Show
        Mamta A. Satoor added a comment - Knut, thanks for reviewing the patch. Thanks for catching the isEmpty() usage. I have changed that in my codeline to instead use length() to determine if we are dealing with empty name. As for schema name, I did intentionally make the change to use the current schema, but we can determine if that is the right thing to do or not. While going through existing procedures, I have found that we have 2 flavors of procedures when it comes to dealing with empty or null schema name. For instance, when '' is passed for the schema name, SYSCS_UTIL.SYSCS_EXPORT_TABLE uses curent schema, syscs_util.SYSCS_INPLACE_COMPRESS_TABLE gives error schema '' does not exist. Top of the trunk(without my changes in the patch attached here) syscs_util.SYSCS_UPDATE_STATISTICS gives parser error(because we pass the schema name as ''). – uses current schema call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('', 'T1' , 't11.del' , null, null, null); – gives parser error - Caused by: java.sql.SQLException: Syntax error: Encountered "\"" at line 1, column 13. call syscs_util.SYSCS_UPDATE_STATISTICS( '', 'T1', '' ); – Caused by: ERROR 42Y07: Schema '' does not exist call syscs_util.SYSCS_INPLACE_COMPRESS_TABLE( '', 'T1', 1,1,1 ); When null is passed for the schema name, SYSCS_UTIL.SYSCS_EXPORT_TABLE uses curent schema, syscs_util.SYSCS_INPLACE_COMPRESS_TABLE gives error schema null doesn't exist, and top of the trunk, syscs_util.SYSCS_UPDATE_STATISTICS gives null pointer exception – uses current schema call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'T1' , 't111.del' , null, null, null); – gives null pointer exception call syscs_util.SYSCS_UPDATE_STATISTICS( null, 'T1', '' ); – schema null doesn't exist - Caused by: ERROR 42Y07: Schema 'null' does not exist call syscs_util.SYSCS_INPLACE_COMPRESS_TABLE( null, 'T1', 1,1,1 ); So, we can have either of the two behaviors for SYSCS_UTIL.SYSCS_EXPORT_TABLE and '' or null for schema name 1)Use current schema or 2)Give parsing error (we internally generate ALTER TABLE sql here and parser will throw error before ALTER TABLE can throw exception for invalid schema name) No matter what we decide, we definitely need to take care of null pointer exception when null is passed for schema name.
        Hide
        Knut Anders Hatlen added a comment -

        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)

        Show
        Knut Anders Hatlen added a comment - 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)
        Mamta A. Satoor made changes -
        Attachment DERBY5750_patch1_diff.txt [ 12532430 ]
        Hide
        Mamta A. Satoor added a comment -

        Attaching a patch which will have no table name information to compress table/drop statistics/update statistics procedures result in the same exception that a user would get when issuing the compress table sql directly without the table name
        eg alter table compress sequential
        Notice that the table name is missing in the compress sql above

        I have added few test cases for each of these procedures.

        Show
        Mamta A. Satoor added a comment - Attaching a patch which will have no table name information to compress table/drop statistics/update statistics procedures result in the same exception that a user would get when issuing the compress table sql directly without the table name eg alter table compress sequential Notice that the table name is missing in the compress sql above I have added few test cases for each of these procedures.
        Mamta A. Satoor made changes -
        Field Original Value New Value
        Assignee Mamta A. Satoor [ mamtas ]
        Mamta A. Satoor created issue -

          People

          • Assignee:
            Mamta A. Satoor
            Reporter:
            Mamta A. Satoor
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development