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

2013-02-03 Thread Pavel Stehule
2013/2/2 Tom Lane t...@sss.pgh.pa.us: Shigeru Hanada shigeru.han...@gmail.com writes: On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule pavel.steh...@gmail.com wrote: possible variants a) don't store NULL values - and remove existing variable when NULL be assigned - it is probably best, but

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

2013-02-03 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com 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

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

2013-02-03 Thread Pavel Stehule
2013/2/3 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com 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

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

2013-02-02 Thread Pavel Stehule
Hello 2013/2/1 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com 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

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 pavel.steh...@gmail.com 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

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

2013-02-02 Thread Pavel Stehule
2013/2/2 Shigeru Hanada shigeru.han...@gmail.com: On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule pavel.steh...@gmail.com 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)

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

2013-02-02 Thread Tom Lane
Shigeru Hanada shigeru.han...@gmail.com writes: On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule pavel.steh...@gmail.com 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)

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

2013-02-02 Thread Pavel Stehule
Hello 2013/2/2 Tom Lane t...@sss.pgh.pa.us: Shigeru Hanada shigeru.han...@gmail.com writes: On Sat, Feb 2, 2013 at 7:30 PM, Pavel Stehule pavel.steh...@gmail.com wrote: possible variants a) don't store NULL values - and remove existing variable when NULL be assigned - it is probably

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

2013-02-02 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2013/2/2 Tom Lane t...@sss.pgh.pa.us: Shigeru Hanada shigeru.han...@gmail.com 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.

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

2013-02-01 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com 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

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 pavel.steh...@gmail.com: Hello 2013/1/26 Tom Lane t...@sss.pgh.pa.us: Andrew Dunstan and...@dunslane.net writes: +1. This looks

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

2013-01-28 Thread Pavel Stehule
Hello 2013/1/26 Tom Lane t...@sss.pgh.pa.us: Andrew Dunstan and...@dunslane.net 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

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

2013-01-26 Thread Tom Lane
I wrote: Pavel Stehule pavel.steh...@gmail.com 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

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

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

2013-01-26 Thread Tom Lane
Andrew Dunstan and...@dunslane.net 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

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

2013-01-26 Thread Pavel Stehule
Hello 2013/1/26 Tom Lane t...@sss.pgh.pa.us: I wrote: Pavel Stehule pavel.steh...@gmail.com 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

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

2013-01-25 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com 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

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

2012-12-19 Thread Pavel Stehule
2012/12/19 Shigeru Hanada shigeru.han...@gmail.com: On Tue, Dec 18, 2012 at 2:52 AM, Pavel Stehule pavel.steh...@gmail.com 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

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 pavel.steh...@gmail.com 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:

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 pavel.steh...@gmail.com 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

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

2012-12-17 Thread Pavel Stehule
2012/12/17 Shigeru Hanada shigeru.han...@gmail.com: On Sun, Oct 28, 2012 at 7:16 AM, Pavel Stehule pavel.steh...@gmail.com 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

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 that stood

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 xvl pattern is too unlike the rest of the surrounding patterns, and furthermore it has been placed within the block

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

2012-10-25 Thread Tom Lane
Alvaro Herrera alvhe...@2ndquadrant.com 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 xvl pattern is too unlike the rest of the surrounding patterns, and

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

2012-10-25 Thread Alvaro Herrera
Tom Lane escribió: Alvaro Herrera alvhe...@2ndquadrant.com 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 xvl pattern is too unlike the rest of the

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

2012-10-25 Thread Pavel Stehule
2012/10/25 Tom Lane t...@sss.pgh.pa.us: Alvaro Herrera alvhe...@2ndquadrant.com 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 xvl pattern is too unlike

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

2012-10-25 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2012/10/25 Tom Lane t...@sss.pgh.pa.us: 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

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

2012-10-25 Thread Pavel Stehule
2012/10/25 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2012/10/25 Tom Lane t...@sss.pgh.pa.us: 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

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 pavel.steh...@gmail.com wrote: 2012/10/16 Shigeru HANADA shigeru.han...@gmail.com: Hi Pavel, On Tue, Oct 16, 2012 at 6:59 AM, Pavel Stehule pavel.steh...@gmail.com wrote: here is updated patch, I moved lot of code from lexer to command.com,

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 pavel.steh...@gmail.com 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

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 pavel.steh...@gmail.com: 2012/10/15 Pavel Stehule pavel.steh...@gmail.com: 2012/10/15 Shigeru HANADA

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

