2016-03-04 03:48:37 +08:00
|
|
|
-- DUMMY IMPLEMENTATION
|
|
|
|
-- Ref: https://github.com/CartoDB/cartodb-postgresql/blob/master/scripts-available/CDB_QueryStatements.sql
|
2016-03-04 07:11:06 +08:00
|
|
|
-- Originally implemented in plpython for performance reasons
|
2016-03-04 03:48:37 +08:00
|
|
|
|
2015-02-05 01:52:37 +08:00
|
|
|
-- Return an array of statements found in the given query text
|
|
|
|
--
|
|
|
|
-- Regexp curtesy of Hubert Lubaczewski (depesz)
|
|
|
|
--
|
2016-03-04 03:48:37 +08:00
|
|
|
CREATE OR REPLACE FUNCTION CDB_QueryStatements(query text)
|
2015-02-05 01:52:37 +08:00
|
|
|
RETURNS SETOF TEXT AS $$
|
2016-03-04 03:48:37 +08:00
|
|
|
with matches as (
|
|
|
|
select regexp_matches($1, $regexp$((?:[^'"$;]+|"[^"]*"|'[^']*'|(\$[^$]*\$).*?\2)+)$regexp$, 'g') as m
|
|
|
|
)
|
|
|
|
select btrim(m[1]) from matches
|
|
|
|
$$
|
|
|
|
LANGUAGE SQL IMMUTABLE STRICT;
|