db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r618054 - in /db/derby/code/branches/10.3/java: engine/org/apache/derby/impl/sql/execute/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Sun, 03 Feb 2008 18:57:17 GMT
Author: bpendleton
Date: Sun Feb  3 10:57:15 2008
New Revision: 618054

URL: http://svn.apache.org/viewvc?rev=618054&view=rev
Log:
DERBY-3355: Alter Column Not Null ignores double quotes around column name

Merged revision 617818 from the trunk.


Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=618054&r1=618053&r2=618054&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Sun Feb  3 10:57:15 2008
@@ -78,6 +78,7 @@
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.RowLocation;
 import org.apache.derby.iapi.types.StringDataValue;
+import org.apache.derby.iapi.util.IdUtil;
 import org.apache.derby.impl.sql.catalog.DDColumnDependableFinder;
 import org.apache.derby.impl.sql.compile.ColumnDefinitionNode;
 
@@ -2428,7 +2429,12 @@
 					// already found a nullable column so add "AND" 
 					if (foundNullable)
 						constraintText.append(" AND ");
-					constraintText.append(columnNames[colCtr] + " IS NOT NULL ");
+					// Delimiting the column name is important in case the
+					// column name uses lower case characters, spaces, or
+					// other unusual characters.
+					constraintText.append(
+						IdUtil.normalToDelimited(columnNames[colCtr]) +
+						" IS NOT NULL ");
 				}
 				foundNullable = true;
 				nullCols[colCtr] = true;

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out?rev=618054&r1=618053&r2=618054&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
Sun Feb  3 10:57:15 2008
@@ -1892,4 +1892,55 @@
 hi        
 my val    
 another   
+ij> -- DERBY-3355: Exercise ALTER TABLE ... NOT NULL with table and column
+-- names which are in mixed case. This is important because
+-- AlterTableConstantAction.validateNotNullConstraint generates and
+-- executes some SQL on-the-fly, and it's important that it properly
+-- delimits the table and column names in that SQL. We also include a few
+-- other "unusual" table and column names.
+create table d3355 ( c1 varchar(10), "c2" varchar(10), c3 varchar(10));
+0 rows inserted/updated/deleted
+ij> create table "d3355_a" ( c1 varchar(10), "c2" varchar(10), c3 varchar(10));
+0 rows inserted/updated/deleted
+ij> create table d3355_qt_col ("""c""4" int, """""C5" int, "c 6" int);
+0 rows inserted/updated/deleted
+ij> create table "d3355_qt_""tab" ( c4 int, c5 int, c6 int);
+0 rows inserted/updated/deleted
+ij> insert into d3355 values ('a', 'b', 'c');
+1 row inserted/updated/deleted
+ij> insert into "d3355_a" values ('d', 'e', 'f');
+1 row inserted/updated/deleted
+ij> insert into d3355_qt_col values (4, 5, 6);
+1 row inserted/updated/deleted
+ij> insert into "d3355_qt_""tab" values (4, 5, 6);
+1 row inserted/updated/deleted
+ij> -- All of these ALTER TABLE statements should succeed.
+alter table d3355 alter column c1 not null;
+0 rows inserted/updated/deleted
+ij> alter table d3355 alter column "c2" not null;
+0 rows inserted/updated/deleted
+ij> alter table d3355 alter column "C3" not null;
+0 rows inserted/updated/deleted
+ij> alter table "d3355_a" alter column c1 not null;
+0 rows inserted/updated/deleted
+ij> alter table "d3355_a" alter column "c2" not null;
+0 rows inserted/updated/deleted
+ij> alter table "d3355_a" alter column "C3" not null;
+0 rows inserted/updated/deleted
+ij> alter table d3355_qt_col alter column """""C5" not null;
+0 rows inserted/updated/deleted
+ij> alter table d3355_qt_col alter column "c 6" not null;
+0 rows inserted/updated/deleted
+ij> alter table "d3355_qt_""tab" alter column c5 not null;
+0 rows inserted/updated/deleted
+ij> -- These ALTER TABLE statements should fail, with no-such-column and/or
+-- no-such-table errors:
+alter table d3355 alter column "c1" not null;
+ERROR 42X14: 'c1' is not a column in table or VTI 'D3355'.
+ij> alter table d3355 alter column c2 not null;
+ERROR 42X14: 'C2' is not a column in table or VTI 'D3355'.
+ij> alter table d3355_a alter column c1 not null;
+ERROR 42Y55: 'ALTER TABLE' cannot be performed on 'D3355_A' because it does not exist.
+ij> alter table "d3355_a" alter column "c1" not null;
+ERROR 42X14: 'c1' is not a column in table or VTI 'd3355_a'.
 ij> 

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql?rev=618054&r1=618053&r2=618054&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
Sun Feb  3 10:57:15 2008
@@ -1103,3 +1103,36 @@
 describe t2371;
 insert into t2371 (a) values (default);
 select * from t2371;
+
+-- DERBY-3355: Exercise ALTER TABLE ... NOT NULL with table and column
+-- names which are in mixed case. This is important because
+-- AlterTableConstantAction.validateNotNullConstraint generates and
+-- executes some SQL on-the-fly, and it's important that it properly
+-- delimits the table and column names in that SQL. We also include a few
+-- other "unusual" table and column names.
+
+create table d3355 ( c1 varchar(10), "c2" varchar(10), c3 varchar(10));
+create table "d3355_a" ( c1 varchar(10), "c2" varchar(10), c3 varchar(10));
+create table d3355_qt_col ("""c""4" int, """""C5" int, "c 6" int);
+create table "d3355_qt_""tab" ( c4 int, c5 int, c6 int); 
+insert into d3355 values ('a', 'b', 'c');
+insert into "d3355_a" values ('d', 'e', 'f');
+insert into d3355_qt_col values (4, 5, 6);
+insert into "d3355_qt_""tab" values (4, 5, 6);
+-- All of these ALTER TABLE statements should succeed.
+alter table d3355 alter column c1 not null;
+alter table d3355 alter column "c2" not null;
+alter table d3355 alter column "C3" not null;
+alter table "d3355_a" alter column c1 not null;
+alter table "d3355_a" alter column "c2" not null;
+alter table "d3355_a" alter column "C3" not null;
+alter table d3355_qt_col alter column """""C5" not null;
+alter table d3355_qt_col alter column "c 6" not null;
+alter table "d3355_qt_""tab" alter column c5 not null;
+-- These ALTER TABLE statements should fail, with no-such-column and/or
+-- no-such-table errors:
+alter table d3355 alter column "c1" not null;
+alter table d3355 alter column c2 not null;
+alter table d3355_a alter column c1 not null;
+alter table "d3355_a" alter column "c1" not null;
+



Mime
View raw message