Hello, this proposal is related to discuss about enhancing "any" type and using this type in other PL than C. Result from this discuss was: * add synonym for type "any" ~ ANY TYPE * add possibility select type from other referenced type ~ "TYPE AS variable (This syntax is impossible, but we can use similar "WITH TYPE AS variable" .. this isn't area of this proposal).
For implementation referenced types we need a storage. We could to use typmodes. What more, typmodes should be nice feature mainly for NUMERIC like types. ==steps== 1. add columns int prorettypmod and int[] proargtypmodes to pg_proc 2. enhance casting arguments to target types - add coerce_type_typmod call to make_fn_arguments (based on proargtypmodes). There are two possible behave: like explicit or implicit cast. In this case I prefer behave like implicit cast - it's protection under silent cut strings, ... CREATE OR REPLACE FUNCTION foo(a varchar(3)) RETURNS varchar AS $$ SELECT $1; $$ LANGUAGE sql; SELECT foo('abcd') ERROR: value too long for type character varying(3) I don't expect compatibility problems - every custom functions created in older versions has typmod -1 for every parameter. 3. PL handler is responsible for correct cast to result typmod. I am not sure, if we have to use implicit or explicit cast on output. I incline to the opinion, that implicit cast is better here. CREATE OR REPLACE FUNCTION foo(a varchar) RETURNS varchar(2) AS $$ SELECT $1; $$ LANGUAGE sql; SELECT foo('abcde'); foo ----- ab (1 row) Compatibility problems are not expected too. 3. support for dumps, ... Because typmod conversions are fixed in plan, isn't possible alter typmod later. Comments? Regards Pavel Stehule -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers