diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-09-19 20:06:13 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-09-19 20:06:13 +0000 |
commit | 3290e6180fcd4b73ea1badb2d10e9bf44496cd91 (patch) | |
tree | 4eee8750313139017616681e3402113c73658557 /src/interfaces/libpq/libpq-events.c | |
parent | 4e57668da475f47242d8552df371a3dbef5205f8 (diff) | |
download | postgresql-3290e6180fcd4b73ea1badb2d10e9bf44496cd91.tar.gz postgresql-3290e6180fcd4b73ea1badb2d10e9bf44496cd91.zip |
Add a PQfireResultCreateEvents function to allow applications to mimic the
sequence of operations that libpq goes through while creating a PGresult.
Also, remove ill-considered "const" decoration on parameters passed to
event procedures.
Diffstat (limited to 'src/interfaces/libpq/libpq-events.c')
-rw-r--r-- | src/interfaces/libpq/libpq-events.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/interfaces/libpq/libpq-events.c b/src/interfaces/libpq/libpq-events.c index 9f46336a58b..8ce3f3e81c5 100644 --- a/src/interfaces/libpq/libpq-events.c +++ b/src/interfaces/libpq/libpq-events.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.2 2008/09/19 16:40:40 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.3 2008/09/19 20:06:13 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -175,3 +175,35 @@ PQresultInstanceData(const PGresult *result, PGEventProc proc) return NULL; } + +/* + * Fire RESULTCREATE events for an application-created PGresult. + * + * The conn argument can be NULL if event procedures won't use it. + */ +int +PQfireResultCreateEvents(PGconn *conn, PGresult *res) +{ + int i; + + if (!res) + return FALSE; + + for (i = 0; i < res->nEvents; i++) + { + if (!res->events[i].resultInitialized) + { + PGEventResultCreate evt; + + evt.conn = conn; + evt.result = res; + if (!res->events[i].proc(PGEVT_RESULTCREATE, &evt, + res->events[i].passThrough)) + return FALSE; + + res->events[i].resultInitialized = TRUE; + } + } + + return TRUE; +} |