You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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;
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;
Submitted by: @asfernandes
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;
============ =========================
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;
============ =========================
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;
============ =========================
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;
============ =========================
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;
============ ==========
1 123áé456
2 123áé456
3 123áé456
Commits: 55627cf 2f30a82 7b5b1c0 2e146d8
The text was updated successfully, but these errors were encountered: