db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sylvain Leroux (JIRA)" <j...@apache.org>
Subject [jira] Updated: (DERBY-1447) add command line history to ij
Date Tue, 23 Feb 2010 14:52:28 GMT

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

Sylvain Leroux updated DERBY-1447:
----------------------------------

    Attachment: DERBY-1447-1a.patch

Attaching a version "1a" of a patch for this issue.

I'm rather unsatisfied by what I have done here:
First, ij has a contrived way of handling its input(s). So I finally had to hook the history/edit
in the main ij parser. This has the disadvantage of adding two more tokens to the parser.
And, since it works at statement-level, it made appear two statements on the same line as
two different entries in the history (see below). A more robust approach could have been to
use a specialized InputStream or to modify on org.apache.derby.impl.tools.ij.StatementFinder.
But it seems such solutions would require a deep rewrite of ij's input handling facilities.

Next, I use an external program to perform the edit. This works with a GUI editor (tested
on Linux with gedit), but /not/ with console-based editors. The problem is that Runtime.getRuntime().exec()
redirects the standard streams of the launched process. So terminal-based editors will not
have direct access to the console.

----

The patch introduces two new commands in ij:
HISTORY -- display the history of all the statements handled by ij
EDIT n   -- Allow to edit a previous statement by its number

The editor to use is defined by the ij.editor property.
Please note it should be a /GUI/ editor - or use some 'launcher' to reset the standard I/O
descriptor to the console.

Here is an example (defining "gedit" as editor):
  sh$ java -Dij.editor=gedit  org.apache.derby.tools.ij 
  ij version 10.6
  ij> connect 'jdbc:derby:memory:dummy;create=true';
  ij> create table t(a int, bint);
  ERROR 42XA9: Column 'BINT' needs an explicit datatype. The datatype can be omitted only
for columns with generation clauses.
  ij> history;
  0 connect 'jdbc:derby:memory:dummy;create=true';
  1 create table t(a int, bint);
  2 history;
  ij> edit 1;
*** At this point, the external editor is launched.
*** I made the required changes, save and quit
*** ij will now execute the modified statement
  ij> create table t(a int, b int);
  0 rows inserted/updated/deleted

In the example below, you will see that two statements on the same line appear as two distinct
statements in the history:
  ij> insert into t values (1, 100); insert into t values (2, 200);
  ij> history;
  0 connect 'jdbc:derby:memory:dummy;create=true';
  1 create table t(a int, bint);
  2 history;
  3 edit 1;
  4 create table t(a int, b int);
  5 insert into t values (1, 100);
  6 insert into t values (2, 200);
  7 history;


> add command line history to ij
> ------------------------------
>
>                 Key: DERBY-1447
>                 URL: https://issues.apache.org/jira/browse/DERBY-1447
>             Project: Derby
>          Issue Type: Improvement
>          Components: Tools
>            Reporter: Gary Orser
>            Assignee: Sylvain Leroux
>            Priority: Minor
>         Attachments: DERBY-1447-1a.patch, jline-0_9_5.jar, jline.diff
>
>
> Using the command line tool 
> org.apache.derby.tools.ij
> is user unfriendly.

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


Mime
View raw message