db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r536227 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/master/ij7.out testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql tools/org/apache/derby/impl/tools/ij/ij.jj
Date Tue, 08 May 2007 15:42:47 GMT
Author: bpendleton
Date: Tue May  8 08:42:46 2007
New Revision: 536227

URL: http://svn.apache.org/viewvc?view=rev&rev=536227
Log:
DERBY-2019: IJ describe command does not handle quotes very well

IJ's describe command already accepted a string for the table name,
but there were several problems with the handling of the table name
in single quotes:
1) The table name was unnecessarily forced to upper case.
2) The command only worked properly if you gave both schema and table name.
3) It had a rather bizarre behavior with an empty string

This patch removes the force-to-upper, cleans up the schema name handling,
addresses the empty string case by treating it as an error,
adds a simple '*' feature as a wildcard, and adds some new tests.

With the patch,
   describe 'CamelCaseTable';
can be used to describe a table with a mixed-case name. 

A separate patch will update the documentation to describe the behavior.


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj

Modified: 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?view=diff&rev=536227&r1=536226&r2=536227
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
Tue May  8 08:42:46 2007
@@ -152,4 +152,64 @@
 ----------------------------------------------------------------------------
 T1                  |TEST                |true  |3   |A   |NULL    |NULL    
 1 row selected
+ij> -- DERBY-2019: ensure that tables with mixed-case names can be described:
+SET SCHEMA APP;
+0 rows inserted/updated/deleted
+ij> create table "CamelCaseTable" (c1 int, c2 varchar(20));
+0 rows inserted/updated/deleted
+ij> -- should fail, as unquoted stirng is treated as case-insensitive upper case:
+describe CamelCaseTable;
+IJ ERROR: No table exists with the name CAMELCASETABLE
+ij> describe APP.CamelCaseTable;
+IJ ERROR: No table exists with the name CAMELCASETABLE
+ij> -- should find the table, as quoted string case is preserved.
+describe 'CamelCaseTable';
+COLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
+------------------------------------------------------------------------------
+C1                  |INTEGER  |0   |10  |10    |NULL      |NULL      |YES     
+C2                  |VARCHAR  |NULL|NULL|20    |NULL      |40        |YES     
+2 rows selected
+ij> -- should fail, as case is wrong:
+describe 'CAMELCaseTable';
+IJ ERROR: No table exists with the name CAMELCaseTable
+ij> -- should work, note that schema name must be upper case:
+describe 'APP.CamelCaseTable';
+COLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
+------------------------------------------------------------------------------
+C1                  |INTEGER  |0   |10  |10    |NULL      |NULL      |YES     
+C2                  |VARCHAR  |NULL|NULL|20    |NULL      |40        |YES     
+2 rows selected
+ij> set SCHEMA USER1;
+0 rows inserted/updated/deleted
+ij> -- should work, even after changing default schema, so long as schema is right
+describe 'APP.CamelCaseTable';
+COLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
+------------------------------------------------------------------------------
+C1                  |INTEGER  |0   |10  |10    |NULL      |NULL      |YES     
+C2                  |VARCHAR  |NULL|NULL|20    |NULL      |40        |YES     
+2 rows selected
+ij> -- should fail, since table is in the other schema
+describe 'CamelCaseTable';
+IJ ERROR: No table exists with the name CamelCaseTable
+ij> -- Can use * as a wildcard for table name:
+describe '*';
+TABLE_SCHEM         |TABLE_NAME          |COLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
+------------------------------------------------------------------------------------------------------------------------
+USER1               |T2                  |I                   |INTEGER  |0   |10  |10   
|NULL      |NULL      |YES     
+USER1               |V1                  |I                   |INTEGER  |0   |10  |10   
|NULL      |NULL      |NO      
+USER1               |V1                  |D                   |DECIMAL  |2   |10  |5    
|NULL      |NULL      |YES     
+USER1               |V1                  |TEST                |VARCHAR  |NULL|NULL|20   
|NULL      |40        |YES     
+4 rows selected
+ij> describe 'APP.*';
+TABLE_SCHEM         |TABLE_NAME          |COLUMN_NAME         |TYPE_NAME|DEC&|NUM&|COLUM&|COLUMN_DEF|CHAR_OCTE&|IS_NULL&
+------------------------------------------------------------------------------------------------------------------------
+APP                 |CamelCaseTable      |C1                  |INTEGER  |0   |10  |10   
|NULL      |NULL      |YES     
+APP                 |CamelCaseTable      |C2                  |VARCHAR  |NULL|NULL|20   
|NULL      |40        |YES     
+APP                 |T1                  |I                   |INTEGER  |0   |10  |10   
|AUTOINCRE&|NULL      |NO      
+APP                 |T1                  |D                   |DECIMAL  |2   |10  |5    
|NULL      |NULL      |YES     
+APP                 |T1                  |TEST                |VARCHAR  |NULL|NULL|20   
|NULL      |40        |YES     
+5 rows selected
+ij> -- Observe behavior with empty string:
+describe '';
+IJ ERROR: No table exists with the name (missing)
 ij> 

Modified: 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?view=diff&rev=536227&r1=536226&r2=536227
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
Tue May  8 08:42:46 2007
@@ -54,3 +54,26 @@
 SHOW INDEXES IN APP;
 SHOW INDEXES FROM APP.t1;
 
+-- DERBY-2019: ensure that tables with mixed-case names can be described:
+SET SCHEMA APP;
+create table "CamelCaseTable" (c1 int, c2 varchar(20));
+-- should fail, as unquoted stirng is treated as case-insensitive upper case:
+describe CamelCaseTable;
+describe APP.CamelCaseTable;
+-- should find the table, as quoted string case is preserved.
+describe 'CamelCaseTable';
+-- should fail, as case is wrong:
+describe 'CAMELCaseTable';
+-- should work, note that schema name must be upper case:
+describe 'APP.CamelCaseTable';
+set SCHEMA USER1;
+-- should work, even after changing default schema, so long as schema is right
+describe 'APP.CamelCaseTable';
+-- should fail, since table is in the other schema
+describe 'CamelCaseTable';
+-- Can use * as a wildcard for table name:
+describe '*';
+describe 'APP.*';
+-- Observe behavior with empty string:
+describe '';
+

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?view=diff&rev=536227&r1=536226&r2=536227
==============================================================================
--- 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 Tue May  8 08:42:46
2007
@@ -868,7 +868,7 @@
 			// 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) {
+			if(schema!=null && table != null) {
 				displayColumns = intArraySubset(displayColumns, 2, 
 												displayColumns.length);
 				columnWidths   = intArraySubset(columnWidths, 2, 
@@ -1607,13 +1607,18 @@
 	)
 	{
 		if(s!=null) {
-			String image = stringValue(s.image.toUpperCase());
+			i2 = stringValue(s.image);
 
-			int dotPosition = image.indexOf('.');
+			if (i2.length() == 0)
+				throw ijException.noSuchTable("(missing)");
+
+			int dotPosition = i2.indexOf('.');
 			if(dotPosition!=-1) {
-				i = image.substring(0,dotPosition);
-				i2 = image.substring(dotPosition+1);
+				i = i2.substring(0,dotPosition);
+				i2 = i2.substring(dotPosition+1);
 			}
+			if ("*".equals(i2))
+				i2 = null;
 		}
 
 		if(i==null)



Mime
View raw message