Re: [HACKERS] proposal: condition blocks in psql

2015-06-29 Thread Merlin Moncure
On Sun, Jun 28, 2015 at 1:59 AM, Fabien COELHO wrote: > \if_ver_eq 9.2 >>> >>> >>> What do you thinking about it? >>> >>> Couldn't this kind of thing be done directly with PL/pgSQL? >> >> >> you can use PL/pgSQL - but there are some limits >> >> * maintenance large plpgsql functions > > > I

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 22:43 GMT+02:00 Corey Huinker : > >> I implemented \foreach five years ago, and this is not simple to >> implement statement - so don't propose it. I wouldn't to inject full >> scripting language to psql. Then it is better to use bash, perl, python. >> >> But well designed conditional

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Corey Huinker
> > > I implemented \foreach five years ago, and this is not simple to > implement statement - so don't propose it. I wouldn't to inject full > scripting language to psql. Then it is better to use bash, perl, python. > > But well designed conditional statements needs only few lines for > implement

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 02:50 PM, Pavel Stehule wrote: I don't propose psql scripting. I propose simple statement for conditional statement execution. The core of my proposal are commands That's a matter of opinion, I guess ... While you may propose only two simple conditional statements at the

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread David G. Johnston
On Sunday, June 28, 2015, Pavel Stehule wrote: > > > 2015-06-28 14:26 GMT+02:00 Tomas Vondra >: > >> Hi, >> >> On 06/28/2015 08:01 AM, Pavel Stehule wrote: >> >>> >>> you can use PL/pgSQL - but there are some limits >>> >>> * maintenance large plpgsql functions >>> >>> * the plpgsql functions or

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 14:26 GMT+02:00 Tomas Vondra : > Hi, > > On 06/28/2015 08:01 AM, Pavel Stehule wrote: > >> >> you can use PL/pgSQL - but there are some limits >> >> * maintenance large plpgsql functions >> >> * the plpgsql functions or anonymous functions create a transaction >> borders - what should n

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 02:21 PM, Pavel Stehule wrote: 2015-06-28 14:12 GMT+02:00 Tomas Vondra mailto:tomas.von...@2ndquadrant.com>>: This proposal is not against to DO parametrization. It is same like conditional block in C (#ifdef). There is similarity with C statements - and both has sense. I'm

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 08:47 AM, Corey Huinker wrote: > 5. I'm actually using psql to connect to redshift, which doesn't have DO blocks at all. I don't see this as a reason to add features to psql, unless there are other compelling reasons for the addition. -- Tomas Vondra http

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 08:01 AM, Pavel Stehule wrote: you can use PL/pgSQL - but there are some limits * maintenance large plpgsql functions * the plpgsql functions or anonymous functions create a transaction borders - what should not be wanted But why is that a problem? Generally (sub)transacti

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 14:12 GMT+02:00 Tomas Vondra : > Hi, > > On 06/28/2015 09:04 AM, Fabien COELHO wrote: > >> >> 2. The general difficulty of getting psql var values into a DO >>> block (currently I use temp tables). >>> >> >> Maybe this means that DO should be extended in some way to allow for >> parame

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 09:04 AM, Fabien COELHO wrote: 2. The general difficulty of getting psql var values into a DO block (currently I use temp tables). Maybe this means that DO should be extended in some way to allow for parameters, at least when PL/pgSQL is used? I agree with this wholeheart

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 10:46 GMT+02:00 Fabien COELHO : > > Hello again Pavel, > > Note that I'm not against cpp-like features on principle, I did macros for > apache configurations a very long time ago, and that I only give my 0.02€ > on this, for what's the € is worth these days:-) > > you can use parameter

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Fabien COELHO
Hello again Pavel, Note that I'm not against cpp-like features on principle, I did macros for apache configurations a very long time ago, and that I only give my 0.02€ on this, for what's the € is worth these days:-) you can use parameters for functions, but you cannot it for DO statement (

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 8:47 GMT+02:00 Corey Huinker : > I was just musing about this today, and was afraid that no one else would > want it! > > This would be useful to me in the following use cases which I have right > now: > > 1. I have a SQL script that invokes \COPY into a temporary table or some > simila

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 8:59 GMT+02:00 Fabien COELHO : > > \if_ver_eq 9.2 >>> >>> What do you thinking about it? >>> >>> Couldn't this kind of thing be done directly with PL/pgSQL? >>> >> >> you can use PL/pgSQL - but there are some limits >> >> * maintenance large plpgsql functions >> > > I agree with

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Fabien COELHO
2. The general difficulty of getting psql var values into a DO block (currently I use temp tables). Maybe this means that DO should be extended in some way to allow for parameters, at least when PL/pgSQL is used? -- Fabien. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Fabien COELHO
\if_ver_eq 9.2 What do you thinking about it? Couldn't this kind of thing be done directly with PL/pgSQL? you can use PL/pgSQL - but there are some limits * maintenance large plpgsql functions I agree with large but that would not necessarily mean complex. Also, some functions could be

Re: [HACKERS] proposal: condition blocks in psql

2015-06-27 Thread Corey Huinker
I was just musing about this today, and was afraid that no one else would want it! This would be useful to me in the following use cases which I have right now: 1. I have a SQL script that invokes \COPY into a temporary table or some similar thing, preventing most of my logic from being pushed in

Re: [HACKERS] proposal: condition blocks in psql

2015-06-27 Thread Pavel Stehule
2015-06-28 7:49 GMT+02:00 Fabien COELHO : > > The proposed syntax of new psql commands >> \if_ver_eq 9.2 >> ... >> \else >> \endif >> > > What do you thinking about it? >> > > Couldn't this kind of thing be done directly with PL/pgSQL? > you can use PL/pgSQL - but there are some limits * maint

Re: [HACKERS] proposal: condition blocks in psql

2015-06-27 Thread Fabien COELHO
The proposed syntax of new psql commands \if_ver_eq 9.2 ... \else \endif What do you thinking about it? Couldn't this kind of thing be done directly with PL/pgSQL? -- Fabien. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http:

[HACKERS] proposal: condition blocks in psql

2015-06-27 Thread Pavel Stehule
Hi I am thinking about simplifying a deployment some multiversion PostgreSQL extensions, and scripts. With current possibilities, we have to use DO statement, what is not optimal or possible in some use cases. The implementation of condition block (possible nested) is very simple. The proposed s