Thread: Followup from yesterday's PL/pgSQL fun...
I posted: Also, this is what I wound up with for that line, which seems ugly, because it couldn't find a quote_literal(inet) without the ::text on it: quote_literal(NEW.netblock::inet::text) ; Is that right? Can I ask 3 questions: 1) should quote_literal find a ::text conversion on it's own? 2) can text(cidr) be added to the default pg_cast table? 3) how can I add text(cidr) myself? -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Larry Rosenman <ler@lerctr.org> writes: > 1) should quote_literal find a ::text conversion on it's own? It won't, because the pg_cast entry for inet->text is marked "explicit casts only". In general I don't like implicit casts across datatype categories, and am hoping to move in the direction of marking more such casts as explicit-only. > 2) can text(cidr) be added to the default pg_cast table? I'll make that happen for 7.4. > 3) how can I add text(cidr) myself? Read the pg_cast description in http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=catalogs.html Insert a suitable row. regards, tom lane
I said: > Larry Rosenman <ler@lerctr.org> writes: >> 3) how can I add text(cidr) myself? > Read the pg_cast description in > http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=catalogs.html > Insert a suitable row. Actually, I think you can do it with CREATE CAST. regards, tom lane
--On Wednesday, May 14, 2003 13:02:48 -0400 Tom Lane <tgl@sss.pgh.pa.us> wrote: > I said: >> Larry Rosenman <ler@lerctr.org> writes: >>> 3) how can I add text(cidr) myself? > >> Read the pg_cast description in >> http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=catalogs >> .html Insert a suitable row. > > Actually, I think you can do it with CREATE CAST. The issue (for me) was decoding the function name(s). I wish there was a \ command to display pg_cast... LER > > regards, tom lane -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Larry Rosenman <ler@lerctr.org> writes: >> Actually, I think you can do it with CREATE CAST. > The issue (for me) was decoding the function name(s). I find the 7.3 OID-alias types very helpful for this sort of thing: regression=# select castsource::regtype, casttarget::regtype, castfunc::regprocedure, castcontext from pg_cast limit 1;castsource| casttarget | castfunc | castcontext ------------+------------+--------------+-------------bigint | smallint | int2(bigint) | a (1 row) > I wish there was a \ command to display pg_cast... There is (\dC). But it's not very bright --- I don't think you can limit the rows displayed at all. regards, tom lane
--On Wednesday, May 14, 2003 13:08:23 -0400 Tom Lane <tgl@sss.pgh.pa.us> wrote: > Larry Rosenman <ler@lerctr.org> writes: >>> Actually, I think you can do it with CREATE CAST. > >> The issue (for me) was decoding the function name(s). > > I find the 7.3 OID-alias types very helpful for this sort of thing: > > regression=# select castsource::regtype, casttarget::regtype, > castfunc::regprocedure, castcontext from pg_cast limit 1; castsource | > casttarget | castfunc | castcontext > ------------+------------+--------------+------------- > bigint | smallint | int2(bigint) | a > (1 row) > >> I wish there was a \ command to display pg_cast... > > There is (\dC). But it's not very bright --- I don't think you can > limit the rows displayed at all. $ psql Welcome to psql 7.3.2, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit ler=# \dC Did not find any relation named "C". ler=# Hrm. > > regards, tom lane -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Larry Rosenman <ler@lerctr.org> writes: > --On Wednesday, May 14, 2003 13:08:23 -0400 Tom Lane <tgl@sss.pgh.pa.us> > wrote: >>> I wish there was a \ command to display pg_cast... >> >> There is (\dC). But it's not very bright --- I don't think you can >> limit the rows displayed at all. > ler=# \dC > Did not find any relation named "C". Mph. It's there in CVS tip ... must have been added since 7.3. regards, tom lane
--On Wednesday, May 14, 2003 14:13:12 -0400 Tom Lane <tgl@sss.pgh.pa.us> wrote: > Larry Rosenman <ler@lerctr.org> writes: >> --On Wednesday, May 14, 2003 13:08:23 -0400 Tom Lane <tgl@sss.pgh.pa.us> >> wrote: >>>> I wish there was a \ command to display pg_cast... >>> >>> There is (\dC). But it's not very bright --- I don't think you can >>> limit the rows displayed at all. > >> ler=# \dC >> Did not find any relation named "C". > > Mph. It's there in CVS tip ... must have been added since 7.3. C'est la vie. That means maybe it can be smartened up to do limiting? :-) -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Larry Rosenman <ler@lerctr.org> writes: >>> There is (\dC). But it's not very bright --- I don't think you can >>> limit the rows displayed at all. > C'est la vie. That means maybe it can be smartened up to do limiting? If someone can think of a reasonable way. The other \d commands all use wildcard patterns to match against object names ... but a cast hasn't got a name, really. regards, tom lane