*** pgsql/src/interfaces/libpq/libpq-events.c 2008/09/19 16:40:40 1.2 --- pgsql/src/interfaces/libpq/libpq-events.c 2008/09/19 20:06:13 1.3 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.1 2008/09/17 04:31:08 tgl Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-events.c,v 1.2 2008/09/19 16:40:40 tgl Exp $ * *------------------------------------------------------------------------- */ *************** PQresultInstanceData(const PGresult *res *** 175,177 **** --- 175,209 ---- 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; + }