Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-03 Thread Pavel Stehule
2013/2/3 Tom Lane : > Pavel Stehule writes: >> now missing variables is replaced by variable's name. We can implement >> some pset option - some like define what do with missing variable > >> \pset missing_variable (use_name | use_null | error ) > > No, it isn't "replaced by variable's name". Wha

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-03 Thread Tom Lane
Pavel Stehule writes: > now missing variables is replaced by variable's name. We can implement > some pset option - some like define what do with missing variable > \pset missing_variable (use_name | use_null | error ) No, it isn't "replaced by variable's name". What actually happens is we don'

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-03 Thread Pavel Stehule
2013/2/2 Tom Lane : > Shigeru Hanada writes: >> On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule >> wrote: >>> possible variants >>> >>> a) don't store NULL values - and remove existing variable when NULL >>> be assigned - it is probably best, but should be confusing for users >>> b) implement fla

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Tom Lane
Pavel Stehule writes: > 2013/2/2 Tom Lane : >> Shigeru Hanada writes: >>> +1 for a). If users want to determine whether the result was NULL, or >>> want to use substitute string for NULL result, they can use coalesce >>> in SELECT clause. Anyway the feature should be documented clearly. >> Yea

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Pavel Stehule
Hello 2013/2/2 Tom Lane : > Shigeru Hanada writes: >> On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule >> wrote: >>> possible variants >>> >>> a) don't store NULL values - and remove existing variable when NULL >>> be assigned - it is probably best, but should be confusing for users >>> b) implem

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Tom Lane
Shigeru Hanada writes: > On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule wrote: >> possible variants >> >> a) don't store NULL values - and remove existing variable when NULL >> be assigned - it is probably best, but should be confusing for users >> b) implement flag IS NULL - for variables >> c)

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Pavel Stehule
2013/2/2 Shigeru Hanada : > On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule wrote: >> possible variants >> >> a) don't store NULL values - and remove existing variable when NULL >> be assigned - it is probably best, but should be confusing for users >> b) implement flag IS NULL - for variables >> c

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Shigeru Hanada
On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule wrote: > possible variants > > a) don't store NULL values - and remove existing variable when NULL > be assigned - it is probably best, but should be confusing for users > b) implement flag IS NULL - for variables > c) use nullPrint > d) use empty Str

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-02 Thread Pavel Stehule
Hello 2013/2/1 Tom Lane : > Pavel Stehule writes: >> here is patch related to your proposal > > I looked at this a bit. It's getting there, though I still don't trust > the places where you've chosen to clear the prefix setting. (Looking at > it, I'm now not sure that I trust the implementation

Re: [HACKERS] proposal - assign result of query to psql variable

2013-02-01 Thread Tom Lane
Pavel Stehule writes: > here is patch related to your proposal I looked at this a bit. It's getting there, though I still don't trust the places where you've chosen to clear the prefix setting. (Looking at it, I'm now not sure that I trust the implementation of \g either.) However, what I want

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-31 Thread Pavel Stehule
Hello can you look, please, on updated version - it respects Tom's proposal and it is significantly reduced? Thank you Pavel Stehule 2013/1/28 Pavel Stehule : > Hello > > 2013/1/26 Tom Lane : >> Andrew Dunstan writes: >>> +1. This looks quite nifty. Maybe useful too to have a default prefix >>

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-28 Thread Pavel Stehule
Hello 2013/1/26 Tom Lane : > Andrew Dunstan writes: >> +1. This looks quite nifty. Maybe useful too to have a default prefix >> via some setting. > > Meh. I would expect that "\gset :foo" would work to specify a computed > prefix if you wanted it --- isn't that sufficient indirection? I'm not >

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-26 Thread Pavel Stehule
Hello 2013/1/26 Tom Lane : > I wrote: >> Pavel Stehule writes: >>> [ gset_13.diff ] > >> One more gripe is that the parsing logic for \gset is pretty >> unintelligible. > > After further thought, it seems to me that the problem here is an > overcomplicated definition of the \gset command; it coul

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-26 Thread Tom Lane
Andrew Dunstan writes: > +1. This looks quite nifty. Maybe useful too to have a default prefix > via some setting. Meh. I would expect that "\gset :foo" would work to specify a computed prefix if you wanted it --- isn't that sufficient indirection? I'm not thrilled with further expanding the s

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-26 Thread Andrew Dunstan
On 01/26/2013 11:42 AM, Tom Lane wrote: A probably-useful extension to this basic concept is to allow \gset to specify an optional prefix, that is select 1 as x, 2 as y \gset p_ would set p_x and p_y. This would make it easier to manage results from multiple \gset operations, and to be

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-26 Thread Tom Lane
I wrote: > Pavel Stehule writes: >> [ gset_13.diff ] > One more gripe is that the parsing logic for \gset is pretty > unintelligible. After further thought, it seems to me that the problem here is an overcomplicated definition of the \gset command; it could be made both more usable and simpler t

