mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow creation of FDWs if the extension is in a non-default schema. Fixes #1320
Root cause:- When user change schema of already created fdw extension then while creating the new fdw we should append the <schema_name>.<fdw_handler_name>. Previously we added only <fdw_handler_name> so while executing the query it will not be able to find fdw handler name without schema name. e.g. If user changed the fdw handler 'postgres_fdw_handler' under schema 'test' then we should display the handler name under fdw as "test. postgres_fdw_handler". Solution:- With this patch, we have added <schema_name>.<fdw_handler_name> so while creating or updating the fdw, proper sql will be generated.
This commit is contained in:
@@ -689,7 +689,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=r_set)
|
||||
|
||||
for row in r_set['rows']:
|
||||
res.append({'label': row['fdwvalue'], 'value': row['fdwvalue']})
|
||||
res.append({'label': row['schema_prefix_fdw_val'], 'value': row['schema_prefix_fdw_val']})
|
||||
|
||||
return make_json_response(data=res, status=200)
|
||||
|
||||
@@ -715,7 +715,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=r_set)
|
||||
|
||||
for row in r_set['rows']:
|
||||
res.append({'label': row['fdwhan'], 'value': row['fdwhan']})
|
||||
res.append({'label': row['schema_prefix_fdw_hand'], 'value': row['schema_prefix_fdw_hand']})
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
{% if data.name %}
|
||||
CREATE FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}{% if data.fdwvalue %}
|
||||
|
||||
VALIDATOR {{ conn|qtIdent(data.fdwvalue) }}{%endif%}{% if data.fdwhan %}
|
||||
VALIDATOR {{ data.fdwvalue }}{%endif%}{% if data.fdwhan %}
|
||||
|
||||
HANDLER {{ conn|qtIdent(data.fdwhan) }}{% endif %}{% if data.fdwoptions %}
|
||||
HANDLER {{ data.fdwhan }}{% endif %}{% if data.fdwoptions %}
|
||||
|
||||
{% set addAlter = "False" %}
|
||||
{% for variable in data.fdwoptions %}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{# ============= Get the handlers of foreign data wrapper ============= #}
|
||||
SELECT proname as fdwhan FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace WHERE pronargs=0 AND prorettype=3115;
|
||||
SELECT nspname, proname as fdwhan,
|
||||
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_hand
|
||||
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
|
||||
WHERE pronargs=0 AND prorettype=3115;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{# ============= Get all the properties of foreign data wrapper ============= #}
|
||||
SELECT fdw.oid as fdwoid, fdwname as name, fdwhandler, fdwvalidator, vh.proname as fdwhan, vp.proname as fdwvalue, description,
|
||||
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl
|
||||
SELECT fdw.oid as fdwoid, fdwname as name, fdwhandler, fdwvalidator, description,
|
||||
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl,
|
||||
quote_ident(vp_nsp.nspname)||'.'||quote_ident(vp.proname) AS fdwvalue,
|
||||
quote_ident(vh_nsp.nspname)||'.'||quote_ident(vh.proname) AS fdwhan
|
||||
FROM pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_proc vh on vh.oid=fdwhandler
|
||||
LEFT OUTER JOIN pg_proc vp on vp.oid=fdwvalidator
|
||||
LEFT OUTER JOIN pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
|
||||
LEFT OUTER JOIN pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
|
||||
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
{% if fid %}
|
||||
WHERE fdw.oid={{fid}}::int
|
||||
@@ -11,4 +15,4 @@ WHERE fdw.oid={{fid}}::int
|
||||
{% if fname %}
|
||||
WHERE fdw.fdwname={{ fname|qtLiteral }}::text
|
||||
{% endif %}
|
||||
ORDER BY fdwname
|
||||
ORDER BY fdwname
|
||||
|
||||
@@ -15,7 +15,7 @@ ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
{# ============= Update foreign data wrapper validator ============= #}
|
||||
{% if data.fdwvalue and data.fdwvalue != o_data.fdwvalue %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
VALIDATOR {{ conn|qtIdent(data.fdwvalue) }};
|
||||
VALIDATOR {{ data.fdwvalue }};
|
||||
|
||||
{% endif %}
|
||||
{% if data.fdwvalue == '' and data.fdwvalue != o_data.fdwvalue %}
|
||||
@@ -26,7 +26,7 @@ ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
{# ============= Update foreign data wrapper handler ============= #}
|
||||
{% if data.fdwhan and data.fdwhan != o_data.fdwhan %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
HANDLER {{ conn|qtIdent(data.fdwhan) }};
|
||||
HANDLER {{ data.fdwhan }};
|
||||
|
||||
{% endif %}
|
||||
{% if data.fdwhan == '' and data.fdwhan != o_data.fdwhan %}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{# ============= Get the validators of foreign data wrapper ============= #}
|
||||
SELECT proname as fdwvalue FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace WHERE proargtypes[0]=1009 AND proargtypes[1]=26;
|
||||
SELECT nspname, proname as fdwvalue,
|
||||
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_val
|
||||
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
|
||||
WHERE proargtypes[0]=1009 AND proargtypes[1]=26;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
{% if data.name %}
|
||||
CREATE FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}{% if data.fdwvalue %}
|
||||
|
||||
VALIDATOR {{ conn|qtIdent(data.fdwvalue) }}{%endif%}{% if data.fdwhan %}
|
||||
VALIDATOR {{ data.fdwvalue }}{%endif%}{% if data.fdwhan %}
|
||||
|
||||
HANDLER {{ conn|qtIdent(data.fdwhan) }}{% endif %}{% if data.fdwoptions %}
|
||||
HANDLER {{ data.fdwhan }}{% endif %}{% if data.fdwoptions %}
|
||||
|
||||
{% set addAlter = "False" %}
|
||||
{% for variable in data.fdwoptions %}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{# ============= Get the handlers of foreign data wrapper ============= #}
|
||||
SELECT proname as fdwhan FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace WHERE pronargs=0 AND prorettype=3115;
|
||||
SELECT nspname, proname as fdwhan,
|
||||
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_hand
|
||||
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
|
||||
WHERE pronargs=0 AND prorettype=3115;
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
{# ============= Get all the properties of foreign data wrapper ============= #}
|
||||
SELECT fdw.oid as fdwoid, fdwname as name, fdwhandler, fdwvalidator, vh.proname as fdwhan, vp.proname as fdwvalue, description,
|
||||
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl
|
||||
SELECT fdw.oid as fdwoid, fdwname as name, fdwhandler, fdwvalidator, description,
|
||||
array_to_string(fdwoptions, ',') AS fdwoptions, pg_get_userbyid(fdwowner) as fdwowner, array_to_string(fdwacl::text[], ', ') as acl,
|
||||
quote_ident(vp_nsp.nspname)||'.'||quote_ident(vp.proname) AS fdwvalue,
|
||||
quote_ident(vh_nsp.nspname)||'.'||quote_ident(vh.proname) AS fdwhan
|
||||
FROM pg_foreign_data_wrapper fdw
|
||||
LEFT OUTER JOIN pg_proc vh on vh.oid=fdwhandler
|
||||
LEFT OUTER JOIN pg_proc vp on vp.oid=fdwvalidator
|
||||
LEFT OUTER JOIN pg_namespace vh_nsp ON vh_nsp.oid=vh.pronamespace
|
||||
LEFT OUTER JOIN pg_namespace vp_nsp ON vp_nsp.oid=vp.pronamespace
|
||||
LEFT OUTER JOIN pg_description des ON (des.objoid=fdw.oid AND des.objsubid=0 AND des.classoid='pg_foreign_data_wrapper'::regclass)
|
||||
{% if fid %}
|
||||
WHERE fdw.oid={{fid}}::int
|
||||
|
||||
@@ -15,7 +15,7 @@ ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
{# ============= Update foreign data wrapper validator ============= #}
|
||||
{% if data.fdwvalue and data.fdwvalue != o_data.fdwvalue %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
VALIDATOR {{ conn|qtIdent(data.fdwvalue) }};
|
||||
VALIDATOR {{ data.fdwvalue }};
|
||||
|
||||
{% endif %}
|
||||
{% if data.fdwvalue == '' and data.fdwvalue != o_data.fdwvalue %}
|
||||
@@ -26,7 +26,7 @@ ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
{# ============= Update foreign data wrapper handler ============= #}
|
||||
{% if data.fdwhan and data.fdwhan != o_data.fdwhan %}
|
||||
ALTER FOREIGN DATA WRAPPER {{ conn|qtIdent(data.name) }}
|
||||
HANDLER {{ conn|qtIdent(data.fdwhan) }};
|
||||
HANDLER {{ data.fdwhan }};
|
||||
|
||||
{% endif %}
|
||||
{% if data.fdwhan == '' and data.fdwhan != o_data.fdwhan %}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{# ============= Get the validators of foreign data wrapper ============= #}
|
||||
SELECT proname as fdwvalue FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace WHERE proargtypes[0]=1009 AND proargtypes[1]=26;
|
||||
SELECT nspname, proname as fdwvalue,
|
||||
quote_ident(nspname)||'.'||quote_ident(proname) AS schema_prefix_fdw_val
|
||||
FROM pg_proc p JOIN pg_namespace nsp ON nsp.oid=pronamespace
|
||||
WHERE proargtypes[0]=1009 AND proargtypes[1]=26;
|
||||
|
||||
Reference in New Issue
Block a user