commit
c4980a90f9
3
Makefile
3
Makefile
@ -1,7 +1,7 @@
|
|||||||
# cartodb/Makefile
|
# cartodb/Makefile
|
||||||
|
|
||||||
EXTENSION = cartodb
|
EXTENSION = cartodb
|
||||||
EXTVERSION = 0.22.2
|
EXTVERSION = 0.23.0
|
||||||
|
|
||||||
SED = sed
|
SED = sed
|
||||||
AWK = awk
|
AWK = awk
|
||||||
@ -88,6 +88,7 @@ UPGRADABLE = \
|
|||||||
0.22.0 \
|
0.22.0 \
|
||||||
0.22.1 \
|
0.22.1 \
|
||||||
0.22.2 \
|
0.22.2 \
|
||||||
|
0.23.0 \
|
||||||
$(EXTVERSION)dev \
|
$(EXTVERSION)dev \
|
||||||
$(EXTVERSION)next \
|
$(EXTVERSION)next \
|
||||||
$(END)
|
$(END)
|
||||||
|
3
NEWS.md
3
NEWS.md
@ -1,3 +1,6 @@
|
|||||||
|
0.23.0 (2018-07-03)
|
||||||
|
* Add a new helper function `_CDB_Table_Exists(table_name_with_optional_schema TEXT)` #332
|
||||||
|
|
||||||
0.22.2 (2018-05-29)
|
0.22.2 (2018-05-29)
|
||||||
* Fix: Fix hyphenates usernames in 0.22.1 fix (#331)
|
* Fix: Fix hyphenates usernames in 0.22.1 fix (#331)
|
||||||
|
|
||||||
|
@ -158,3 +158,20 @@ BEGIN
|
|||||||
RETURN left(string, (i - 1));
|
RETURN left(string, (i - 1));
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE 'plpgsql' IMMUTABLE PARALLEL SAFE;
|
$$ LANGUAGE 'plpgsql' IMMUTABLE PARALLEL SAFE;
|
||||||
|
|
||||||
|
|
||||||
|
-- Checks if a given text representing a qualified or unqualified table name (relation)
|
||||||
|
-- actually exists in the database. It is meant to be used as a guard for other function/queries.
|
||||||
|
CREATE OR REPLACE FUNCTION cartodb._CDB_Table_Exists(table_name_with_optional_schema TEXT)
|
||||||
|
RETURNS bool
|
||||||
|
AS $$
|
||||||
|
DECLARE
|
||||||
|
table_exists bool := false;
|
||||||
|
BEGIN
|
||||||
|
table_exists := EXISTS(SELECT * FROM pg_class WHERE table_name_with_optional_schema::regclass::oid = oid AND relkind = 'r');
|
||||||
|
RETURN table_exists;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN invalid_schema_name OR undefined_table THEN
|
||||||
|
RETURN false;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE PLPGSQL VOLATILE PARALLEL UNSAFE;
|
||||||
|
@ -126,3 +126,13 @@ SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 6);
|
|||||||
|
|
||||||
-- Test _CDB_Octet_Truncate UTF8 case
|
-- Test _CDB_Octet_Truncate UTF8 case
|
||||||
SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 7);
|
SELECT * FROM cartodb._CDB_Octet_Truncate('piraña', 7);
|
||||||
|
|
||||||
|
-- Test _CDB_Table_Exists
|
||||||
|
CREATE TABLE public.this_table_exists();
|
||||||
|
SELECT cartodb._CDB_Table_Exists('this_table_does_not_exist');
|
||||||
|
SELECT cartodb._CDB_Table_Exists('this_schema_does_not_exist.this_table_does_not_exist');
|
||||||
|
SELECT cartodb._CDB_Table_Exists('this_table_exists');
|
||||||
|
SELECT cartodb._CDB_Table_Exists('public.this_table_exists');
|
||||||
|
SELECT cartodb._CDB_Table_Exists('raster_overviews'); -- view created by postgis
|
||||||
|
SELECT cartodb._CDB_Table_Exists('public.raster_overviews');
|
||||||
|
DROP TABLE public.this_table_exists
|
||||||
|
@ -57,3 +57,11 @@ DROP TABLE
|
|||||||
pira
|
pira
|
||||||
pirañ
|
pirañ
|
||||||
piraña
|
piraña
|
||||||
|
CREATE TABLE
|
||||||
|
f
|
||||||
|
f
|
||||||
|
t
|
||||||
|
t
|
||||||
|
f
|
||||||
|
f
|
||||||
|
DROP TABLE
|
||||||
|
Loading…
Reference in New Issue
Block a user