LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
53 stars 24 forks source link

[FRG-285] Second statement to use default column value gets AssertionError #587

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="jhyde", created="Wed, 18 Jul 2007 11:52:10 -0500 (GMT-05:00)"] If you create a table where one of the columns has a default value, and you insert into that table, the statement works fine. But if you execute a similar statement, get an assertion error.

Testcase:

set schema 'sales';
create table t (i integer primary key not null, j varchar(10) default 'foo');
No rows affected (1.161 seconds)
insert into t (i) values (1);
1 row affected (1.136 seconds)
insert into t (i) values (2);
Error: java.lang.AssertionError: type mismatch:
type1:
CHAR(3) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL
type2:
CHAR(3) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL
(state=,code=0)

Note that the type is CHAR(3), the same as the default value. I'm guessing that the type of the default value is cached from the previous execution, but belongs to a different type-factory so does not compare equal.

dynamobi-build commented 12 years ago

[author="jvs", created="Wed, 18 Jul 2007 15:33:33 -0500 (GMT-05:00)"] Oof...must be caused by the fact that default value expressions are loaded using the global code cache.

dynamobi-build commented 12 years ago

[author="jvs", created="Wed, 18 Jul 2007 15:48:26 -0500 (GMT-05:00)"] Unfortunately, just cloning the RexNode returned from the cache isn't good enough, since that keeps the original type descriptor.

dynamobi-build commented 12 years ago

[author="jhyde", created="Thu, 19 Jul 2007 10:54:26 -0500 (GMT-05:00)"] Fixed in change 9619.