Re: [HACKERS] proposal - assign result of query to psql variable

2013-01-25 Thread Tom Lane
Pavel Stehule writes: > [ gset_13.diff ] I looked at this a bit. I think you need to reconsider when and how the \gset state gets cleaned up. Doing it inside StoreQueryResult is not very good because that only gets reached upon successful execution. Consider for example select 1/0 \gse

Re: [HACKERS] proposal - assign result of query to psql variable

2012-12-19 Thread Pavel Stehule
2012/12/19 Shigeru Hanada : > On Tue, Dec 18, 2012 at 2:52 AM, Pavel Stehule > wrote: >> Attached updated patch > > Seems fine. I'll mark this as "ready for committer". > > Nice work! thank you very much Regards Pavel > > -- > Shigeru HANADA -- Sent via pgsql-hackers mailing list (pgsql-h

Re: [HACKERS] proposal - assign result of query to psql variable

2012-12-18 Thread Shigeru Hanada
On Tue, Dec 18, 2012 at 2:52 AM, Pavel Stehule wrote: > Attached updated patch Seems fine. I'll mark this as "ready for committer". Nice work! -- Shigeru HANADA -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql

Re: [HACKERS] proposal - assign result of query to psql variable

2012-12-17 Thread Pavel Stehule
2012/12/17 Shigeru Hanada : > On Sun, Oct 28, 2012 at 7:16 AM, Pavel Stehule > wrote: >> Hello >> >> here is updated patch >> >> main change - it doesn't touch psql lexer - like Tom proposed >> other points respect Phil's notices > > I reviewed v12 patch. It provides gset command which works > c

Re: [HACKERS] proposal - assign result of query to psql variable

