Re: generic reloptions improvement - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: generic reloptions improvement
Date
Msg-id 20090104213108.GD26552@alvh.no-ip.org
Whole thread Raw
In response to Re: generic reloptions improvement  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: generic reloptions improvement  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-hackers
Alvaro Herrera wrote:

> Some notes about this patch:
>
> - the string type handling (basically all the new code) is untested.
> I'll have a look tomorrow at the btree test code I sent the other day to
> add a string option and see how it goes.

Okay, it was basically fine except for the attached minor correction.
Warning: I intend to commit this patch fairly soon!

As far as I can see, the new code can work with the options you've
defined in the SEPgsql code just fine.  Handling string options in
itself is fine; the complexity (as I already said) is in allocating
memory for the string if you want to store it unchanged in the bytea
stuff in relcache.  Since you're not storing the string itself but
convert it to an Oid, there's no problem.

Actually, storing the string itself works fine as long as you have a
single one, because you can define the option struct like this:

/* must follow StdRdOptions conventions */
typedef struct BtOptions
{
    int32    vl_len_;
    int        fillfactor;
    char    teststring[1];
} BtOptions;

and there are no pointers involved.  This doesn't work:

typedef struct BtOptions
{
    int32    vl_len_;
    int        fillfactor;
    char    *teststring;
} BtOptions;

because then there's a pointer, and it fails as soon as the bytea * is
copied by the relcache code.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment

pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: dblink vs SQL/MED - security and implementation details
Next
From: Alvaro Herrera
Date:
Subject: Re: generic reloptions improvement