Merge branch 'b0.2'
Conflicts: Makefile NEWS
This commit is contained in:
commit
1bb8b85503
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ UPGRADABLE = \
|
|||||||
0.1.0 \
|
0.1.0 \
|
||||||
0.1.1 \
|
0.1.1 \
|
||||||
0.2.0 \
|
0.2.0 \
|
||||||
0.2.0dev \
|
0.2.1 \
|
||||||
$(EXTVERSION)next \
|
$(EXTVERSION)next \
|
||||||
$(END)
|
$(END)
|
||||||
|
|
||||||
|
13
NEWS
13
NEWS
@ -1,6 +1,19 @@
|
|||||||
0.3.0dev - 2014-MM-DD
|
0.3.0dev - 2014-MM-DD
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
0.2.1 - 2014-06-11
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Enhancements:
|
||||||
|
|
||||||
|
- Do not force re-cartodbfication on CREATE FROM unpackaged
|
||||||
|
- Drop useless DEFAULT specification in plpgsql variable declarations
|
||||||
|
- List plpythonu requirement first, to 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
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@ comment = 'Turn a database into a cartodb user database.'
|
|||||||
superuser = true
|
superuser = true
|
||||||
relocatable = false
|
relocatable = false
|
||||||
schema = cartodb
|
schema = cartodb
|
||||||
requires = 'schema_triggers, postgis, plpythonu'
|
requires = 'plpythonu, schema_triggers, postgis'
|
||||||
|
@ -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;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp)
|
CREATE OR REPLACE FUNCTION CDB_DateToNumber(input timestamp)
|
||||||
RETURNS double precision AS $$
|
RETURNS double precision AS $$
|
||||||
DECLARE output double precision DEFAULT NULL;
|
DECLARE output double precision;
|
||||||
BEGIN
|
BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT extract (EPOCH FROM input) INTO output;
|
SELECT extract (EPOCH FROM input) INTO output;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
--
|
--
|
||||||
CREATE OR REPLACE FUNCTION CDB_StringToDate(input character varying)
|
CREATE OR REPLACE FUNCTION CDB_StringToDate(input character varying)
|
||||||
RETURNS date AS $$
|
RETURNS date AS $$
|
||||||
DECLARE output DATE DEFAULT NULL;
|
DECLARE output DATE;
|
||||||
BEGIN
|
BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
output := input::date;
|
output := input::date;
|
||||||
|
@ -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
|
||||||
|
@ -4,7 +4,22 @@ ver=$1
|
|||||||
input=cartodb--${ver}.sql
|
input=cartodb--${ver}.sql
|
||||||
output=cartodb--unpackaged--${ver}.sql
|
output=cartodb--unpackaged--${ver}.sql
|
||||||
|
|
||||||
cat ${input} | grep -v 'duplicated extension$' > ${output}
|
echo "-- Script generated by $0 on `date`" > ${output}
|
||||||
|
|
||||||
|
# Migrate CDB functions from public schema to cartodb schema
|
||||||
|
cat ${input} |
|
||||||
|
grep '^ *CREATE OR REPLACE FUNCTION' |
|
||||||
|
grep -v ' cartodb\.' | # should only match DDL hooks
|
||||||
|
sed 's/).*$/)/' |
|
||||||
|
sed 's/DEFAULT [^ ,)]*//g' |
|
||||||
|
sed 's/CREATE OR REPLACE FUNCTION /ALTER FUNCTION public./' |
|
||||||
|
sed 's/$/ SET SCHEMA cartodb;/' |
|
||||||
|
sed 's/^/DO LANGUAGE plpgsql \$\$ BEGIN /' |
|
||||||
|
sed "s/$/ EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'Got % (%)', SQLERRM, SQLSTATE; END; \$\$;/" |
|
||||||
|
cat >> ${output}
|
||||||
|
|
||||||
|
# Upgrade all functions
|
||||||
|
cat ${input} | grep -v 'duplicated extension$' >> ${output}
|
||||||
|
|
||||||
# Migrate CDB_TableMetadata
|
# Migrate CDB_TableMetadata
|
||||||
cat >> ${output} <<'EOF'
|
cat >> ${output} <<'EOF'
|
||||||
@ -29,32 +44,34 @@ BEGIN
|
|||||||
DROP FUNCTION public._CDB_UserQuotaInBytes();
|
DROP FUNCTION public._CDB_UserQuotaInBytes();
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql';
|
$$ LANGUAGE 'plpgsql';
|
||||||
|
|
||||||
-- Cartodbfy tables with a trigger using 'CDB_CheckQuota' or
|
|
||||||
-- 'CDB_TableMetadata_Trigger' from the 'public' schema
|
|
||||||
select cartodb.CDB_CartodbfyTable(relname::regclass) from (
|
|
||||||
-- names of tables using public.CDB_CheckQuota or
|
|
||||||
-- public.CDB_TableMetadata_Trigger in their triggers
|
|
||||||
SELECT distinct c.relname
|
|
||||||
FROM
|
|
||||||
pg_trigger t,
|
|
||||||
pg_class c,
|
|
||||||
pg_proc p,
|
|
||||||
pg_namespace n
|
|
||||||
WHERE
|
|
||||||
n.nspname = 'public' AND
|
|
||||||
p.pronamespace = n.oid AND
|
|
||||||
p.proname IN ( 'cdb_checkquota', 'cdb_tablemetadata_trigger' ) AND
|
|
||||||
t.tgrelid = c.oid AND
|
|
||||||
p.oid = t.tgfoid
|
|
||||||
) as foo;
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Drop functions from public schema
|
## Cartodbfy tables with a trigger using 'CDB_CheckQuota' or
|
||||||
cat ${input} |
|
## 'CDB_TableMetadata_Trigger' from the 'public' schema
|
||||||
grep '^ *CREATE OR REPLACE FUNCTION' |
|
#cat >> ${output} <<'EOF'
|
||||||
grep -v ' cartodb\.' | # should only match DDL hooks
|
#select cartodb.CDB_CartodbfyTable(relname::regclass) from (
|
||||||
sed 's/).*$/);/' |
|
# -- names of tables using public.CDB_CheckQuota or
|
||||||
sed 's/DEFAULT [^ ,)]*//g' |
|
# -- public.CDB_TableMetadata_Trigger in their triggers
|
||||||
sed 's/CREATE OR REPLACE FUNCTION /DROP FUNCTION public./' |
|
# SELECT distinct c.relname
|
||||||
cat >> ${output}
|
# FROM
|
||||||
|
# pg_trigger t,
|
||||||
|
# pg_class c,
|
||||||
|
# pg_proc p,
|
||||||
|
# pg_namespace n
|
||||||
|
# WHERE
|
||||||
|
# n.nspname = 'public' AND
|
||||||
|
# p.pronamespace = n.oid AND
|
||||||
|
# p.proname IN ( 'cdb_checkquota', 'cdb_tablemetadata_trigger' ) AND
|
||||||
|
# t.tgrelid = c.oid AND
|
||||||
|
# p.oid = t.tgfoid
|
||||||
|
#) as foo;
|
||||||
|
#EOF
|
||||||
|
|
||||||
|
## Drop any leftover function from public schema (there should be none)
|
||||||
|
#cat ${input} |
|
||||||
|
# grep '^ *CREATE OR REPLACE FUNCTION' |
|
||||||
|
# grep -v ' cartodb\.' | # should only match DDL hooks
|
||||||
|
# sed 's/).*$/);/' |
|
||||||
|
# sed 's/DEFAULT [^ ,)]*//g' |
|
||||||
|
# sed 's/CREATE OR REPLACE FUNCTION /DROP FUNCTION IF EXISTS public./' |
|
||||||
|
# cat >> ${output}
|
||||||
|
Loading…
Reference in New Issue
Block a user