pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Joe Conway <mail@joeconway.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Hackers (PostgreSQL) <pgsql-hackers@postgresql.org>
Subject: Re: dblink patches for comment
Date: Mon, 01 Jun 2009 20:25:06 -0700
Message-ID: <4A249B92.5080006@joeconway.com> (raw )
In-Reply-To: <29955.1243904994@sss.pgh.pa.us >
References: <4A1C9C8C.6030405@joeconway.com >
<20613.1243466644@sss.pgh.pa.us >
<4A22DCCC.8030807@joeconway.com >
<29955.1243904994@sss.pgh.pa.us >
Tom Lane wrote:
> Joe Conway <mail@joeconway.com> writes:
>> Probably better if I break this up in logical chunks too. This patch
>> only addresses the refactoring you requested here:
>> http://archives.postgresql.org/message-id/28719.1230996378@sss.pgh.pa.us
>
> This looks sane to me in a quick once-over, though I've not tested it.
Thanks -- committed.
> A small suggestion for future patches: don't bother to reindent code
> chunks that aren't changing --- it just complicates the diff with a
> lot of uninteresting whitespace changes. You can either do that after
> review, or leave it to be done by pgindent. (Speaking of which, we
> need to schedule that soon...)
Sorry. "cvs diff -cb" seems to help (see attached). It is half the size
and much more readable.
Joe
Attachments:
[text/x-patch] dblink.2009.06.01.01-async_refactor.diff (4.1K, ../4A249B92.5080006@joeconway.com/2-dblink.2009.06.01.01-async_refactor.diff)
download | inline diff:
Index: dblink.c
===================================================================
RCS file: /opt/src/cvs/pgsql/contrib/dblink/dblink.c,v
retrieving revision 1.77
diff -c -b -r1.77 dblink.c
*** dblink.c 1 Jan 2009 17:23:31 -0000 1.77
--- dblink.c 2 Jun 2009 03:04:04 -0000
***************
*** 77,83 ****
/*
* Internal declarations
*/
! static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get);
static remoteConn *getConnectionByName(const char *name);
static HTAB *createConnHash(void);
static void createNewConnection(const char *name, remoteConn * rconn);
--- 77,83 ----
/*
* Internal declarations
*/
! static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async);
static remoteConn *getConnectionByName(const char *name);
static HTAB *createConnHash(void);
static void createNewConnection(const char *name, remoteConn * rconn);
***************
*** 689,713 ****
Datum
dblink_record(PG_FUNCTION_ARGS)
{
! return dblink_record_internal(fcinfo, false, false);
}
PG_FUNCTION_INFO_V1(dblink_send_query);
Datum
dblink_send_query(PG_FUNCTION_ARGS)
{
! return dblink_record_internal(fcinfo, true, false);
}
PG_FUNCTION_INFO_V1(dblink_get_result);
Datum
dblink_get_result(PG_FUNCTION_ARGS)
{
! return dblink_record_internal(fcinfo, true, true);
}
static Datum
! dblink_record_internal(FunctionCallInfo fcinfo, bool is_async, bool do_get)
{
FuncCallContext *funcctx;
TupleDesc tupdesc = NULL;
--- 689,735 ----
Datum
dblink_record(PG_FUNCTION_ARGS)
{
! return dblink_record_internal(fcinfo, false);
}
PG_FUNCTION_INFO_V1(dblink_send_query);
Datum
dblink_send_query(PG_FUNCTION_ARGS)
{
! PGconn *conn = NULL;
! char *connstr = NULL;
! char *sql = NULL;
! remoteConn *rconn = NULL;
! char *msg;
! bool freeconn = false;
! int retval;
!
! if (PG_NARGS() == 2)
! {
! DBLINK_GET_CONN;
! sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
! }
! else
! /* shouldn't happen */
! elog(ERROR, "wrong number of arguments");
!
! /* async query send */
! retval = PQsendQuery(conn, sql);
! if (retval != 1)
! elog(NOTICE, "%s", PQerrorMessage(conn));
!
! PG_RETURN_INT32(retval);
}
PG_FUNCTION_INFO_V1(dblink_get_result);
Datum
dblink_get_result(PG_FUNCTION_ARGS)
{
! return dblink_record_internal(fcinfo, true);
}
static Datum
! dblink_record_internal(FunctionCallInfo fcinfo, bool is_async)
{
FuncCallContext *funcctx;
TupleDesc tupdesc = NULL;
***************
*** 775,788 ****
/* shouldn't happen */
elog(ERROR, "wrong number of arguments");
}
! else if (is_async && do_get)
{
/* get async result */
if (PG_NARGS() == 2)
{
/* text,bool */
DBLINK_GET_CONN;
! fail = PG_GETARG_BOOL(2);
}
else if (PG_NARGS() == 1)
{
--- 797,810 ----
/* shouldn't happen */
elog(ERROR, "wrong number of arguments");
}
! else /* is_async */
{
/* get async result */
if (PG_NARGS() == 2)
{
/* text,bool */
DBLINK_GET_CONN;
! fail = PG_GETARG_BOOL(1);
}
else if (PG_NARGS() == 1)
{
***************
*** 793,816 ****
/* shouldn't happen */
elog(ERROR, "wrong number of arguments");
}
- else
- {
- /* send async query */
- if (PG_NARGS() == 2)
- {
- DBLINK_GET_CONN;
- sql = text_to_cstring(PG_GETARG_TEXT_PP(1));
- }
- else
- /* shouldn't happen */
- elog(ERROR, "wrong number of arguments");
- }
if (!conn)
DBLINK_CONN_NOT_AVAIL;
- if (!is_async || (is_async && do_get))
- {
/* synchronous query, or async result retrieval */
if (!is_async)
res = PQexec(conn, sql);
--- 815,824 ----
***************
*** 911,929 ****
funcctx->attinmeta = attinmeta;
MemoryContextSwitchTo(oldcontext);
- }
- else
- {
- /* async query send */
- MemoryContextSwitchTo(oldcontext);
- PG_RETURN_INT32(PQsendQuery(conn, sql));
- }
- }
-
- if (is_async && !do_get)
- {
- /* async query send -- should not happen */
- elog(ERROR, "async query send called more than once");
}
--- 919,924 ----
view thread (5+ messages) latest in thread
Message-ID: <4A249B92.5080006@joeconway.com>
Permalink: ../4A249B92.5080006@joeconway.com/
Also on: postgresql.org/message-id/4A249B92.5080006@joeconway.com
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: mail@joeconway.com, tgl@sss.pgh.pa.us
Subject: Re: dblink patches for comment
In-Reply-To: <4A249B92.5080006@joeconway.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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