2012-12-17 Thread Shigeru Hanada
On Sun, Oct 28, 2012 at 7:16 AM, Pavel Stehule wrote: > Hello > > here is updated patch > > main change - it doesn't touch psql lexer - like Tom proposed > other points respect Phil's notices I reviewed v12 patch. It provides gset command which works consistently with other psql commands, such a

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-28 Thread Pavel Stehule
Hello here is updated patch main change - it doesn't touch psql lexer - like Tom proposed other points respect Phil's notices >> > > My first review... > > Patch applied cleanly to master and make check was fine. > > I tested it out and it operates as advertised. There were a couple > things th

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-27 Thread Pavel Stehule
Hello > > My first review... > > Patch applied cleanly to master and make check was fine. > > I tested it out and it operates as advertised. There were a couple > things that stood out to me though. > > 1) NULL values are not displayed properly after \pset null is run. > > postgres=# \pset null '(

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Pavel Stehule
2012/10/25 Tom Lane : > Pavel Stehule writes: >> 2012/10/25 Tom Lane : >>> Personally I saw no reason for this patch to touch psqlscan.l in the >>> first place. Commands such as \set just scan variable names with >>> psql_scan_slash_option(OT_NORMAL); why shouldn't this act the same? > >> it cann

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Tom Lane
Pavel Stehule writes: > 2012/10/25 Tom Lane : >> Personally I saw no reason for this patch to touch psqlscan.l in the >> first place. Commands such as \set just scan variable names with >> psql_scan_slash_option(OT_NORMAL); why shouldn't this act the same? > it cannot be same, because current sc

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Pavel Stehule
2012/10/25 Tom Lane : > Alvaro Herrera writes: >> I gave this a look. I think it needs to be revised by somebody with a >> better understanding of scanner (flex) than me, but I didn't like the >> changes in psqlscan.l at all; the new pattern is too unlike the >> rest of the surrounding patterns,

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Alvaro Herrera
Tom Lane escribió: > Alvaro Herrera writes: > > I gave this a look. I think it needs to be revised by somebody with a > > better understanding of scanner (flex) than me, but I didn't like the > > changes in psqlscan.l at all; the new pattern is too unlike the > > rest of the surrounding patterns

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Tom Lane
Alvaro Herrera writes: > I gave this a look. I think it needs to be revised by somebody with a > better understanding of scanner (flex) than me, but I didn't like the > changes in psqlscan.l at all; the new pattern is too unlike the > rest of the surrounding patterns, and furthermore it has been

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-25 Thread Alvaro Herrera
I gave this a look. I think it needs to be revised by somebody with a better understanding of scanner (flex) than me, but I didn't like the changes in psqlscan.l at all; the new pattern is too unlike the rest of the surrounding patterns, and furthermore it has been placed within the block that sa

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-24 Thread Phil Sorber
On Tue, Oct 16, 2012 at 12:24 PM, Pavel Stehule wrote: > 2012/10/16 Shigeru HANADA : >> Hi Pavel, >> >> On Tue, Oct 16, 2012 at 6:59 AM, Pavel Stehule >> wrote: >>> here is updated patch, I moved lot of code from lexer to command.com, >>> and now more \gset doesn't disable other backslash command

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-16 Thread Pavel Stehule
2012/10/16 Shigeru HANADA : > Hi Pavel, > > On Tue, Oct 16, 2012 at 6:59 AM, Pavel Stehule > wrote: >> here is updated patch, I moved lot of code from lexer to command.com, >> and now more \gset doesn't disable other backslash commands on same >> line. > > * lexer changes > IIUC, new function psql

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-16 Thread Pavel Stehule
Hello here is updated patch, I moved lot of code from lexer to command.com, and now more \gset doesn't disable other backslash commands on same line. Regards Pavel 2012/10/15 Pavel Stehule : > 2012/10/15 Pavel Stehule : >> 2012/10/15 Shigeru HANADA : >>> Hi Pavel, >>> >>> First of all, I'm sorr

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-16 Thread Shigeru HANADA
Hi Pavel, On Tue, Oct 16, 2012 at 6:59 AM, Pavel Stehule wrote: > here is updated patch, I moved lot of code from lexer to command.com, > and now more \gset doesn't disable other backslash commands on same > line. * lexer changes IIUC, new function psql_scan_varlist_varname scans input and retur

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-15 Thread Pavel Stehule
2012/10/15 Pavel Stehule : > 2012/10/15 Shigeru HANADA : >> Hi Pavel, >> >> First of all, I'm sorry that my previous review was rough. I looked >> your patch and existing code closely again. >> >> On 2012/10/15, at 12:57, Pavel Stehule wrote: >>> 2012/10/14 Tom Lane : * ExecQueryUsingCursor'

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-15 Thread Pavel Stehule
2012/10/15 Shigeru HANADA : > Hi Pavel, > > First of all, I'm sorry that my previous review was rough. I looked > your patch and existing code closely again. > > On 2012/10/15, at 12:57, Pavel Stehule wrote: >> 2012/10/14 Tom Lane : >>> * ExecQueryUsingCursor's concept of how to process command r

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-15 Thread Shigeru HANADA
Hi Pavel, First of all, I'm sorry that my previous review was rough. I looked your patch and existing code closely again. On 2012/10/15, at 12:57, Pavel Stehule wrote: > 2012/10/14 Tom Lane : >> * ExecQueryUsingCursor's concept of how to process command results >> (why? surely we don't need \g

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-15 Thread Pavel Stehule
2012/10/15 Pavel Stehule : > Hello > > 2012/10/14 Tom Lane : >> Pavel Stehule writes: >>> [ gset_08.diff ] >> >> In the course of adding a new backslash command, this patch manages to >> touch: >> >> * the main loop's concept of what types of backslash commands exist >> (PSQL_CMD_NOSEND ... what

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-15 Thread Pavel Stehule
Hello 2012/10/14 Tom Lane : > Pavel Stehule writes: >> [ gset_08.diff ] > > In the course of adding a new backslash command, this patch manages to > touch: > > * the main loop's concept of what types of backslash commands exist > (PSQL_CMD_NOSEND ... what's the point of that, rather than making

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-14 Thread Pavel Stehule
Hello fast reply 2012/10/14 Tom Lane : > Pavel Stehule writes: >> [ gset_08.diff ] > > In the course of adding a new backslash command, this patch manages to > touch: > > * the main loop's concept of what types of backslash commands exist > (PSQL_CMD_NOSEND ... what's the point of that, rather

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-14 Thread Tom Lane
Pavel Stehule writes: > [ gset_08.diff ] In the course of adding a new backslash command, this patch manages to touch: * the main loop's concept of what types of backslash commands exist (PSQL_CMD_NOSEND ... what's the point of that, rather than making this work the same as \g?) * SendQuery'

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-14 Thread Shigeru HANADA
Hi Pavel, On Sat, Oct 13, 2012 at 12:58 AM, Pavel Stehule wrote: * merge Shigeru's doc patch * rename psql regression test from "psql" to "psql_cmd" Those changes seem good. Besides, I found an error message which doesn't end with '¥n' in common.c. In general, messages passed to psql_erro

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-14 Thread Pavel Stehule
Hello 2012/10/14 Erik Rijkers : > On Sat, October 13, 2012 19:26, Pavel Stehule wrote: >> 2012/10/13 Shigeru HANADA : >>> After you determine whether it's ok or unnecessary, I'll mark this patch as >>> "Ready for committer". >>> >> > > I found this behaviour which I think must count as a bug. > \g

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-13 Thread Erik Rijkers
On Sat, October 13, 2012 19:26, Pavel Stehule wrote: > 2012/10/13 Shigeru HANADA : >> After you determine whether it's ok or unnecessary, I'll mark this patch as >> "Ready for committer". >> > I found this behaviour which I think must count as a bug. \gset doesn't allow more \\-separated lines beh

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-13 Thread Pavel Stehule
2012/10/13 Shigeru HANADA : > Hi Pavel, > > > On Sat, Oct 13, 2012 at 12:58 AM, Pavel Stehule > wrote: >> >> * merge Shigeru's doc patch >> * rename psql regression test from "psql" to "psql_cmd" > > > Those changes seem good. > > Besides, I found an error message which doesn't end with '¥n' in co

