pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feeddblink: give search_path
6+ messages / 4 participants
[nested] [flat]
* dblink: give search_path
@ 2018-04-11 06:44 Thiemo Kellner <thiemo@gelassene-pferde.biz>
0 siblings, 3 replies; 6+ messages in thread
From: Thiemo Kellner @ 2018-04-11 06:44 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
Hi all
I try to execute a function not in the Schema I connect to with
dblink. Is there way to tell dblink to set search_path in a specific
way? I have not found a solution in the documentation. I tried with
the set search_path definition in the function declarations to no avail.
Function Schema: logger
Database: act
User: act
User Default Schema: act
Kind regards
Thiemo
--
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0x8F70EFD2D972CBEF
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: dblink: give search_path
@ 2018-04-11 07:00 Rene Romero Benavides <rene.romero.b@gmail.com>
parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
2 siblings, 1 reply; 6+ messages in thread
From: Rene Romero Benavides @ 2018-04-11 07:00 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
What about setting the search path at the user level?
ALTER ROLE act SET search_path = act,logger;
Best.
2018-04-11 1:44 GMT-05:00 Thiemo Kellner <thiemo@gelassene-pferde.biz>:
> Hi all
>
> I try to execute a function not in the Schema I connect to with dblink. Is
> there way to tell dblink to set search_path in a specific way? I have not
> found a solution in the documentation. I tried with the set search_path
> definition in the function declarations to no avail.
>
> Function Schema: logger
> Database: act
> User: act
> User Default Schema: act
>
> Kind regards
>
> Thiemo
>
> --
> Öffentlicher PGP-Schlüssel: http://pgp.mit.edu/pks/lookup?
> op=get&search=0x8F70EFD2D972CBEF
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
--
El genio es 1% inspiración y 99% transpiración.
Thomas Alva Edison
http://pglearn.blogspot.mx/
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: dblink: give search_path
@ 2018-04-11 09:37 Thiemo Kellner, NHC Barhufpflege <thiemo.kellner@gelassene-pferde.biz>
parent: Rene Romero Benavides <rene.romero.b@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Thiemo Kellner, NHC Barhufpflege @ 2018-04-11 09:37 UTC (permalink / raw)
To: pgsql-general <pgsql-general@lists.postgresql.org>
Zitat von Rene Romero Benavides <rene.romero.b@gmail.com>:
> What about setting the search path at the user level?
> ALTER ROLE act SET search_path = act,logger;
>
> Best.
Thanks for the inspiration. Maybe it is best to create a dedicated
user for logging anyway...
--
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0x8F70EFD2D972CBEF
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: dblink: give search_path
@ 2018-04-11 13:24 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
2 siblings, 0 replies; 6+ messages in thread
From: Adrian Klaver @ 2018-04-11 13:24 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general <pgsql-general@lists.postgresql.org>
On 04/10/2018 11:44 PM, Thiemo Kellner wrote:
> Hi all
>
> I try to execute a function not in the Schema I connect to with dblink.
> Is there way to tell dblink to set search_path in a specific way? I have
> not found a solution in the documentation. I tried with the set
> search_path definition in the function declarations to no avail.
https://www.postgresql.org/docs/10/static/contrib-dblink-connect.html
"
Notes
If untrusted users have access to a database that has not adopted a
secure schema usage pattern, begin each session by removing
publicly-writable schemas from search_path. One could, for example, add
options=-csearch_path= to connstr. This consideration is not specific to
dblink; it applies to every interface for executing arbitrary SQL commands.
"
or schema qualify the function:
select logger.some_func();
>
> Function Schema: logger
> Database: act
> User: act
> User Default Schema: act
>
> Kind regards
>
> Thiemo
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: dblink: give search_path
@ 2018-04-11 14:26 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
2 siblings, 1 reply; 6+ messages in thread
From: Adrian Klaver @ 2018-04-11 14:26 UTC (permalink / raw)
To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general <pgsql-general@lists.postgresql.org>
On 04/10/2018 11:44 PM, Thiemo Kellner wrote:
> Hi all
>
> I try to execute a function not in the Schema I connect to with dblink.
> Is there way to tell dblink to set search_path in a specific way? I have
> not found a solution in the documentation. I tried with the set
> search_path definition in the function declarations to no avail.
In addition to my previous suggestions:
test=# SELECT public.dblink_connect('dbname=production ');
dblink_connect
----------------
OK
test=# select * from public.dblink('show search_path') as
t1(search_path text);
search_path
-------------
main
test=# select public.dblink_exec('set search_path=main,utility');
dblink_exec
-------------
SET
(1 row)
test=# select * from public.dblink('show search_path') as
t1(search_path text);
search_path
---------------
main, utility
>
> Function Schema: logger
> Database: act
> User: act
> User Default Schema: act
>
> Kind regards
>
> Thiemo
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: dblink: give search_path
@ 2018-04-17 11:23 Thiemo Kellner, NHC Barhufpflege <thiemo.kellner@gelassene-pferde.biz>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 6+ messages in thread
From: Thiemo Kellner, NHC Barhufpflege @ 2018-04-17 11:23 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Zitat von Adrian Klaver <adrian.klaver@aklaver.com>:
> In addition to my previous suggestions:
>
> test=# SELECT public.dblink_connect('dbname=production ');
> dblink_connect
> ----------------
> OK
>
> test=# select * from public.dblink('show search_path') as
> t1(search_path text);
> search_path
> -------------
> main
>
> test=# select public.dblink_exec('set search_path=main,utility');
> dblink_exec
> -------------
> SET
> (1 row)
>
> test=# select * from public.dblink('show search_path') as
> t1(search_path text);
> search_path
> ---------------
> main, utility
>
Hi Adrian. Thanks for pointing this out. I wonder why I did not think
of it myself. However, I moved to a dedicated logging user such
avoiding this Problem. I also seems a clean solution that way.
--
+49 (0)1578-772 37 37
+41 (0)78 947 36 21
Öffentlicher PGP-Schlüssel:
http://pgp.mit.edu/pks/lookup?op=get&search=0x8F70EFD2D972CBEF
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-04-17 11:23 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 06:44 dblink: give search_path Thiemo Kellner <thiemo@gelassene-pferde.biz>
2018-04-11 07:00 ` Rene Romero Benavides <rene.romero.b@gmail.com>
2018-04-11 09:37 ` Thiemo Kellner, NHC Barhufpflege <thiemo.kellner@gelassene-pferde.biz>
2018-04-11 13:24 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-04-11 14:26 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-04-17 11:23 ` Thiemo Kellner, NHC Barhufpflege <thiemo.kellner@gelassene-pferde.biz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox