do { \
char *conname_or_str = text_to_cstring(PG_GETARG_TEXT_PP(0)); \
rconn = getConnectionByName(conname_or_str); \
- if(rconn) \
+ if (rconn) \
{ \
conn = rconn->conn; \
+ conname = conname_or_str; \
} \
else \
{ \
#define DBLINK_GET_NAMED_CONN \
do { \
- char *conname = text_to_cstring(PG_GETARG_TEXT_PP(0)); \
+ conname = text_to_cstring(PG_GETARG_TEXT_PP(0)); \
rconn = getConnectionByName(conname); \
- if(rconn) \
+ if (rconn) \
conn = rconn->conn; \
else \
DBLINK_CONN_NOT_AVAIL; \
Datum
dblink_send_query(PG_FUNCTION_ARGS)
{
+ char *conname = NULL;
PGconn *conn = NULL;
char *sql = NULL;
remoteConn *rconn = NULL;
Datum
dblink_is_busy(PG_FUNCTION_ARGS)
{
+ char *conname = NULL;
PGconn *conn = NULL;
remoteConn *rconn = NULL;
dblink_cancel_query(PG_FUNCTION_ARGS)
{
int res = 0;
+ char *conname = NULL;
PGconn *conn = NULL;
remoteConn *rconn = NULL;
PGcancel *cancel;
dblink_error_message(PG_FUNCTION_ARGS)
{
char *msg;
+ char *conname = NULL;
PGconn *conn = NULL;
remoteConn *rconn = NULL;
Datum
dblink_get_notify(PG_FUNCTION_ARGS)
{
+ char *conname = NULL;
PGconn *conn = NULL;
remoteConn *rconn = NULL;
PGnotify *notify;
FROM dblink('myconn','SELECT * FROM foobar',false) AS t(a int, b text, c text[])
WHERE t.a > 7;
NOTICE: relation "foobar" does not exist
-CONTEXT: Error occurred on dblink connection named "unnamed": could not execute query.
+CONTEXT: Error occurred on dblink connection named "myconn": could not execute query.
a | b | c
---+---+---
(0 rows)
-- this should fail because there is no open transaction
SELECT dblink_exec('myconn','DECLARE xact_test CURSOR FOR SELECT * FROM foo');
ERROR: DECLARE CURSOR can only be used in transaction blocks
-CONTEXT: Error occurred on dblink connection named "unnamed": could not execute command.
+CONTEXT: Error occurred on dblink connection named "myconn": could not execute command.
-- reset remote transaction state
SELECT dblink_exec('myconn','ABORT');
dblink_exec