From ca367d0fe7767c5335072e5bcdb5c10db84519b5 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 31 May 2016 18:39:03 +0200 Subject: [PATCH 1/2] Use plpython version of CDB_QueryStatements --- .travis.yml | 3 ++- test/support/prepare_db.sh | 4 ++-- test/support/sql/_CDB_QueryStatements.sql | 16 ---------------- 3 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 test/support/sql/_CDB_QueryStatements.sql diff --git a/.travis.yml b/.travis.yml index 3be5a067..16adbe89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ sudo: false addons: - postgresql: "9.3" + postgresql: "9.4" apt: packages: + - postgresql-plpython-9.4 - pkg-config - libcairo2-dev - libjpeg8-dev diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index dbf27d35..0cee098b 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -75,8 +75,8 @@ if test x"$PREPARE_PGSQL" = xyes; then dropdb "${TEST_DB}" createdb -Ttemplate_postgis -EUTF8 "${TEST_DB}" || die "Could not create test database" - LOCAL_SQL_SCRIPTS='_CDB_QueryStatements windshaft.test gadm4 ported/populated_places_simple_reduced' - REMOTE_SQL_SCRIPTS='CDB_QueryTables CDB_CartodbfyTable CDB_TableMetadata CDB_ForeignTable CDB_UserTables CDB_ColumnNames CDB_AnalysisCatalog CDB_ZoomFromScale CDB_Overviews CDB_QuantileBins CDB_JenksBins CDB_HeadsTailsBins CDB_EqualIntervalBins CDB_Hexagon CDB_XYZ' + LOCAL_SQL_SCRIPTS='windshaft.test gadm4 ported/populated_places_simple_reduced' + REMOTE_SQL_SCRIPTS='CDB_QueryStatements CDB_QueryTables CDB_CartodbfyTable CDB_TableMetadata CDB_ForeignTable CDB_UserTables CDB_ColumnNames CDB_AnalysisCatalog CDB_ZoomFromScale CDB_Overviews CDB_QuantileBins CDB_JenksBins CDB_HeadsTailsBins CDB_EqualIntervalBins CDB_Hexagon CDB_XYZ' CURL_ARGS="" for i in ${REMOTE_SQL_SCRIPTS} diff --git a/test/support/sql/_CDB_QueryStatements.sql b/test/support/sql/_CDB_QueryStatements.sql deleted file mode 100644 index 27627280..00000000 --- a/test/support/sql/_CDB_QueryStatements.sql +++ /dev/null @@ -1,16 +0,0 @@ --- DUMMY IMPLEMENTATION --- Ref: https://github.com/CartoDB/cartodb-postgresql/blob/master/scripts-available/CDB_QueryStatements.sql --- Originally implemented in plpython for performance reasons - --- Return an array of statements found in the given query text --- --- Regexp curtesy of Hubert Lubaczewski (depesz) --- -CREATE OR REPLACE FUNCTION CDB_QueryStatements(query text) -RETURNS SETOF TEXT AS $$ - with matches as ( - select regexp_matches($1, $regexp$((?:[^'"$;]+|"[^"]*"|'[^']*'|(\$[^$]*\$).*?\2)+)$regexp$, 'g') as m - ) - select btrim(m[1]) from matches -$$ -LANGUAGE SQL IMMUTABLE STRICT; From 8a07f9f57edbb3d1d308d3a0149842458d56bc45 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 31 May 2016 18:45:43 +0200 Subject: [PATCH 2/2] Create plpythonu extension --- test/support/prepare_db.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/support/prepare_db.sh b/test/support/prepare_db.sh index 0cee098b..e552c954 100755 --- a/test/support/prepare_db.sh +++ b/test/support/prepare_db.sh @@ -88,6 +88,7 @@ if test x"$PREPARE_PGSQL" = xyes; then echo ${CURL_ARGS} | xargs curl -L -s fi + psql -c "CREATE EXTENSION IF NOT EXISTS plpythonu;" ${TEST_DB} ALL_SQL_SCRIPTS="${REMOTE_SQL_SCRIPTS} ${LOCAL_SQL_SCRIPTS}" for i in ${ALL_SQL_SCRIPTS} do