Skip site navigation (1) Skip section navigation (2)

Re: libpq object hooks

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: libpq object hooks
Date: 2008-05-14 18:09:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
Attached is an updated patch.  The only change to this patch is that 
hookNames are now compared with strcmp rather than strcasecmp.  The 
comparisons occur in fe-mics.c (bottom of file) during PQhookData and 

Not sure this needs clarification, but PQcopyResult, PQresultAlloc and 
PQsetvalue are not part of the object hooks API.  They are part of 
libpq's result management functions (at least that is what I call them).

Hook API
- PQaddObjectHooks
- PQaddGlobalObjectHooks ** CAN BE REMOVED, SEE BELOW
- PQhookData
- PQresultHookData

Result Management (I would put PQmakeEmptyResult here)
- PQcopyResult
- PQsetvalue
- PQresultAlloc (light wrapper to internal pqResultAlloc)

PQaddGlobalObjectHooks can be removed by handling per-conn and global 
hook registeration through PQaddObjectHooks.  If the provided PGconn is 
NULL, add hooks to global libpq list:

PQaddObjectHooks(PGconn *conn, PGobjectHooks *hooks)
   if(conn == NULL)
     ;// global hook register
     ;// per-conn register

This would make the Object Hooks API 3 functions instead of 4.  The same 
rules apply to global hook registeration, do this from main() before 
using libpq as the ObjectHooks list is not thread-safe (no locking).

NOTE: The patch is called objhooks.patch which is a misleading.  The 
patch is really comprised of the API calls needed to make libpqtypes 
work.  If anyone feels this should be broken into two patches (like 
objhooks.patch and resmgnt.patch), let us know.

Andrew Chernow
eSilo, LLC
every bit counts

Attachment: objhooks.patch
Description: text/plain (31.8 KB)

In response to


pgsql-hackers by date

Next:From: Marc MunroDate: 2008-05-14 19:07:04
Subject: Surprising syntax error
Previous:From: Tom LaneDate: 2008-05-14 17:56:46
Subject: Re: missing $PostgreSQL:$

pgsql-patches by date

Next:From: davegDate: 2008-05-14 19:47:27
Subject: Re: libpq object hooks
Previous:From: Andrew ChernowDate: 2008-05-14 16:34:08
Subject: Re: libpq object hooks

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group