Re: Proposal: make "opaque" obsolete

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Rod Taylor <rbt(at)zort(dot)ca>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal: make "opaque" obsolete
Date: 2002-08-21 14:33:08
Message-ID: 20229.1029940388@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joe Conway <mail(at)joeconway(dot)com> writes:
> I'll give it a shot, but a crude gameplan/general guidance to get me
> started would be much appreciated.

AFAIK, the only code you should need to touch is in
src/include/utils/array.h
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/arrayutils.c

Look around for other references to ArrayType, but I don't *think* there
is anything else that processes arrays directly; everything else
should be calling construct_array() or deconstruct_array().

Adding an element-type OID field to the array header (ArrayType struct)
ought to be a pretty straightforward exercise. We need to debate
whether to store a typmod as well; I'm not sure that the space for it
would be justified.

The other thing that was bothering me was that the code is sloppy about
alignment: although the overall start of the data area is correctly
MAXALIGN'd, the offsets of individual data items in the array aren't
necessarily made to be multiples of the element data type's alignment
spec. This would probably result in core dumps for datatypes whose size
is not a multiple of their alignment requirement. (The only standard
one is INTERVAL. For reasons I've never quite figured out, an array
of INTERVAL doesn't provoke core dumps; seems like it should, at least
on machines where doubles actually require 8-byte alignment.) There are
a dozen or two places in arrayfuncs.c that understand the alignment
conventions for array elements, and they all need to be changed. The
att_align macro in src/include/access/tupmacs.h is probably the thing
to be using; look at the code in heaptuple.c to see how we position
field values inside a tuple, and do likewise.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sir Mordred The Traitor 2002-08-21 14:42:04 i'll promise, i'll be polite :-)
Previous Message Tom Lane 2002-08-21 14:14:40 Re: CVS broken - large file support?