Changeset: 2d55e82a7f6c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2d55e82a7f6c
Modified Files:
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_table.c
        sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err
        sql/test/pg_regress/Tests/alter_table.sql
        sql/test/pg_regress/Tests/alter_table.stable.err
        sql/test/pg_regress/Tests/alter_table.stable.out
        sql/test/pg_regress/postgresql2sql99.sh
Branch: transaction-replication
Log Message:

Merge with default branch


diffs (truncated from 1737 to 300 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -569,7 +569,11 @@ alter_table(mvc *sql, char *sname, sql_t
                        /* for non empty check for nulls */
                        if (c->null == 0) {
                                void *nilptr = 
ATOMnilptr(c->type.type->localtype);
-                               if 
(table_funcs.column_find_row(sql->session->tr, nc, nilptr, NULL) != oid_nil)
+                               rids *nils = 
table_funcs.rids_select(sql->session->tr, nc, nilptr, NULL, NULL);  
+                               int has_nils = (table_funcs.rids_next(nils) != 
oid_nil);
+
+                               table_funcs.rids_destroy(nils);
+                               if (has_nils)
                                        return sql_message("40002!ALTER TABLE: 
NOT NULL constraint violated for column %s.%s", c->t->base.name, c->base.name);
                        }
                }
diff --git a/sql/storage/bat/bat_table.c b/sql/storage/bat/bat_table.c
--- a/sql/storage/bat/bat_table.c
+++ b/sql/storage/bat/bat_table.c
@@ -274,7 +274,7 @@ rids_select( sql_trans *tr, sql_column *
        b = full_column(tr, key);
        if (!kvl)
                kvl = ATOMnilptr(b->ttype);
-       if (!kvh)
+       if (!kvh && key_value_low != ATOMnilptr(b->ttype))
                kvh = ATOMnilptr(b->ttype);
        hi = (kvl == kvh);
        r = BATsubselect(b, s, kvl, kvh, 1, hi, 0);
diff --git 
a/sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err 
b/sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err
--- a/sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err
+++ b/sql/test/BugTracker-2009/Tests/primekeyconstraint.SF-2783425.stable.err
@@ -69,9 +69,9 @@ stderr of test 'primekeyconstraint.SF-27
 # 08:02:34 >  mclient -lsql -umonetdb -Pmonetdb --host=eir --port=30582 
 # 08:02:34 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-23599/.s.monetdb.33852
+MAPI  = (monetdb) /var/tmp/mtest-11898/.s.monetdb.35572
 QUERY = ALTER TABLE way_nds ADD CONSTRAINT pk_way_nds PRIMARY KEY (way, idx);
-ERROR = !UPDATE: PRIMARY KEY constraint 'way_nds.pk_way_nds' violated
+ERROR = !ALTER TABLE: NOT NULL constraint violated for column way_nds.way
 
 # 08:02:34 >  
 # 08:02:34 >  Done.
diff --git a/sql/test/pg_regress/Tests/alter_table.sql 
b/sql/test/pg_regress/Tests/alter_table.sql
--- a/sql/test/pg_regress/Tests/alter_table.sql
+++ b/sql/test/pg_regress/Tests/alter_table.sql
@@ -163,6 +163,7 @@ SELECT * FROM tmp_new2;
 
 DROP TABLE tmp_new;
 DROP TABLE tmp_new2;
+DROP TABLE tmp;
 
 
 -- ALTER TABLE ... RENAME on non-table relations
@@ -235,7 +236,7 @@ DROP TABLE tmp2;
 -- Note: these tables are TEMP to avoid name conflicts when this test
 -- is run in parallel with foreign_key.sql.
 
-CREATE TEMP TABLE PKTABLE (ptest1 int PRIMARY KEY);
+CREATE /* TEMP */ TABLE PKTABLE (ptest1 int PRIMARY KEY);
 CREATE TEMP TABLE FKTABLE (ftest1 inet);
 -- This next should fail, because inet=int does not exist
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
@@ -245,26 +246,26 @@ ALTER TABLE FKTABLE ADD FOREIGN KEY(ftes
 -- This should succeed, even though they are different types
 -- because varchar=int does exist
 DROP TABLE FKTABLE;
-CREATE TEMP TABLE FKTABLE (ftest1 varchar);
+CREATE /* TEMP */ TABLE FKTABLE (ftest1 varchar(10));
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable;
 -- As should this
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1);
 DROP TABLE pktable cascade;
 DROP TABLE fktable;
 
-CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 inet,
+CREATE /* TEMP */ TABLE PKTABLE (ptest1 int, ptest2 inet,
                            PRIMARY KEY(ptest1, ptest2));
 -- This should fail, because we just chose really odd types
-CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+CREATE /* TEMP */ TABLE FKTABLE (ftest1 inet, ftest2 timestamp);
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2) references pktable;
 DROP TABLE FKTABLE;
 -- Again, so should this...
-CREATE TEMP TABLE FKTABLE (ftest1 cidr, ftest2 timestamp);
+CREATE /* TEMP*/  TABLE FKTABLE (ftest1 inet, ftest2 timestamp);
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
      references pktable(ptest1, ptest2);
 DROP TABLE FKTABLE;
 -- This fails because we mixed up the column ordering
-CREATE TEMP TABLE FKTABLE (ftest1 int, ftest2 inet);
+CREATE /* TEMP */ TABLE FKTABLE (ftest1 int, ftest2 inet);
 ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1, ftest2)
      references pktable(ptest2, ptest1);
 -- As does this...
@@ -272,6 +273,9 @@ ALTER TABLE FKTABLE ADD FOREIGN KEY(ftes
      references pktable(ptest1, ptest2);
 
 -- temp tables should go away by themselves, need not drop them.
+-- MonetDB: disabled the TEMP in CERATE TEMP (see bug 3565) so we do need to 
drop them in our version
+DROP TABLE FKTABLE;
+DROP TABLE PKTABLE cascade;
 
 -- test check constraint adding
 
@@ -319,7 +323,7 @@ drop table atacc1;
 -- inheritance related tests
 create table atacc1 (test int);
 create table atacc2 (test2 int);
-create table atacc3 (test3 int); -- inherits (atacc1, atacc2)
+create table atacc3 (test int, test2 int, test3 int); -- inherits (atacc1, 
atacc2)
 alter table atacc2 add constraint foo check (test2>0);
 -- fail and then succeed on atacc2
 insert into atacc2 (test2) values (-3);
@@ -335,7 +339,7 @@ drop table atacc1;
 
 create table atacc1 (test int);
 create table atacc2 (test2 int);
-create table atacc3 (test3 int); -- inherits (atacc1, atacc2)
+create table atacc3 (test int, test2 int, test3 int); -- inherits (atacc1, 
atacc2)
 alter table only atacc2 add constraint foo check (test2>0);
 -- fail and then succeed on atacc2
 insert into atacc2 (test2) values (-3);
@@ -391,6 +395,7 @@ insert into atacc1 (test,test2) values (
 insert into atacc1 (test,test2) values (4,5);
 insert into atacc1 (test,test2) values (5,4);
 insert into atacc1 (test,test2) values (5,5);
+alter table atacc1 drop constraint atacc_test1;
 drop table atacc1;
 
 -- lets do some naming tests
@@ -420,6 +425,7 @@ alter table atacc1 add constraint atacc_
 alter table atacc1 drop constraint atacc_test1 restrict;
 -- try adding a primary key on oid (should succeed)
 alter table atacc1 add constraint atacc_oid1 primary key(oid);
+alter table atacc1 add constraint atacc_test1 primary key (test);
 drop table atacc1;
 
 -- let's do one where the primary key constraint fails when added
@@ -430,6 +436,8 @@ insert into atacc1 (test) values (2);
 -- add a primary key (fails)
 alter table atacc1 add constraint atacc_test1 primary key (test);
 insert into atacc1 (test) values (3);
+delete from atacc1 where test = 2;
+alter table atacc1 add constraint atacc_test1 primary key (test);
 drop table atacc1;
 
 -- let's do another one where the primary key constraint fails when added
@@ -491,8 +499,10 @@ alter table atacc1 add constraint "atacc
 alter table atacc1 alter column test drop not null;
 alter table atacc1 drop constraint "atacc1_pkey";
 alter table atacc1 alter column test drop not null;
+alter table atacc1 alter test set null;
 insert into atacc1 values (null);
 alter table atacc1 alter test set not null;
+select * from atacc1;
 delete from atacc1;
 alter table atacc1 alter test set not null;
 
@@ -514,7 +524,7 @@ drop table atacc1;
 
 -- test inheritance
 create table parent (a int);
-create table child (b varchar(255)); -- inherits (parent)
+create table child (a int, b varchar(255)); -- inherits (parent)
 
 alter table parent alter a set not null;
 insert into parent values (NULL);
@@ -522,10 +532,12 @@ insert into child (a, b) values (NULL, '
 alter table parent alter a drop not null;
 insert into parent values (NULL);
 insert into child (a, b) values (NULL, 'foo');
-alter table only parent alter a set not null;
+--alter table only parent alter a set not null;
+alter table parent alter a set not null;
 alter table child alter a set not null;
 delete from parent;
-alter table only parent alter a set not null;
+--alter table only parent alter a set not null;
+alter table parent alter a set not null;
 insert into parent values (NULL);
 alter table child alter a set not null;
 insert into child (a, b) values (NULL, 'foo');
@@ -541,10 +553,16 @@ create table def_test (
        c2      text default 'initial_default'
 );
 insert into def_test default values;
+select * from def_test;
+
 alter table def_test alter column c1 drop default;
 insert into def_test default values;
+select * from def_test;
+
 alter table def_test alter column c2 drop default;
 insert into def_test default values;
+select * from def_test;
+
 alter table def_test alter column c1 set default 10;
 alter table def_test alter column c2 set default 'new_default';
 insert into def_test default values;
@@ -648,8 +666,11 @@ drop view myview;
 -- test some commands to make sure they fail on the dropped column
 analyze atacc1(a);
 analyze atacc1("........pg.dropped.1........");
+
 vacuum analyze atacc1(a);
 vacuum analyze atacc1("........pg.dropped.1........");
+call vacuum('sys', 'atacc1');
+call analyze('sys', 'atacc1');
 
 
 alter table atacc1 alter a set storage plain;
@@ -683,7 +704,7 @@ create index "testing_idx" on atacc1("..
 
 -- test create as and select into
 insert into atacc1 values (21, 22, 23);
-create table test1 as select * from atacc1;
+create table test1 as select * from atacc1 WITH DATA;
 select * from test1;
 drop table test1;
 select * into test2 from atacc1;
@@ -702,7 +723,7 @@ drop table atacc1;
 create table parent (a int, b int, c int);
 insert into parent values (1, 2, 3);
 alter table parent drop a;
-create table child (d varchar(255)); -- inherits (parent)
+create table child (b int, c int, d varchar(255)); -- inherits (parent)
 insert into child values (12, 13, 'testing');
 
 select * from parent;
@@ -740,8 +761,8 @@ drop table test;
 -- test inheritance
 
 create table dropColumn (a int, b int, e int);
-create table dropColumnChild (c int); -- inherits (dropColumn)
-create table dropColumnAnother (d int); -- inherits (dropColumnChild)
+create table dropColumnChild (a int, b int, e int, c int); -- inherits 
(dropColumn)
+create table dropColumnAnother (a int, b int, e int, c int, d int); -- 
inherits (dropColumnChild)
 
 -- these two should fail
 alter table dropColumnchild drop column a;
@@ -753,8 +774,8 @@ alter table dropColumnChild drop column 
 alter table dropColumn drop column a;
 
 create table renameColumn (a int);
-create table renameColumnChild (b int); -- inherits (renameColumn)
-create table renameColumnAnother (c int); -- inherits (renameColumnChild)
+create table renameColumnChild (a int, b int); -- inherits (renameColumn)
+create table renameColumnAnother (a int, b int, c int); -- inherits 
(renameColumnChild)
 
 -- these three should fail
 alter table renameColumnChild rename column a to d;
@@ -775,7 +796,7 @@ alter table only renameColumn add column
 -- Test corner cases in dropping of inherited columns
 
 create table p1 (f1 int, f2 int);
-create table c1 (f1 int not null); -- inherits(p1)
+create table c1 (f2 int, f1 int not null); -- inherits(p1)
 
 -- should be rejected since c1.f1 is inherited
 alter table c1 drop column f1;
@@ -786,10 +807,11 @@ select f1 from c1;
 alter table c1 drop column f1;
 select f1 from c1;
 
+drop table c1;
 drop table p1 cascade;
 
 create table p1 (f1 int, f2 int);
-create table c1 (); -- inherits(p1)
+create table c1 (f1 int, f2 int); -- inherits(p1)
 
 -- should be rejected since c1.f1 is inherited
 alter table c1 drop column f1;
@@ -797,10 +819,11 @@ alter table p1 drop column f1;
 -- c1.f1 is dropped now, since there is no local definition for it
 select f1 from c1;
 
+drop table c1;
 drop table p1 cascade;
 
 create table p1 (f1 int, f2 int);
-create table c1 (); -- inherits(p1)
+create table c1 (f1 int, f2 int); -- inherits(p1)
 
 -- should be rejected since c1.f1 is inherited
 alter table c1 drop column f1;
@@ -808,6 +831,7 @@ alter table only p1 drop column f1;
 -- c1.f1 is NOT dropped, but must now be considered non-inherited
 alter table c1 drop column f1;
 
+drop table c1;
 drop table p1 cascade;
 
 create table p1 (f1 int, f2 int);
@@ -819,6 +843,7 @@ alter table only p1 drop column f1;
 -- c1.f1 is still there, but no longer inherited
 alter table c1 drop column f1;
 
+drop table c1;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to