(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 1
Message: Possible patch for better index name choosing
*** src/test/regress/expected/constraints.out	Sun Dec 20 21:40:15 2009
--- src/test/regress/results/constraints.out	Sun Dec 20 21:40:54 2009
***************
*** 359,370 ****
  DROP TABLE UNIQUE_TBL;
  CREATE TABLE UNIQUE_TBL (i int, t text,
  	UNIQUE(i,t));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_key" for table "unique_tbl"
  INSERT INTO UNIQUE_TBL VALUES (1, 'one');
  INSERT INTO UNIQUE_TBL VALUES (2, 'two');
  INSERT INTO UNIQUE_TBL VALUES (1, 'three');
  INSERT INTO UNIQUE_TBL VALUES (1, 'one');
! ERROR:  duplicate key value violates unique constraint "unique_tbl_i_key"
  DETAIL:  Key (i, t)=(1, one) already exists.
  INSERT INTO UNIQUE_TBL VALUES (5, 'one');
  INSERT INTO UNIQUE_TBL (t) VALUES ('six');
--- 359,370 ----
  DROP TABLE UNIQUE_TBL;
  CREATE TABLE UNIQUE_TBL (i int, t text,
  	UNIQUE(i,t));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "unique_tbl_i_t_key" for table "unique_tbl"
  INSERT INTO UNIQUE_TBL VALUES (1, 'one');
  INSERT INTO UNIQUE_TBL VALUES (2, 'two');
  INSERT INTO UNIQUE_TBL VALUES (1, 'three');
  INSERT INTO UNIQUE_TBL VALUES (1, 'one');
! ERROR:  duplicate key value violates unique constraint "unique_tbl_i_t_key"
  DETAIL:  Key (i, t)=(1, one) already exists.
  INSERT INTO UNIQUE_TBL VALUES (5, 'one');
  INSERT INTO UNIQUE_TBL (t) VALUES ('six');
***************
*** 523,529 ****
      (c1 WITH &&, (c2::circle) WITH ~=)
      WHERE (circle_center(c1) <> '(0,0)')
  );
! NOTICE:  CREATE TABLE / EXCLUDE will create implicit index "circles_c1_exclusion" for table "circles"
  -- these should succeed because they don't match the index predicate
  INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>');
  INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>');
--- 523,529 ----
      (c1 WITH &&, (c2::circle) WITH ~=)
      WHERE (circle_center(c1) <> '(0,0)')
  );
! NOTICE:  CREATE TABLE / EXCLUDE will create implicit index "circles_c1_c2_exclusion" for table "circles"
  -- these should succeed because they don't match the index predicate
  INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>');
  INSERT INTO circles VALUES('<(0,0), 5>', '<(0,0), 5>');
***************
*** 531,537 ****
  INSERT INTO circles VALUES('<(10,10), 10>', '<(0,0), 5>');
  -- fail, overlaps
  INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 5>');
! ERROR:  conflicting key value violates exclusion constraint "circles_c1_exclusion"
  DETAIL:  Key (c1, (c2::circle))=(<(20,20),10>, <(0,0),5>) conflicts with existing key (c1, (c2::circle))=(<(10,10),10>, <(0,0),5>).
  -- succeed because c1 doesn't overlap
  INSERT INTO circles VALUES('<(20,20), 1>', '<(0,0), 5>');
--- 531,537 ----
  INSERT INTO circles VALUES('<(10,10), 10>', '<(0,0), 5>');
  -- fail, overlaps
  INSERT INTO circles VALUES('<(20,20), 10>', '<(0,0), 5>');
! ERROR:  conflicting key value violates exclusion constraint "circles_c1_c2_exclusion"
  DETAIL:  Key (c1, (c2::circle))=(<(20,20),10>, <(0,0),5>) conflicts with existing key (c1, (c2::circle))=(<(10,10),10>, <(0,0),5>).
  -- succeed because c1 doesn't overlap
  INSERT INTO circles VALUES('<(20,20), 1>', '<(0,0), 5>');
***************
*** 540,547 ****
  -- should fail on existing data without the WHERE clause
  ALTER TABLE circles ADD EXCLUDE USING gist
    (c1 WITH &&, (c2::circle) WITH ~=);
! NOTICE:  ALTER TABLE / ADD EXCLUDE will create implicit index "circles_c1_exclusion1" for table "circles"
! ERROR:  could not create exclusion constraint "circles_c1_exclusion1"
  DETAIL:  Key (c1, (c2::circle))=(<(0,0),5>, <(0,0),5>) conflicts with key (c1, (c2::circle))=(<(0,0),5>, <(0,0),5>).
  DROP TABLE circles;
  -- Check deferred exclusion constraint
--- 540,547 ----
  -- should fail on existing data without the WHERE clause
  ALTER TABLE circles ADD EXCLUDE USING gist
    (c1 WITH &&, (c2::circle) WITH ~=);
! NOTICE:  ALTER TABLE / ADD EXCLUDE will create implicit index "circles_c1_c2_exclusion1" for table "circles"
! ERROR:  could not create exclusion constraint "circles_c1_c2_exclusion1"
  DETAIL:  Key (c1, (c2::circle))=(<(0,0),5>, <(0,0),5>) conflicts with key (c1, (c2::circle))=(<(0,0),5>, <(0,0),5>).
  DROP TABLE circles;
  -- Check deferred exclusion constraint

======================================================================

*** src/test/regress/expected/inherit.out	Mon Oct 12 15:49:24 2009
--- src/test/regress/results/inherit.out	Sun Dec 20 21:41:09 2009
***************
*** 1033,1051 ****
   b      | text |           | extended | B
  Indexes:
      "t_all_pkey" PRIMARY KEY, btree (a)