Re: [HACKERS] proposal - assign result of query to psql variable

2012-10-12 Thread Pavel Stehule
Hello here is updated version of gset patch. * merge Shigeru's doc patch * rename psql regression test from "psql" to "psql_cmd" Regards Pavel Stehule 2012/9/27 Pavel Stehule : > Hello > > 2012/9/21 Shigeru HANADA : >> Hi Pavel, >> >> (2012/09/21 2:01), Pavel Stehule wrote: - Is it inten

Re: [HACKERS] proposal - assign result of query to psql variable

2012-09-27 Thread Pavel Stehule
Hello 2012/9/21 Shigeru HANADA : > Hi Pavel, > > (2012/09/21 2:01), Pavel Stehule wrote: >>> - Is it intentional that \gset can set special variables such as >>> AUTOCOMMIT and HOST? I don't see any downside for this behavior, >>> because \set also can do that, but it is not documented nor tested

Re: [HACKERS] proposal - assign result of query to psql variable

2012-09-21 Thread Shigeru HANADA
Hi Pavel, (2012/09/21 2:01), Pavel Stehule wrote: >> - Is it intentional that \gset can set special variables such as >> AUTOCOMMIT and HOST? I don't see any downside for this behavior, >> because \set also can do that, but it is not documented nor tested at all. >> > > I use a same "SetVariable

