Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf2587ca54 | ||
|
|
d1d5ed6df3 | ||
|
|
37160c7b35 | ||
|
|
811c7474de | ||
|
|
1f63811383 | ||
|
|
913bfd72f8 | ||
|
|
15dd4935d6 | ||
|
|
39e558f494 | ||
|
|
03636fafc4 | ||
|
|
6b3b28f01f | ||
|
|
186ed34ee5 | ||
|
|
e4ce12d1a3 | ||
|
|
5de395a4a8 | ||
|
|
3429e93979 | ||
|
|
777e8c6e4c |
@@ -44,7 +44,7 @@ the extension into your test database.
|
||||
|
||||
During development the cartodb extension version doesn't change with
|
||||
every commit, so testing latest change requires cheating with PostgreSQL
|
||||
so to enforce re-load of the scripts. To help with cheating, "make install"
|
||||
as to enforce the scripts to reload. To help with cheating, "make install"
|
||||
also installs migration scripts to go from "V" to "V"next and from "V"next
|
||||
to "V". Example to upgrade a 0.2.0dev version:
|
||||
|
||||
|
||||
4
Makefile
4
Makefile
@@ -1,7 +1,7 @@
|
||||
# cartodb/Makefile
|
||||
|
||||
EXTENSION = cartodb
|
||||
EXTVERSION = 0.11.0
|
||||
EXTVERSION = 0.11.2
|
||||
|
||||
SED = sed
|
||||
|
||||
@@ -51,6 +51,8 @@ UPGRADABLE = \
|
||||
0.10.1 \
|
||||
0.10.2 \
|
||||
0.11.0 \
|
||||
0.11.1 \
|
||||
0.11.2 \
|
||||
$(EXTVERSION)dev \
|
||||
$(EXTVERSION)next \
|
||||
$(END)
|
||||
|
||||
10
NEWS.md
10
NEWS.md
@@ -1,6 +1,16 @@
|
||||
next (2015-mm-dd)
|
||||
-----------------
|
||||
|
||||
0.11.2 (2015-10-19)
|
||||
-------------------
|
||||
* Fix schema not being specified on pg_get_serial_sequence [#170](https://github.com/CartoDB/cartodb-postgresql/pull/170)
|
||||
* Log invalidation function call duration in seconds [#163](https://github.com/CartoDB/cartodb-postgresql/pull/163)
|
||||
|
||||
0.11.1 (2015-10-06)
|
||||
-------------------
|
||||
* Added CDB_DateToNumber(timestamp with time zone) [#169](https://github.com/CartoDB/cartodb-postgresql/pull/169)
|
||||
* cartodbfy now discards cartodb_id candidates that contain nulls [#148](https://github.com/CartoDB/cartodb-postgresql/issues/148)
|
||||
|
||||
0.11.0 (2015-09-dd)
|
||||
-------------------
|
||||
* Groups API
|
||||
|
||||
@@ -362,7 +362,7 @@ $$ LANGUAGE PLPGSQL;
|
||||
-- As before, this drops all the metadata and geom sync triggers
|
||||
--
|
||||
-- (2) _CDB_Has_Usable_Primary_ID()
|
||||
-- Returns TRUE if it can find a unique integer primary key named
|
||||
-- Returns TRUE if it can find a unique and not null integer primary key named
|
||||
-- 'cartodb_id' or can rename an existing key.
|
||||
-- Returns FALSE otherwise.
|
||||
--
|
||||
@@ -551,7 +551,7 @@ BEGIN
|
||||
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('found good ''%s''', const.pkey);
|
||||
RETURN true;
|
||||
|
||||
-- Check and see if the column values are unique,
|
||||
-- Check and see if the column values are unique and not null,
|
||||
-- if they are, we can use this column...
|
||||
ELSE
|
||||
|
||||
@@ -559,13 +559,17 @@ BEGIN
|
||||
useable_key := true;
|
||||
|
||||
BEGIN
|
||||
sql := Format('ALTER TABLE %s ADD CONSTRAINT %s_unique UNIQUE (%s)', reloid::text, const.pkey, const.pkey);
|
||||
sql := Format('ALTER TABLE %s ADD CONSTRAINT %s_pk PRIMARY KEY (%s)', reloid::text, const.pkey, const.pkey);
|
||||
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', sql;
|
||||
EXECUTE sql;
|
||||
EXCEPTION
|
||||
-- Failed unique check...
|
||||
WHEN unique_violation THEN
|
||||
RAISE NOTICE 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('column %s is not unique', const.pkey);
|
||||
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('column %s is not unique', const.pkey);
|
||||
useable_key := false;
|
||||
-- Failed not null check...
|
||||
WHEN not_null_violation THEN
|
||||
RAISE DEBUG 'CDB(_CDB_Has_Usable_Primary_ID): %', Format('column %s contains nulls', const.pkey);
|
||||
useable_key := false;
|
||||
-- Other fatal error
|
||||
WHEN others THEN
|
||||
@@ -574,7 +578,7 @@ BEGIN
|
||||
|
||||
-- Clean up test constraint
|
||||
IF useable_key THEN
|
||||
PERFORM _CDB_SQL(Format('ALTER TABLE %s DROP CONSTRAINT %s_unique', reloid::text, const.pkey));
|
||||
PERFORM _CDB_SQL(Format('ALTER TABLE %s DROP CONSTRAINT %s_pk', reloid::text, const.pkey));
|
||||
|
||||
-- Move non-unique column out of the way
|
||||
ELSE
|
||||
|
||||
@@ -13,3 +13,19 @@ RETURN output;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
||||
-- Convert timestamp with time zone to double precision
|
||||
--
|
||||
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp with time zone)
|
||||
RETURNS double precision AS $$
|
||||
DECLARE output double precision;
|
||||
BEGIN
|
||||
BEGIN
|
||||
SELECT extract (EPOCH FROM input) INTO output;
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RETURN NULL;
|
||||
END;
|
||||
RETURN output;
|
||||
END;
|
||||
$$
|
||||
LANGUAGE 'plpgsql' STABLE STRICT;
|
||||
|
||||
@@ -163,7 +163,7 @@ BEGIN
|
||||
group_role := cartodb._CDB_Group_GroupRole(group_name);
|
||||
FOR column_name IN EXECUTE 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = current_database() AND TABLE_SCHEMA = $1 AND TABLE_NAME = $2 AND COLUMN_DEFAULT LIKE ''nextval%''' USING username, table_name
|
||||
LOOP
|
||||
EXECUTE 'SELECT PG_GET_SERIAL_SEQUENCE($1, $2)' USING table_name, column_name INTO sequence_name;
|
||||
EXECUTE format('SELECT PG_GET_SERIAL_SEQUENCE(''%I.%I'', ''%I'')', username, table_name, column_name) INTO sequence_name;
|
||||
IF sequence_name IS NOT NULL THEN
|
||||
IF do_grant THEN
|
||||
-- Here %s is needed since sequence_name has quotes
|
||||
|
||||
@@ -64,6 +64,10 @@ DECLARE
|
||||
tabname TEXT;
|
||||
rec RECORD;
|
||||
found BOOL;
|
||||
function_start timestamptz;
|
||||
function_end timestamptz;
|
||||
function_duration float;
|
||||
log_error_verbosity_value text;
|
||||
BEGIN
|
||||
|
||||
IF TG_OP = 'UPDATE' or TG_OP = 'INSERT' THEN
|
||||
@@ -72,6 +76,8 @@ BEGIN
|
||||
tabname = OLD.tabname;
|
||||
END IF;
|
||||
|
||||
function_start := clock_timestamp();
|
||||
|
||||
-- Notify table data update
|
||||
-- This needs a little bit more of research regarding security issues
|
||||
-- see https://github.com/CartoDB/cartodb/pull/241
|
||||
@@ -105,7 +111,14 @@ BEGIN
|
||||
EXIT;
|
||||
END LOOP;
|
||||
IF NOT found THEN RAISE WARNING 'Missing cdb_invalidate_varnish()'; END IF;
|
||||
|
||||
|
||||
function_end := clock_timestamp();
|
||||
SELECT extract(epoch from (function_end - function_start)) INTO function_duration;
|
||||
SELECT setting INTO log_error_verbosity_value FROM pg_settings WHERE name='log_error_verbosity';
|
||||
SET log_error_verbosity=TERSE;
|
||||
RAISE LOG 'invalidation_duration: %', function_duration::text;
|
||||
PERFORM 'SET log_error_verbosity= ' || log_error_verbosity_value;
|
||||
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$
|
||||
|
||||
@@ -250,7 +250,7 @@ INSERT INTO existing_cartodb_id (cartodb_id, description) VALUES
|
||||
(20, 'b'),
|
||||
(30, 'c');
|
||||
SELECT CDB_CartodbfyTableCheck('existing_cartodb_id', 'Existing cartodb_id values are respected #138');
|
||||
SELECT * from existing_cartodb_id;
|
||||
SELECT cartodb_id,the_geom,the_geom_webmercator,description,name from existing_cartodb_id;
|
||||
DROP TABLE existing_cartodb_id;
|
||||
|
||||
-- Table with both the_geom and wkb_geometry
|
||||
@@ -281,6 +281,44 @@ INSERT INTO many_colliding_columns VALUES (
|
||||
SELECT CDB_CartodbfyTableCheck('many_colliding_columns', 'Many colliding columns #141');
|
||||
DROP TABLE many_colliding_columns;
|
||||
|
||||
-- Table with null cartodb_id
|
||||
CREATE TABLE test (
|
||||
cartodb_id integer
|
||||
);
|
||||
INSERT INTO test VALUES
|
||||
(1),
|
||||
(2),
|
||||
(NULL),
|
||||
(3);
|
||||
SELECT CDB_CartodbfyTableCheck('test', 'Table with null cartodb_id #148');
|
||||
SELECT cartodb_id, cartodb_id_1 from test;
|
||||
DROP TABLE test;
|
||||
|
||||
-- Table with non unique cartodb_id
|
||||
CREATE TABLE test (
|
||||
cartodb_id integer
|
||||
);
|
||||
INSERT INTO test VALUES
|
||||
(1),
|
||||
(2),
|
||||
(2);
|
||||
SELECT CDB_CartodbfyTableCheck('test', 'Table with non unique cartodb_id #148');
|
||||
SELECT cartodb_id, cartodb_id_1 from test;
|
||||
DROP TABLE test;
|
||||
|
||||
-- Table with non unique and null cartodb_id
|
||||
CREATE TABLE test (
|
||||
cartodb_id integer
|
||||
);
|
||||
INSERT INTO test VALUES
|
||||
(1),
|
||||
(2),
|
||||
(NULL),
|
||||
(2);
|
||||
SELECT CDB_CartodbfyTableCheck('test', 'Table with non unique and null cartodb_id #148');
|
||||
SELECT cartodb_id, cartodb_id_1 from test;
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
-- TODO: table with existing custom-triggered the_geom
|
||||
|
||||
|
||||
@@ -79,5 +79,28 @@ CREATE TABLE
|
||||
INSERT 0 1
|
||||
Many colliding columns #141 cartodbfied fine
|
||||
DROP TABLE
|
||||
CREATE TABLE
|
||||
INSERT 0 4
|
||||
Table with null cartodb_id #148 cartodbfied fine
|
||||
1|1
|
||||
2|2
|
||||
3|
|
||||
4|3
|
||||
DROP TABLE
|
||||
CREATE TABLE
|
||||
INSERT 0 3
|
||||
Table with non unique cartodb_id #148 cartodbfied fine
|
||||
1|1
|
||||
2|2
|
||||
3|2
|
||||
DROP TABLE
|
||||
CREATE TABLE
|
||||
INSERT 0 4
|
||||
Table with non unique and null cartodb_id #148 cartodbfied fine
|
||||
1|1
|
||||
2|2
|
||||
3|
|
||||
4|2
|
||||
DROP TABLE
|
||||
DROP FUNCTION
|
||||
DROP FUNCTION
|
||||
|
||||
2
test/CDB_DateToNumberTest.sql
Normal file
2
test/CDB_DateToNumberTest.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00'::timestamp);
|
||||
SELECT * FROM CDB_DateToNumber('1999-01-08 00:00:00+05'::timestamp with time zone);
|
||||
2
test/CDB_DateToNumberTest_expect
Normal file
2
test/CDB_DateToNumberTest_expect
Normal file
@@ -0,0 +1,2 @@
|
||||
915753600
|
||||
915735600
|
||||
Reference in New Issue
Block a user