!     "t_all_b_key" btree (b)
!     "t_all_key" btree ((a || b))
  Check constraints:
      "t1_a_check" CHECK (length(a) > 2)
  Has OIDs: no
  
  SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 't_all'::regclass ORDER BY c.relname, objsubid;
!    relname   | objsubid |     description     
! -------------+----------+---------------------
!  t_all_b_key |        0 | index b_key
!  t_all_key   |        1 | index column fnidx
!  t_all_pkey  |        0 | index pkey
!  t_all_pkey  |        1 | index column pkey.a
  (4 rows)
  
  CREATE TABLE inh_error1 () INHERITS (t1, t4);
--- 1033,1051 ----
   b      | text |           | extended | B
  Indexes:
      "t_all_pkey" PRIMARY KEY, btree (a)
!     "t_all_b_idx" btree (b)
!     "t_all_expr_idx" btree ((a || b))
  Check constraints:
      "t1_a_check" CHECK (length(a) > 2)
  Has OIDs: no
  
  SELECT c.relname, objsubid, description FROM pg_description, pg_index i, pg_class c WHERE classoid = 'pg_class'::regclass AND objoid = i.indexrelid AND c.oid = i.indexrelid AND i.indrelid = 't_all'::regclass ORDER BY c.relname, objsubid;
!     relname     | objsubid |     description     
! ----------------+----------+---------------------
!  t_all_b_idx    |        0 | index b_key
!  t_all_expr_idx |        1 | index column fnidx
!  t_all_pkey     |        0 | index pkey
!  t_all_pkey     |        1 | index column pkey.a
  (4 rows)
  
  CREATE TABLE inh_error1 () INHERITS (t1, t4);

======================================================================

*** src/test/regress/expected/foreign_key.out	Sun Nov 22 00:20:41 2009
--- src/test/regress/results/foreign_key.out	Sun Dec 20 21:41:46 2009
***************
*** 736,742 ****
  DROP TABLE PKTABLE;
  -- Test for referencing column number smaller than referenced constraint
  CREATE TABLE PKTABLE (ptest1 int, ptest2 int, UNIQUE(ptest1, ptest2));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_ptest1_key" for table "pktable"
  CREATE TABLE FKTABLE_FAIL1 (ftest1 int REFERENCES pktable(ptest1));
  ERROR:  there is no unique constraint matching given keys for referenced table "pktable"
  DROP TABLE FKTABLE_FAIL1;
--- 736,742 ----
  DROP TABLE PKTABLE;
  -- Test for referencing column number smaller than referenced constraint
  CREATE TABLE PKTABLE (ptest1 int, ptest2 int, UNIQUE(ptest1, ptest2));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_ptest1_ptest2_key" for table "pktable"
  CREATE TABLE FKTABLE_FAIL1 (ftest1 int REFERENCES pktable(ptest1));
  ERROR:  there is no unique constraint matching given keys for referenced table "pktable"
  DROP TABLE FKTABLE_FAIL1;
***************
*** 860,866 ****
  create table pktable_base (base1 int not null);
  create table pktable (ptest1 int, primary key(base1), unique(base1, ptest1)) inherits (pktable_base);
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_base1_key" for table "pktable"
  create table fktable (ftest1 int references pktable(base1));
  -- now some ins, upd, del
  insert into pktable(base1) values (1);
--- 860,866 ----
  create table pktable_base (base1 int not null);
  create table pktable (ptest1 int, primary key(base1), unique(base1, ptest1)) inherits (pktable_base);
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_base1_ptest1_key" for table "pktable"
  create table fktable (ftest1 int references pktable(base1));
  -- now some ins, upd, del
  insert into pktable(base1) values (1);
***************
*** 1098,1104 ****
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
  NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id2_key" for table "pktable"
  NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id3_key" for table "pktable"
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id1_key" for table "pktable"
  CREATE TEMP TABLE fktable (
          x1      INT4 REFERENCES pktable(id1),
          x2      VARCHAR(4) REFERENCES pktable(id2),
--- 1098,1104 ----
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable"
  NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id2_key" for table "pktable"
  NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id3_key" for table "pktable"
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "pktable_id1_id2_id3_key" for table "pktable"
  CREATE TEMP TABLE fktable (
          x1      INT4 REFERENCES pktable(id1),
          x2      VARCHAR(4) REFERENCES pktable(id2),

======================================================================

*** src/test/regress/expected/alter_table.out	Sat Aug  1 16:59:17 2009
--- src/test/regress/results/alter_table.out	Sun Dec 20 21:42:47 2009
***************
*** 159,165 ****
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "tmp2_pkey" for table "tmp2"
  CREATE TABLE tmp3 (a int, b int);
  CREATE TABLE tmp4 (a int, b int, unique(a,b));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "tmp4_a_key" for table "tmp4"
  CREATE TABLE tmp5 (a int, b int);
  -- Insert rows into tmp2 (pktable)
  INSERT INTO tmp2 values (1);
--- 159,165 ----
  NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "tmp2_pkey" for table "tmp2"
  CREATE TABLE tmp3 (a int, b int);
  CREATE TABLE tmp4 (a int, b int, unique(a,b));
! NOTICE:  CREATE TABLE / UNIQUE will create implicit index "tmp4_a_b_key" for table "tmp4"
  CREATE TABLE tmp5 (a int, b int);
  -- Insert rows into tmp2 (pktable)
  INSERT INTO tmp2 values (1);

======================================================================