Removing typename from A_Const (was: Empty arrays with ARRAY[])

Lists: pgsql-hackerspgsql-patches
From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-14 21:23:13
Message-ID: 37ed240d0804141423y36a29943r20bab71df9531140@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 21, 2008 at 7:47 AM, Tom Lane wrote:
> I didn't do anything about removing A_Const's typename field, but I'm
> thinking that would be a good cleanup patch.
>

Here's my attempt to remove the typename field from A_Const. There
were a few places (notably flatten_set_variable_args() in guc.c, and
typenameTypeMod() in parse_type.c) where the code expected to see an
A_Const with a typename, and I had to adjust for an A_Const within a
TypeCast. Nonetheless, there was an overall net reduction of 34 lines
of code, so I think this was a win.

All regression tests passed on x86_64 gentoo.

Added to May CommitFest.

Cheers,
BJ
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIA8s/5YBsbHkuyV0RAlMdAJ0dWdoZd5cypvInAR2msO8XA8qqxACeILSw
bCI2TGAQI3m3TBoJspvV4OQ=
=dGP9
-----END PGP SIGNATURE-----

Attachment Content-Type Size
aconst-no-typename_0.diff.bz2 application/x-bzip2 5.3 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 16:27:02
Message-ID: 20080428162702.GC5761@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Brendan Jurd escribió:

> Here's my attempt to remove the typename field from A_Const. There
> were a few places (notably flatten_set_variable_args() in guc.c, and
> typenameTypeMod() in parse_type.c) where the code expected to see an
> A_Const with a typename, and I had to adjust for an A_Const within a
> TypeCast. Nonetheless, there was an overall net reduction of 34 lines
> of code, so I think this was a win.

Do say ... why don't we do away with A_Const altogether and just replace
it with Value? After this patch, I don't see what's the difference.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 16:50:18
Message-ID: 13756.1209401418@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Brendan Jurd escribi:
>> Here's my attempt to remove the typename field from A_Const. There
>> were a few places (notably flatten_set_variable_args() in guc.c, and
>> typenameTypeMod() in parse_type.c) where the code expected to see an
>> A_Const with a typename, and I had to adjust for an A_Const within a
>> TypeCast. Nonetheless, there was an overall net reduction of 34 lines
>> of code, so I think this was a win.

> Do say ... why don't we do away with A_Const altogether and just replace
> it with Value? After this patch, I don't see what's the difference.

They're logically different things, and after I get done putting a parse
location field into A_Const, they'll still be physically different too.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 16:54:34
Message-ID: 20080428165434.GD5761@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Brendan Jurd escribi:
> >> Here's my attempt to remove the typename field from A_Const. There
> >> were a few places (notably flatten_set_variable_args() in guc.c, and
> >> typenameTypeMod() in parse_type.c) where the code expected to see an
> >> A_Const with a typename, and I had to adjust for an A_Const within a
> >> TypeCast. Nonetheless, there was an overall net reduction of 34 lines
> >> of code, so I think this was a win.
>
> > Do say ... why don't we do away with A_Const altogether and just replace
> > it with Value? After this patch, I don't see what's the difference.
>
> They're logically different things, and after I get done putting a parse
> location field into A_Const, they'll still be physically different too.

Aha. Are you working from Brendan's patch? I was going to commit it.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 17:05:38
Message-ID: 13947.1209402338@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Tom Lane escribi:
>> They're logically different things, and after I get done putting a parse
>> location field into A_Const, they'll still be physically different too.

> Aha. Are you working from Brendan's patch? I was going to commit it.

Sure, go ahead. I was going to add the parse location at the same time,
but it can perfectly well be done as a separate patch.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 20:25:03
Message-ID: 20080428202503.GF5761@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Tom Lane escribió:
> >> They're logically different things, and after I get done putting a parse
> >> location field into A_Const, they'll still be physically different too.
>
> > Aha. Are you working from Brendan's patch? I was going to commit it.
>
> Sure, go ahead. I was going to add the parse location at the same time,
> but it can perfectly well be done as a separate patch.

I came up with the attached patch. I added the location bits (although
I am unsure if I got the locations right in the parser), but they are
unused -- figuring out how to use them would take me longer than I can
to spend on this.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
aconst-no-typename-1.patch text/x-diff 41.0 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 20:55:15
Message-ID: 20080428205514.GH5761@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera escribió:
> Tom Lane escribió:
> > Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > > Tom Lane escribió:
> > >> They're logically different things, and after I get done putting a parse
> > >> location field into A_Const, they'll still be physically different too.
> >
> > > Aha. Are you working from Brendan's patch? I was going to commit it.
> >
> > Sure, go ahead. I was going to add the parse location at the same time,
> > but it can perfectly well be done as a separate patch.
>
> I came up with the attached patch. I added the location bits (although
> I am unsure if I got the locations right in the parser), but they are
> unused -- figuring out how to use them would take me longer than I can
> to spend on this.

Hmm, I'm now wondering if the location should be added to Value as well,
so that it can be passed down to Const?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 20:57:11
Message-ID: 16856.1209416231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> I came up with the attached patch.

I wasn't envisioning anything anywhere near this invasive. We only
need locations on constants in a few contexts, I think.

BTW, you broke _equalAConst() ... it was a bad idea anyway to recast
it on the assumption that there would never again be more than one
field.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 21:01:25
Message-ID: 20080428210125.GI5761@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Tom Lane escribió:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > I came up with the attached patch.
>
> I wasn't envisioning anything anywhere near this invasive. We only
> need locations on constants in a few contexts, I think.

Aha. OK, I'll commit the original patch and let you deal with the rest
of it :-)

> BTW, you broke _equalAConst() ... it was a bad idea anyway to recast
> it on the assumption that there would never again be more than one
> field.

Oops, sorry, I had intended to revert that part and forgot.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Removing typename from A_Const (was: Empty arrays with ARRAY[])
Date: 2008-04-28 21:07:28
Message-ID: 17166.1209416848@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-patches

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Hmm, I'm now wondering if the location should be added to Value as well,
> so that it can be passed down to Const?

Just for the record, we don't want it in Const. Parse locations are
only useful in the "raw grammar" output, mainly because they aren't
helpful unless you still have the original query string laying about.

regards, tom lane