dblink module printing unnamed connection (with commit acaf7ccb94)

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: dblink module printing unnamed connection (with commit acaf7ccb94)
Date: 2017-03-23 05:38:04
Message-ID: CAGPqQf1WVpyL7Zaoo=u1xNGtaYusABXqbW56hT0SWbA29GmAfQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,

DBLINK contrib module started showing :"unnamed" connection name.

Consider the below test:

postgres=# CREATE ROLE alice NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN
PASSWORD 'wonderland';
CREATE ROLE
postgres=# GRANT EXECUTE ON FUNCTION dblink_connect_u(text,text) to alice;
GRANT
postgres=# \c postgres alice
You are now connected to database "postgres" as user "alice".
postgres=> SELECT dblink_connect_u('sm_conn_30','dbname=postgres user=alice
password=wonderland');
dblink_connect_u
------------------
OK
(1 row)

postgres=> SELECT * FROM dblink_send_query('sm_conn_30','SELECT
pg_stat_reset()') as dgr;
dgr
-----
1
(1 row)

postgres=> SELECT * FROM dblink_get_result('sm_conn_30') AS dgr(curr_user
boolean);
ERROR: permission denied for function pg_stat_reset
CONTEXT: Error occurred on dblink connection named "*unnamed*": could not
execute query.

This started with below commit:

commit acaf7ccb94a3916ea83712671a3563f0eb595558
Author: Peter Eisentraut <peter_e(at)gmx(dot)net>
Date: Sun Dec 25 12:00:00 2016 -0500

dblink: Replace some macros by static functions

Also remove some unused code and the no longer useful dblink.h file.

Reviewed-by: Tsunakawa, Takayuki <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>

Before this, macro used to assign the conname local variable; I quickly
worked
on the fix and attached patch do fix the issues. Patch assign the conname
local variable, so that error context show the correct connection name.

Regards,
Rushabh Lathia
www.EnterpriseDB.com

Attachment Content-Type Size
dblink_error_context.patch text/x-patch 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2017-03-23 05:54:02 Re: GUC for cleanup indexes threshold.
Previous Message Haribabu Kommi 2017-03-23 05:33:54 Re: [WIP] RE: DECLARE STATEMENT setting up a connection in ECPG