db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: Question about softupgrade mode ..
Date Fri, 29 Apr 2005 16:34:49 GMT
TomohitoNakayama wrote:

> Hello.
> 

>> I think adding extra information to the DefaultInfo is the correct way
>> and is the way the system was designed. The column's definition is
>> through the interface DefaultInfo, thus allowing different object
>> implementations to be stored in the column, representing additional
>> information as needed.
> 
> 
> Thinking freely in these days,
> I came to thought it would be worth to rollback to first phase of
> desicion aboout solution1-3.

I think you are close to a good solution for implementing GENERATED BY
DEFAULT.

You other e-mails say that currently for GENERATED ALWAYS that no
information is stored in the COLUMNDEFAULT column of SYSCOLUMNS, I
assume that means a NULL.

Then you propose that you always store information in the COLUMNDEFAULT
 column for GENERATED ALWAYS and GENERATED BY DEFAULT, but this has some
issues related to upgrade.

I think your proposal should be modified a little and take advantage of
the current implementation of DefaultInfoImpl.

1) Continue to store NULL in the COLUMNDEFAULT column of SYSCOLUMNS for
GENERATED ALWAYS, means there is no default option. This makes sense,
this column is not applicable for GENERATED ALWAYS

2) For GENERATED BY DEFAULT store a non-NULL value in the COLUMNDEFAULT
column of SYSCOLUMNS, using the an instance of the DefaultInfoImpl
class. This class has a spare field in its stored format that is
currently always zero, this is very useful to add meaning or
functionality to its stored form. So I would propose

    - existing defaults continue as they are, the extra field becomes
     a status field and a value of zero means a regular default.

    - GENERATED BY DEFAULT store a one (1) in that field and null
references for the defaultText and defaultValue. So a 1 means that the
default is a generated by default column.

3) Add methods and fields as needed to DefaultInfo and DefaultInfoImpl

	e.g. in DefaultInfo

       static final int DEFAULT_CLAUSE = 0; // regular DEFAULT
       static final int GENERATED_DEFAULT = 1;

       /**
           Return default type of column, one of DEFAULT_CLAUSE or
GENERATED_DEFAULT
       */
       int getDefaultType()

4) Only upgrade code (apart from testing) needed is the soft upgrade
check to disallow GENERATED BY DEFAULT when running in soft upgrade mode.


Dan.



Mime
View raw message