Remove PARALLEL mode in older versions (up to 9.6)
This commit is contained in:
parent
0abc2ba250
commit
0f7a1c4882
16
Makefile
16
Makefile
@ -4,6 +4,7 @@ EXTENSION = cartodb
|
|||||||
EXTVERSION = 0.19.2
|
EXTVERSION = 0.19.2
|
||||||
|
|
||||||
SED = sed
|
SED = sed
|
||||||
|
AWK = awk
|
||||||
|
|
||||||
CDBSCRIPTS = \
|
CDBSCRIPTS = \
|
||||||
scripts-enabled/*.sql \
|
scripts-enabled/*.sql \
|
||||||
@ -109,16 +110,22 @@ REGRESS = test_setup $(REGRESS_LEGACY)
|
|||||||
|
|
||||||
PG_CONFIG = pg_config
|
PG_CONFIG = pg_config
|
||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
|
PG_PARALLEL := $(shell $(PG_CONFIG) --version | ($(AWK) '{$$2*=1000; if ($$2 >= 9600) print 1; else print 0;}' 2> /dev/null || echo 0))
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
|
|
||||||
$(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_version.sql Makefile
|
$(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_version.sql Makefile
|
||||||
echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@
|
echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@
|
||||||
cat $(CDBSCRIPTS) | \
|
cat $(CDBSCRIPTS) | \
|
||||||
$(SED) -e 's/public\./cartodb./g' \
|
$(SED) -e 's/public\./cartodb./g' \
|
||||||
-e 's/:DATABASE_USERNAME/cdb_org_admin/g' \
|
-e 's/:DATABASE_USERNAME/cdb_org_admin/g' \
|
||||||
-e "s/''public''/''cartodb''/g" >> $@
|
-e "s/''public''/''cartodb''/g" >> $@
|
||||||
echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@
|
echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@
|
||||||
cat cartodb_version.sql >> $@
|
cat cartodb_version.sql >> $@
|
||||||
|
ifeq ($(PG_PARALLEL), 0)
|
||||||
|
# Remove PARALLEL in aggregates and functions
|
||||||
|
$(SED) -e 's/PARALLEL \= [A-Z]*/''/g' \
|
||||||
|
-e 's/PARALLEL [A-Z]*/''/g' -i $@
|
||||||
|
endif
|
||||||
|
|
||||||
$(EXTENSION)--unpackaged--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql util/create_from_unpackaged.sh Makefile
|
$(EXTENSION)--unpackaged--$(EXTVERSION).sql: $(EXTENSION)--$(EXTVERSION).sql util/create_from_unpackaged.sh Makefile
|
||||||
./util/create_from_unpackaged.sh $(EXTVERSION)
|
./util/create_from_unpackaged.sh $(EXTVERSION)
|
||||||
@ -131,6 +138,9 @@ $(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql: $(EXTENSION)--$(EXTVERSION).
|
|||||||
|
|
||||||
$(EXTENSION).control: $(EXTENSION).control.in Makefile
|
$(EXTENSION).control: $(EXTENSION).control.in Makefile
|
||||||
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
|
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
|
||||||
|
ifeq ($(PG_PARALLEL), 0)
|
||||||
|
echo -e "\033[0;31mExtension created without PARALLEL support\033[0m"
|
||||||
|
endif
|
||||||
|
|
||||||
cartodb_version.sql: cartodb_version.sql.in Makefile $(GITDIR)/index
|
cartodb_version.sql: cartodb_version.sql.in Makefile $(GITDIR)/index
|
||||||
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
|
$(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
SET SCHEMA 'cartodb';
|
|
||||||
\i scripts-available/CDB_Quota.sql
|
|
||||||
\i scripts-available/CDB_TableMetadata.sql
|
|
||||||
\i scripts-available/CDB_ColumnNames.sql
|
|
||||||
\i scripts-available/CDB_ColumnType.sql
|
|
||||||
\i scripts-available/CDB_AnalysisCatalog.sql
|
|
||||||
SET SCHEMA 'public';
|
|
@ -12,6 +12,8 @@
|
|||||||
DATABASE=test_extension
|
DATABASE=test_extension
|
||||||
CMD='echo psql'
|
CMD='echo psql'
|
||||||
CMD=psql
|
CMD=psql
|
||||||
|
SED=sed
|
||||||
|
PG_PARALLEL=$(pg_config --version | awk '{$2*=1000; if ($2 >= 9600) print 1; else print 0;}' 2> /dev/null || echo 0)
|
||||||
|
|
||||||
OK=0
|
OK=0
|
||||||
PARTIALOK=0
|
PARTIALOK=0
|
||||||
@ -26,6 +28,30 @@ function clear_partial_result() {
|
|||||||
PARTIALOK=0
|
PARTIALOK=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_sql_file() {
|
||||||
|
if [[ $PG_PARALLEL -eq 0 ]]
|
||||||
|
then
|
||||||
|
tmp_file=/tmp/$(basename $1)_no_parallel
|
||||||
|
${SED} $1 -e 's/PARALLEL \= [A-Z]*/''/g' -e 's/PARALLEL [A-Z]*/''/g' > $tmp_file
|
||||||
|
${CMD} -d ${DATABASE} -f $tmp_file
|
||||||
|
rm $tmp_file
|
||||||
|
else
|
||||||
|
${CMD} -d ${DATABASE} -f $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_sql_file_schema() {
|
||||||
|
if [[ $PG_PARALLEL -eq 0 ]]
|
||||||
|
then
|
||||||
|
tmp_file=/tmp/$(basename $1)_no_parallel
|
||||||
|
${SED} $1 -e 's/PARALLEL \= [A-Z]*/''/g' -e 's/PARALLEL [A-Z]*/''/g' > $tmp_file
|
||||||
|
PGOPTIONS="$PGOPTIONS --search_path=\"$2\"" ${CMD} -d ${DATABASE} -f $tmp_file
|
||||||
|
rm $tmp_file
|
||||||
|
else
|
||||||
|
PGOPTIONS="$PGOPTIONS --search_path=\"$2\"" ${CMD} -d ${DATABASE} -f $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sql() {
|
function sql() {
|
||||||
local ROLE
|
local ROLE
|
||||||
@ -180,11 +206,15 @@ function setup_database() {
|
|||||||
sql "CREATE EXTENSION plpythonu;"
|
sql "CREATE EXTENSION plpythonu;"
|
||||||
|
|
||||||
log_info "########################### BOOTSTRAP ###########################"
|
log_info "########################### BOOTSTRAP ###########################"
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Organizations.sql
|
load_sql_file scripts-available/CDB_Organizations.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_OverviewsSupport.sql
|
load_sql_file scripts-available/CDB_OverviewsSupport.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_AnalysisSupport.sql
|
load_sql_file scripts-available/CDB_AnalysisSupport.sql
|
||||||
# trick to allow forcing a schema when loading SQL files (see: http://bit.ly/1HeLnhL)
|
|
||||||
${CMD} -d ${DATABASE} -f test/extension/run_at_cartodb_schema.sql
|
load_sql_file_schema scripts-available/CDB_Quota.sql cartodb
|
||||||
|
load_sql_file_schema scripts-available/CDB_TableMetadata.sql cartodb
|
||||||
|
load_sql_file_schema scripts-available/CDB_ColumnNames.sql cartodb
|
||||||
|
load_sql_file_schema scripts-available/CDB_ColumnType.sql cartodb
|
||||||
|
load_sql_file_schema scripts-available/CDB_AnalysisCatalog.sql cartodb
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
@ -423,8 +453,8 @@ function test_cdb_column_type() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_schema_and_table_names_with_dots() {
|
function test_cdb_querytables_schema_and_table_names_with_dots() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
|
|
||||||
sql postgres 'CREATE SCHEMA "foo.bar";'
|
sql postgres 'CREATE SCHEMA "foo.bar";'
|
||||||
sql postgres 'CREATE TABLE "foo.bar"."c.a.r.t.o.d.b" (a int);'
|
sql postgres 'CREATE TABLE "foo.bar"."c.a.r.t.o.d.b" (a int);'
|
||||||
@ -439,8 +469,8 @@ function test_cdb_querytables_schema_and_table_names_with_dots() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_table_name_with_dots() {
|
function test_cdb_querytables_table_name_with_dots() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
|
|
||||||
sql postgres 'CREATE TABLE "w.a.d.u.s" (a int);';
|
sql postgres 'CREATE TABLE "w.a.d.u.s" (a int);';
|
||||||
|
|
||||||
@ -451,8 +481,8 @@ function test_cdb_querytables_table_name_with_dots() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_happy_cases() {
|
function test_cdb_querytables_happy_cases() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
|
|
||||||
sql postgres 'CREATE TABLE wadus (a int);';
|
sql postgres 'CREATE TABLE wadus (a int);';
|
||||||
sql postgres 'CREATE TABLE "FOOBAR" (a int);';
|
sql postgres 'CREATE TABLE "FOOBAR" (a int);';
|
||||||
@ -475,17 +505,17 @@ function test_cdb_querytables_happy_cases() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_foreign_tables() {
|
function test_foreign_tables() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_TableMetadata.sql
|
load_sql_file scripts-available/CDB_TableMetadata.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Conf.sql
|
load_sql_file scripts-available/CDB_Conf.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_ForeignTable.sql
|
load_sql_file scripts-available/CDB_ForeignTable.sql
|
||||||
|
|
||||||
|
|
||||||
DATABASE=fdw_target setup_database
|
DATABASE=fdw_target setup_database
|
||||||
${CMD} -d fdw_target -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d fdw_target -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
${CMD} -d fdw_target -f scripts-available/CDB_TableMetadata.sql
|
load_sql_file scripts-available/CDB_TableMetadata.sql
|
||||||
|
|
||||||
DATABASE=fdw_target sql postgres "DO
|
DATABASE=fdw_target sql postgres "DO
|
||||||
\$\$
|
\$\$
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
DATABASE=test_organizations
|
DATABASE=test_organizations
|
||||||
CMD='echo psql'
|
|
||||||
CMD=psql
|
CMD=psql
|
||||||
|
SED=sed
|
||||||
|
PG_PARALLEL=$(pg_config --version | awk '{$2*=1000; if ($2 >= 9600) print 1; else print 0;}' 2> /dev/null || echo 0)
|
||||||
|
|
||||||
OK=0
|
OK=0
|
||||||
PARTIALOK=0
|
PARTIALOK=0
|
||||||
@ -24,6 +25,18 @@ function clear_partial_result() {
|
|||||||
PARTIALOK=0
|
PARTIALOK=0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function load_sql_file() {
|
||||||
|
if [[ $PG_PARALLEL -eq 0 ]]
|
||||||
|
then
|
||||||
|
tmp_file=/tmp/$(basename $1)_no_parallel
|
||||||
|
${SED} $1 -e 's/PARALLEL \= [A-Z]*/''/g' -e 's/PARALLEL [A-Z]*/''/g' > $tmp_file
|
||||||
|
${CMD} -d ${DATABASE} -f $tmp_file
|
||||||
|
rm $tmp_file
|
||||||
|
else
|
||||||
|
${CMD} -d ${DATABASE} -f $1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sql() {
|
function sql() {
|
||||||
local ROLE
|
local ROLE
|
||||||
@ -163,10 +176,10 @@ function setup() {
|
|||||||
sql "GRANT USAGE ON SCHEMA cartodb TO public;"
|
sql "GRANT USAGE ON SCHEMA cartodb TO public;"
|
||||||
|
|
||||||
log_info "########################### BOOTSTRAP ###########################"
|
log_info "########################### BOOTSTRAP ###########################"
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Organizations.sql
|
load_sql_file scripts-available/CDB_Organizations.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Conf.sql
|
load_sql_file scripts-available/CDB_Conf.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Groups.sql
|
load_sql_file scripts-available/CDB_Groups.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_Groups_API.sql
|
load_sql_file scripts-available/CDB_Groups_API.sql
|
||||||
|
|
||||||
log_info "############################# SETUP #############################"
|
log_info "############################# SETUP #############################"
|
||||||
create_role_and_schema cdb_org_admin
|
create_role_and_schema cdb_org_admin
|
||||||
@ -380,20 +393,20 @@ function test_user_can_read_when_it_has_permission_after_organization_permission
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_returns_schema_and_table_name() {
|
function test_cdb_querytables_returns_schema_and_table_name() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
sql cdb_testmember_1 "select * from CDB_QueryTables('select * from foo');" should "{cdb_testmember_1.foo}"
|
sql cdb_testmember_1 "select * from CDB_QueryTables('select * from foo');" should "{cdb_testmember_1.foo}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_returns_schema_and_table_name_for_several_schemas() {
|
function test_cdb_querytables_returns_schema_and_table_name_for_several_schemas() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
sql postgres "select * from CDB_QueryTables('select * from cdb_testmember_1.foo, cdb_testmember_2.bar');" should "{cdb_testmember_1.foo,cdb_testmember_2.bar}"
|
sql postgres "select * from CDB_QueryTables('select * from cdb_testmember_1.foo, cdb_testmember_2.bar');" should "{cdb_testmember_1.foo,cdb_testmember_2.bar}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_cdb_querytables_does_not_return_functions_as_part_of_the_resultset() {
|
function test_cdb_querytables_does_not_return_functions_as_part_of_the_resultset() {
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryStatements.sql
|
load_sql_file scripts-available/CDB_QueryStatements.sql
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_QueryTables.sql
|
load_sql_file scripts-available/CDB_QueryTables.sql
|
||||||
sql postgres "select * from CDB_QueryTables('select * from cdb_testmember_1.foo, cdb_testmember_2.bar, plainto_tsquery(''foo'')');" should "{cdb_testmember_1.foo,cdb_testmember_2.bar}"
|
sql postgres "select * from CDB_QueryTables('select * from cdb_testmember_1.foo, cdb_testmember_2.bar, plainto_tsquery(''foo'')');" should "{cdb_testmember_1.foo,cdb_testmember_2.bar}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +432,7 @@ function test_cdb_usertables_should_work_with_orgusers() {
|
|||||||
|
|
||||||
|
|
||||||
# test CDB_UserTables with publicuser
|
# test CDB_UserTables with publicuser
|
||||||
${CMD} -d ${DATABASE} -f scripts-available/CDB_UserTables.sql
|
load_sql_file scripts-available/CDB_UserTables.sql
|
||||||
|
|
||||||
sql publicuser "SELECT count(*) FROM CDB_UserTables('all')" should 1
|
sql publicuser "SELECT count(*) FROM CDB_UserTables('all')" should 1
|
||||||
sql publicuser "SELECT count(*) FROM CDB_UserTables('public')" should 1
|
sql publicuser "SELECT count(*) FROM CDB_UserTables('public')" should 1
|
||||||
|
Loading…
Reference in New Issue
Block a user