Issue Details (XML | Word | Printable)

Key: CORE-6358
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Adriano dos Santos Fernandes
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

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

Created: 07/Jul/20 05:15 PM   Updated: 10/Jul/20 03:31 PM
Component/s: Engine
Affects Version/s: 4.0 Beta 2, 3.0.6
Fix Version/s: 3.0.7, 4.0 RC 1

QA Status: Done successfully


 Description  « Hide
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


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.