Re: [HACKERS] proposal: condition blocks in psql

2015-06-29 Thread Merlin Moncure
On Sun, Jun 28, 2015 at 1:59 AM, Fabien COELHO coe...@cri.ensmp.fr 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 agree with

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

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 tomas.von...@2ndquadrant.com 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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 14:12 GMT+02:00 Tomas Vondra tomas.von...@2ndquadrant.com: 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

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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 14:26 GMT+02:00 Tomas Vondra tomas.von...@2ndquadrant.com: 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 -

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

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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 8:59 GMT+02:00 Fabien COELHO coe...@cri.ensmp.fr: \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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 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

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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 7:49 GMT+02:00 Fabien COELHO coe...@cri.ensmp.fr: 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 *

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 corey.huin...@gmail.com: 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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Tomas Vondra
Hi, On 06/28/2015 02:50 PM, Pavel Stehule wrote: bI don't propose psql scripting./b 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

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread David G. Johnston
On Sunday, June 28, 2015, Pavel Stehule pavel.steh...@gmail.com wrote: 2015-06-28 14:26 GMT+02:00 Tomas Vondra tomas.von...@2ndquadrant.com javascript:_e(%7B%7D,'cvml','tomas.von...@2ndquadrant.com');: Hi, On 06/28/2015 08:01 AM, Pavel Stehule wrote: you can use PL/pgSQL - but there

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 10:46 GMT+02:00 Fabien COELHO coe...@cri.ensmp.fr: 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

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 implementation,

Re: [HACKERS] proposal: condition blocks in psql

2015-06-28 Thread Pavel Stehule
2015-06-28 22:43 GMT+02:00 Corey Huinker corey.huin...@gmail.com: 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

[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

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: