From aed88fd958a7e38f07e820828ba97f208cdf31d2 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Tue, 22 Oct 2019 15:29:45 +0200 Subject: [PATCH] Force all PG12 to use plpython3u --- .travis.yml | 2 +- Makefile | 12 +++-- NEWS.md | 3 ++ test/CDB_OAuth_expect.pg12 | 90 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 test/CDB_OAuth_expect.pg12 diff --git a/.travis.yml b/.travis.yml index e2358a3..58847e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: - if [[ $POSTGRESQL_VERSION == '9.6' ]]; then sudo apt-get install -y postgresql-contrib-9.6; fi; - sudo apt-get install -y --allow-unauthenticated postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION-scripts postgis # For pre12, install plpython2. For PG12 install plpython3 and make it default - - if [[ $POSTGRESQL_VERSION != '12' ]]; then sudo apt-get install -y postgresql-plpython-$POSTGRESQL_VERSION && sudo pip install redis==2.4.9; else sudo apt-get install -y postgresql-plpython3-12 && find . \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/plpythonu/plpython3u/g' && pip3 install redis; fi; + - if [[ $POSTGRESQL_VERSION != '12' ]]; then sudo apt-get install -y postgresql-plpython-$POSTGRESQL_VERSION && sudo pip install redis==2.4.9; else sudo apt-get install -y postgresql-plpython3-12 && pip3 install redis==2.4.9; fi; - sudo pg_dropcluster --stop $POSTGRESQL_VERSION main - sudo rm -rf /etc/postgresql/$POSTGRESQL_VERSION /var/lib/postgresql/$POSTGRESQL_VERSION - sudo pg_createcluster -u postgres $POSTGRESQL_VERSION main -- --auth-local trust --auth-host password diff --git a/Makefile b/Makefile index f59fa62..885e0da 100644 --- a/Makefile +++ b/Makefile @@ -134,12 +134,18 @@ PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) PG_VERSION := $(shell $(PG_CONFIG) --version | $(AWK) '{split($$2,a,"."); print a[1]}') +PG_12_GE := $(shell [ $(PG_VERSION) -ge 12 ] && echo true) +PLPYTHONU := "plpythonu" +ifeq ($(PG_12_GE), true) +PLPYTHONU := "plpython3u" +endif $(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_version.sql Makefile echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@ cat $(CDBSCRIPTS) | \ $(SED) -e 's/@extschema@/cartodb/g' \ - -e "s/@postgisschema@/public/g" >> $@ + -e 's/@postgisschema@/public/g' \ + -e 's/plpythonu/$(PLPYTHONU)/g' >> $@ echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@ cat cartodb_version.sql >> $@ @@ -153,10 +159,10 @@ $(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql: $(EXTENSION)--$(EXTVERSION). cp $< $@ $(EXTENSION).control: $(EXTENSION).control.in Makefile - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' $< > $@ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/g' -e 's/plpythonu/$(PLPYTHONU)/g' $< > $@ cartodb_version.sql: cartodb_version.sql.in Makefile $(GITDIR)/index - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" $< > $@ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' $< > $@ # Needed for consistent `echo` results with backslashes SHELL = bash diff --git a/NEWS.md b/NEWS.md index 0ebb16e..3213def 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +0.32.0 (XXXX-XX-XX) +* Make PG12 depend on plpython3u instead of plpythonu + 0.31.0 (2019-10-08) * Ghost tables: Add missing tags (#370) * Set search_path in security definer functions. diff --git a/test/CDB_OAuth_expect.pg12 b/test/CDB_OAuth_expect.pg12 new file mode 100644 index 0000000..73767d2 --- /dev/null +++ b/test/CDB_OAuth_expect.pg12 @@ -0,0 +1,90 @@ + +CREATE TABLE +INSERT 0 1 +SELECT 1 +CREATE VIEW +SELECT 1 +SELECT 1 +1 +1 +1 +1 +1 +ERROR: permission denied for table test +ERROR: permission denied for table test_tablesas +ERROR: permission denied for view test_view +ERROR: permission denied for materialized view test_mview +ERROR: permission denied for table test_selectinto +DROP TABLE +DROP VIEW +DROP MATERIALIZED VIEW +DROP TABLE +DROP TABLE +NOTICE: event trigger "oauth_reassign_tables_trigger" does not exist, skipping + +CREATE TABLE +INSERT 0 1 +SELECT 1 +CREATE VIEW +SELECT 1 +SELECT 1 +1 +1 +1 +1 +1 +ERROR: permission denied for table test2 +ERROR: permission denied for table test2_tablesas +ERROR: permission denied for view test2_view +ERROR: permission denied for materialized view test2_mview +ERROR: permission denied for table test2_selectinto +DROP TABLE +DROP VIEW +DROP MATERIALIZED VIEW +DROP TABLE +DROP TABLE + +CREATE TABLE +INSERT 0 1 +SELECT 1 +CREATE VIEW +SELECT 1 +SELECT 1 +1 +1 +1 +1 +1 +ERROR: permission denied for table test3 +ERROR: permission denied for table test3_tablesas +ERROR: permission denied for view test3_view +ERROR: permission denied for materialized view test3_mview +ERROR: permission denied for table test3_selectinto +DROP TABLE +DROP VIEW +DROP MATERIALIZED VIEW +DROP TABLE +DROP TABLE + +CREATE TABLE +INSERT 0 1 +SELECT 1 +CREATE VIEW +SELECT 1 +SELECT 1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +DROP TABLE +DROP VIEW +DROP MATERIALIZED VIEW +DROP TABLE +DROP TABLE +