From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | Merlin Moncure <mmoncure(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Subject: | Re: dblink: add polymorphic functions. |
Date: | 2015-07-30 16:51:07 |
Message-ID: | 27045.1438275067@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Joe Conway <mail(at)joeconway(dot)com> writes:
> What about just TYPE then?
> SELECT x::TYPE(some_expression) FROM ...
> SELECT CAST (x AS TYPE(some_expression)) FROM ...
Yeah, that would work. Quick-hack proof-of-concept patch attached.
Some usage examples in the regression database:
regression=# select pg_typeof(43::type(q1)) from int8_tbl;
pg_typeof
-----------
bigint
bigint
bigint
bigint
bigint
(5 rows)
regression=# select pg_typeof(43::type(q1/0.0)) from int8_tbl;
pg_typeof
-----------
numeric
numeric
numeric
numeric
numeric
(5 rows)
regression=# select pg_typeof(43::type(f1)) from point_tbl;
ERROR: cannot cast type integer to point
LINE 1: select pg_typeof(43::type(f1)) from point_tbl;
^
The main limitation of this patch is that it won't work for call sites
that pass pstate == NULL to LookupTypeName. There are a fair number
of them, some of which wouldn't care because they could never invoke
this notation anyway, but for others we'd need to do some work to cons
up a suitable pstate.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
add-type-of-expression-notation-1.patch | text/x-diff | 2.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2015-07-30 16:58:39 | Re: multivariate statistics / patch v7 |
Previous Message | Joe Conway | 2015-07-30 16:40:53 | Re: [COMMITTERS] pgsql: Row-Level Security Policies (RLS) |