From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Petr Jelinek <pjmodos(at)pjmodos(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Proposal: USING clause for DO statement |
Date: | 2009-11-21 19:40:02 |
Message-ID: | 26839.1258832402@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> See my earlier comment:
>> Perhaps part of the problem is that psql can't interpolate its
>> variable into strings. Solving that might lessen the impetus for this,
>> and have other uses besides.
It seems to me that this is sliding down the wrong slope. You're
basically assuming that psql itself is or should be a programming
language. It's not. The variable mechanism is an enormous kluge
with limited flexibility caused by a horrid syntax; and psql hasn't
got any control structures at all.
I think Petr was on the right track. What people really want is not
psql scripts but plpgsql scripts. DO effectively gives that to them,
with a few characters' worth of overhead. The problem they have to
solve is to interpolate actual-parameter values into such a script;
but it's not clear to me that that's noticeably harder than getting
such values into a psql script. I foresee people doing things like
psql -c 'DO $$'"declare x int := $SHELLVARIABLE; ... "'$$;' ...
The fact that $ is special to the shell as well as to DO is
kind of a PITA here, but it's not that hard to work around.
The main limitation of this type of approach is that it's hard to
properly quote a variable value that might contain any random character
sequence. However, that's also true of the variable-interpolation stuff
Pavel was proposing. In any case I don't think that "getting stuff from
psql variables into a DO script" is the way to define the problem.
It's "getting stuff from shell variables into a DO script" that is the
real-world problem. Maybe psql is the wrong tool altogether.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-11-21 19:42:04 | Re: Hot standby and removing VACUUM FULL |
Previous Message | Greg Smith | 2009-11-21 19:32:49 | Re: Hot standby and removing VACUUM FULL |