Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-04-26 Thread Pavel Stehule
2016-04-25 19:40 GMT+02:00 Bruce Momjian : > > Good summary. Is there a TODO item here? > no, it is not Regars Pavel > > --- > > On Tue, Mar 15, 2016 at 08:17:07PM -0400, Tom Lane wrote: > > Pavel

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-04-25 Thread Bruce Momjian
Good summary. Is there a TODO item here? --- On Tue, Mar 15, 2016 at 08:17:07PM -0400, Tom Lane wrote: > Pavel Stehule writes: > >> Robert Haas writes: > >>> That's not a

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Tom Lane
Jim Nasby writes: > On 3/3/16 4:51 AM, Pavel Stehule wrote: >> CREATE TABLE a(a int); >> CREATE TABLE b(a a.a%TYPE) >> >> And the people expecting the living relation between table a and table >> b. So when I do ALTER a.a, then b.a should be changed. What if I drop >>

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Pavel Stehule
2016-03-16 20:53 GMT+01:00 Jim Nasby : > On 3/3/16 4:51 AM, Pavel Stehule wrote: > >> CREATE TABLE a(a int); >> CREATE TABLE b(a a.a%TYPE) >> >> And the people expecting the living relation between table a and table >> b. So when I do ALTER a.a, then b.a should be

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Joe Conway
On 03/16/2016 09:38 AM, Pavel Stehule wrote: > 2016-03-16 16:50 GMT+01:00 Pavel Stehule >: > 2016-03-16 16:46 GMT+01:00 Joe Conway >: > > On 03/15/2016 05:17 PM, Tom Lane

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Pavel Stehule
2016-03-16 16:46 GMT+01:00 Joe Conway : > On 03/15/2016 05:17 PM, Tom Lane wrote: > > In short, I think we should reject this implementation and instead try > > to implement the type operators we want in the core grammar's Typename > > production, from which plpgsql will pick

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Pavel Stehule
2016-03-17 1:02 GMT+01:00 David G. Johnston : > On Wed, Mar 16, 2016 at 4:39 PM, Tom Lane wrote: > >> Jim Nasby writes: >> > On 3/3/16 4:51 AM, Pavel Stehule wrote: >> >> CREATE TABLE a(a int); >> >> CREATE TABLE b(a

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread David G. Johnston
On Wed, Mar 16, 2016 at 4:39 PM, Tom Lane wrote: > Jim Nasby writes: > > On 3/3/16 4:51 AM, Pavel Stehule wrote: > >> CREATE TABLE a(a int); > >> CREATE TABLE b(a a.a%TYPE) > >> > >> And the people expecting the living relation between table a and

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Jim Nasby
On 3/15/16 7:17 PM, Tom Lane wrote: In short, I think we should reject this implementation and instead try to implement the type operators we want in the core grammar's Typename production, from which plpgsql will pick it up automatically. +1. Something else that's been discussed is allowing

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Jim Nasby
On 3/3/16 4:51 AM, Pavel Stehule wrote: CREATE TABLE a(a int); CREATE TABLE b(a a.a%TYPE) And the people expecting the living relation between table a and table b. So when I do ALTER a.a, then b.a should be changed. What if I drop a.a or drop a? So this is reason, why I don't would this

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-19 Thread Pavel Stehule
2016-03-17 0:39 GMT+01:00 Tom Lane : > Jim Nasby writes: > > On 3/3/16 4:51 AM, Pavel Stehule wrote: > >> CREATE TABLE a(a int); > >> CREATE TABLE b(a a.a%TYPE) > >> > >> And the people expecting the living relation between table a and table > >> b.

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-18 Thread Pavel Stehule
2016-03-16 16:50 GMT+01:00 Pavel Stehule : > > > 2016-03-16 16:46 GMT+01:00 Joe Conway : > >> On 03/15/2016 05:17 PM, Tom Lane wrote: >> > In short, I think we should reject this implementation and instead try >> > to implement the type operators we

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-18 Thread Joe Conway
On 03/15/2016 05:17 PM, Tom Lane wrote: > In short, I think we should reject this implementation and instead try > to implement the type operators we want in the core grammar's Typename > production, from which plpgsql will pick it up automatically. That is > going to require some other syntax

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-15 Thread Tom Lane
Pavel Stehule writes: >> Robert Haas writes: >>> That's not a dumb idea. I think %TYPE is an Oracle-ism, and it >>> doesn't seem to have been their best-ever design decision. > Using %TYPE has sense in PostgreSQL too. It's certainly useful

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Tom Lane
Pavel Stehule writes: > Where you are expecting the implementation? In PLpgSQL only, or generally > in DDL, or in both levels? I'd envision this as something the main parser does and plpgsql piggybacks on. One of the many half-baked things about %TYPE is that the main

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Pavel Stehule
2016-03-14 20:38 GMT+01:00 Tom Lane : > Robert Haas writes: > > On Mon, Mar 14, 2016 at 12:04 PM, Tom Lane wrote: > >> Or in short: maybe it's time to blow up %TYPE and start fresh. > > > That's not a dumb idea. I think %TYPE is an

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Tom Lane
Robert Haas writes: > On Mon, Mar 14, 2016 at 12:04 PM, Tom Lane wrote: >> Or in short: maybe it's time to blow up %TYPE and start fresh. > That's not a dumb idea. I think %TYPE is an Oracle-ism, and it > doesn't seem to have been their best-ever

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Robert Haas
On Mon, Mar 14, 2016 at 12:04 PM, Tom Lane wrote: > I wrote: >> However ... one thing I was intending to mention on this thread is that >> "get the array type over this type" isn't the only extension one might >> wish for. Another likely desire is "get the type of field 'foo'

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Tom Lane
I wrote: > However ... one thing I was intending to mention on this thread is that > "get the array type over this type" isn't the only extension one might > wish for. Another likely desire is "get the type of field 'foo' of this > composite type". I don't suggest that this patch needs to

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Artur Zakirov
On 14.03.2016 17:54, Tom Lane wrote: Joe Conway writes: This new version of the patch was posted after the commitfest item was marked ready for committer. Does anyone have further comments or objections to the concept or syntax before I try to take this forward? The

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Tom Lane
Joe Conway writes: > This new version of the patch was posted after the commitfest item was > marked ready for committer. Does anyone have further comments or > objections to the concept or syntax before I try to take this forward? The quoted excerpt fails to say what

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-14 Thread Joe Conway
On 03/03/2016 05:45 AM, Pavel Stehule wrote: > 2016-02-24 22:18 GMT+01:00 Peter Eisentraut >: > > On 1/18/16 4:21 PM, Robert Haas wrote: > > One idea that occurs to me is: If you can DECLARE BAR FOO%TYPE, but > > then you want to make BAR an

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-03 Thread Pavel Stehule
Hi 2016-03-03 0:27 GMT+01:00 Jim Nasby : > On 3/2/16 3:52 PM, Pavel Stehule wrote: > >> Right, and it's arguably dubious that that doesn't already work. >> Unfortunately, these % things are just random plpgsql parser hacks, >> not >> real types. Maybe this

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-03 Thread Pavel Stehule
Hi 2016-02-24 22:18 GMT+01:00 Peter Eisentraut : > On 1/18/16 4:21 PM, Robert Haas wrote: > > One idea that occurs to me is: If you can DECLARE BAR FOO%TYPE, but > > then you want to make BAR an array of that type rather than a scalar, > > why not write that as DECLARE BAR

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-02 Thread Jim Nasby
On 3/2/16 3:52 PM, Pavel Stehule wrote: Right, and it's arguably dubious that that doesn't already work. Unfortunately, these % things are just random plpgsql parser hacks, not real types. Maybe this should be done in the main PostgreSQL parser with parameter hooks, if we wanted

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-03-02 Thread Pavel Stehule
Hi 2016-02-24 22:18 GMT+01:00 Peter Eisentraut : > On 1/18/16 4:21 PM, Robert Haas wrote: > > One idea that occurs to me is: If you can DECLARE BAR FOO%TYPE, but > > then you want to make BAR an array of that type rather than a scalar, > > why not write that as DECLARE BAR

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-02-24 Thread Peter Eisentraut
On 1/18/16 4:21 PM, Robert Haas wrote: > One idea that occurs to me is: If you can DECLARE BAR FOO%TYPE, but > then you want to make BAR an array of that type rather than a scalar, > why not write that as DECLARE BAR FOO%TYPE[]? That seems quite > natural to me. Right, and it's arguably dubious

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-02-24 Thread Pavel Stehule
Hi 2016-02-24 10:48 GMT+01:00 Artur Zakirov : On 21.02.2016 11:31, Pavel Stehule wrote: > >> Hi >> >> I am sending updated version - the changes are related to fix comments. >> >> > Great. > > I am new in reviewing, I think Pavel took into account all comments. This >

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-02-24 Thread Artur Zakirov
On 21.02.2016 11:31, Pavel Stehule wrote: Hi I am sending updated version - the changes are related to fix comments. Great. I am new in reviewing, I think Pavel took into account all comments. This patch is compiled and regression tests are passed. So I change its status to "Ready for

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-02-21 Thread Pavel Stehule
Hi I am sending updated version - the changes are related to fix comments. 2016-02-19 10:41 GMT+01:00 Artur Zakirov : > It seems all fixes are done. I tested the patch and regression tests > passed. > > I think here Alvaro means that you should keep original comment

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-02-19 Thread Artur Zakirov
It seems all fixes are done. I tested the patch and regression tests passed. On 27.01.2016 20:58, Pavel Stehule wrote: > --- 1681,1687 >* -- >*/ > PLpgSQL_type * > ! plpgsql_parse_wordtype(char *ident, int reftype_mode) > { >

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-27 Thread Pavel Stehule
Hi 2016-01-18 21:37 GMT+01:00 Alvaro Herrera : > > diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c > > new file mode 100644 > > index 1ae4bb7..c819517 > > *** a/src/pl/plpgsql/src/pl_comp.c > > --- b/src/pl/plpgsql/src/pl_comp.c > >

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-19 Thread Pavel Stehule
2016-01-18 22:48 GMT+01:00 Robert Haas : > On Mon, Jan 18, 2016 at 4:35 PM, Pavel Stehule > wrote: > >> I know that Oracle uses syntax of this general type, but I've always > >> found it ugly. It's also pretty non-extensible. You could want > >>

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-19 Thread Robert Haas
On Tue, Jan 19, 2016 at 4:53 AM, Pavel Stehule wrote: > It is, but sometime the polymorphic types can help. > > The proposed feature/syntax has sense primary for polymorphic types. It > should to follow our polymorphic types. The primary pair is > "anyarray","anyelement"

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-19 Thread Pavel Stehule
2016-01-20 0:34 GMT+01:00 Robert Haas : > On Tue, Jan 19, 2016 at 4:53 AM, Pavel Stehule > wrote: > > It is, but sometime the polymorphic types can help. > > > > The proposed feature/syntax has sense primary for polymorphic types. It > > should to

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-18 Thread Alvaro Herrera
> diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c > new file mode 100644 > index 1ae4bb7..c819517 > *** a/src/pl/plpgsql/src/pl_comp.c > --- b/src/pl/plpgsql/src/pl_comp.c > *** plpgsql_parse_tripword(char *word1, char > *** 1617,1622 > --- 1617,1677

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-18 Thread Alvaro Herrera
FWIW the reason I read through this patch is that I wondered if there was anything in common with this other patch https://commitfest.postgresql.org/8/459/ -- and the answer seems to be "no". What that patch does is add a new construct TYPE(1+1) which in this case returns "int4"; I guess if we

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-18 Thread Robert Haas
On Mon, Jan 18, 2016 at 4:35 PM, Pavel Stehule wrote: >> I know that Oracle uses syntax of this general type, but I've always >> found it ugly. It's also pretty non-extensible. You could want >> similar things for range types and any other container types we might >>

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-18 Thread Robert Haas
On Mon, Jan 18, 2016 at 3:51 PM, Alvaro Herrera wrote: > BTW are we all agreed that enabling > foo%ARRAYTYPE > and > foo%ELEMENTYPE > in plpgsql's DECLARE section is what we want for this? I know that Oracle uses syntax of this general type, but I've always found it

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2016-01-18 Thread Pavel Stehule
2016-01-18 22:21 GMT+01:00 Robert Haas : > On Mon, Jan 18, 2016 at 3:51 PM, Alvaro Herrera > wrote: > > BTW are we all agreed that enabling > > foo%ARRAYTYPE > > and > > foo%ELEMENTYPE > > in plpgsql's DECLARE section is what we want for this?

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-23 Thread Michael Paquier
On Tue, Dec 22, 2015 at 5:59 PM, Pavel Stehule wrote: > Hi > > 2015-12-21 16:21 GMT+01:00 Artur Zakirov : >> >> Hi. >> I have tried to do some review of this patch. Below are my comments. >> >> Introduction: >> >> This patch fixes and adds the

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-22 Thread Pavel Stehule
Hi 2015-12-21 16:21 GMT+01:00 Artur Zakirov : > Hi. > I have tried to do some review of this patch. Below are my comments. > > Introduction: > > This patch fixes and adds the following functionality: > - %TYPE - now can be used for composite types. > - %ARRAYTYPE - new

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-21 Thread Pavel Stehule
Hi 2015-12-21 16:21 GMT+01:00 Artur Zakirov : > Hi. > I have tried to do some review of this patch. Below are my comments. > > Introduction: > > This patch fixes and adds the following functionality: > - %TYPE - now can be used for composite types. > - %ARRAYTYPE -

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-21 Thread Artur Zakirov
Hi. I have tried to do some review of this patch. Below are my comments. Introduction: This patch fixes and adds the following functionality: - %TYPE - now can be used for composite types. - %ARRAYTYPE - new functionality, provides the array type from a variable or table column. - %ELEMENTTYPE

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-20 Thread Jim Nasby
On 10/30/15 6:01 AM, Pavel Stehule wrote: I am sending patch that enables to use references to polymorphic parameters of row types. Another functionality is possibility to get array or element type of referenced variable. It removes some gaps when polymorphic parameters are used. Did this make

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-12-20 Thread Pavel Stehule
2015-12-21 1:06 GMT+01:00 Jim Nasby : > On 10/30/15 6:01 AM, Pavel Stehule wrote: > >> I am sending patch that enables to use references to polymorphic >> parameters of row types. Another functionality is possibility to get >> array or element type of referenced

Re: [HACKERS] plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types

2015-10-30 Thread Pavel Stehule
2015-10-19 9:52 GMT+02:00 Pavel Stehule : > Hi, > > We cannot to declare variable with referenced type on other composite > variable. This limit is probably artificial, because any composite type is > any type too in PostgreSQL. > > The issue: > > referencing on composite