Merge pull request #127 from CartoDB/123-fix-indices

Fix for index generation when renaming table #123
This commit is contained in:
Rafa de la Torre 2015-08-27 16:44:19 +02:00
commit 45383d7c8a
4 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,7 @@
0.9.4 (2015-08-28)
------------------
* Fixed issue with indices when renaming tables [#123](https://github.com/CartoDB/cartodb-postgresql/issues/123)
0.9.3 (2015-08-27) 0.9.3 (2015-08-27)
------------------ ------------------
* Modify sampling of quota trigger [#126](https://github.com/CartoDB/cartodb-postgresql/issues/126) * Modify sampling of quota trigger [#126](https://github.com/CartoDB/cartodb-postgresql/issues/126)

View File

@ -1234,7 +1234,7 @@ BEGIN
AND c.oid = reloid AND c.oid = reloid
AND am.amname != 'gist' AND am.amname != 'gist'
LOOP LOOP
sql := Format('CREATE INDEX %s_%s_gix ON %s USING GIST (%s)', relname, rec.attname, reloid::text, rec.attname); sql := Format('CREATE INDEX ON %s USING GIST (%s)', reloid::text, rec.attname);
PERFORM _CDB_SQL(sql, '_CDB_Add_Indexes'); PERFORM _CDB_SQL(sql, '_CDB_Add_Indexes');
END LOOP; END LOOP;

View File

@ -216,6 +216,15 @@ WHERE c.conrelid = 't'::regclass and a.attrelid = c.conrelid
AND c.conkey[1] = a.attnum AND NOT a.attisdropped; AND c.conkey[1] = a.attnum AND NOT a.attisdropped;
DROP TABLE t; DROP TABLE t;
-- tables can be renamed and there's no index name clashing #123
CREATE TABLE original();
SELECT CDB_CartodbfyTable('original');
ALTER TABLE original RENAME TO original_renamed;
CREATE TABLE original();
SELECT CDB_CartodbfyTable('original');
DROP TABLE original_renamed;
DROP TABLE original;
-- TODO: table with existing custom-triggered the_geom -- TODO: table with existing custom-triggered the_geom
DROP FUNCTION CDB_CartodbfyTableCheck(regclass, text); DROP FUNCTION CDB_CartodbfyTableCheck(regclass, text);

View File

@ -51,5 +51,12 @@ CREATE TABLE
cartodb_id serial primary key cartodbfied fine cartodb_id serial primary key cartodbfied fine
t_pkey|cartodb_id t_pkey|cartodb_id
DROP TABLE DROP TABLE
CREATE TABLE
original
ALTER TABLE
CREATE TABLE
original
DROP TABLE
DROP TABLE
DROP FUNCTION DROP FUNCTION
DROP FUNCTION DROP FUNCTION