On Tue, 31 Mar 2015 01:20:39 -0300, Adriano dos Santos Fernandes
<[email protected]> wrote:
> Hi!
> 
> Currently there is inconsistencies in fields [NOT] NULL flag on its
> (field) flag does not matches the domain.
> 
> Use CONNECT or CREATE DATABASE to specify a database
> SQL> create database 'z.fdb';
> SQL> create domain d1n integer not null;
> SQL> create table t1 (n1 d1n);
> SQL>
> SQL> insert into t1 values (null);  -- ok
> Statement failed, SQLSTATE = 23000
> validation error for column "T1"."N1", value "*** null ***"
> SQL>
> SQL> alter table t1 alter n1 null;
> SQL>
> SQL> show table t1;
> N1                              (D1N) INTEGER Not Null
> SQL>
> SQL> insert into t1 values (null);
> 
> So after the field flag is changed, ISQL thinks a field reported as NULL
> will use the domain's flag.
> 
> But the engine treats the field flag as an override.
> 
> Whatever you choose who is correct, we have problems.
> 
> If setting a field to NULLable means setting its
> RDB$RELATION_FIELDS.RDB$NULL_FLAG to NULL and let the domain
> (RDB$FIELDS.RDB$NULL_FLAG) flag be used, the engine must be fixed.
> 
> If setting a field to NULLable means setting its
> RDB$RELATION_FIELDS.RDB$NULL_FLAG to say it's NULLable, then ISQL must
> be fixed and more. Then how one would revert a field to use the domain's
> flag? Would need a new command? ALTER TABLE T1 ALTER N1 DOMAIN_NULL_FLAG
> (argh!!)
> 
> Decision of this has more implications, like when changing the flag of a
> domain used in a primary key.

I'd say a field is only allowed to further restrict its domain definition,
not relax its constraints. So if the domain is NOT NULL, then the field can
never allow NULL, but if the domain allows NULL, then the field can
restrict to NOT NULL.

Mark

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to