1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

Another round of updates for new fmgr, mostly in the datetime code.

This commit is contained in:
Tom Lane
2000-06-09 01:11:16 +00:00
parent 20ad43b576
commit ae526b4070
27 changed files with 2206 additions and 2007 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.55 2000/06/02 15:57:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.56 2000/06/09 01:11:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -538,8 +538,11 @@ _ReadLOArray(char *str,
if (inputfile == NULL)
elog(ERROR, "array_in: missing file name");
lobjId = lo_creat(0);
*fd = lo_open(lobjId, INV_READ);
lobjId = DatumGetObjectId(DirectFunctionCall1(lo_creat,
Int32GetDatum(0)));
*fd = DatumGetInt32(DirectFunctionCall2(lo_open,
ObjectIdGetDatum(lobjId),
Int32GetDatum(INV_READ)));
if (*fd < 0)
elog(ERROR, "Large object create failed");
retStr = inputfile;
@@ -877,17 +880,23 @@ array_ref(ArrayType *array,
v = _ReadChunkArray1El(indx, elmlen, fd, array, isNull);
else
{
if (lo_lseek(fd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
#ifdef LOARRAY
v = (struct varlena *) LOread(fd, elmlen);
v = (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread,
Int32GetDatum(fd),
Int32GetDatum(elmlen)));
#endif
}
if (*isNull)
RETURN_NULL;
if (VARSIZE(v) - VARHDRSZ < elmlen)
RETURN_NULL;
lo_close(fd);
DirectFunctionCall1(lo_close, Int32GetDatum(fd));
retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen);
if (reftype == 0)
{ /* not by value */
@@ -1029,7 +1038,9 @@ array_clip(ArrayType *array,
memmove(buff, &rsize, VARHDRSZ);
#ifdef LOARRAY
if (!*isNull)
bytes = LOwrite(newfd, (struct varlena *) buff);
bytes = DatumGetInt32(DirectFunctionCall2(lowrite,
Int32GetDatum(newfd),
PointerGetDatum(buff)));
#endif
pfree(buff);
}
@@ -1140,20 +1151,25 @@ array_set(ArrayType *array,
if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0)
return (char *) array;
#endif
if (lo_lseek(fd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
return (char *) array;
v = (struct varlena *) palloc(elmlen + VARHDRSZ);
VARSIZE(v) = elmlen + VARHDRSZ;
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, VARDATA(v));
#ifdef LOARRAY
n = LOwrite(fd, v);
n = DatumGetInt32(DirectFunctionCall2(lowrite,
Int32GetDatum(fd),
PointerGetDatum(v)));
#endif
/*
* if (n < VARSIZE(v) - VARHDRSZ) RETURN_NULL;
*/
pfree(v);
lo_close(fd);
DirectFunctionCall1(lo_close, Int32GetDatum(fd));
return (char *) array;
}
if (elmlen > 0)
@@ -1270,14 +1286,14 @@ array_assgn(ArrayType *array,
return (char *) array;
#endif
_LOArrayRange(lowerIndx, upperIndx, len, fd, newfd, array, 1, isNull);
lo_close(newfd);
DirectFunctionCall1(lo_close, Int32GetDatum(newfd));
}
else
{
_LOArrayRange(lowerIndx, upperIndx, len, fd, (int) ARR_DATA_PTR(newArr),
array, 0, isNull);
}
lo_close(fd);
DirectFunctionCall1(lo_close, Int32GetDatum(fd));
return (char *) array;
}
_ArrayRange(lowerIndx, upperIndx, len, ARR_DATA_PTR(newArr), array, 0);
@@ -1758,7 +1774,10 @@ _LOArrayRange(int *st,
mda_get_prod(n, dim, prod);
st_pos = tuple2linear(n, st, prod);
offset = st_pos * bsize;
if (lo_lseek(srcfd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(srcfd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
return;
mda_get_range(n, span, st, endp);
mda_get_offset_values(n, dist, prod, span);
@@ -1770,7 +1789,10 @@ _LOArrayRange(int *st,
do
{
offset += (dist[j] * bsize);
if (lo_lseek(srcfd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(srcfd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
return;
tmp = _LOtransfer((char **) &srcfd, inc, 1, (char **) &destfd, isSrcLO, 1);
if (tmp < inc)
@@ -1812,7 +1834,10 @@ _ReadArray(int *st,
mda_get_prod(n, dim, prod);
st_pos = tuple2linear(n, st, prod);
offset = st_pos * bsize;
if (lo_lseek(srcfd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(srcfd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
return;
mda_get_range(n, span, st, endp);
mda_get_offset_values(n, dist, prod, span);
@@ -1824,7 +1849,10 @@ _ReadArray(int *st,
do
{
offset += (dist[j] * bsize);
if (lo_lseek(srcfd, offset, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(srcfd),
Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0)
return;
tmp = _LOtransfer((char **) &destfd, inc, 1, (char **) &srcfd, 1, isDestLO);
if (tmp < inc)
@@ -1857,13 +1885,18 @@ _LOtransfer(char **destfd,
resid > 0 && (inc = min(resid, MAX_READ)) > 0; resid -= inc)
{
#ifdef LOARRAY
v = (struct varlena *) LOread((int) *srcfd, inc);
v = (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread,
Int32GetDatum((int32) *srcfd),
Int32GetDatum(inc)));
if (VARSIZE(v) - VARHDRSZ < inc)
{
pfree(v);
return -1;
}
tmp += LOwrite((int) *destfd, v);
tmp += DatumGetInt32(DirectFunctionCall2(lowrite,
Int32GetDatum((int32) *destfd),
PointerGetDatum(v)));
#endif
pfree(v);

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.25 2000/01/26 05:57:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.26 2000/06/09 01:11:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -385,7 +385,9 @@ write_chunk(struct varlena * a_chunk, int ofile)
int got_n = 0;
#ifdef LOARRAY
got_n = LOwrite(ofile, a_chunk);
got_n = DatumGetInt32(DirectFunctionCall2(lowrite,
Int32GetDatum(ofile),
PointerGetDatum(a_chunk)));
#endif
return got_n;
}
@@ -400,13 +402,19 @@ write_chunk(struct varlena * a_chunk, int ofile)
static int
seek_and_read(int pos, int size, char *buff, int fp, int from)
{
struct varlena *v = NULL;
struct varlena *v;
/* Assuming only one file */
if (lo_lseek(fp, pos, from) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fp),
Int32GetDatum(pos),
Int32GetDatum(from))) < 0)
elog(ERROR, "File seek error");
#ifdef LOARRAY
v = (struct varlena *) LOread(fp, size);
v = (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread,
Int32GetDatum(fp),
Int32GetDatum(size)));
#endif
if (VARSIZE(v) - VARHDRSZ < size)
elog(ERROR, "File read error");
@@ -505,7 +513,10 @@ _ReadChunkArray(int *st,
for (i = j = 0; i < n; i++)
j += chunk_st[i] * PC[i];
temp_seek = srcOff = j * csize * bsize;
if (lo_lseek(fp, srcOff, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fp),
Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
jj = n - 1;
@@ -526,7 +537,10 @@ _ReadChunkArray(int *st,
bptr *= bsize;
if (isDestLO)
{
if (lo_lseek((int) destfp, bptr, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum((int32) destfp),
Int32GetDatum(bptr),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
}
else
@@ -538,7 +552,10 @@ _ReadChunkArray(int *st,
{
temp = (dist[jj] * csize + block_seek + temp_seek) * bsize;
srcOff += temp;
if (lo_lseek(fp, srcOff, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fp),
Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
}
for (i = n - 1, to_read = bsize; i >= 0;
@@ -550,14 +567,20 @@ _ReadChunkArray(int *st,
if (cdist[j])
{
srcOff += (cdist[j] * bsize);
if (lo_lseek(fp, srcOff, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fp),
Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
}
block_seek += cdist[j];
bptr += adist[j] * bsize;
if (isDestLO)
{
if (lo_lseek((int) destfp, bptr, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum((int32) destfp),
Int32GetDatum(bptr),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
}
else
@@ -675,10 +698,16 @@ _ReadChunkArray1El(int *st,
srcOff += (st[i] - chunk_st[i] * C[i]) * PCHUNK[i];
srcOff *= bsize;
if (lo_lseek(fp, srcOff, SEEK_SET) < 0)
if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fp),
Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL;
#ifdef LOARRAY
return (struct varlena *) LOread(fp, bsize);
return (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread,
Int32GetDatum(fp),
Int32GetDatum(bsize)));
#endif
return (struct varlena *) 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.9 2000/06/05 07:28:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.10 2000/06/09 01:11:08 tgl Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc
@@ -2372,9 +2372,11 @@ DCH_cache_search(char *str)
* TIMESTAMP to_char()
* -------------------
*/
text *
timestamp_to_char(Timestamp *dt, text *fmt)
Datum
timestamp_to_char(PG_FUNCTION_ARGS)
{
Timestamp dt = PG_GETARG_TIMESTAMP(0);
text *fmt = PG_GETARG_TEXT_P(1);
text *result,
*result_tmp;
FormatNode *format;
@@ -2386,13 +2388,10 @@ timestamp_to_char(Timestamp *dt, text *fmt)
flag = 0,
x = 0;
if ((!PointerIsValid(dt)) || (!PointerIsValid(fmt)))
return NULL;
len = VARSIZE(fmt) - VARHDRSZ;
if ((!len) || (TIMESTAMP_NOT_FINITE(*dt)))
return textin("");
if ((!len) || (TIMESTAMP_NOT_FINITE(dt)))
return PointerGetDatum(textin(""));
tm->tm_sec = 0;
tm->tm_year = 0;
@@ -2404,18 +2403,18 @@ timestamp_to_char(Timestamp *dt, text *fmt)
tm->tm_isdst = 0;
tm->tm_mon = 1;
if (TIMESTAMP_IS_EPOCH(*dt))
if (TIMESTAMP_IS_EPOCH(dt))
{
x = timestamp2tm(SetTimestamp(*dt), NULL, tm, &fsec, NULL);
x = timestamp2tm(SetTimestamp(dt), NULL, tm, &fsec, NULL);
}
else if (TIMESTAMP_IS_CURRENT(*dt))
else if (TIMESTAMP_IS_CURRENT(dt))
{
x = timestamp2tm(SetTimestamp(*dt), &tz, tm, &fsec, &tzn);
x = timestamp2tm(SetTimestamp(dt), &tz, tm, &fsec, &tzn);
}
else
x = timestamp2tm(*dt, &tz, tm, &fsec, &tzn);
x = timestamp2tm(dt, &tz, tm, &fsec, &tzn);
if (x != 0)
elog(ERROR, "to_char(): Unable to convert timestamp to tm");
@@ -2508,7 +2507,7 @@ timestamp_to_char(Timestamp *dt, text *fmt)
VARSIZE(result) = len + VARHDRSZ;
pfree(result_tmp);
return result;
PG_RETURN_TEXT_P(result);
}
@@ -2519,20 +2518,19 @@ timestamp_to_char(Timestamp *dt, text *fmt)
* ( to_timestamp is reverse to_char() )
* ---------------------
*/
Timestamp *
to_timestamp(text *date_str, text *fmt)
Datum
to_timestamp(PG_FUNCTION_ARGS)
{
text *date_str = PG_GETARG_TEXT_P(0);
text *fmt = PG_GETARG_TEXT_P(1);
FormatNode *format;
int flag = 0;
Timestamp *result;
Timestamp result;
char *str;
int len = 0,
fsec = 0,
tz = 0;
if ((!PointerIsValid(date_str)) || (!PointerIsValid(fmt)))
return NULL;
tm->tm_sec = 0;
tm->tm_year = 0;
tm->tm_min = 0;
@@ -2543,8 +2541,6 @@ to_timestamp(text *date_str, text *fmt)
tm->tm_isdst = 0;
tm->tm_mon = 1;
result = palloc(sizeof(Timestamp));
len = VARSIZE(fmt) - VARHDRSZ;
if (len)
@@ -2668,10 +2664,10 @@ to_timestamp(text *date_str, text *fmt)
#ifdef DEBUG_TO_FROM_CHAR
NOTICE_TM;
#endif
if (tm2timestamp(tm, fsec, &tz, result) != 0)
elog(ERROR, "to_datatime(): can't convert 'tm' to timestamp.");
if (tm2timestamp(tm, fsec, &tz, &result) != 0)
elog(ERROR, "to_timestamp(): can't convert 'tm' to timestamp.");
return result;
PG_RETURN_TIMESTAMP(result);
}
/* ----------
@@ -2679,10 +2675,13 @@ to_timestamp(text *date_str, text *fmt)
* Make Date from date_str which is formated at argument 'fmt'
* ----------
*/
DateADT
to_date(text *date_str, text *fmt)
Datum
to_date(PG_FUNCTION_ARGS)
{
return timestamp_date(to_timestamp(date_str, fmt));
/* Quick hack: since our inputs are just like to_timestamp,
* hand over the whole input info struct...
*/
return DirectFunctionCall1(timestamp_date, to_timestamp(fcinfo));
}
/**********************************************************************

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.22 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.23 2000/06/09 01:11:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,23 +34,28 @@ static int my_varattno(Relation rd, char *a);
*
* ----------------------------------------------------------------
*/
bool
int4notin(int32 not_in_arg, char *relation_and_attr)
Datum
int4notin(PG_FUNCTION_ARGS)
{
int32 not_in_arg = PG_GETARG_INT32(0);
text *relation_and_attr = PG_GETARG_TEXT_P(1);
Relation relation_to_scan;
int32 integer_value;
HeapTuple current_tuple;
HeapScanDesc scan_descriptor;
bool dummy,
bool isNull,
retval;
int attrid;
int attrid,
strlength;
char *relation,
*attribute;
char my_copy[NAMEDATALEN * 2 + 2];
Datum value;
strncpy(my_copy, relation_and_attr, sizeof(my_copy));
my_copy[sizeof(my_copy) - 1] = '\0';
strlength = VARSIZE(relation_and_attr) - VARHDRSZ + 1;
if (strlength > sizeof(my_copy))
strlength = sizeof(my_copy);
StrNCpy(my_copy, VARDATA(relation_and_attr), strlength);
relation = (char *) strtok(my_copy, ".");
attribute = (char *) strtok(NULL, ".");
@@ -81,7 +86,9 @@ int4notin(int32 not_in_arg, char *relation_and_attr)
value = heap_getattr(current_tuple,
(AttrNumber) attrid,
RelationGetDescr(relation_to_scan),
&dummy);
&isNull);
if (isNull)
continue;
integer_value = DatumGetInt32(value);
if (not_in_arg == integer_value)
{
@@ -94,15 +101,21 @@ int4notin(int32 not_in_arg, char *relation_and_attr)
heap_endscan(scan_descriptor);
heap_close(relation_to_scan, AccessShareLock);
return retval;
PG_RETURN_BOOL(retval);
}
bool
oidnotin(Oid the_oid, char *compare)
Datum
oidnotin(PG_FUNCTION_ARGS)
{
Oid the_oid = PG_GETARG_OID(0);
#ifdef NOT_USED
text *relation_and_attr = PG_GETARG_TEXT_P(1);
#endif
if (the_oid == InvalidOid)
return false;
return int4notin(the_oid, compare);
PG_RETURN_BOOL(false);
/* XXX assume oid maps to int4 */
return int4notin(fcinfo);
}
/*
@@ -117,7 +130,7 @@ my_varattno(Relation rd, char *a)
for (i = 0; i < rd->rd_rel->relnatts; i++)
{
if (!namestrcmp(&rd->rd_att->attrs[i]->attname, a))
if (namestrcmp(&rd->rd_att->attrs[i]->attname, a) == 0)
return i + 1;
}
return -1;

View File

@@ -3,7 +3,7 @@
* out of its tuple
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.50 2000/05/30 04:24:51 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.51 2000/06/09 01:11:09 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -319,9 +319,10 @@ pg_get_viewdef(NameData *rname)
* get_indexdef - Get the definition of an index
* ----------
*/
text *
pg_get_indexdef(Oid indexrelid)
Datum
pg_get_indexdef(PG_FUNCTION_ARGS)
{
Oid indexrelid = PG_GETARG_OID(0);
text *indexdef;
HeapTuple ht_idx;
HeapTuple ht_idxrel;
@@ -541,7 +542,7 @@ pg_get_indexdef(Oid indexrelid)
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "get_viewdef: SPI_finish() failed");
return indexdef;
PG_RETURN_TEXT_P(indexdef);
}

View File

@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.69 2000/06/05 07:28:52 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.70 2000/06/09 01:11:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1038,14 +1038,16 @@ convert_timevalue_to_scalar(Datum value, Oid typid)
switch (typid)
{
case TIMESTAMPOID:
return *((Timestamp *) DatumGetPointer(value));
return DatumGetTimestamp(value);
case ABSTIMEOID:
return *abstime_timestamp(value);
return DatumGetTimestamp(DirectFunctionCall1(abstime_timestamp,
value));
case DATEOID:
return *date_timestamp(value);
return DatumGetTimestamp(DirectFunctionCall1(date_timestamp,
value));
case INTERVALOID:
{
Interval *interval = (Interval *) DatumGetPointer(value);
Interval *interval = DatumGetIntervalP(value);
/*
* Convert the month part of Interval to days using
@@ -1056,17 +1058,17 @@ convert_timevalue_to_scalar(Datum value, Oid typid)
interval->month * (365.25 / 12.0 * 24.0 * 60.0 * 60.0);
}
case RELTIMEOID:
return (RelativeTime) DatumGetInt32(value);
return DatumGetRelativeTime(value);
case TINTERVALOID:
{
TimeInterval interval = (TimeInterval) DatumGetPointer(value);
TimeInterval interval = DatumGetTimeInterval(value);
if (interval->status != 0)
return interval->data[1] - interval->data[0];
return 0; /* for lack of a better idea */
}
case TIMEOID:
return *((TimeADT *) DatumGetPointer(value));
return DatumGetTimeADT(value);
}
/* Can't get here unless someone tries to use scalarltsel/scalargtsel
* on an operator with one timevalue and one non-timevalue operand.

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.31 2000/05/28 17:56:06 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.32 2000/06/09 01:11:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -140,8 +140,12 @@ SetDefine(char *querystr, char *typename)
* never executed. At runtime, the OID of the actual set is substituted
* into the :funcid.
*/
int
seteval(Oid funcoid)
Datum
seteval(PG_FUNCTION_ARGS)
{
return 17;
Oid funcoid = PG_GETARG_OID(0);
elog(ERROR, "seteval called for OID %u", funcoid);
PG_RETURN_INT32(0); /* keep compiler happy */
}

View File

@@ -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;
text *relname = PG_GETARG_TEXT_P(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
ItemPointer result,
ret;
char *str;
Relation rel;
if (!relname)
return result;
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);
}

File diff suppressed because it is too large Load Diff