Adding NOT NULL column with DEFAULT value may cause default values to update 
when selecting or have the wrong charset
---------------------------------------------------------------------------------------------------------------------

                 Key: CORE-6358
                 URL: http://tracker.firebirdsql.org/browse/CORE-6358
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 3.0.6, 4.0 Beta 2
            Reporter: Adriano dos Santos Fernandes


Since v2 when adding NOT NULL columns with default value we store the default 
value in metadata and read that value when reading pre-existent data. Before 
that, default values were evaluated at query time producing different values.

For example we have now:

recreate table t (n integer);
insert into t values (1);
insert into t values (2);
commit;
alter table t add t1 timestamp default current_timestamp not null;

select * from t;

           N                        T1
============ =========================
           1 2020-07-07 12:56:04.7740 
           2 2020-07-07 12:56:04.7740 

-- wait and see the same values

select * from t;

           N                        T1
============ =========================
           1 2020-07-07 12:56:04.7740 
           2 2020-07-07 12:56:04.7740 

But this is not done correctly when the default expression is not from the same 
type of the field. For example:


recreate table t (n integer);
insert into t values (1);
insert into t values (2);
commit;
alter table t add t1 timestamp default 'now' not null;

select * from t;

           N                        T1
============ =========================
           1 2020-07-07 12:56:04.7740 
           2 2020-07-07 12:56:04.7740 

-- wait and the values are changed

select * from t;

           N                        T1
============ =========================
           1 2020-07-07 12:58:08.1254 
           2 2020-07-07 12:58:08.1254 

Another problem is with charset. With a connection using UTF8 charset:

recreate table t2 (n integer);
insert into t2 values (1);
insert into t2 values (2);
commit;
alter table t2 add c1 varchar(10) character set win1252 default '123áé456' not 
null;
insert into t2 (n) values (3);
select * from t2;

           N C1
============ ==========
           1 123áé456
           2 123áé456
           3 123áé456


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to