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
RECREATE TABLE T (ID INT NOT NULL, DESCR VARCHAR(32) NOT NULL);
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (1, 'No F1 field');
COMMIT;
ALTER TABLE T ADD F1 VARCHAR(16) DEFAULT 'XYZ' NOT NULL;
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (2, 'F1 field, default XYZ');
COMMIT;
SELECT * FROM T;
COMMIT;
ALTER TABLE T ALTER COLUMN F1 SET DEFAULT 'ABC';
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (3, 'F1 field, default ABC');
COMMIT;
SELECT * FROM T;
COMMIT;
After the first select all is as expected:
ID DESCR F1
============ ================================ ================
1 No F1 field XYZ
2 F1 field, default XYZ XYZ
after the second select
expected
ID DESCR F1
============ ================================ ================
1 No F1 field ABC
2 F1 field, default XYZ XYZ
3 F1 field, default ABC ABC
actual
ID DESCR F1
============ ================================ ================
1 No F1 field XYZ
2 F1 field, default XYZ XYZ
3 F1 field, default ABC ABC
Note value of the field F1 at the first record: it is expected that is should be the same as latest DEFAULT value.
Also note that 2nd and 3rd INSERTs assigns correct value to the omitted field - same as latest DEFAULT value.
The text was updated successfully, but these errors were encountered:
When record in old format is read it should be converted to the most current format.
Engine look up default values for the new NOT NULL fields (not present in original format).
Default values is stored at RDB$RELATION_FIELDS (in source and BLR form).
Since ODS12 default value for the NOT NULL fields is stored at RDB$FORMAT.RDB$DESCRIPTOR blob also.
AFAIU, it was done to have ability to convert record into any format, not necessary most current.
The problem is that change of default value it is not recorded at RDB$FORMAT: new format is not created
and current format is not updated. New default stored in RDB$RELATION_FIELDS only (and it allows to
assign values to the fields omitted in INSERT statement).
Submitted by: @hvlad
RECREATE TABLE T (ID INT NOT NULL, DESCR VARCHAR(32) NOT NULL);
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (1, 'No F1 field');
COMMIT;
ALTER TABLE T ADD F1 VARCHAR(16) DEFAULT 'XYZ' NOT NULL;
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (2, 'F1 field, default XYZ');
COMMIT;
SELECT * FROM T;
COMMIT;
ALTER TABLE T ALTER COLUMN F1 SET DEFAULT 'ABC';
COMMIT;
INSERT INTO T (ID, DESCR) VALUES (3, 'F1 field, default ABC');
COMMIT;
SELECT * FROM T;
COMMIT;
After the first select all is as expected:
============ ================================ ================
1 No F1 field XYZ
2 F1 field, default XYZ XYZ
after the second select
expected
============ ================================ ================
1 No F1 field ABC
2 F1 field, default XYZ XYZ
3 F1 field, default ABC ABC
actual
============ ================================ ================
1 No F1 field XYZ
2 F1 field, default XYZ XYZ
3 F1 field, default ABC ABC
Note value of the field F1 at the first record: it is expected that is should be the same as latest DEFAULT value.
Also note that 2nd and 3rd INSERTs assigns correct value to the omitted field - same as latest DEFAULT value.
The text was updated successfully, but these errors were encountered: