Re: COPY enhancements

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Pierre Frédéric Caillaud <lists(at)peufeu(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Emmanuel Cecchet <manu(at)asterdata(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY enhancements
Date: 2009-09-11 21:21:12
Message-ID: 603c8f070909111421x1858a05ew542eccc5b50b5b33@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/9/11 Stephen Frost <sfrost(at)snowman(dot)net>:
>>>>        Postgres has a hstore data type which seems well suited for passing
>>>> key/value option pairs...
>>
>> Quite apart from any other reason, it is not builtin, so there is no way
>> that any builtin thing can use it.
>
> Clearly, that's fixable..  I think it's an interesting concept, but I
> don't know that I'd advocate it (using hstore for this in some way).

Unless I'm missing something, which is possible, this whole line of
conversation is based on a misunderstanding. Data types, like hstore,
are things that have input/output functions, index methods, and
on-disk representations. In-memory data structures require none of
these things, and can use techniques not suitable for on-disk
representations, such as pointers. The parser already has an object
called a DefElem which is well-suited for exactly the kind of option
handling we're talking about here, and hstore would not be, not only
because it's the wrong kind of object (a data type rather than an
in-memory data structure), but because a DefElem can do things that
hstore can't, like store as the associated value a list of parse
nodes.

The original reference to hstore was a suggestion that it might be
possible to pass an hstore argument to COPY rather than having to
build up a command string and pass it to EXECUTE. That may or may not
be a useful innovation - personally, I tend to think not - but it
seems to me that it would require COPY to execute an arbitrary
subquery and use the results as options. We have no other commands
that work that way to my knowledge, but beyond that, Pierre Frédéric
Caillaud seemed to be suggesting this would be an "easier" way to
implement an options syntax. Integrating hstore into core and then
making COPY able to execute a subquery to get its options is certainly
not easier than a straightforward grammar modification; it's taking a
small project and turning it into several big ones.

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2009-09-11 21:27:19 Re: COPY enhancements
Previous Message Jeff Davis 2009-09-11 21:19:20 Re: COALESCE and NULLIF semantics