FDW - Can't query data from remote server using a non-superuser
proddata opened this issue · comments
Georg Traar commented
CrateDB version
5.7.0-SNAPSHOT-267e58a
CrateDB setup information
local single node
Azure PostgreSQL server (remote)
Problem description
Can't query a remote postgres server when using any non-superuser
Steps to Reproduce
PostgreSQL:
CREATE TABLE georg_text (txt TEXT);
insert into georg_text values ('Hello');
CrateDB:
CREATE USER georg;
GRANT ALL TO georg;
SET SESSION AUTHORIZATION georg;
SELECT current_user;
+--------------+
| CURRENT_USER |
+--------------+
| georg |
+--------------+
SELECT 1 row in set (0.070 sec)
CREATE SERVER azure_postgres FOREIGN DATA WRAPPER jdbc OPTIONS (url 'jdbc:postgresql://xxxxxx.postgres.database.azure.com:5432/postgres');
-- CREATE OK, 1 row affected (0.093 sec)
CREATE USER MAPPING FOR georg SERVER azure_postgres OPTIONS ("user" 'pgcrate', password 'xxxxxxxxx');
-- CREATE OK, 1 row affected (0.050 sec)
CREATE FOREIGN TABLE local_schema.georg_text (txt text) SERVER azure_postgres OPTIONS (schema_name 'public');
-- CREATE OK, 1 row affected (0.069 sec)
SELECT * FROM local_schema.georg_text;
-- UnsupportedFeatureException[Only a super user can connect to localhost unless `fdw.allow_local` is set to true]
Actual Result
UnsupportedFeatureException[Only a super user can connect to localhost unless `fdw.allow_local` is set to true]
Expected Result
+-------+
| txt |
+-------+
| Hello |
+-------+
SELECT 1 row in set (1.167 sec)
jeeminso commented
Thanks for reporting @proddata.
The bug is caused by
that cannot parse
jdbc:postgresql:...
properly.
I think we should use something like https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/Driver.html#parseURL-java.lang.String-java.util.Properties-