Re: [HACKERS] proposal - assign result of query to psql variable

2012-09-21 Thread Pavel Stehule
Hello 2012/9/19 Shigeru HANADA : > On Fri, Aug 10, 2012 at 3:21 AM, Pavel Stehule > wrote: >> there is new version of this patch >> >> * cleaned var list parser >> * new regress tests >> * support FETCH_COUNT > 0 > > Here are my review comments. > > Submission > == > The patch is formatte

Re: [HACKERS] proposal - assign result of query to psql variable

2012-09-19 Thread Shigeru HANADA
On Fri, Aug 10, 2012 at 3:21 AM, Pavel Stehule wrote: > there is new version of this patch > > * cleaned var list parser > * new regress tests > * support FETCH_COUNT > 0 Here are my review comments. Submission == The patch is formatted in context diff style, and it could be applied clea

Re: [HACKERS] proposal - assign result of query to psql variable

2012-08-09 Thread Pavel Stehule
Hello there is new version of this patch * cleaned var list parser * new regress tests * support FETCH_COUNT > 0 Regards Pavel Stehule 2012/8/1 David Fetter : > On Sat, Jul 28, 2012 at 06:11:21PM +0200, Pavel Stehule wrote: >> Hello >> >> 2012/7/27 Tom Lane : >> > Pavel Stehule writes: >> >>

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-31 Thread David Fetter
On Sat, Jul 28, 2012 at 06:11:21PM +0200, Pavel Stehule wrote: > Hello > > 2012/7/27 Tom Lane : > > Pavel Stehule writes: > >> 2012/7/26 David Fetter : > > How about > > \gset var1,,,var2,var3... > > > I don't like this - you can use fake variable - and ignoring some > variable

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-28 Thread Pavel Stehule
Hello 2012/7/27 Tom Lane : > Pavel Stehule writes: >> 2012/7/26 David Fetter : > 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? > >> s

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-26 Thread Tom Lane
Pavel Stehule writes: > 2012/7/26 David Fetter : 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

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread Pavel Stehule
2012/7/26 David Fetter : > On Thu, Jul 26, 2012 at 08:31:13AM +0200, Pavel Stehule wrote: >> 2012/7/26 David Fetter : >> > On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: >> >> Pavel Stehule writes: >> >> > \eset variable [, variable [..]] query -- it raise exception when >> >> > more t

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread David Fetter
On Thu, Jul 26, 2012 at 08:31:13AM +0200, Pavel Stehule wrote: > 2012/7/26 David Fetter : > > On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: > >> Pavel Stehule writes: > >> > \eset variable [, variable [..]] query -- it raise exception when > >> > more than one row is returned or when

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread Pavel Stehule
2012/7/26 David Fetter : > On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: >> Pavel Stehule 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 typ

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread David Fetter
On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: > Pavel Stehule 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

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread Pavel Stehule
2012/7/26 Tom Lane : > Pavel Stehule 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 lea

Re: [HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread Tom Lane
Pavel Stehule 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

[HACKERS] proposal - assign result of query to psql variable

2012-07-25 Thread Pavel Stehule
Hello we cannot actually store result of query to psql variable I propose a new slash statement "\eset for this purpose Syntax: \eset variable [, variable [..]] query -- it raise exception when more than one row is returned or when no row is returned Usage: \eset var1, var2 select version(),