diff options
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 2877999500c..bbbb5aa2cfc 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.123 2000/11/12 00:36:56 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.124 2000/11/16 22:30:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -48,9 +48,9 @@ static void CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_print); static void CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null_print); static Oid GetOutputFunction(Oid type); -static Oid GetTypeElement(Oid type); static Oid GetInputFunction(Oid type); -static Oid IsTypeByVal(Oid type); +static Oid GetTypeElement(Oid type); +static bool IsTypeByVal(Oid type); static void CopyReadNewline(FILE *fp, int *newline); static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_print); @@ -669,7 +669,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, continue; } #endif /* _DROP_COLUMN_HACK__ */ - byval[i] = (bool) IsTypeByVal(attr[i]->atttypid); + byval[i] = IsTypeByVal(attr[i]->atttypid); } lineno = 0; @@ -893,65 +893,64 @@ static Oid GetOutputFunction(Oid type) { HeapTuple typeTuple; - - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(type), - 0, 0, 0); - - if (HeapTupleIsValid(typeTuple)) - return (int) ((Form_pg_type) GETSTRUCT(typeTuple))->typoutput; - - elog(ERROR, "GetOutputFunction: Cache lookup of type %u failed", type); - return InvalidOid; + Oid result; + + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(type), + 0, 0, 0); + if (!HeapTupleIsValid(typeTuple)) + elog(ERROR, "GetOutputFunction: Cache lookup of type %u failed", type); + result = ((Form_pg_type) GETSTRUCT(typeTuple))->typoutput; + ReleaseSysCache(typeTuple); + return result; } static Oid -GetTypeElement(Oid type) +GetInputFunction(Oid type) { HeapTuple typeTuple; - - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(type), - 0, 0, 0); - - if (HeapTupleIsValid(typeTuple)) - return (int) ((Form_pg_type) GETSTRUCT(typeTuple))->typelem; - - elog(ERROR, "GetOutputFunction: Cache lookup of type %u failed", type); - return InvalidOid; + Oid result; + + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(type), + 0, 0, 0); + if (!HeapTupleIsValid(typeTuple)) + elog(ERROR, "GetInputFunction: Cache lookup of type %u failed", type); + result = ((Form_pg_type) GETSTRUCT(typeTuple))->typinput; + ReleaseSysCache(typeTuple); + return result; } static Oid -GetInputFunction(Oid type) +GetTypeElement(Oid type) { HeapTuple typeTuple; - - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(type), - 0, 0, 0); - - if (HeapTupleIsValid(typeTuple)) - return (int) ((Form_pg_type) GETSTRUCT(typeTuple))->typinput; - - elog(ERROR, "GetInputFunction: Cache lookup of type %u failed", type); - return InvalidOid; + Oid result; + + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(type), + 0, 0, 0); + if (!HeapTupleIsValid(typeTuple)) + elog(ERROR, "GetTypeElement: Cache lookup of type %u failed", type); + result = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem; + ReleaseSysCache(typeTuple); + return result; } -static Oid +static bool IsTypeByVal(Oid type) { HeapTuple typeTuple; - - typeTuple = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(type), - 0, 0, 0); - - if (HeapTupleIsValid(typeTuple)) - return (int) ((Form_pg_type) GETSTRUCT(typeTuple))->typbyval; - - elog(ERROR, "GetInputFunction: Cache lookup of type %u failed", type); - - return InvalidOid; + bool result; + + typeTuple = SearchSysCache(TYPEOID, + ObjectIdGetDatum(type), + 0, 0, 0); + if (!HeapTupleIsValid(typeTuple)) + elog(ERROR, "IsTypeByVal: Cache lookup of type %u failed", type); + result = ((Form_pg_type) GETSTRUCT(typeTuple))->typbyval; + ReleaseSysCache(typeTuple); + return result; } |