db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Upgrade work when a new column is added to an existing system table...
Date Fri, 19 Mar 2010 21:53:17 GMT

I was looking for some guidence regarding upgrade work involved when a
new column needs to be added to an existing system table and that
column needs to be initialized to different value depending on the row
in the table.

As part of DERBY-1482, I need to add a new column to SYSTRIGGERS. That
column is going to be of the type
org.apache.derby.catalog.ReferencedColumns. The purpose of this column
is to keep track of all the columns (from the trigger table) which are
referenced in the trigger action through the REFERENCE clause of
create trigger tr1 after update of id on t1 referencing old as oldt
	for each row insert into t2(id2) values (oldt.j);
For the trigger above, we will note in SYSTRIGGERS that column j from
the trigger table t1 is getting referenced in the trigger action. We
will use this information to decide which columns need to be read in
when the user executes an UPDATE t1(updating column id) SQL which will
fire the trigger tr1. This will be especially useful if the table t1
has LOB columns.

My question is did we need to add a new column to an existing system
table in the past? If yes, I would love to reuse that code if possible
rather than reinventing the wheel. I do see following method in
DataDictionaryImpl but do not see it getting called from anywhere
	  * Upgrade an existing catalog by adding columns.
	  * @param	rowFactory				Associated with this catalog.
	  * @param	newColumnIDs			Array of 1-based column ids.
	  * @param	tc						Transaction controller
	  * @exception StandardException Standard Derby error policy
	public void	upgrade_addColumns( CatalogRowFactory rowFactory, int[]
newColumnIDs,TransactionController tc)
					throws StandardException

If we do not have an existing infrastructure for adding a new column,
I will explore the work needed. If anyone has any pointers/thoughts,
would greatly appreciate that.

Another needed step for upgrade for my specific situation is to
initialize the new column correctly so the existing triggers don't


View raw message