Re: embedded list v2

Andres Freund <andres@2ndquadrant.com>

From: Andres Freund <andres@2ndquadrant.com>
To: pgsql-hackers@postgresql.org
Cc: Alvaro Herrera <alvherre@commandprompt.com>, Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@postgresql.org>, Peter Geoghegan <peter@2ndquadrant.com>, Bruce Momjian <bruce@momjian.us>
Date: 2012-06-28T21:55:24Z
Lists: pgsql-hackers
On Thursday, June 28, 2012 11:45:08 PM Alvaro Herrera wrote:
> Excerpts from Andres Freund's message of jue jun 28 17:06:49 -0400 2012:
> > On Thursday, June 28, 2012 10:03:26 PM Andres Freund wrote:
> > > What I wonder is how hard it would be to remove catcache.h's structs
> > > into the  implementation. Thats the reason why the old and new list
> > > implementation currently is included all over the backend...
> > 
> > Moving them into the implementation isn't possible, but catcache.h being
> > included just about everywhere simply isn't needed.
> > 
> > It being included everywhere was introduced by a series of commits from
> > Bruce: b85a965f5fc7243d0386085e12f7a6c836503b42
> > b43ebe5f83b28e06a3fd933b989aeccf0df7844a
> > e0522505bd13bc5aae993fc50b8f420665d78e96
> > and others
> > 
> > That looks broken. An implementation file not including its own header...
> > A minimal patch to fix this particular problem is attached (looks like
> > there are others in the series).
> 
> Hmm, I think this is against project policy -- we do want each header to
> be compilable separately.  I would go instead the way of splitting
> resowner.h in two or more pieces.
It was done nearly the same way in catcache.h before Bruce changed things. You 
can see still the rememnants of that in syscache.h:
/* list-search interface.  Users of this must import catcache.h too */
extern struct catclist *SearchSysCacheList(int cacheId, int nkeys,
				   Datum key1, Datum key2, Datum key3, Datum key4);

The only difference is that gcc warns if you declare a struct in a parameter - 
thats why I forward declared it explicitly...

resowner.h still compiles standalone and is still usable. You can even call 
ResourceOwnerRememberCatCacheListRef if you get the list parameter from 
somewhere else.

Andres
-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Provide some static-assertion functionality on all compilers.

  2. Add infrastructure for compile-time assertions about variable types.

  3. Remove 576 references of include files that were not needed.

  4. More include file adjustments.

  5. Allow each C include file to compile on its own by including any needed