Merge tag '0.4.1'

v0.4.1
This commit is contained in:
Kartones 2014-10-21 16:48:23 +02:00
commit dc6ac7f56b
3 changed files with 20 additions and 3 deletions

View File

@ -1,7 +1,7 @@
# cartodb/Makefile # cartodb/Makefile
EXTENSION = cartodb EXTENSION = cartodb
EXTVERSION = 0.4.0 EXTVERSION = 0.4.1
SED = sed SED = sed
@ -27,6 +27,7 @@ UPGRADABLE = \
0.3.4 \ 0.3.4 \
0.3.5 \ 0.3.5 \
0.3.6 \ 0.3.6 \
0.4.0 \
$(EXTVERSION)dev \ $(EXTVERSION)dev \
$(EXTVERSION)next \ $(EXTVERSION)next \
$(END) $(END)

View File

@ -67,6 +67,7 @@ DECLARE
had_column BOOLEAN; had_column BOOLEAN;
i INTEGER; i INTEGER;
new_name TEXT; new_name TEXT;
cartodb_id_name TEXT;
BEGIN BEGIN
<< cartodb_id_setup >> << cartodb_id_setup >>
LOOP --{ LOOP --{
@ -75,6 +76,7 @@ BEGIN
sql := 'ALTER TABLE ' || reloid::text || ' ADD cartodb_id SERIAL NOT NULL UNIQUE'; sql := 'ALTER TABLE ' || reloid::text || ' ADD cartodb_id SERIAL NOT NULL UNIQUE';
RAISE DEBUG 'Running %', sql; RAISE DEBUG 'Running %', sql;
EXECUTE sql; EXECUTE sql;
cartodb_id_name := 'cartodb_id';
EXIT cartodb_id_setup; EXIT cartodb_id_setup;
EXCEPTION EXCEPTION
WHEN duplicate_column THEN WHEN duplicate_column THEN
@ -114,6 +116,7 @@ BEGIN
BEGIN BEGIN
RAISE DEBUG 'Running %', sql; RAISE DEBUG 'Running %', sql;
EXECUTE sql; EXECUTE sql;
cartodb_id_name := 'cartodb_id';
EXIT cartodb_id_setup; EXIT cartodb_id_setup;
EXCEPTION EXCEPTION
WHEN unique_violation OR not_null_violation THEN WHEN unique_violation OR not_null_violation THEN
@ -139,6 +142,7 @@ BEGIN
WHEN others THEN WHEN others THEN
RAISE EXCEPTION 'Cartodbfying % (renaming cartodb_id): % (%)', reloid, SQLERRM, SQLSTATE; RAISE EXCEPTION 'Cartodbfying % (renaming cartodb_id): % (%)', reloid, SQLERRM, SQLSTATE;
END; END;
cartodb_id_name := new_name;
EXIT rename_column; EXIT rename_column;
END LOOP; --} END LOOP; --}
CONTINUE cartodb_id_setup; CONTINUE cartodb_id_setup;
@ -185,6 +189,18 @@ BEGIN
END; END;
END IF; END IF;
-- Set primary key of the table if not already present (e.g. tables created from SQL API)
IF cartodb_id_name IS NULL THEN
RAISE EXCEPTION 'Cartodbfying % (Didnt get cartodb_id field name)', reloid;
END IF;
BEGIN
sql := 'ALTER TABLE ' || reloid::text || ' ADD PRIMARY KEY (cartodb_id)';
EXECUTE sql;
EXCEPTION
WHEN others THEN
RAISE DEBUG 'Table % Already had PRIMARY KEY', reloid;
END;
END; END;
$$ LANGUAGE PLPGSQL; $$ LANGUAGE PLPGSQL;

View File

@ -7,7 +7,7 @@ ERROR: Quota exceeded by 3.9990234375KB
INSERT 0 1024 INSERT 0 1024
8 8
ERROR: Quota exceeded by 103.9921875KB ERROR: Quota exceeded by 123.9921875KB
0 0
INSERT 0 1 INSERT 0 1
DROP TABLE DROP TABLE