mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Further cleanups for relations in schemas: teach nextval and other
sequence functions how to cope with qualified names. Same code is also used for int4notin, currtid_byrelname, pgstattuple. Also, move TOAST tables into special pg_toast namespace.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.28 2001/10/25 05:49:45 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.29 2002/03/30 01:02:41 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* input routine largely stolen from boxin().
|
||||
@ -19,6 +19,7 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/heapam.h"
|
||||
#include "catalog/namespace.h"
|
||||
#include "utils/builtins.h"
|
||||
|
||||
#define DatumGetItemPointer(X) ((ItemPointer) DatumGetPointer(X))
|
||||
@ -146,14 +147,13 @@ currtid_byreloid(PG_FUNCTION_ARGS)
|
||||
*result = Current_last_tid;
|
||||
PG_RETURN_ITEMPOINTER(result);
|
||||
}
|
||||
|
||||
rel = heap_open(reloid, AccessShareLock);
|
||||
|
||||
ItemPointerCopy(tid, result);
|
||||
if ((rel = heap_open(reloid, AccessShareLock)) != NULL)
|
||||
{
|
||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
||||
heap_close(rel, AccessShareLock);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Relation %u not found", reloid);
|
||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
||||
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
||||
PG_RETURN_ITEMPOINTER(result);
|
||||
}
|
||||
@ -164,23 +164,19 @@ currtid_byrelname(PG_FUNCTION_ARGS)
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
|
||||
ItemPointer result;
|
||||
char *str;
|
||||
RangeVar *relrv;
|
||||
Relation rel;
|
||||
|
||||
str = DatumGetCString(DirectFunctionCall1(textout,
|
||||
PointerGetDatum(relname)));
|
||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname,
|
||||
"currtid_byrelname"));
|
||||
rel = heap_openrv(relrv, AccessShareLock);
|
||||
|
||||
result = (ItemPointer) palloc(sizeof(ItemPointerData));
|
||||
ItemPointerCopy(tid, result);
|
||||
if ((rel = heap_openr(str, AccessShareLock)) != NULL)
|
||||
{
|
||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
||||
heap_close(rel, AccessShareLock);
|
||||
}
|
||||
else
|
||||
elog(ERROR, "Relation %s not found", str);
|
||||
|
||||
pfree(str);
|
||||
heap_get_latest_tid(rel, SnapshotNow, result);
|
||||
|
||||
heap_close(rel, AccessShareLock);
|
||||
|
||||
PG_RETURN_ITEMPOINTER(result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user