Re: proposal - assign result of query to psql variable

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal - assign result of query to psql variable
Date: 2012-07-26 06:44:23
Message-ID: CAFj8pRD1hZhQYgq1sWU7Kz0rPu=phiRgSg0ejgc9fLAuTpw9uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/7/26 David Fetter <david(at)fetter(dot)org>:
> On Thu, Jul 26, 2012 at 08:31:13AM +0200, Pavel Stehule wrote:
>> 2012/7/26 David Fetter <david(at)fetter(dot)org>:
>> > On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote:
>> >> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> >> > \eset variable [, variable [..]] query -- it raise exception when
>> >> > more than one row is returned or when no row is returned
>> >>
>> >> Better would be a variant on \g, that is you type in the query and
>> >> then tell it where to put the result. We have learned the hard way
>> >> that putting SQL commands into the arguments of backslash commands
>> >> is a horrid idea. Maybe
>> >>
>> >> select x,y,... from ...
>> >> \gset var1 var2 ...
>> >
>> > How about
>> >
>> > \gset var1,,,var2,var3...
>> >
>>
>> I don't like this - you can use fake variable - and ignoring some
>> variable has no big effect on client
>
> Why assign to a variable you'll never use?

so why you get data from server, when you would not to use it ?

no offence, probably it is not hard to implement it - because we use
own parser, but I see this proposal little bit obscure

Tom - your proposal release of stored dataset just before next
statement, not like now on the end of statement?

Regards

Pavel

>
> Cheers,
> David.
>
> P.S. The bike shed should be puce with blaze orange pin-striping.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
> Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
> iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
>
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2012-07-26 10:22:19 Re: Re: [BUGS] BUG #6733: All Tables Empty After pg_upgrade (PG 9.2.0 beta 2)
Previous Message David Fetter 2012-07-26 06:36:55 Re: proposal - assign result of query to psql variable