db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-4829) dblook fails if there is a column privilege on a table whose name contains a quote
Date Fri, 01 Oct 2010 11:30:33 GMT

     [ https://issues.apache.org/jira/browse/DERBY-4829?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Knut Anders Hatlen updated DERBY-4829:

    Attachment: derby-4829-1a.diff

Here's a patch with a fix and a test case.

Description of the changes:

* impl/tools/dblook/DB_GrantRevoke.java:

Use a prepared statement instead of a statement so that the schema name and table name can
be parameters. This avoids the trouble with having to quote them as string literals with single
quotes. (We still need to quote them as identifiers with double quotes some places, but that
was done correctly in the existing code.)

Also remember to close the statement and result set.

Quote the column names in the generated GRANT statement.

Add the missing "ON <schema name>.<table name>" part of the generated GRANT statement.

* tests/tools/dblook_makeDB.sql:

Created table with special characters in name/columns and granted column privileges. Without
the fix, this made the different variants of dblook_test fail because the dblook error log
was not empty, and also because the dblook output got some extra statements.

* functionTests/master/**/dblook_test*.out:

Updated the canons for the dblook_test variants so that they expect the extra output caused
by the new database objects added in dblook_makeDB.sql. Some of the canons also got this error
text added, because of the bug in the table exclusion logic mentioned in my previous comment:

+FAILED: to execute cmd from DDL script:
+GRANT SELECT("'Single' and ""double"" quoted column name") ON "'Single' and ""double"" quoted
schema name"."'Single' and ""double"" quoted table name" TO "SOMEONE"
+Schema ''Single' and "double" quoted schema name' does not exist

I have only run the following tests yet:

derbynet/dblook_test_net.java (client and JCC)
derbynet/dblook_test_net_territory.java (client and JCC)

I'll run the full regression test suite and come back with the results.

> dblook fails if there is a column privilege on a table whose name contains a quote
> ----------------------------------------------------------------------------------
>                 Key: DERBY-4829
>                 URL: https://issues.apache.org/jira/browse/DERBY-4829
>             Project: Derby
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions:
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: derby-4829-1a.diff
> 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
> 	... 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.

View raw message