Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 67635 invoked from network); 9 Aug 2006 23:58:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Aug 2006 23:58:52 -0000 Received: (qmail 37010 invoked by uid 500); 9 Aug 2006 23:58:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 36719 invoked by uid 500); 9 Aug 2006 23:58:50 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 36698 invoked by uid 99); 9 Aug 2006 23:58:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Aug 2006 16:58:50 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.42.249] (HELO nwkea-pix-1.sun.com) (192.18.42.249) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Aug 2006 16:58:47 -0700 Received: from d1-sfbay-09.sun.com ([192.18.39.119]) by nwkea-pix-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id k79NwR9e026225; Wed, 9 Aug 2006 16:58:27 -0700 (PDT) Received: from conversion-daemon.d1-sfbay-09.sun.com by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0J3R00C0194GR000@d1-sfbay-09.sun.com> (original mail from David.Vancouvering@Sun.COM); Wed, 09 Aug 2006 16:58:27 -0700 (PDT) Received: from [192.9.61.102] by d1-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0J3R00JOA99DNP30@d1-sfbay-09.sun.com>; Wed, 09 Aug 2006 16:58:27 -0700 (PDT) Date: Wed, 09 Aug 2006 16:58:32 -0700 From: David Van Couvering Subject: Re: svn commit: r430177 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/ma... In-reply-to: <20060809225359.ECFBB1A981A@eris.apache.org> Sender: David.Vancouvering@Sun.COM To: Derby Development Cc: derby-commits@db.apache.org Message-id: <44DA76A8.1040602@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=UTF-8 Content-transfer-encoding: 7BIT References: <20060809225359.ECFBB1A981A@eris.apache.org> User-Agent: Thunderbird 1.5.0.2 (X11/20060427) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Great stuff, Havard! Is documentation coming for this? David fuzzylogic@apache.org wrote: > Author: fuzzylogic > Date: Wed Aug 9 15:53:53 2006 > New Revision: 430177 > > URL: http://svn.apache.org/viewvc?rev=430177&view=rev > Log: > DERBY-1146: Add SHOW TABLES and DESCRIBE commands to ij. > > Committed for Havard Mork > > Added: > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out (with props) > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql (with props) > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties (with props) > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java (with props) > Modified: > db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java > db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/odbc_metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out > db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java > db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java > db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties > db/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java > > Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java (original) > +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java Wed Aug 9 15:53:53 2006 > @@ -283,7 +283,7 @@ > public String getDatabaseProductVersion() { > ProductVersionHolder myPVH = Monitor.getMonitor().getEngineVersion(); > > - return myPVH.getVersionBuildString(false); > + return myPVH.getVersionBuildString(true); > } > > /** > > Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties (original) > +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties Wed Aug 9 15:53:53 2006 > @@ -133,8 +133,8 @@ > FROM \ > SYS.SYSTABLES, \ > SYS.SYSSCHEMAS, \ > - (VALUES ('T','TABLE'), \ > - ('S','SYSTEM TABLE'), ('V', 'VIEW')) T(TTABBREV,TABLE_TYPE) \ > + (VALUES ('T','TABLE'), ('S','SYSTEM TABLE'), \ > + ('V', 'VIEW'), ('A', 'SYNONYM')) T(TTABBREV,TABLE_TYPE) \ > WHERE (TTABBREV=TABLETYPE \ > AND (SYS.SYSTABLES.SCHEMAID = SYS.SYSSCHEMAS.SCHEMAID) \ > AND ((1=1) OR ? IS NOT NULL) \ > @@ -272,7 +272,8 @@ > # so we wrap the values in a select to name it. > getTableTypes=\ > SELECT CAST (RTRIM(TABLE_TYPE) AS VARCHAR(12)) AS TABLE_TYPE \ > - FROM (VALUES 'SYSTEM TABLE', 'TABLE', 'VIEW') TABLETYPES(TABLE_TYPE) \ > + FROM (VALUES 'SYNONYM', 'SYSTEM TABLE', 'TABLE', 'VIEW') \ > + TABLETYPES(TABLE_TYPE) \ > ORDER BY TABLE_TYPE > > # parameter 1 = pattern for catalog name > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/metadata.out Wed Aug 9 15:53:53 2006 > @@ -284,6 +284,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/odbc_metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/odbc_metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/odbc_metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/odbc_metadata.out Wed Aug 9 15:53:53 2006 > @@ -314,6 +314,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out Wed Aug 9 15:53:53 2006 > @@ -377,6 +377,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out Wed Aug 9 15:53:53 2006 > @@ -377,6 +377,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out Wed Aug 9 15:53:53 2006 > @@ -407,6 +407,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out Wed Aug 9 15:53:53 2006 > @@ -1106,6 +1106,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > @@ -2597,6 +2598,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out Wed Aug 9 15:53:53 2006 > @@ -49,6 +49,12 @@ > DISCONNECT [ CURRENT | connectionName | ALL ]; > -- drop current, named, or all connections; > -- the default is CURRENT > + SHOW SCHEMAS; -- lists all schemas in the current database > + SHOW [ TABLES | VIEWS | PROCEDURES | SYNONYMS ] { IN schema }; > + -- lists tables, views, procedures or synonyms > + SHOW INDEXES { IN schema | FROM table }; > + -- lists indexes in a schema, or for a table > + DESCRIBE name; -- lists columns in the named table > COMMIT; -- commits the current transaction > ROLLBACK; -- rolls back the current transaction > PREPARE name AS 'SQL-J text'; -- prepares the SQL-J text > > Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out?rev=430177&view=auto > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out (added) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out Wed Aug 9 15:53:53 2006 > @@ -0,0 +1,89 @@ > +ij> -- This test will cover SHOW TABLES, SHOW SCHEMAS, etc. > +-- and the DESCRIBE command. > +connect 'jdbc:derby:wombat;create=true'; > +ij> SET SCHEMA = APP; > +0 rows inserted/updated/deleted > +ij> CREATE TABLE t1 (i int generated always as identity, d DECIMAL(5,2), test VARCHAR(20)); > +0 rows inserted/updated/deleted > +ij> CREATE SCHEMA USER1; > +0 rows inserted/updated/deleted > +ij> SET SCHEMA = USER1; > +0 rows inserted/updated/deleted > +ij> CREATE TABLE t2 (i int); > +0 rows inserted/updated/deleted > +ij> CREATE SYNONYM USER1.T3 FOR USER1.T2; > +0 rows inserted/updated/deleted > +ij> CREATE VIEW v1 AS SELECT * from app.t1; > +0 rows inserted/updated/deleted > +ij> CREATE INDEX idx1 ON APP.t1 (test ASC); > +0 rows inserted/updated/deleted > +ij> CREATE PROCEDURE APP.PROCTEST(IN A INTEGER, OUT B DECIMAL(10,2)) > +PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA > +EXTERNAL NAME 'a.b.c.d.e'; > +0 rows inserted/updated/deleted > +ij> -- first display all tables, then display tables in one schema > +SHOW TABLES; > +TABLE_SCHEM |TABLE_NAME |REMARKS > +------------------------------------------------------------------------ > +APP |T1 | > +USER1 |T2 | > +2 rows selected > +ij> SHOW TABLES IN APP; > +TABLE_SCHEM |TABLE_NAME |REMARKS > +------------------------------------------------------------------------ > +APP |T1 | > +1 row selected > +ij> -- 'describe t1' will give error, as not in current schema > +DESCRIBE t1; > +IJ ERROR: No table exists with the name T1 > +ij> DESCRIBE APP.t1; > +COLUMN_NAME |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL& > +------------------------------------------------------------------------------ > +I |INTEGER |0 |10 |10 |AUTOINCRE&|NULL |NO > +D |DECIMAL |2 |10 |5 |NULL |NULL |YES > +TEST |VARCHAR |NULL|NULL|20 |NULL |40 |YES > +3 rows selected > +ij> DESCRIBE v1; > +COLUMN_NAME |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL& > +------------------------------------------------------------------------------ > +I |INTEGER |0 |10 |10 |NULL |NULL |NO > +D |DECIMAL |2 |10 |5 |NULL |NULL |YES > +TEST |VARCHAR |NULL|NULL|20 |NULL |40 |YES > +3 rows selected > +ij> SHOW SCHEMAS; > +TABLE_SCHEM > +------------------------------ > +APP > +NULLID > +SQLJ > +SYS > +SYSCAT > +SYSCS_DIAG > +SYSCS_UTIL > +SYSFUN > +SYSIBM > +SYSPROC > +SYSSTAT > +USER1 > +12 rows selected > +ij> SHOW VIEWS IN USER1; > +TABLE_SCHEM |TABLE_NAME |REMARKS > +------------------------------------------------------------------------ > +USER1 |V1 | > +1 row selected > +ij> SHOW PROCEDURES IN APP; > +PROCEDURE_SCHEM |PROCEDURE_NAME |REMARKS > +------------------------------------------------------------------------ > +APP |PROCTEST |a.b.c.d.e > +1 row selected > +ij> SHOW SYNONYMS IN USER1; > +TABLE_SCHEM |TABLE_NAME |REMARKS > +------------------------------------------------------------------------ > +USER1 |T3 | > +1 row selected > +ij> SHOW INDEXES FROM APP.t1; > +TABLE_NAME |COLUMN_NAME |NON_U&|TYPE|ASC&|CARDINA&|PAGES > +---------------------------------------------------------------------------- > +T1 |TEST |true |3 |A |NULL |NULL > +1 row selected > +ij> > > Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/ij.out Wed Aug 9 15:53:53 2006 > @@ -49,6 +49,12 @@ > DISCONNECT [ CURRENT | connectionName | ALL ]; > -- drop current, named, or all connections; > -- the default is CURRENT > + SHOW SCHEMAS; -- lists all schemas in the current database > + SHOW [ TABLES | VIEWS | PROCEDURES | SYNONYMS ] { IN schema }; > + -- lists tables, views, procedures or synonyms > + SHOW INDEXES { IN schema | FROM table }; > + -- lists indexes in a schema, or for a table > + DESCRIBE name; -- lists columns in the named table > COMMIT; -- commits the current transaction > ROLLBACK; -- rolls back the current transaction > PREPARE name AS 'SQL-J text'; -- prepares the SQL-J text > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out Wed Aug 9 15:53:53 2006 > @@ -377,6 +377,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out Wed Aug 9 15:53:53 2006 > @@ -407,6 +407,7 @@ > ,APP,SCREWIE,VIEW,,null,null,null,null,null > getTableTypes(): > TABLE_TYPE[VARCHAR] > +SYNONYM > SYSTEM TABLE > TABLE > VIEW > > Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall (original) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall Wed Aug 9 15:53:53 2006 > @@ -10,5 +10,6 @@ > tools/ij4.sql > tools/ij5.sql > tools/ij6.sql > +tools/ij7.sql > tools/ijConnName.sql > tools/URLCheck.sql > > Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql?rev=430177&view=auto > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql (added) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql Wed Aug 9 15:53:53 2006 > @@ -0,0 +1,35 @@ > + > +-- This test will cover SHOW TABLES, SHOW SCHEMAS, etc. > +-- and the DESCRIBE command. > + > +connect 'jdbc:derby:wombat;create=true'; > + > +SET SCHEMA = APP; > +CREATE TABLE t1 (i int generated always as identity, d DECIMAL(5,2), test VARCHAR(20)); > + > +CREATE SCHEMA USER1; > +SET SCHEMA = USER1; > +CREATE TABLE t2 (i int); > + > +CREATE SYNONYM USER1.T3 FOR USER1.T2; > +CREATE VIEW v1 AS SELECT * from app.t1; > +CREATE INDEX idx1 ON APP.t1 (test ASC); > +CREATE PROCEDURE APP.PROCTEST(IN A INTEGER, OUT B DECIMAL(10,2)) > +PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA > +EXTERNAL NAME 'a.b.c.d.e'; > + > +-- first display all tables, then display tables in one schema > +SHOW TABLES; > +SHOW TABLES IN APP; > + > +-- 'describe t1' will give error, as not in current schema > +DESCRIBE t1; > +DESCRIBE APP.t1; > +DESCRIBE v1; > + > +SHOW SCHEMAS; > +SHOW VIEWS IN USER1; > +SHOW PROCEDURES IN APP; > +SHOW SYNONYMS IN USER1; > +SHOW INDEXES FROM APP.t1; > + > > Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties?rev=430177&view=auto > ============================================================================== > --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties (added) > +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties Wed Aug 9 15:53:53 2006 > @@ -0,0 +1,4 @@ > +ij.showNoConnectionsAtStart=false > + > +#Exclude for J2ME/Foundation - need to look into reason for failure > +runwithfoundation=false > \ No newline at end of file > > Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7_app.properties > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj Wed Aug 9 15:53:53 2006 > @@ -551,6 +551,240 @@ > return new ijVectorResult(v,w); > } > > + /** > + Returns a subset of the input integer array > + > + @param input The input integer array > + @param start Starting index, inclusive > + @param end Ending index, exclusive > + */ > + public static int[] intArraySubset(final int[] input, int start, int end) { > + int[] res = new int[end-start]; > + System.arraycopy(input, start, res, 0, end-start); > + return res; > + } > + > + /** > + Verify that a table exists within a schema. Throws an exception > + if table does not exist. > + > + @param schema Schema for the table > + @param table Name of table to check for existence of > + */ > + public void verifyTableExists(String schema, String table) > + throws SQLException { > + if(schema == null) > + return; > + > + ResultSet rs = null; > + try { > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getTables(null,schema,table,null); > + if(!rs.next()) > + throw ijException.noSuchTable(table); > + } finally { > + if(rs!=null) > + rs.close(); > + } > + } > + > + /** > + Return a resultset of tables (or views, procs...) in the given schema. > + > + @param schema Schema to get tables for, or null for search > + in all schemas. > + @param tableType Types of tables to return, see > + {@link java.sql.DatabaseMetaData#getTableTypes} > + */ > + public ijResult showTables(String schema, String[] tableType) throws SQLException { > + ResultSet rs = null; > + try { > + haveConnection(); > + > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getTables(null,schema,null,tableType); > + > + int[] displayColumns = new int[] { > + rs.findColumn("TABLE_SCHEM"), > + rs.findColumn("TABLE_NAME"), > + rs.findColumn("REMARKS"), > + }; > + int[] columnWidths = new int[] { > + 20, > + 30, > + 20, > + }; > + > + return new ijResultSetResult(rs, displayColumns, columnWidths); > + } catch (SQLException e) { > + if(rs!=null) > + rs.close(); > + throw e; > + } > + } > + > + /** > + Return a resultset of indexes for the given table or schema > + > + @param schema schema to find indexes for > + @param table table to find indexes for > + */ > + public ijResult showIndexes(String schema, String table) throws SQLException { > + ResultSet rs = null; > + try { > + haveConnection(); > + verifyTableExists(schema, table); > + > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getIndexInfo(null, schema, table, false, true); > + > + int[] displayColumns = new int[] { > + rs.findColumn("TABLE_SCHEM"), > + rs.findColumn("TABLE_NAME"), > + rs.findColumn("COLUMN_NAME"), > + rs.findColumn("NON_UNIQUE"), > + rs.findColumn("TYPE"), > + rs.findColumn("ASC_OR_DESC"), > + rs.findColumn("CARDINALITY"), > + rs.findColumn("PAGES"), > + }; > + int[] columnWidths = new int[] { > + 20, > + 20, > + 20, > + 6, > + 4, > + 4, > + 8, > + 8, > + }; > + > + if(schema!=null) { > + displayColumns = intArraySubset(displayColumns, 1, > + displayColumns.length); > + columnWidths = intArraySubset(columnWidths, 1, > + columnWidths.length); > + } > + return new ijResultSetResult(rs, displayColumns, columnWidths); > + } catch (SQLException e) { > + if(rs!=null) > + rs.close(); > + throw e; > + } > + } > + > + /** > + Return a resultset of procedures from database metadata > + */ > + public ijResult showProcedures(String schema) throws SQLException { > + ResultSet rs = null; > + try { > + haveConnection(); > + > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getProcedures(null,schema,null); > + > + int[] displayColumns = new int[] { > + rs.findColumn("PROCEDURE_SCHEM"), > + rs.findColumn("PROCEDURE_NAME"), > + rs.findColumn("REMARKS"), > + }; > + int[] columnWidths = new int[] { > + 20, > + 30, > + 20, > + }; > + > + return new ijResultSetResult(rs, displayColumns, columnWidths); > + } catch (SQLException e) { > + if(rs!=null) > + rs.close(); > + throw e; > + } > + } > + > + /** > + Return a resultset of schemas from database metadata > + */ > + public ijResult showSchemas() throws SQLException { > + ResultSet rs = null; > + try { > + haveConnection(); > + > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getSchemas(); > + > + int[] displayColumns = new int[] { > + rs.findColumn("TABLE_SCHEM") > + }; > + int[] columnWidths = new int[] { > + 30 > + }; > + > + return new ijResultSetResult(rs, displayColumns, columnWidths); > + } catch (SQLException e) { > + if(rs!=null) > + rs.close(); > + throw e; > + } > + } > + > + /** > + Outputs the names of all fields of given table. Outputs field > + names and data type. > + */ > + public ijResult describeTable(String schema, String table) throws SQLException { > + ResultSet rs = null; > + try { > + haveConnection(); > + verifyTableExists(schema,table); > + > + DatabaseMetaData dbmd = theConnection.getMetaData(); > + rs = dbmd.getColumns(null,schema,table,null); > + > + int[] displayColumns = new int[] { > + rs.findColumn("TABLE_SCHEM"), > + rs.findColumn("TABLE_NAME"), > + rs.findColumn("COLUMN_NAME"), > + rs.findColumn("TYPE_NAME"), > + rs.findColumn("DECIMAL_DIGITS"), > + rs.findColumn("NUM_PREC_RADIX"), > + rs.findColumn("COLUMN_SIZE"), > + rs.findColumn("COLUMN_DEF"), > + rs.findColumn("CHAR_OCTET_LENGTH"), > + rs.findColumn("IS_NULLABLE"), > + }; > + int[] columnWidths = new int[] { > + 20, > + 20, > + 20, > + 9, > + 4, > + 4, > + 6, > + 10, > + 10, > + 8 > + }; > + > + // > + // If schema is specified (if util.getSelectedSchema in > + // DescTableStatement() returns correct value), then we > + // don't need to output schema and table names. > + if(schema!=null) { > + displayColumns = intArraySubset(displayColumns, 2, > + displayColumns.length); > + columnWidths = intArraySubset(columnWidths, 2, > + columnWidths.length); > + } > + > + return new ijResultSetResult(rs, displayColumns, columnWidths); > + } catch (SQLException e) { > + if(rs!=null) > + rs.close(); > + throw e; > + } > + } > > private Object makeXid(int xid) > { > @@ -589,6 +823,7 @@ > { /* ij Keywords */ > > | > +| > | > | > | > @@ -603,6 +838,7 @@ > | > | > | > +| > | > | > | > @@ -614,10 +850,13 @@ > | > | > | > +| > | > | > | > | > +| > +| > | > | > | > @@ -634,6 +873,7 @@ > | > | > | > +| > | > | > | > @@ -645,14 +885,18 @@ > | > | > | > +| > | > | > | > | > | > | > +| > +| > | > | > +| > | > | > | > @@ -985,6 +1229,7 @@ > | r=CloseStatement() > | r=CommitStatement() > | r=ConnectStatement() > +| r=DescTableStatement() > | r=DisconnectStatement() > | r=DriverStatement() > | r=ElapsedTimeStatement() > @@ -1012,7 +1257,7 @@ > | r=RemoveStatement() > | r=RunStatement() > | r=SetConnectionStatement() > -| r=ShowConnectionsStatement() > +| r=ShowStatement() > | r=WaitForStatement() > | r=XA_DataSourceStatement() > | r=XA_ConnectStatement() > @@ -1246,6 +1491,43 @@ > > > /** > + * Handles DESCRIBE table > + */ > +ijResult > +DescTableStatement() > +throws SQLException > +: > +{ > + String i = null; > + String i2 = null; > + Token s = null; > +} > +{ > + > + ( ( i=identifier() i2=identifier() ) > + | i2=identifier() > + | s= > + ) > + { > + if(s!=null) { > + String image = stringValue(s.image.toUpperCase()); > + > + int dotPosition = image.indexOf('.'); > + if(dotPosition!=-1) { > + i = image.substring(0,dotPosition); > + i2 = image.substring(dotPosition+1); > + } > + } > + > + if(i==null) > + i = util.getSelectedSchema(theConnection); > + > + return describeTable(i,i2); > + } > +} > + > + > +/** > * Handles CONNECT yadda.yadda.foo( stringArg, ... stringArg ) AS connectionName > */ > ijResult > @@ -1334,19 +1616,69 @@ > } > > /** > - Shows the current connections for the current environment. > + * Handles showing current connections for the current environment, and > + * SHOW TABLES/VIEWS/... commands. > */ > ijResult > -ShowConnectionsStatement() > +ShowStatement() > throws SQLException > : > { > + String schema = null; > + String tblname = null; > + String str = null; > + String[] types = null; > + Token t = null; > + Token v = null; > } > { > > { > return showConnectionsMethod(false); > } > +| (t= | v= | | ) > + [ schema=identifier() ] > + { > + if(t!=null) { > + // Only show non-system tables by default. > + // If schema specified (i.e. SYS), also display system tables. > + if(schema!=null) > + types = new String[] { "TABLE", "SYSTEM TABLE" }; > + else > + types = new String[] { "TABLE" }; > + } > + else if(v!=null) > + types = new String[] { "VIEW" }; > + else > + types = new String[] { "ALIAS" }; > + return showTables(schema, types); > + } > +| > + [ ( schema=identifier()) | > + ( tblname=identifier() [ str=identifier() ] ) ] > + { > + if(str != null) { > + // if absolute table reference given > + schema = tblname; > + tblname = str; > + } > + > + // If user specifies a table name, then assume schema is > + // current schema. Note that getSelectedSchema may return > + // null for some DBMSes. > + if(schema == null && tblname != null) > + schema = util.getSelectedSchema(theConnection); > + return showIndexes(schema,tblname); > + } > +| > + [ schema=identifier() ] > + { > + return showProcedures(schema); > + } > +| > + { > + return showSchemas(); > + } > } > > /** > @@ -3097,6 +3429,7 @@ > ( > tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > @@ -3111,6 +3444,7 @@ > | tok = > | tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > @@ -3121,10 +3455,13 @@ > | tok = > | tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > | tok = > +| tok = > +| tok = > | tok = > | tok = > | tok = > @@ -3141,6 +3478,7 @@ > | tok = > | tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > @@ -3151,14 +3489,18 @@ > | tok = > | tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > | tok = > | tok = > | tok = > +| tok = > +| tok = > | tok = > | tok = > +| tok = > | tok = > | tok = > | tok = > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijException.java Wed Aug 9 15:53:53 2006 > @@ -53,6 +53,7 @@ > private final static String NoSuchAsyncStatement = "IJ_NoAsynStatEx"; > private final static String NoSuchConnection = "IJ_NoConnExisWi"; > private final static String NoSuchProtocol = "IJ_NoProtExisWi"; > + private final static String NoSuchTable = "IJ_NoSuchTable"; > private final static String NotJDBC20 = "IJ_IsOnlySuppIn"; > private final static String NoUsingResults = "IJ_UsinClauHadN"; > private final static String ObjectWasNull = "IJ_UnabToEsta"; > @@ -122,6 +123,9 @@ > } > static ijException noSuchProtocol(String c) { > return new ijException(LocalizedResource.getMessage(NoSuchProtocol, c)); > + } > + static ijException noSuchTable(String c) { > + return new ijException(LocalizedResource.getMessage(NoSuchTable, c)); > } > static public ijException notJDBC20(String operation) { > return new ijException(LocalizedResource.getMessage(NotJDBC20, operation)); > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResult.java Wed Aug 9 15:53:53 2006 > @@ -54,6 +54,8 @@ > ResultSet getNextRowOfResultSet(); > Vector getVector(); > SQLException getException(); > + int[] getColumnDisplayList(); > + int[] getColumnWidthList(); > > void closeStatement() throws SQLException ; > > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultImpl.java Wed Aug 9 15:53:53 2006 > @@ -53,6 +53,9 @@ > public Vector getVector() { return null; } > public SQLException getException() { return null; } > > + public int[] getColumnDisplayList() { return null; } > + public int[] getColumnWidthList() { return null; } > + > public void closeStatement() throws SQLException { } > > public abstract SQLWarning getSQLWarnings() throws SQLException; > @@ -66,6 +69,10 @@ > if (isVector()) return LocalizedResource.getMessage("IJ_Vec0",getVector().toString()); > if (isMulti()) return LocalizedResource.getMessage("IJ_Mul0",getVector().toString()); > if (isException()) return LocalizedResource.getMessage("IJ_Exc0",getException().toString()); > + try { > + if (isResultSet()) return LocalizedResource.getMessage("IJ_Rse0",getStatement().toString()); > + } catch(SQLException se) { > + } > return LocalizedResource.getMessage("IJ_Unkn0",this.getClass().getName()); > } > } > > Added: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java?rev=430177&view=auto > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java (added) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java Wed Aug 9 15:53:53 2006 > @@ -0,0 +1,81 @@ > +/* > + > + Derby - Class org.apache.derby.impl.tools.ij.ijResultSetResult > + > + Licensed to the Apache Software Foundation (ASF) under one > + or more contributor license agreements. See the NOTICE file > + distributed with this work for additional information > + regarding copyright ownership. The ASF licenses this file > + to you under the Apache License, Version 2.0 (the > + "License"); you may not use this file except in compliance > + with the License. You may obtain a copy of the License at > + > + http://www.apache.org/licenses/LICENSE-2.0 > + > + Unless required by applicable law or agreed to in writing, software > + distributed under the License is distributed on an "AS IS" BASIS, > + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + See the License for the specific language governing permissions and > + limitations under the License. > + > + */ > + > +package org.apache.derby.impl.tools.ij; > + > +import java.sql.Connection; > +import java.sql.ResultSet; > +import java.sql.Statement; > +import java.sql.SQLException; > +import java.sql.SQLWarning; > + > +/** > + * This impl is intended to be used with a resultset, > + * where the execution of the statement is already complete. > + */ > +public class ijResultSetResult extends ijResultImpl { > + > + ResultSet resultSet; > + Statement statement; > + > + int[] displayColumns = null; > + int[] columnWidths = null; > + > + /** > + * Create a ijResultImpl that represents a result set. > + */ > + public ijResultSetResult(ResultSet r) throws SQLException { > + resultSet = r; > + statement = resultSet.getStatement(); > + } > + > + /** > + * Create a ijResultImpl that represents a result set, only > + * displaying a subset of the columns, using specified column widths. > + * > + * @param r The result set to display > + * @param display Which column numbers to display, or null to display > + * all columns. > + * @param widths The widths of the columns specified in 'display', or > + * null to display using default column sizes. > + */ > + public ijResultSetResult(ResultSet r, int[] display, > + int[] widths) throws SQLException { > + resultSet = r; > + statement = resultSet.getStatement(); > + > + displayColumns = display; > + columnWidths = widths; > + } > + > + public boolean isResultSet() throws SQLException { return statement==null || statement.getUpdateCount() == -1; } > + > + public ResultSet getResultSet() throws SQLException { return resultSet; } > + > + public void closeStatement() throws SQLException { if(statement!=null) statement.close(); else resultSet.close(); } > + > + public int[] getColumnDisplayList() { return displayColumns; } > + public int[] getColumnWidthList() { return columnWidths; } > + > + public SQLWarning getSQLWarnings() throws SQLException { return resultSet.getWarnings(); } > + public void clearSQLWarnings() throws SQLException { resultSet.clearWarnings(); } > +} > > Propchange: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ijResultSetResult.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/util.java Wed Aug 9 15:53:53 2006 > @@ -853,6 +853,35 @@ > (framework.toUpperCase(Locale.ENGLISH).indexOf("JCC") != -1))); > } > > - > + /** > + * Selects the current schema from the given connection. > + * > + * As there are no way of getting current schema supported by > + * all major DBMS-es, this method may return null. > + * > + * @param theConnection Connection to get current schema for > + * @return the current schema of the connection, or null if error. > + */ > + public static String getSelectedSchema(Connection theConnection) throws SQLException { > + String schema = null; > + if (theConnection == null) > + return null; > + Statement st = theConnection.createStatement(); > + try { > + if(!st.execute("VALUES CURRENT SCHEMA")) > + return null; > + > + ResultSet rs = st.getResultSet(); > + if(rs==null || !rs.next()) > + return null; > + schema = rs.getString(1); > + } catch(SQLException e) { > + // There are no standard way of getting schema. > + // Getting default schema may fail. > + } finally { > + st.close(); > + } > + return schema; > + } > } > > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Wed Aug 9 15:53:53 2006 > @@ -451,6 +451,15 @@ > JDBCDisplayUtil.ShowWarnings(out,result.getSQLWarnings()); > result.clearSQLWarnings(); > } > + } else if (result.isResultSet()) { > + ResultSet rs = result.getResultSet(); > + try { > + JDBCDisplayUtil.DisplayResults(out,rs,connEnv[currCE].getConnection(), result.getColumnDisplayList(), result.getColumnWidthList()); > + } catch (SQLException se) { > + result.closeStatement(); > + throw se; > + } > + result.closeStatement(); > } else if (result.isException()) { > JDBCDisplayUtil.ShowException(out,result.getException()); > } > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Wed Aug 9 15:53:53 2006 > @@ -65,6 +65,13 @@ > \ -- drop current, named, or all connections;\n\ > \ -- the default is CURRENT\n\ > \ \n\ > +\ SHOW SCHEMAS; -- lists all schemas in the current database\n\ > +\ SHOW [ TABLES | VIEWS | PROCEDURES | SYNONYMS ] { IN schema };\n\ > +\ -- lists tables, views, procedures or synonyms\n\ > +\ SHOW INDEXES { IN schema | FROM table };\n\ > +\ -- lists indexes in a schema, or for a table\n\ > +\ DESCRIBE name; -- lists columns in the named table\n\ > +\ \n\ > \ COMMIT; -- commits the current transaction\n\ > \ ROLLBACK; -- rolls back the current transaction\n\ > \ \n\ > @@ -129,6 +136,7 @@ > IJ_NoAsynStatEx=No async statement exists with the name {0} > IJ_NoConnExisWi=No connection exists with the name {0} > IJ_NoProtExisWi=No protocol exists with the name {0} > +IJ_NoSuchTable=No table exists with the name {0} > IJ_IsOnlySuppIn={0} is only supported in JDBC 2.0 and greater. > IJ_UsinClauHadN=Using clause had no results > IJ_UnabToEsta=Unable to establish {0} > @@ -149,6 +157,7 @@ > IJ_Vec0=VEC::{0} > IJ_Mul0=MUL::{0} > IJ_Exc0=EXC::{0} > +IJ_Rse0=RST::{0} > IJ_Unkn0=UNKNOWN::{0} > # From util.java > IJ_UsageJavaComCloudToolsIjPPropeInput=Usage: java org.apache.derby.tools.ij [-p propertyfile] [-ca connectionAttributePropertyFile] [inputfile] > > Modified: db/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java > URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java?rev=430177&r1=430176&r2=430177&view=diff > ============================================================================== > --- db/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java (original) > +++ db/derby/code/trunk/java/tools/org/apache/derby/tools/JDBCDisplayUtil.java Wed Aug 9 15:53:53 2006 > @@ -258,18 +258,20 @@ > static public void DisplayResults(PrintWriter out, Statement stmt, Connection conn ) > throws SQLException > { > - indent_DisplayResults( out, stmt, conn, 0); > + indent_DisplayResults( out, stmt, conn, 0, null, null); > } > > static private void indent_DisplayResults > - (PrintWriter out, Statement stmt, Connection conn, int indentLevel) > + (PrintWriter out, Statement stmt, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException { > > checkNotNull(stmt, "Statement"); > > ResultSet rs = stmt.getResultSet(); > if (rs != null) { > - indent_DisplayResults(out, rs, conn, indentLevel); > + indent_DisplayResults(out, rs, conn, indentLevel, > + displayColumns, displayColumnWidths); > rs.close(); // let the result set go away > } > else { > @@ -297,20 +299,48 @@ > } > > /** > + Calculates column display widths from the default widths of the > + result set. > + */ > + static private int[] getColumnDisplayWidths(ResultSetMetaData rsmd, int[] dispColumns, > + boolean localizedOutput) > + throws SQLException { > + int count = (dispColumns == null) ? rsmd.getColumnCount() : dispColumns.length; > + int[] widths = new int[count]; > + > + for(int i=0; i + int colnum = (dispColumns == null) ? (i + 1) : dispColumns[i]; > + int dispsize = localizedOutput > + ? LocalizedResource.getInstance().getColumnDisplaySize(rsmd, colnum) > + : rsmd.getColumnDisplaySize(colnum); > + widths[i] = Math.min(maxWidth, > + Math.max((rsmd.isNullable(colnum) == ResultSetMetaData.columnNoNulls)? > + 0 : MINWIDTH, dispsize)); > + } > + return widths; > + } > + > + > + /** > @param out the place to write to > @param rs the ResultSet to display > @param conn the Connection against which the ResultSet was retrieved > + @param displayColumns Column numbers to display, or null if all > + @param displayColumnWidths Column widths, in characters, if displayColumns is specified. > > @exception SQLException on JDBC access failure > */ > - static public void DisplayResults(PrintWriter out, ResultSet rs, Connection conn) > + static public void DisplayResults(PrintWriter out, ResultSet rs, Connection conn, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException > { > - indent_DisplayResults( out, rs, conn, 0); > + indent_DisplayResults( out, rs, conn, 0, displayColumns, > + displayColumnWidths); > } > > static private void indent_DisplayResults > - (PrintWriter out, ResultSet rs, Connection conn, int indentLevel) > + (PrintWriter out, ResultSet rs, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException { > ResultSetMetaData rsmd = rs.getMetaData(); > checkNotNull(rsmd, "ResultSetMetaData"); > @@ -324,7 +354,11 @@ > else > nestedResults = null; > > - int len = indent_DisplayBanner(out,rsmd, indentLevel); > + if(displayColumnWidths == null) > + displayColumnWidths = getColumnDisplayWidths(rsmd, displayColumns,true); > + > + int len = indent_DisplayBanner(out,rsmd, indentLevel, displayColumns, > + displayColumnWidths); > > // When displaying rows, keep going past errors > // unless/until the maximum # of errors is reached. > @@ -335,7 +369,9 @@ > doNext = rs.next(); > if (doNext) { > > - DisplayRow(out, rs, rsmd, len, nestedResults, conn, indentLevel); > + DisplayRow(out, rs, rsmd, len, nestedResults, conn, > + indentLevel, displayColumns, > + displayColumnWidths); > ShowWarnings(out, rs); > numberOfRowsSelected++; > } > @@ -392,7 +428,8 @@ > LocalizedResource.OutputWriter().println(b); > LocalizedResource.OutputWriter().println(LocalizedResource.getMessage("UT_Resul0", LocalizedResource.getNumber(i))); > LocalizedResource.OutputWriter().println(b); > - indent_DisplayResults(out, (ResultSet) nr.elementAt(i), conn, indentLevel); > + indent_DisplayResults(out, (ResultSet) nr.elementAt(i), conn, > + indentLevel, null, null); > } > } > > @@ -409,10 +446,12 @@ > static public void DisplayNextRow(PrintWriter out, ResultSet rs, Connection conn ) > throws SQLException > { > - indent_DisplayNextRow( out, rs, conn, 0 ); > + indent_DisplayNextRow( out, rs, conn, 0, null, (rs == null) ? null > + : getColumnDisplayWidths(rs.getMetaData(), null, true)); > } > > - static private void indent_DisplayNextRow(PrintWriter out, ResultSet rs, Connection conn, int indentLevel ) > + static private void indent_DisplayNextRow(PrintWriter out, ResultSet rs, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > Vector nestedResults; > @@ -431,8 +470,9 @@ > > // Only print stuff out if there is a row to be had. > if (rs.next()) { > - int rowLen = indent_DisplayBanner(out, rsmd, indentLevel); > - DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel ); > + int rowLen = indent_DisplayBanner(out, rsmd, indentLevel, displayColumns, displayColumnWidths); > + DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel, > + null, null ); > } > else { > indentedPrintLine( out, indentLevel, LocalizedResource.getMessage("UT_NoCurreRow")); > @@ -458,10 +498,12 @@ > static public void DisplayCurrentRow(PrintWriter out, ResultSet rs, Connection conn ) > throws SQLException > { > - indent_DisplayCurrentRow( out, rs, conn, 0 ); > + indent_DisplayCurrentRow( out, rs, conn, 0, null, (rs == null) ? null > + : getColumnDisplayWidths(rs.getMetaData(), null, true) ); > } > > - static private void indent_DisplayCurrentRow(PrintWriter out, ResultSet rs, Connection conn, int indentLevel ) > + static private void indent_DisplayCurrentRow(PrintWriter out, ResultSet rs, Connection conn, > + int indentLevel, int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > Vector nestedResults; > @@ -481,8 +523,9 @@ > ResultSetMetaData rsmd = rs.getMetaData(); > checkNotNull(rsmd, "ResultSetMetaData"); > > - int rowLen = indent_DisplayBanner(out, rsmd, indentLevel); > - DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel ); > + int rowLen = indent_DisplayBanner(out, rsmd, indentLevel, displayColumns, displayColumnWidths); > + DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel, > + displayColumns, displayColumnWidths ); > > ShowWarnings(out, rs); > > @@ -504,42 +547,38 @@ > static public int DisplayBanner(PrintWriter out, ResultSetMetaData rsmd ) > throws SQLException > { > - return indent_DisplayBanner( out, rsmd, 0 ); > + return indent_DisplayBanner( out, rsmd, 0, null, > + getColumnDisplayWidths(rsmd, null, true) ); > } > > - static private int indent_DisplayBanner(PrintWriter out, ResultSetMetaData rsmd, int indentLevel ) > + static private int indent_DisplayBanner(PrintWriter out, ResultSetMetaData rsmd, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > StringBuffer buf = new StringBuffer(); > > - int numCols = rsmd.getColumnCount(); > + int numCols = displayColumnWidths.length; > int rowLen; > > // do some precalculation so the buffer is allocated only once > // buffer is twice as long as the display length plus one for a newline > rowLen = (numCols - 1); // for the column separators > - for (int i=1; i <= numCols; i++) { > - rowLen += Math.min(maxWidth, > - Math.max((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH, LocalizedResource.getInstance().getColumnDisplaySize(rsmd, i))); > - } > + for (int i=1; i <= numCols; i++) > + rowLen += displayColumnWidths[i-1]; > buf.ensureCapacity(rowLen); > > // get column header info > // truncate it to the column display width > // add a bar between each item. > for (int i=1; i <= numCols; i++) { > + int colnum = displayColumns==null ? i : displayColumns[i-1]; > > if (i>1) > buf.append('|'); > > - String s = rsmd.getColumnLabel(i); > + String s = rsmd.getColumnLabel(colnum); > > - int w = Math.min(maxWidth, > - Math.max(((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH), LocalizedResource.getInstance().getColumnDisplaySize(rsmd, i))); > + int w = displayColumnWidths[i-1]; > > if (s.length() < w) { > > @@ -592,34 +631,39 @@ > @param nestedResults > @param conn > @param indentLevel number of tab stops to indent line > + @param displayColumns A list of column numbers to display > + @param displayColumnWidths If displayColumns is set, the width of > + columns to display, in characters. > > @exception SQLException thrown on JDBC access failure > */ > - static private void DisplayRow(PrintWriter out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector nestedResults, Connection conn, int indentLevel ) > + static private void DisplayRow(PrintWriter out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector nestedResults, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths ) > throws SQLException > { > StringBuffer buf = new StringBuffer(); > buf.ensureCapacity(rowLen); > > - int numCols = rsmd.getColumnCount(); > + int numCols = displayColumnWidths.length; > int i; > > // get column header info > // truncate it to the column display width > // add a bar between each item. > for (i=1; i <= numCols; i++){ > + int colnum = displayColumns==null ? i : displayColumns[i-1]; > if (i>1) > buf.append('|'); > > String s; > - switch (rsmd.getColumnType(i)) { > + switch (rsmd.getColumnType(colnum)) { > default: > - s = LocalizedResource.getInstance().getLocalizedString(rs, rsmd, i ); > + s = LocalizedResource.getInstance().getLocalizedString(rs, rsmd, colnum ); > break; > case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT: > case Types.OTHER: > { > - Object o = rs.getObject(i); > + Object o = rs.getObject(colnum); > if (o == null) { s = "NULL"; } > else if (o instanceof ResultSet && nestedResults != null) > { > @@ -629,7 +673,7 @@ > else > { > try { > - s = rs.getString(i); > + s = rs.getString(colnum); > } catch (SQLException se) { > // oops, they don't support refetching the column > s = o.toString(); > @@ -640,10 +684,7 @@ > } > if (s==null) s = "NULL"; > > - int w = Math.min(maxWidth, > - Math.max((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH, LocalizedResource.getInstance().getColumnDisplaySize(rsmd, i))); > + int w = displayColumnWidths[i-1]; > if (s.length() < w) { > StringBuffer fullS = new StringBuffer(s); > fullS.ensureCapacity(w); > @@ -816,18 +857,20 @@ > static public void DisplayResults(PrintStream out, Statement stmt, Connection conn ) > throws SQLException > { > - indent_DisplayResults( out, stmt, conn, 0); > + indent_DisplayResults( out, stmt, conn, 0, null, null); > } > > static private void indent_DisplayResults > - (PrintStream out, Statement stmt, Connection conn, int indentLevel) > + (PrintStream out, Statement stmt, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException { > > checkNotNull(stmt, "Statement"); > > ResultSet rs = stmt.getResultSet(); > if (rs != null) { > - indent_DisplayResults(out, rs, conn, indentLevel); > + indent_DisplayResults(out, rs, conn, indentLevel, displayColumns, > + displayColumnWidths); > rs.close(); // let the result set go away > } > else { > @@ -852,11 +895,12 @@ > static public void DisplayResults(PrintStream out, ResultSet rs, Connection conn) > throws SQLException > { > - indent_DisplayResults( out, rs, conn, 0); > + indent_DisplayResults( out, rs, conn, 0, null, null); > } > > static private void indent_DisplayResults > - (PrintStream out, ResultSet rs, Connection conn, int indentLevel) > + (PrintStream out, ResultSet rs, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException { > ResultSetMetaData rsmd = rs.getMetaData(); > checkNotNull(rsmd, "ResultSetMetaData"); > @@ -870,7 +914,11 @@ > else > nestedResults = null; > > - int len = indent_DisplayBanner(out,rsmd, indentLevel); > + if(displayColumnWidths == null) > + displayColumnWidths = getColumnDisplayWidths(rsmd, displayColumns, false); > + > + int len = indent_DisplayBanner(out,rsmd, indentLevel, displayColumns, > + displayColumnWidths); > > // When displaying rows, keep going past errors > // unless/until the maximum # of errors is reached. > @@ -881,7 +929,9 @@ > doNext = rs.next(); > if (doNext) { > > - DisplayRow(out, rs, rsmd, len, nestedResults, conn, indentLevel); > + DisplayRow(out, rs, rsmd, len, nestedResults, conn, > + indentLevel, displayColumns, > + displayColumnWidths); > ShowWarnings(out, rs); > numberOfRowsSelected++; > } > @@ -930,17 +980,20 @@ > System.out.println(b); > System.out.println(s+i+" +"); > System.out.println(b); > - indent_DisplayResults(out, (ResultSet) nr.elementAt(i), conn, indentLevel); > + indent_DisplayResults(out, (ResultSet) nr.elementAt(i), conn, > + indentLevel, null, null); > } > } > > static public void DisplayNextRow(PrintStream out, ResultSet rs, Connection conn ) > throws SQLException > { > - indent_DisplayNextRow( out, rs, conn, 0 ); > + indent_DisplayNextRow( out, rs, conn, 0, null, (rs == null) ? null > + : getColumnDisplayWidths(rs.getMetaData(),null,false) ); > } > > - static private void indent_DisplayNextRow(PrintStream out, ResultSet rs, Connection conn, int indentLevel ) > + static private void indent_DisplayNextRow(PrintStream out, ResultSet rs, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > Vector nestedResults; > @@ -959,8 +1012,9 @@ > > // Only print stuff out if there is a row to be had. > if (rs.next()) { > - int rowLen = indent_DisplayBanner(out, rsmd, indentLevel); > - DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel ); > + int rowLen = indent_DisplayBanner(out, rsmd, indentLevel, null, null); > + DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel, > + displayColumns, displayColumnWidths); > } > else { > indentedPrintLine( out, indentLevel, LocalizedResource.getMessage("UT_NoCurreRow")); > @@ -976,10 +1030,12 @@ > static public void DisplayCurrentRow(PrintStream out, ResultSet rs, Connection conn ) > throws SQLException > { > - indent_DisplayCurrentRow( out, rs, conn, 0 ); > + indent_DisplayCurrentRow( out, rs, conn, 0, null, (rs == null) ? null > + : getColumnDisplayWidths(rs.getMetaData(),null,false) ); > } > > - static private void indent_DisplayCurrentRow(PrintStream out, ResultSet rs, Connection conn, int indentLevel ) > + static private void indent_DisplayCurrentRow(PrintStream out, ResultSet rs, Connection conn, > + int indentLevel, int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > Vector nestedResults; > @@ -999,8 +1055,9 @@ > ResultSetMetaData rsmd = rs.getMetaData(); > checkNotNull(rsmd, "ResultSetMetaData"); > > - int rowLen = indent_DisplayBanner(out, rsmd, indentLevel); > - DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel ); > + int rowLen = indent_DisplayBanner(out, rsmd, indentLevel, displayColumns, displayColumnWidths); > + DisplayRow(out, rs, rsmd, rowLen, nestedResults, conn, indentLevel, > + displayColumns, displayColumnWidths); > > ShowWarnings(out, rs); > > @@ -1012,26 +1069,24 @@ > static public int DisplayBanner(PrintStream out, ResultSetMetaData rsmd ) > throws SQLException > { > - return indent_DisplayBanner( out, rsmd, 0 ); > + return indent_DisplayBanner( out, rsmd, 0, null, > + getColumnDisplayWidths(rsmd,null,false) ); > } > > - static private int indent_DisplayBanner(PrintStream out, ResultSetMetaData rsmd, int indentLevel ) > + static private int indent_DisplayBanner(PrintStream out, ResultSetMetaData rsmd, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths ) > throws SQLException { > > StringBuffer buf = new StringBuffer(); > > - int numCols = rsmd.getColumnCount(); > + int numCols = displayColumnWidths.length; > int rowLen; > > // do some precalculation so the buffer is allocated only once > // buffer is twice as long as the display length plus one for a newline > rowLen = (numCols - 1); // for the column separators > for (int i=1; i <= numCols; i++) { > - rowLen += Math.min(maxWidth, > - Math.max((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH, > - rsmd.getColumnDisplaySize(i))); > + rowLen += displayColumnWidths[i-1]; > } > buf.ensureCapacity(rowLen); > > @@ -1039,17 +1094,14 @@ > // truncate it to the column display width > // add a bar between each item. > for (int i=1; i <= numCols; i++) { > + int colnum = displayColumns==null ? i : displayColumns[i-1]; > > if (i>1) > buf.append('|'); > > - String s = rsmd.getColumnLabel(i); > + String s = rsmd.getColumnLabel(colnum); > > - int w = Math.min(maxWidth, > - Math.max(((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH), > - rsmd.getColumnDisplaySize(i))); > + int w = displayColumnWidths[i-1]; > > if (s.length() < w) { > // build a string buffer to hold the whitespace > @@ -1095,31 +1147,33 @@ > return rowLen; > } // DisplayBanner > > - static private void DisplayRow(PrintStream out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector nestedResults, Connection conn, int indentLevel ) > + static private void DisplayRow(PrintStream out, ResultSet rs, ResultSetMetaData rsmd, int rowLen, Vector nestedResults, Connection conn, int indentLevel, > + int[] displayColumns, int[] displayColumnWidths) > throws SQLException > { > StringBuffer buf = new StringBuffer(); > buf.ensureCapacity(rowLen); > > - int numCols = rsmd.getColumnCount(); > + int numCols = displayColumnWidths.length; > int i; > > // get column header info > // truncate it to the column display width > // add a bar between each item. > for (i=1; i <= numCols; i++){ > + int colnum = displayColumns==null ? i : displayColumns[i-1]; > if (i>1) > buf.append('|'); > > String s; > - switch (rsmd.getColumnType(i)) { > + switch (rsmd.getColumnType(colnum)) { > default: > - s = rs.getString(i); > + s = rs.getString(colnum); > break; > case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT: > case Types.OTHER: > { > - Object o = rs.getObject(i); > + Object o = rs.getObject(colnum); > if (o == null) { s = "NULL"; } > else if (o instanceof ResultSet && nestedResults != null) > { > @@ -1129,7 +1183,7 @@ > else > { > try { > - s = rs.getString(i); > + s = rs.getString(colnum); > } catch (SQLException se) { > // oops, they don't support refetching the column > s = o.toString(); > @@ -1141,11 +1195,7 @@ > > if (s==null) s = "NULL"; > > - int w = Math.min(maxWidth, > - Math.max((rsmd.isNullable(i) == > - ResultSetMetaData.columnNoNulls)? > - 0 : MINWIDTH, > - rsmd.getColumnDisplaySize(i))); > + int w = displayColumnWidths[i-1]; > if (s.length() < w) { > StringBuffer fullS = new StringBuffer(s); > fullS.ensureCapacity(w); > >