|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.125 2005/07/06 19:02:52 momjian Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.126 2005/07/07 04:36:08 momjian Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
|
28 | 28 | #include "utils/builtins.h"
|
29 | 29 | #include "utils/lsyscache.h"
|
30 | 30 | #include "utils/pg_locale.h"
|
31 |
| -#include "utils/syscache.h" |
32 | 31 |
|
33 | 32 |
|
34 | 33 | typedef struct varlena unknown;
|
@@ -2364,22 +2363,15 @@ pg_column_size(PG_FUNCTION_ARGS)
|
2364 | 2363 | {
|
2365 | 2364 | /* On the first call lookup the datatype of the supplied argument */
|
2366 | 2365 | Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0);
|
2367 |
| - HeapTuple tp; |
2368 |
| - int typlen; |
| 2366 | + int typlen = get_typlen(argtypeid); |
2369 | 2367 |
|
2370 |
| - tp = SearchSysCache(TYPEOID, |
2371 |
| - ObjectIdGetDatum(argtypeid), |
2372 |
| - 0, 0, 0); |
2373 |
| - if (!HeapTupleIsValid(tp)) |
| 2368 | + |
| 2369 | + if (typlen == 0) |
2374 | 2370 | {
|
2375 | 2371 | /* Oid not in pg_type, should never happen. */
|
2376 |
| - ereport(ERROR, |
2377 |
| - (errcode(ERRCODE_INTERNAL_ERROR), |
2378 |
| - errmsg("invalid typid: %u", argtypeid))); |
| 2372 | + elog(ERROR, "cache lookup failed for type %u", argtypeid); |
2379 | 2373 | }
|
2380 |
| - |
2381 |
| - typlen = ((Form_pg_type)GETSTRUCT(tp))->typlen; |
2382 |
| - ReleaseSysCache(tp); |
| 2374 | + |
2383 | 2375 | fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
|
2384 | 2376 | sizeof(int));
|
2385 | 2377 | *(int *)fcinfo->flinfo->fn_extra = typlen;
|
|
0 commit comments