db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r440550 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/altertable.out tests/lang/altertable.sql
Date Wed, 06 Sep 2006 01:00:35 GMT
Author: bpendleton
Date: Tue Sep  5 18:00:35 2006
New Revision: 440550

URL: http://svn.apache.org/viewvc?view=rev&rev=440550
Log:
DERBY-1491: Provide ALTER TABLE functionality to change a column's default value

This change contains new test cases in the altertable.sql test which explore
the behavior of the ALTER TABLE ALTER COLUMN statement to alter a column's
defaults. Note that this patch only includes new tests; the current product
already supports the functionality to change a column's default value. The
code to support this was a side effect of the DERBY-119 changes, which wired up
the already-existing parser routines to the new ALTER TABLE t ALTER COLUMN c
statement.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out?view=diff&rev=440550&r1=440549&r2=440550
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/altertable.out
Tue Sep  5 18:00:35 2006
@@ -927,4 +927,35 @@
 0 rows inserted/updated/deleted
 ij> alter table atmcn_5 alter column b null;
 ERROR 42Z20: Column 'B' cannot be made nullable. It is part of a primary key or unique constraint,
which cannot have any nullable columns.
+ij> -- tests for ALTER TABLE ALTER COLUMN DEFAULT
+create table atmod_1 (a integer, b varchar(10));
+0 rows inserted/updated/deleted
+ij> insert into atmod_1 values (1, 'one');
+1 row inserted/updated/deleted
+ij> alter table atmod_1 alter column a default -1;
+0 rows inserted/updated/deleted
+ij> insert into atmod_1 values (default, 'minus one');
+1 row inserted/updated/deleted
+ij> insert into atmod_1 (b) values ('b');
+1 row inserted/updated/deleted
+ij> select * from atmod_1;
+A          |B         
+----------------------
+1          |one       
+-1         |minus one 
+-1         |b         
+ij> alter table atmod_1 alter a default 42;
+0 rows inserted/updated/deleted
+ij> insert into atmod_1 values(3, 'three');
+1 row inserted/updated/deleted
+ij> insert into atmod_1 values (default, 'forty two');
+1 row inserted/updated/deleted
+ij> select * from atmod_1;
+A          |B         
+----------------------
+1          |one       
+-1         |minus one 
+-1         |b         
+3          |three     
+42         |forty two 
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql?view=diff&rev=440550&r1=440549&r2=440550
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/altertable.sql
Tue Sep  5 18:00:35 2006
@@ -581,3 +581,16 @@
 -- show that a column which has a UNIQUE constraint cannot be modified NULL:
 create table atmcn_5 (a integer not null, b integer not null unique);
 alter table atmcn_5 alter column b null;
+
+-- tests for ALTER TABLE ALTER COLUMN DEFAULT
+create table atmod_1 (a integer, b varchar(10));
+insert into atmod_1 values (1, 'one');
+alter table atmod_1 alter column a default -1;
+insert into atmod_1 values (default, 'minus one');
+insert into atmod_1 (b) values ('b');
+select * from atmod_1;
+alter table atmod_1 alter a default 42;
+insert into atmod_1 values(3, 'three');
+insert into atmod_1 values (default, 'forty two');
+select * from atmod_1;
+



Mime
View raw message