Copy cartodb lib/sql scripts from CDB_CartodbfyTable branch

This commit is contained in:
Sandro Santilli
2014-05-05 17:13:06 +02:00
parent 7a5ce833a4
commit 2f1fdf5a15
43 changed files with 1569 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
-- Return an array of statements found in the given query text
--
-- Curtesy of Hubert Lubaczewski (depesz)
--
CREATE OR REPLACE FUNCTION CDB_QueryStatements(query text)
RETURNS SETOF TEXT AS $$
SELECT stmt FROM (
SELECT btrim(q[1], E' \n\t\r;') as stmt FROM (
SELECT regexp_matches( $1, $REG$((?:[^'"$;]+|"[^"]*"|'(?:[^']*|'')*'|(\$[^$]*\$).*?\2)+)$REG$, 'g' ) as q
) i
) j
WHERE stmt <> '';
$$ language sql IMMUTABLE STRICT;