To me the behavior described under "actual" intuitively sounds like the correct
behavior. Why do you expect that the column value would change to 'ABC'?
The column was created with a default, which means that existing rows will get
that value, afaik it shouldn't change if the default later is changed. Is there
a requirement in the SQL standard that supports your expectation?
Mark
PS I will see if I can find something to back up my claim, but that will have
to wait until Saturday.
----- Bericht beantwoorden -----
Van: "Vlad Khorsun (JIRA)" <trac...@firebirdsql.org>
Aan: <firebird-devel@lists.sourceforge.net>
Onderwerp: [Firebird-devel] [FB-Tracker] Created: (CORE-5507) Wrong value of
the new field at the old records, created before that new field was added.
Datum: do, mrt. 23, 2017 23:11
Wrong value of the new field at the old records, created before that new field
was added.
-----------------------------------------------------------------------------------------
Key: CORE-5507
URL: http://tracker.firebirdsql.org/browse/CORE-5507
Project: Firebird Core
Issue Type: Bug
Components: Engine
Affects Versions: 3.0.2
Reporter: Vlad Khorsun
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.
--
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
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel