Skip to content

Commit 294de2d

Browse files
committed
pg_column_size() cleanup for messages and code cleanup.
Mark Kirkwood
1 parent eefdbba commit 294de2d

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -28,7 +28,6 @@
2828
#include "utils/builtins.h"
2929
#include "utils/lsyscache.h"
3030
#include "utils/pg_locale.h"
31-
#include "utils/syscache.h"
3231

3332

3433
typedef struct varlena unknown;
@@ -2364,22 +2363,15 @@ pg_column_size(PG_FUNCTION_ARGS)
23642363
{
23652364
/* On the first call lookup the datatype of the supplied argument */
23662365
Oid argtypeid = get_fn_expr_argtype(fcinfo->flinfo, 0);
2367-
HeapTuple tp;
2368-
int typlen;
2366+
int typlen = get_typlen(argtypeid);
23692367

2370-
tp = SearchSysCache(TYPEOID,
2371-
ObjectIdGetDatum(argtypeid),
2372-
0, 0, 0);
2373-
if (!HeapTupleIsValid(tp))
2368+
2369+
if (typlen == 0)
23742370
{
23752371
/* 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);
23792373
}
2380-
2381-
typlen = ((Form_pg_type)GETSTRUCT(tp))->typlen;
2382-
ReleaseSysCache(tp);
2374+
23832375
fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
23842376
sizeof(int));
23852377
*(int *)fcinfo->flinfo->fn_extra = typlen;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy