Re: massive quotes? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: massive quotes?
Date
Msg-id 29697.1062278759@sss.pgh.pa.us
Whole thread Raw
In response to Re: massive quotes?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: massive quotes?
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> I think the idea would be to execute what's effectively a COPY IN during
>> the CREATE FUNCTION command, and then use the data so collected as the
>> function body.  It seems doable offhand, though we'd have to think about
>> whether this breaks any aspect of the FE/BE protocol, or whether it's
>> truly a user-friendly interface.

> Wow, imagine libpq creating a function.  Doesn't it just pass the
> entire string to the server?  How would COPY IN handle that?

I don't think libpq would know the difference.  It certainly has no idea
that a command that you send to the backend is a COPY --- it only finds
that out when the Start Copy In message comes back from the backend.
I believe the same is true of psql.  So if a CREATE FUNCTION command
were to issue Start Copy In, both those layers would happily cooperate
in passing through everything you type up to "\.".  Then we take that
pile of bits and use it as the function body string in the rest of
CREATE FUNCTION.  (None of this need have anything to do with the
existing commands/copy.c backend code, either, though some small part
of the code might be worth sharing.)

Other client libraries such as jdbc might need more surgery, though,
if they have more smarts about COPY than libpq does.

I'm also wondering why the backend need have anything at all to do with
an improved function-definition mode.  If you look in the archives you
will see speculation about inventing psql backslash commands that would
assist in entering raw function definitions by taking something you type
and suitably quotifying it.  This seems to me to be a cleaner and more
localized approach to getting much the same functionality.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Manfred Spraul
Date:
Subject: Re: Linux2.6 overcommit behaviour
Next
From: Tom Lane
Date:
Subject: Re: SetVariable