2012-10-16 Thread Pavel Stehule
2012/10/16 Shigeru HANADA shigeru.han...@gmail.com: Hi Pavel, On Tue, Oct 16, 2012 at 6:59 AM, Pavel Stehule pavel.steh...@gmail.com 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. *

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

2012-10-15 Thread Pavel Stehule
Hello 2012/10/14 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com 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

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

2012-10-15 Thread Pavel Stehule
2012/10/15 Pavel Stehule pavel.steh...@gmail.com: Hello 2012/10/14 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com 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

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

2012-10-15 Thread Pavel Stehule
2012/10/15 Shigeru HANADA shigeru.han...@gmail.com: 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 pavel.steh...@gmail.com wrote: 2012/10/14 Tom Lane t...@sss.pgh.pa.us: *

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

2012-10-15 Thread Pavel Stehule
2012/10/15 Pavel Stehule pavel.steh...@gmail.com: 2012/10/15 Shigeru HANADA shigeru.han...@gmail.com: 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 pavel.steh...@gmail.com

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

2012-10-14 Thread Pavel Stehule
Hello 2012/10/14 Erik Rijkers e...@xs4all.nl: On Sat, October 13, 2012 19:26, Pavel Stehule wrote: 2012/10/13 Shigeru HANADA shigeru.han...@gmail.com: 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

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 pavel.steh...@gmail.com 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

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

2012-10-13 Thread Pavel Stehule
2012/10/13 Shigeru HANADA shigeru.han...@gmail.com: Hi Pavel, On Sat, Oct 13, 2012 at 12:58 AM, Pavel Stehule pavel.steh...@gmail.com 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

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 shigeru.han...@gmail.com: 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

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 pavel.steh...@gmail.com: Hello 2012/9/21 Shigeru HANADA shigeru.han...@gmail.com: Hi Pavel, (2012/09/21 2:01),

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

2012-09-27 Thread Pavel Stehule
Hello 2012/9/21 Shigeru HANADA shigeru.han...@gmail.com: 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

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

2012-09-22 Thread Pavel Stehule
Hello 2012/9/19 Shigeru HANADA shigeru.han...@gmail.com: On Fri, Aug 10, 2012 at 3:21 AM, Pavel Stehule pavel.steh...@gmail.com 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

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

2012-09-22 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 function,

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 pavel.steh...@gmail.com 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

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 da...@fetter.org: On Sat, Jul 28, 2012 at 06:11:21PM +0200, Pavel Stehule wrote: Hello 2012/7/27 Tom Lane t...@sss.pgh.pa.us:

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 t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2012/7/26 David Fetter da...@fetter.org: How about \gset var1,,,var2,var3... I don't like this - you can use fake variable - and

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

2012-07-28 Thread Pavel Stehule
Hello 2012/7/27 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2012/7/26 David Fetter da...@fetter.org: 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

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

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

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

2012-07-26 Thread Pavel Stehule
2012/7/26 David Fetter da...@fetter.org: On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: Pavel Stehule pavel.steh...@gmail.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

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

2012-07-26 Thread David Fetter
On Thu, Jul 26, 2012 at 08:31:13AM +0200, Pavel Stehule wrote: 2012/7/26 David Fetter da...@fetter.org: On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: Pavel Stehule pavel.steh...@gmail.com writes: \eset variable [, variable [..]] query -- it raise exception when more than

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

2012-07-26 Thread Pavel Stehule
2012/7/26 David Fetter da...@fetter.org: On Thu, Jul 26, 2012 at 08:31:13AM +0200, Pavel Stehule wrote: 2012/7/26 David Fetter da...@fetter.org: On Thu, Jul 26, 2012 at 01:36:17AM -0400, Tom Lane wrote: Pavel Stehule pavel.steh...@gmail.com writes: \eset variable [, variable [..]] query

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

2012-07-26 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2012/7/26 David Fetter da...@fetter.org: 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

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

2012-07-25 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.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

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

2012-07-25 Thread Pavel Stehule
2012/7/26 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.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