Hi,
I have attached a review package for this feature to the JIRA
entry. Following is a brief description of the changes involved.
Changed sqlgrammar.jj to add parser support for ALTER TABLE <tablename> ALTER <columnName>
RESTART WITH
integer-constant
Also, added another element to the array which keeps track of
autoincrement information in the parser. This 4th element will record
if the autoincrement column is getting added or it is getting altered
for INCREMENT BY value change or it is getting altered for RESTART WITH value change. This information is required later
in the compile and execute phase.
In the compile phase, this information is used to see if a user
is trying to sneak in a value of 0 for INCREMENT BY. A value of 0 for
INCREMENT BY should be caught at the time of autoincrement column add
or at the time of autoincrement column alter to change the INCREMENT BY value. At the time
of autoincrement column alter
to change the RESTART
WITH value, the
INCREMENT BY value should not be checked. This is done in
ColumnDefinitionNode.java. TableElementList generates ColumnInfo which
needs to keep track of autoincrement column change status from
ColumnDefinitionNode. This infromation in ColumnInfo will be used at
execute time.
In the execute phase, we need to know which columns of
SYSCOLUMNS table need to be changed for an ALTER TABLE command on the autoincrement column. In
the past, we only allowed to change the INCREMENT BY criteria of an
autoincrement column but with
this feature, it is possible for a user to change the start with value of autoincrement
column and leave the INCREMENT BY unchanged. This autoincrement column
change information is passed to the execute phase via ColumnInfo.
In order to provide this distinction between ALTER BY..INCREMENT BY.. and ALTER BY..RESTART WITH..,
I have had to add a variable in ColumnDefinitionNode.java,
ColumnInfo.java and ColumnDescriptor.java. The value of the variable in
each of these classes depend on what parser recorded for the
autoincrement column status ie adding an autoincrement column/changing
INCREMENT BY of the autoincrement column/changing RESTART WITH
of the autoincrement column.
Hope this information along with
the comments in the code will help in the code review. Please let me
know if you have any comments.
The svn stat changes for this feature is as follows
M java\engine\org\apache\derby\impl\sql\compile\QueryTreeNode.java
M
java\engine\org\apache\derby\impl\sql\compile\ColumnDefinitionNode.java
M
java\engine\org\apache\derby\impl\sql\compile\CreateSchemaNode.java
M java\engine\org\apache\derby\impl\sql\compile\sqlgrammar.jj
M
java\engine\org\apache\derby\impl\sql\compile\TableElementList.java
M
java\engine\org\apache\derby\impl\sql\compile\CreateViewNode.java
M
java\engine\org\apache\derby\impl\sql\compile\ModifyColumnNode.java
M java\engine\org\apache\derby\impl\sql\execute\ColumnInfo.java
M
java\engine\org\apache\derby\impl\sql\execute\CreateTableConstantAction.java
M
java\engine\org\apache\derby\impl\sql\execute\AlterTableConstantAction.java
M
java\engine\org\apache\derby\impl\sql\catalog\SYSCOLUMNSRowFactory.java
M
java\engine\org\apache\derby\iapi\sql\dictionary\ColumnDescriptor.java
M
java\testing\org\apache\derbyTesting\functionTests\tests\lang\autoincrement.sql
M
java\testing\org\apache\derbyTesting\functionTests\master\autoincrement.out
I have modified autoincrement.sql to add tests for RESTART WITH. The derbyall suite ran fine on my Windows XP
machine
with
Sun's jdk142.
thanks,
Mamta