Re: Implicit casts to text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Implicit casts to text
Date: 2007-05-04 23:45:28
Message-ID: 12297.1178322328@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Awhile back I wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> FWIW, is the attached patch about what you had in mind? (It probably only
>> covers "normal" types at the moment.)

> Hm, I hadn't realized that it would take as little work as that ...
> I have an itchy feeling that you missed something but I'm not sure
> what.

On closer inspection, my gut feeling was right: this patch doesn't work,
because it assumes that I/O functions have the same calling conventions
as cast functions, which they don't --- the semantics for second and
third arguments, if used, are different.

We could tweak build_coercion_expression() to generate the correct
arguments, but there are more problems downstream, eg in
exprIsLengthCoercion() which will misinterpret the arguments in such
a node. So I'm inclined to think that we really need a specialized
expression node type, perhaps "CoerceViaIO". This might have some
usefulness in plpgsql too, if it could piggyback on that rather than
doing its own ad-hoc conversions.

An alternative, which would be less pretty but also less work, is to
implement the cast this way only for types with single-argument input
functions. Those that require extra args would still have to have
explicit pg_cast entries. The main problem with this is we can't
support varchar on the same basis as text, because its input function
wants extra arguments.

BTW, I note that uuid has snuck in with assignment casts to and from
text. Is this really what we want if we're tightening up everything
else?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message roger 2007-05-05 01:29:11 how does one set the plpython python interpreter?
Previous Message Stephen Frost 2007-05-04 22:07:02 Re: Removing pg_auth_members.grantor (was Grantor name gets lost when grantor role dropped)