Do not add unique index on cartodb_id if already a primary key
Closes #38
This commit is contained in:
parent
afcc2498c8
commit
bc0966c46e
4
NEWS
4
NEWS
@ -7,6 +7,10 @@ Enhancements:
|
|||||||
- Drop useless DEFAULT specification in plpgsql variable declarations
|
- Drop useless DEFAULT specification in plpgsql variable declarations
|
||||||
- List plpythonu requirement first, so get pg_catalog scanned before public
|
- List plpythonu requirement first, so get pg_catalog scanned before public
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Do not add unique index on cartodb_id if already a primary key (#38)
|
||||||
|
|
||||||
0.2.0 - 2014-06-09
|
0.2.0 - 2014-06-09
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ BEGIN
|
|||||||
AND a.attrelid = reloid
|
AND a.attrelid = reloid
|
||||||
AND NOT a.attisdropped
|
AND NOT a.attisdropped
|
||||||
AND a.attname = 'cartodb_id'
|
AND a.attname = 'cartodb_id'
|
||||||
AND c.contype = 'u' ) -- unique
|
AND c.contype IN ( 'u', 'p' ) ) -- unique or pkey
|
||||||
THEN
|
THEN
|
||||||
sql := sql || ', ADD unique(cartodb_id)';
|
sql := sql || ', ADD unique(cartodb_id)';
|
||||||
END IF;
|
END IF;
|
||||||
|
@ -200,6 +200,14 @@ SELECT CDB_CartodbfyTableCheck('t', 'unsequenced cartodb_id');
|
|||||||
select cartodb_id FROM t;
|
select cartodb_id FROM t;
|
||||||
DROP TABLE t;
|
DROP TABLE t;
|
||||||
|
|
||||||
|
-- table with existing cartodb_id serial primary key
|
||||||
|
CREATE TABLE t ( cartodb_id serial primary key );
|
||||||
|
SELECT CDB_CartodbfyTableCheck('t', 'cartodb_id serial primary key');
|
||||||
|
SELECT c.conname, a.attname FROM pg_constraint c, pg_attribute a
|
||||||
|
WHERE c.conrelid = 't'::regclass and a.attrelid = c.conrelid
|
||||||
|
AND c.conkey[1] = a.attnum AND NOT a.attisdropped;
|
||||||
|
DROP TABLE t;
|
||||||
|
|
||||||
-- table with existing the_geom and created_at and containing null values
|
-- table with existing the_geom and created_at and containing null values
|
||||||
-- Really, a test for surviving an longstanding PostgreSQL bug:
|
-- Really, a test for surviving an longstanding PostgreSQL bug:
|
||||||
-- http://www.postgresql.org/message-id/20140530143150.GA11051@localhost
|
-- http://www.postgresql.org/message-id/20140530143150.GA11051@localhost
|
||||||
|
@ -45,6 +45,10 @@ unsequenced cartodb_id cartodbfied fine
|
|||||||
1
|
1
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
CREATE TABLE
|
CREATE TABLE
|
||||||
|
cartodb_id serial primary key cartodbfied fine
|
||||||
|
t_pkey|cartodb_id
|
||||||
|
DROP TABLE
|
||||||
|
CREATE TABLE
|
||||||
null geom and timestamp values cartodbfied fine
|
null geom and timestamp values cartodbfied fine
|
||||||
DROP TABLE
|
DROP TABLE
|
||||||
DROP FUNCTION
|
DROP FUNCTION
|
||||||
|
Loading…
Reference in New Issue
Block a user