diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-18 21:35:25 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-18 21:35:25 +0000 |
commit | b26dfb95222fddd25322bdddf3a5a58d3392d8b1 (patch) | |
tree | 757cf0bafab985d38a5c84d3afebe5edd34c4f27 /src/backend/utils/adt/regproc.c | |
parent | cc70ba2e4daa78ba99619770e19beb06de3dfd1c (diff) | |
download | postgresql-b26dfb95222fddd25322bdddf3a5a58d3392d8b1.tar.gz postgresql-b26dfb95222fddd25322bdddf3a5a58d3392d8b1.zip |
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
Diffstat (limited to 'src/backend/utils/adt/regproc.c')
-rw-r--r-- | src/backend/utils/adt/regproc.c | 68 |
1 files changed, 13 insertions, 55 deletions
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 22c93c431a0..638f5293ed2 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.75 2002/09/04 20:31:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.76 2002/09/18 21:35:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -49,7 +49,7 @@ static void parseNameAndArgTypes(const char *string, const char *caller, /* * regprocin - converts "proname" to proc OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_proc entry. @@ -71,15 +71,8 @@ regprocin(PG_FUNCTION_ARGS) pro_name_or_oid[0] <= '9' && strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(pro_name_or_oid))); - result = (RegProcedure) GetSysCacheOid(PROCOID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!RegProcedureIsValid(result)) - elog(ERROR, "No procedure with oid %s", pro_name_or_oid); PG_RETURN_OID(result); } @@ -211,7 +204,7 @@ regprocout(PG_FUNCTION_ARGS) /* * regprocedurein - converts "proname(args)" to proc OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_proc entry. @@ -235,15 +228,8 @@ regprocedurein(PG_FUNCTION_ARGS) pro_name_or_oid[0] <= '9' && strspn(pro_name_or_oid, "0123456789") == strlen(pro_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(pro_name_or_oid))); - result = (RegProcedure) GetSysCacheOid(PROCOID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!RegProcedureIsValid(result)) - elog(ERROR, "No procedure with oid %s", pro_name_or_oid); PG_RETURN_OID(result); } @@ -361,7 +347,7 @@ regprocedureout(PG_FUNCTION_ARGS) /* * regoperin - converts "oprname" to operator OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '0' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_operator entry. @@ -383,15 +369,8 @@ regoperin(PG_FUNCTION_ARGS) opr_name_or_oid[0] <= '9' && strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(opr_name_or_oid))); - result = GetSysCacheOid(OPEROID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!OidIsValid(result)) - elog(ERROR, "No operator with oid %s", opr_name_or_oid); PG_RETURN_OID(result); } @@ -531,7 +510,7 @@ regoperout(PG_FUNCTION_ARGS) /* * regoperatorin - converts "oprname(args)" to operator OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '0' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_operator entry. @@ -556,15 +535,8 @@ regoperatorin(PG_FUNCTION_ARGS) opr_name_or_oid[0] <= '9' && strspn(opr_name_or_oid, "0123456789") == strlen(opr_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(opr_name_or_oid))); - result = GetSysCacheOid(OPEROID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!OidIsValid(result)) - elog(ERROR, "No operator with oid %s", opr_name_or_oid); PG_RETURN_OID(result); } @@ -698,7 +670,7 @@ regoperatorout(PG_FUNCTION_ARGS) /* * regclassin - converts "classname" to class OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_class entry. @@ -719,15 +691,8 @@ regclassin(PG_FUNCTION_ARGS) class_name_or_oid[0] <= '9' && strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(class_name_or_oid))); - result = GetSysCacheOid(RELOID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!OidIsValid(result)) - elog(ERROR, "No class with oid %s", class_name_or_oid); PG_RETURN_OID(result); } @@ -843,7 +808,7 @@ regclassout(PG_FUNCTION_ARGS) /* * regtypein - converts "typename" to type OID * - * We also accept a numeric OID, mostly for historical reasons. + * We also accept a numeric OID, for symmetry with the output routine. * * '-' signifies unknown (OID 0). In all other cases, the input must * match an existing pg_type entry. @@ -870,15 +835,8 @@ regtypein(PG_FUNCTION_ARGS) typ_name_or_oid[0] <= '9' && strspn(typ_name_or_oid, "0123456789") == strlen(typ_name_or_oid)) { - Oid searchOid; - - searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, + result = DatumGetObjectId(DirectFunctionCall1(oidin, CStringGetDatum(typ_name_or_oid))); - result = GetSysCacheOid(TYPEOID, - ObjectIdGetDatum(searchOid), - 0, 0, 0); - if (!OidIsValid(result)) - elog(ERROR, "No type with oid %s", typ_name_or_oid); PG_RETURN_OID(result); } |