diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-06-09 01:11:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-06-09 01:11:16 +0000 |
commit | ae526b407039dd743eb318a9f05eba1ee7594738 (patch) | |
tree | 2858f9b0426a2054b81350e36562ea9d2ba0ab39 /src/backend/utils/adt/tid.c | |
parent | 20ad43b576d9360b0e9ce9bd868c989443cf9d36 (diff) | |
download | postgresql-ae526b407039dd743eb318a9f05eba1ee7594738.tar.gz postgresql-ae526b407039dd743eb318a9f05eba1ee7594738.zip |
Another round of updates for new fmgr, mostly in the datetime code.
Diffstat (limited to 'src/backend/utils/adt/tid.c')
-rw-r--r-- | src/backend/utils/adt/tid.c | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index c2a9e2c7982..263470a063c 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.19 2000/06/08 22:37:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.20 2000/06/09 01:11:09 tgl Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -160,19 +160,21 @@ text_tid(const text *string) /* * Functions to get latest tid of a specified tuple. - * Maybe these implementations is moved - * to another place -*/ -ItemPointer -currtid_byreloid(Oid reloid, ItemPointer tid) + * + * Maybe these implementations should be moved to another place + */ +Datum +currtid_byreloid(PG_FUNCTION_ARGS) { - ItemPointer result = NULL, - ret; - Relation rel; + Oid reloid = PG_GETARG_OID(0); + ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1); + ItemPointer result, + ret; + Relation rel; result = (ItemPointer) palloc(sizeof(ItemPointerData)); ItemPointerSetInvalid(result); - if (rel = heap_open(reloid, AccessShareLock), rel) + if ((rel = heap_open(reloid, AccessShareLock)) != NULL) { ret = heap_get_latest_tid(rel, SnapshotNow, tid); if (ret) @@ -182,25 +184,24 @@ currtid_byreloid(Oid reloid, ItemPointer tid) else elog(ERROR, "Relation %u not found", reloid); - return result; -} /* currtid_byreloid() */ + PG_RETURN_POINTER(result); +} -ItemPointer -currtid_byrelname(const text *relname, ItemPointer tid) +Datum +currtid_byrelname(PG_FUNCTION_ARGS) { - ItemPointer result = NULL, - ret; - char *str; - Relation rel; - - if (!relname) - return result; + text *relname = PG_GETARG_TEXT_P(0); + ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1); + ItemPointer result, + ret; + char *str; + Relation rel; - str = textout((text *) relname); + str = textout(relname); result = (ItemPointer) palloc(sizeof(ItemPointerData)); ItemPointerSetInvalid(result); - if (rel = heap_openr(str, AccessShareLock), rel) + if ((rel = heap_openr(str, AccessShareLock)) != NULL) { ret = heap_get_latest_tid(rel, SnapshotNow, tid); if (ret) @@ -208,8 +209,9 @@ currtid_byrelname(const text *relname, ItemPointer tid) heap_close(rel, AccessShareLock); } else - elog(ERROR, "Relation %s not found", textout((text *) relname)); + elog(ERROR, "Relation %s not found", str); + pfree(str); - return result; -} /* currtid_byrelname() */ + PG_RETURN_POINTER(result); +} |