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

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

The reason for this is that DB_GrantRevoke.generateColumnPrivs() generates a 
query:

                        String queryCols = "SELECT COLUMNNUMBER, COLUMNNAME " +
                                "FROM SYS.SYSCOLUMNS C, SYS.SYSTABLES T, 
SYS.SYSSCHEMAS S " +
                                "WHERE T.TABLEID = C.REFERENCEID and S.SCHEMAID 
= T.SCHEMAID "+
                                "and T.TABLENAME = '"+tableName+"' AND 
SCHEMANAME = '"+schemaName +
                                "' ORDER BY COLUMNNUMBER";

tableName and schemaName have been pre-processed so that all their double 
quotes have been expanded to two double quotes. This would be correct if they 
were used as identifiers in the query, but since they are used as string 
literals, it's their single quotes that should have been expanded, not their 
double quotes.

This query therefore doesn't produce any results. If the table names had 
contained single quotes, the query would have failed with a syntax error.

> dblook fails if there is a column privilege on a table whose name contains a 
> double quote
> -----------------------------------------------------------------------------------------
>
>                 Key: DERBY-4829
>                 URL: https://issues.apache.org/jira/browse/DERBY-4829
>             Project: Derby
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: 10.6.2.1
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>
> Create a table with a column privilege like this in ij:
> connect 'jdbc:derby:db;create=true';
> call 
> syscs_util.syscs_set_database_property('derby.database.sqlAuthorization', 
> 'true');
> create table """" (x int);
> disconnect;
> connect 'jdbc:derby:db;shutdown=true';
> connect 'jdbc:derby:db';
> grant select (x) on """" to someone;
> exit;
> If you then run dblook -d jdbc:derby:db, you'll see this:
> -- ----------------------------------------------
> -- GRANT statements for columns
> -- ----------------------------------------------
> -- Note: At least one unexpected error/warning message was
> -- encountered during DDL generation.  See dblook.log
> -- to review the message(s).
> And in dblook.log you'll find this:
> java.sql.SQLException: Invalid cursor state - no current row.
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
>       at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown 
> Source)
>       at org.apache.derby.impl.jdbc.EmbedResultSet.checkOnRow(Unknown Source)
>       at org.apache.derby.impl.jdbc.EmbedResultSet.getColumn(Unknown Source)
>       at org.apache.derby.impl.jdbc.EmbedResultSet.getString(Unknown Source)
>       at 
> org.apache.derby.impl.tools.dblook.DB_GrantRevoke.mapColumnsToNames(Unknown 
> Source)
>       at 
> org.apache.derby.impl.tools.dblook.DB_GrantRevoke.columnPrivStatement(Unknown 
> Source)
>       at 
> org.apache.derby.impl.tools.dblook.DB_GrantRevoke.generateColumnPrivs(Unknown 
> Source)
>       at 
> org.apache.derby.impl.tools.dblook.DB_GrantRevoke.doAuthorizations(Unknown 
> Source)
>       at org.apache.derby.tools.dblook.go(Unknown Source)
>       at org.apache.derby.tools.dblook.<init>(Unknown Source)
>       at org.apache.derby.tools.dblook.main(Unknown Source)
> Caused by: java.sql.SQLException: Invalid cursor state - no current row.
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
>       at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
>  Source)
>       ... 16 more
> -- **--> DEBUG: Invalid cursor state - no current row.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to