Issue Details (XML | Word | Printable)

Key: DERBY-4117
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Knut Anders Hatlen
Reporter: Knut Anders Hatlen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

dblook script fails when URL contains special characters

Created: 25/Mar/09 08:58 AM   Updated: 04/May/09 06:24 PM
Component/s: Tools
Affects Version/s: None
Fix Version/s: 10.5.1.1, 10.6.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works d4117.diff 2009-03-25 09:19 AM Knut Anders Hatlen 0.4 kB

Resolution Date: 26/Mar/09 11:48 AM
Labels:


 Description  « Hide
This problem was discovered when testing 10.5.1.0-RC1. The dblook shell script fails if the database URL contains characters that have a special meaning to the shell, even if those characters are properly escaped/quoted on the command line. Example:

$ ./bin/dblook -d 'jdbc:derby:jar:(demo/databases/toursdb.jar)toursdb'
./bin/dblook[29]: eval: syntax error at line 1: `(' unexpected

Connection attributes, like create=true, will be ignored because the semi-colon makes the script execute the setting of the connection attribute as a separate shell command:

$ ./bin/dblook -d 'jdbc:derby:NewDatabase;create=true'
-- Timestamp: 2009-03-25 09:54:56.169
-- Source database is: NewDatabase
-- Connection URL is: jdbc:derby:NewDatabase
-- appendLogs: false

-- Note: At least one unexpected error/warning message was
-- encountered during DDL generation. See dblook.log
-- to review the message(s).

In dblook.log:

java.sql.SQLException: Database 'NewDatabase' not found.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
...

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Knut Anders Hatlen added a comment - 25/Mar/09 09:19 AM
It looks like the problem is caused by the use of eval in bin/dblook, which makes it necessary to escape each special character twice in order to get it to work. Attached is a patch that removes the use of eval and instead uses exec directly. Now the examples mentioned in the bug description work as expected.

Knut Anders Hatlen made changes - 25/Mar/09 09:19 AM
Field Original Value New Value
Attachment d4117.diff [ 12403592 ]
Knut Anders Hatlen made changes - 25/Mar/09 09:19 AM
Assignee Knut Anders Hatlen [ knutanders ]
Knut Anders Hatlen made changes - 25/Mar/09 09:19 AM
Status Open [ 1 ] In Progress [ 3 ]
Knut Anders Hatlen made changes - 25/Mar/09 09:19 AM
Derby Info [Patch Available]
Repository Revision Date User Message
ASF #758603 Thu Mar 26 11:45:49 UTC 2009 kahatlen DERBY-4117: dblook script fails when URL contains special characters

Make dblook quote its arguments properly before passing them on to the
java command. This prevents problems when the database URL contains
characters which have a special meaning to the shell, for example:

$ ./bin/dblook -d 'jdbc:derby:jar:(demo/databases/toursdb.jar)toursdb'
./bin/dblook[29]: eval: syntax error at line 1: `(' unexpected
Files Changed
MODIFY /db/derby/code/trunk/bin/dblook

Repository Revision Date User Message
ASF #758604 Thu Mar 26 11:47:50 UTC 2009 kahatlen DERBY-4117: dblook script fails when URL contains special characters

Merged fix from trunk (revision 758603).
Files Changed
MODIFY /db/derby/code/branches/10.5/bin/dblook

Knut Anders Hatlen added a comment - 26/Mar/09 11:48 AM
Committed to trunk with revision 758603.
Merged to 10.5 and committed revision 758604.

Knut Anders Hatlen made changes - 26/Mar/09 11:48 AM
Status In Progress [ 3 ] Closed [ 6 ]
Derby Info [Patch Available]
Fix Version/s 10.5.1.1 [ 12313771 ]
Fix Version/s 10.6.0.0 [ 12313727 ]
Resolution Fixed [ 1 ]
Myrna van Lunteren made changes - 04/May/09 06:24 PM
Affects Version/s 10.5.1.0 [ 12313770 ]