Issue Details (XML | Word | Printable)

Key: DERBY-4013
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Dag H. Wanvik
Reporter: Dag H. Wanvik
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Allow standard SQL syntax: ALTER TABLE ALTER [COLUMN] <col> SET DEFAULT <default>

Created: 09/Jan/09 06:31 PM   Updated: 04/May/09 06:22 PM
Component/s: SQL
Affects Version/s: 10.0.2.0, 10.0.2.1, 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1, 10.3.3.0, 10.4.1.3, 10.4.2.0
Fix Version/s: 10.5.1.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-4013.diff 2009-01-09 08:11 PM Dag H. Wanvik 5 kB
File Licensed for inclusion in ASF works derby-4013.stat 2009-01-09 08:11 PM Dag H. Wanvik 0.2 kB
File Licensed for inclusion in ASF works derby-4013b.diff 2009-01-12 04:23 PM Dag H. Wanvik 6 kB
File Licensed for inclusion in ASF works derby-4013b.stat 2009-01-12 04:23 PM Dag H. Wanvik 0.2 kB
File Licensed for inclusion in ASF works derby-4013c.diff 2009-01-22 10:25 PM Dag H. Wanvik 7 kB
File Licensed for inclusion in ASF works derby-4013c.stat 2009-01-22 10:25 PM Dag H. Wanvik 0.2 kB
File Licensed for inclusion in ASF works derby-4013d.diff 2009-01-26 05:39 PM Dag H. Wanvik 8 kB
File Licensed for inclusion in ASF works derby-4013d.stat 2009-01-26 05:39 PM Dag H. Wanvik 0.2 kB
Issue Links:
Dependants
 

Resolution Date: 26/Jan/09 06:29 PM


 Description  « Hide
Presently, the Derby syntax is ALTER TABLE ALTER [COLUMN] <col> [WITH] DEFAULT <default>.
The "SET" keyword is not accepted, only an optional "WITH". It would be good to accept the standard syntax here as well.
Cf. SQL 2003, section 11.12 <alter column definition> and section 11.13 <set column default clause>.

Also, DROP DEFAULT is standard syntax not supported, so we should add that, too.

Repro on trunk:

$ java org.apache.derby.tools.ij
ij version 10.5
ij> connect 'jdbc:derby:wombat;create=true';
ij> create table t(i int default 0, j int);
0 rows inserted/updated/deleted
ij> alter table t alter column j with default 1;
0 rows inserted/updated/deleted
ij> insert into t values (default, default);
1 row inserted/updated/deleted
ij> select * from t;
I |J
-----------------------
0 |1

1 row selected
ij> alter table t alter column j default 2;
0 rows inserted/updated/deleted
ij> insert into t values (default, default);
1 row inserted/updated/deleted
ij> select * from t;
I |J
-----------------------
0 |1
0 |2

2 rows selected
ij> alter table t alter column j set default 3;
ERROR 42X01: Syntax error: Encountered "set" at line 1, column 30.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #736390 Wed Jan 21 19:47:06 UTC 2009 chaase3 DERBY-4016: Document syntax change for ALTER TABLE in Reference Manual

This patch updates the ALTER TABLE topic to reflect the changes made for DERBY-4013.

Patch: DERBY-4016.diff
Files Changed
MODIFY /db/derby/docs/trunk/src/ref/rrefsqlj81859.dita

Repository Revision Date User Message
ASF #737774 Mon Jan 26 18:27:37 UTC 2009 dag DERBY-4013 Allow standard SQL syntax: ALTER TABLE ALTER [COLUMN] <col> SET DEFAULT <default>

Patch DERBY-4014d, which adds the standard SQL syntax SET DEFAULT and DROP DEFAULT, in
addition to the non-standard syntax we already have.

Note that we are not 100% in compliance, since DROP DEFAULT does not
fail as it should when there is no existing default - it is a noop right now.

A new test, AlterColumnTest, is also added.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterColumnTest.java