pgsql: Remove typename from A_Const.

Started by Alvaro Herreraalmost 18 years ago4 messageshackers
Jump to latest
#1Alvaro Herrera
alvherre@postgresql.org

Log Message:
-----------
Remove typename from A_Const.

Brendan Jurd, minor editorialization by me.

Modified Files:
--------------
pgsql/src/backend/nodes:
copyfuncs.c (r1.392 -> r1.393)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c?r1=1.392&r2=1.393)
equalfuncs.c (r1.321 -> r1.322)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c?r1=1.321&r2=1.322)
outfuncs.c (r1.325 -> r1.326)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/outfuncs.c?r1=1.325&r2=1.326)
pgsql/src/backend/parser:
gram.y (r2.612 -> r2.613)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/gram.y?r1=2.612&r2=2.613)
parse_expr.c (r1.227 -> r1.228)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_expr.c?r1=1.227&r2=1.228)
parse_target.c (r1.159 -> r1.160)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_target.c?r1=1.159&r2=1.160)
parse_type.c (r1.95 -> r1.96)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_type.c?r1=1.95&r2=1.96)
parse_utilcmd.c (r2.12 -> r2.13)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_utilcmd.c?r1=2.12&r2=2.13)
pgsql/src/backend/utils/misc:
guc.c (r1.447 -> r1.448)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/misc/guc.c?r1=1.447&r2=1.448)
pgsql/src/include/catalog:
catversion.h (r1.452 -> r1.453)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.452&r2=1.453)
pgsql/src/include/nodes:
parsenodes.h (r1.362 -> r1.363)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/parsenodes.h?r1=1.362&r2=1.363)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#1)
Re: [COMMITTERS] pgsql: Remove typename from A_Const.

alvherre@postgresql.org (Alvaro Herrera) writes:

Remove typename from A_Const.

I'm thinking this could be cleaned up further. The patch as applied
removes the ::int4 typename decoration that had been inserted by
makeIntConst(), while leaving in place the ::float8 decoration inserted
by makeFloatConst(). The kindest thing that can be said about that
is that it's inconsistent. Now as far as I can see in a look through
gram.y, these routines (and makeAConst) were used only in places where
the typename qualification was really unnecessary, that is typmods
and GUC variable values and so on, not general expression contexts where
we might really need to determine a data type for the constant. So what
I'm thinking is that we should get rid of the ::float8 decoration too,
and thereby be able to revert some of the ugly code added elsewhere such
as guc.c.

Is there a reason it was done this way that I'm missing?

regards, tom lane

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#2)
Re: [COMMITTERS] pgsql: Remove typename from A_Const.

Tom Lane escribi�:

alvherre@postgresql.org (Alvaro Herrera) writes:

Remove typename from A_Const.

I'm thinking this could be cleaned up further. The patch as applied
removes the ::int4 typename decoration that had been inserted by
makeIntConst(), while leaving in place the ::float8 decoration inserted
by makeFloatConst(). The kindest thing that can be said about that
is that it's inconsistent.

That's very kind, yes :-) I think that cast can be removed safely.

Now as far as I can see in a look through
gram.y, these routines (and makeAConst) were used only in places where
the typename qualification was really unnecessary, that is typmods
and GUC variable values and so on, not general expression contexts where
we might really need to determine a data type for the constant. So what
I'm thinking is that we should get rid of the ::float8 decoration too,
and thereby be able to revert some of the ugly code added elsewhere such
as guc.c.

Hmm, I'm not sure but I think the typecast is needed in the guc.c code
in order to pass the fact that the Const is an Interval. This is used
to process things such as

set time zone interval '-8:30' ;

Perhaps this can be detected by some other mechanism but currently it's
being driven by the cast.

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#3)
Re: [COMMITTERS] pgsql: Remove typename from A_Const.

Alvaro Herrera <alvherre@commandprompt.com> writes:

Tom Lane escribi�:

I'm thinking is that we should get rid of the ::float8 decoration too,
and thereby be able to revert some of the ugly code added elsewhere such
as guc.c.

Hmm, I'm not sure but I think the typecast is needed in the guc.c code
in order to pass the fact that the Const is an Interval.

Yeah, I had just found that out --- it's not so much that we care that
it's an interval, as that the original input might have had typmod
restrictions that need to be applied to the interval value. Definitely
a kluge to support a corner case ...

Anyway, I'm in the middle of testing removal of the ::float8 cast
--- we can at least simplify parse_type.c's handling of typmods here.
I also see that we can eliminate some manual construction of A_Const's
in gram.y, since makeFloatConst and friends no longer do any unwanted
extra stuff.

regards, tom lane