You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Duncan Groenewald <du...@xtra.co.nz> on 2006/08/10 13:51:31 UTC

How to modify the SQLParser to handle NULL in column definitions ?

Can anyone provide a pointer as to what needs to be modified in order 
for derby to handle a column definition that includes a NULL, as shown 
below:

create testtable(
    code int   NOT NULL,
    description varchar(32) NULL
)

I have no real idea how the parser works but figured it can't be that 
hard to be able to handle this without complaining about a syntax 
error.  It looks to me like this gets done in the SQLParser.java file 
but I have not been able to figure out how it works.  There is also a 
sqlgrammar.jj file which I assume is not actually used for anything 
although it looks like it might be some kind of definition file for 
SQLParser.

Thanks in advance.
Duncan


Re: How to modify the SQLParser to handle NULL in column definitions ?

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
Hi,

This is a developer question which should be posted on derby-dev.
Anyway, although I know there are databases which allow you to specify
nullability by the keyword NULL (which is redundant since columns are
nullable unless given a NOT NULL constraint), this is *not* a part of
the SQL standard. The create statement below should be written

create testtable(
    code int   NOT NULL,
    description varchar(32)
 )

which would be more portable since it then would be standard compliant.

Duncan Groenewald wrote:
> Can anyone provide a pointer as to what needs to be modified in order
> for derby to handle a column definition that includes a NULL, as shown
> below:
> 
> create testtable(
>    code int   NOT NULL,
>    description varchar(32) NULL
> )
> 
> I have no real idea how the parser works but figured it can't be that
> hard to be able to handle this without complaining about a syntax
> error.  It looks to me like this gets done in the SQLParser.java file
> but I have not been able to figure out how it works.  There is also a
> sqlgrammar.jj file which I assume is not actually used for anything
> although it looks like it might be some kind of definition file for
> SQLParser.
> 
> Thanks in advance.
> Duncan
> 


-- 
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway