Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1637257772 | ||
|
|
a904b101a3 | ||
|
|
917a975baa | ||
|
|
0568b36a90 | ||
|
|
6d122462bb | ||
|
|
ffaf5e4400 | ||
|
|
2a4ecd4850 | ||
|
|
3f4479fe12 | ||
|
|
34032964c0 | ||
|
|
6c57751579 | ||
|
|
9a3ac908a9 | ||
|
|
80fdd00541 |
40
.travis.yml
40
.travis.yml
@@ -1,26 +1,38 @@
|
||||
dist: xenial
|
||||
language: c
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
env:
|
||||
- PGUSER=postgres PGDATABASE=postgres
|
||||
global:
|
||||
- PGUSER=postgres
|
||||
- PGDATABASE=postgres
|
||||
- PGOPTIONS='-c client_min_messages=NOTICE'
|
||||
- PGPORT=5432
|
||||
- POSTGIS_VERSION="2.5"
|
||||
|
||||
matrix:
|
||||
- POSTGRESQL_VERSION="9.5"
|
||||
- POSTGRESQL_VERSION="10"
|
||||
- POSTGRESQL_VERSION="11"
|
||||
|
||||
env:
|
||||
- POSTGRESQL_VERSION="9.5", POSTGIS_VERSION="2.4"
|
||||
- POSTGRESQL_VERSION="10", POSTGIS_VERSION="2.4"
|
||||
|
||||
before_install:
|
||||
- export POSTGIS_PACKAGE_VERSION=$(apt list postgis -a 2>/dev/null | grep $POSTGIS_VERSION | awk '{ print $2 }')
|
||||
- sudo service postgresql stop;
|
||||
- sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-$POSTGRESQL_VERSION postgresql-client-$POSTGRESQL_VERSION postgresql-server-dev-$POSTGRESQL_VERSION postgis=$POSTGIS_PACKAGE_VERSION postgresql-$POSTGRESQL_VERSION-postgis-scripts postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION postgresql-plpython-$POSTGRESQL_VERSION
|
||||
- echo -e "# TYPE DATABASE USER ADDRESS METHOD \nlocal all postgres trust\nlocal all all trust\nhost all all 127.0.0.1/32 trust" | sudo tee /etc/postgresql/$POSTGRESQL_VERSION/main/pg_hba.conf
|
||||
- export PGPORT=`grep ^port /etc/postgresql/$POSTGRESQL_VERSION/main/postgresql.conf | awk '{print $3}'`
|
||||
- export PGUSER=postgres
|
||||
- export PGDATABASE=postgres
|
||||
- sudo service postgresql restart $POSTGRESQL_VERSION;
|
||||
- sudo apt-get remove postgresql* -y
|
||||
- sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-$POSTGRESQL_VERSION postgresql-client-$POSTGRESQL_VERSION postgresql-server-dev-$POSTGRESQL_VERSION postgresql-common
|
||||
- if [[ $POSTGRESQL_VERSION == '9.5' ]]; then sudo apt-get install -y postgresql-contrib-9.5; fi;
|
||||
- sudo apt-get install -y --allow-unauthenticated postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION postgresql-$POSTGRESQL_VERSION-postgis-$POSTGIS_VERSION-scripts postgis postgresql-plpython-$POSTGRESQL_VERSION
|
||||
- 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 -- -A trust
|
||||
- sudo /etc/init.d/postgresql start $POSTGRESQL_VERSION || sudo journalctl -xe
|
||||
|
||||
script:
|
||||
- make
|
||||
- sudo make install
|
||||
- PGOPTIONS='-c client_min_messages=NOTICE' PGUSER=postgres make installcheck ||
|
||||
{ cat regression.diffs; false; }
|
||||
- make installcheck
|
||||
|
||||
after_failure:
|
||||
- pg_lsclusters
|
||||
- cat regression.out
|
||||
- cat regression.diffs
|
||||
|
||||
4
Makefile
4
Makefile
@@ -1,7 +1,7 @@
|
||||
# cartodb/Makefile
|
||||
|
||||
EXTENSION = cartodb
|
||||
EXTVERSION = 0.24.0
|
||||
EXTVERSION = 0.25.0
|
||||
|
||||
SED = sed
|
||||
AWK = awk
|
||||
@@ -92,6 +92,8 @@ UPGRADABLE = \
|
||||
0.23.1 \
|
||||
0.23.2 \
|
||||
0.24.0 \
|
||||
0.24.1 \
|
||||
0.25.0 \
|
||||
$(EXTVERSION)dev \
|
||||
$(EXTVERSION)next \
|
||||
$(END)
|
||||
|
||||
7
NEWS.md
7
NEWS.md
@@ -1,3 +1,10 @@
|
||||
0.25.0 (2019-02-22)
|
||||
* Add `CDB_Username` to get the cartodb username from the current PostgreSQL user
|
||||
|
||||
0.24.1 (2019-01-02)
|
||||
* Drop functions removed in 0.12 (#341)
|
||||
* Travis: Test with PostgreSQL 9.5, 10 and 11.
|
||||
|
||||
0.24.0 (2018-09-13)
|
||||
* Travis: Test with PostgreSQL 9.5 and 10.
|
||||
* _cdb_estimated_extent: Fix bug with ST_EstimatedExtent interaction.
|
||||
|
||||
14
scripts-available/CDB_DDLTriggers.sql
Normal file
14
scripts-available/CDB_DDLTriggers.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
--
|
||||
-- Legacy file
|
||||
-- Introduced again to make sure that updates do not leave dangling functions
|
||||
--
|
||||
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_handle_create_table();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_handle_drop_table();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_handle_alter_column();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_handle_drop_column();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_handle_add_column();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_disable_ddl_hooks();
|
||||
DROP FUNCTION IF EXISTS cartodb.cdb_enable_ddl_hooks();
|
||||
|
||||
|
||||
@@ -31,13 +31,17 @@ BEGIN
|
||||
|
||||
-- Then we transform to WGS84 latlon, which is
|
||||
-- where we have known coordinates for the clipping
|
||||
--
|
||||
--
|
||||
latlon_input := ST_Transform(geom, 4326);
|
||||
|
||||
-- Don't bother clipping if the geometry boundary doesn't
|
||||
-- go outside the valid extent.
|
||||
IF latlon_input @ valid_extent THEN
|
||||
RETURN ST_Transform(latlon_input, 3857);
|
||||
BEGIN
|
||||
RETURN ST_Transform(latlon_input, 3857);
|
||||
EXCEPTION WHEN OTHERS THEN
|
||||
RETURN NULL;
|
||||
END;
|
||||
END IF;
|
||||
|
||||
-- Since we're going to use ST_Intersection on input
|
||||
@@ -65,7 +69,7 @@ BEGIN
|
||||
-- We transform to web mercator
|
||||
to_webmercator := ST_Transform(clipped_input, 3857);
|
||||
|
||||
-- Finally we convert EMPTY to NULL
|
||||
-- Finally we convert EMPTY to NULL
|
||||
-- See https://github.com/Vizzuality/cartodb/issues/706
|
||||
-- And retain "multi" status
|
||||
ret := CASE WHEN ST_IsEmpty(to_webmercator) THEN NULL::geometry
|
||||
|
||||
6
scripts-available/CDB_Username.sql
Normal file
6
scripts-available/CDB_Username.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- Returns the cartodb username of the current PostgreSQL session
|
||||
CREATE OR REPLACE FUNCTION CDB_Username()
|
||||
RETURNS text
|
||||
AS $$
|
||||
SELECT CDB_Conf_GetConf(CONCAT('api_keys_', session_user))->>'username';
|
||||
$$ LANGUAGE SQL STABLE PARALLEL SAFE SECURITY DEFINER;
|
||||
1
scripts-enabled/900-CDB_DDLTriggers.sql
Symbolic link
1
scripts-enabled/900-CDB_DDLTriggers.sql
Symbolic link
@@ -0,0 +1 @@
|
||||
../scripts-available/CDB_DDLTriggers.sql
|
||||
1
scripts-enabled/920-CDB_Username.sql
Symbolic link
1
scripts-enabled/920-CDB_Username.sql
Symbolic link
@@ -0,0 +1 @@
|
||||
../scripts-available/CDB_Username.sql
|
||||
22
test/CDB_Username.sql
Normal file
22
test/CDB_Username.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
SELECT session_user; -- postgres
|
||||
SELECT CDB_Username(); -- (NULL)
|
||||
|
||||
-- Add the role fulano with api_key and connect with it
|
||||
\set QUIET on
|
||||
CREATE ROLE fulano LOGIN;
|
||||
GRANT USAGE ON SCHEMA cartodb TO fulano;
|
||||
GRANT EXECUTE ON FUNCTION CDB_Username() TO fulano;
|
||||
INSERT INTO cdb_conf (key, value) VALUES ('api_keys_fulano', '{"username": "fulanito", "permissions":[]}');
|
||||
SET SESSION AUTHORIZATION fulano;
|
||||
\set QUIET off
|
||||
|
||||
SELECT session_user; -- fulano
|
||||
SELECT CDB_Username(); -- fulanito
|
||||
|
||||
-- Remove fulano
|
||||
\set QUIET on
|
||||
SET SESSION AUTHORIZATION postgres;
|
||||
REVOKE USAGE ON SCHEMA cartodb FROM fulano;
|
||||
REVOKE EXECUTE ON FUNCTION CDB_Username() FROM fulano;
|
||||
DROP ROLE fulano;
|
||||
\set QUIET off
|
||||
4
test/CDB_Username_expect
Normal file
4
test/CDB_Username_expect
Normal file
@@ -0,0 +1,4 @@
|
||||
postgres
|
||||
|
||||
fulano
|
||||
fulanito
|
||||
Reference in New Issue
Block a user