Another batch of fmgr updates. I think I have gotten all old-style

functions that take pass-by-value datatypes.  Should be ready for
port testing ...
This commit is contained in:
Tom Lane 2000-06-13 07:35:40 +00:00
parent 8f057d971d
commit f2d1205322
51 changed files with 1640 additions and 1592 deletions

@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.55 2000/05/30 04:24:28 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.56 2000/06/13 07:34:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -47,7 +47,6 @@ static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, int level,
static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it,
GISTSTATE *giststate); GISTSTATE *giststate);
static int gistnospace(Page p, IndexTuple it); static int gistnospace(Page p, IndexTuple it);
void gistdelete(Relation r, ItemPointer tid);
static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t); static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t);
static void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, static void gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
Relation r, Page pg, OffsetNumber o, int b, bool l); Relation r, Page pg, OffsetNumber o, int b, bool l);
@ -60,17 +59,20 @@ static char *int_range_out(INTRANGE *r);
/* /*
** routine to build an index. Basically calls insert over and over ** routine to build an index. Basically calls insert over and over
*/ */
void Datum
gistbuild(Relation heap, gistbuild(PG_FUNCTION_ARGS)
Relation index,
int natts,
AttrNumber *attnum,
IndexStrategy istrat,
uint16 pint,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo)
{ {
Relation heap = (Relation) PG_GETARG_POINTER(0);
Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
#ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc scan; HeapScanDesc scan;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
@ -83,12 +85,10 @@ gistbuild(Relation heap,
int nb, int nb,
nh, nh,
ni; ni;
#ifndef OMIT_PARTIAL_INDEX #ifndef OMIT_PARTIAL_INDEX
ExprContext *econtext; ExprContext *econtext;
TupleTable tupleTable; TupleTable tupleTable;
TupleTableSlot *slot; TupleTableSlot *slot;
#endif #endif
Node *pred, Node *pred,
*oldPred; *oldPred;
@ -302,6 +302,8 @@ gistbuild(Relation heap,
/* be tidy */ /* be tidy */
pfree(nulls); pfree(nulls);
pfree(d); pfree(d);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
@ -310,9 +312,16 @@ gistbuild(Relation heap,
* This is the public interface routine for tuple insertion in GiSTs. * This is the public interface routine for tuple insertion in GiSTs.
* It doesn't do any work; just locks the relation and passes the buck. * It doesn't do any work; just locks the relation and passes the buck.
*/ */
InsertIndexResult Datum
gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) gistinsert(PG_FUNCTION_ARGS)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
InsertIndexResult res; InsertIndexResult res;
IndexTuple itup; IndexTuple itup;
GISTSTATE giststate; GISTSTATE giststate;
@ -351,7 +360,7 @@ gistinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
pfree(itup); pfree(itup);
pfree(compvec); pfree(compvec);
return res; PG_RETURN_POINTER(res);
} }
/* /*
@ -596,7 +605,9 @@ gistAdjustKeys(Relation r,
/* delete old tuple */ /* delete old tuple */
ItemPointerSet(&oldtid, stk->gs_blk, stk->gs_child); ItemPointerSet(&oldtid, stk->gs_blk, stk->gs_child);
gistdelete(r, (ItemPointer) &oldtid); DirectFunctionCall2(gistdelete,
PointerGetDatum(r),
PointerGetDatum(&oldtid));
/* generate and insert new tuple */ /* generate and insert new tuple */
tupDesc = r->rd_att; tupDesc = r->rd_att;
@ -890,7 +901,9 @@ gistintinsert(Relation r,
/* remove old left pointer, insert the 2 new entries */ /* remove old left pointer, insert the 2 new entries */
ItemPointerSet(&ltid, stk->gs_blk, stk->gs_child); ItemPointerSet(&ltid, stk->gs_blk, stk->gs_child);
gistdelete(r, (ItemPointer) &ltid); DirectFunctionCall2(gistdelete,
PointerGetDatum(r),
PointerGetDatum(&ltid));
gistentryinserttwo(r, stk, ltup, rtup, giststate); gistentryinserttwo(r, stk, ltup, rtup, giststate);
} }
@ -1105,9 +1118,11 @@ gistfreestack(GISTSTACK *s)
/* /*
** remove an entry from a page ** remove an entry from a page
*/ */
void Datum
gistdelete(Relation r, ItemPointer tid) gistdelete(PG_FUNCTION_ARGS)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
BlockNumber blkno; BlockNumber blkno;
OffsetNumber offnum; OffsetNumber offnum;
Buffer buf; Buffer buf;
@ -1134,6 +1149,7 @@ gistdelete(Relation r, ItemPointer tid)
WriteBuffer(buf); WriteBuffer(buf);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void void

@ -29,21 +29,23 @@ static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc,
Relation r, Page p, OffsetNumber offset); Relation r, Page p, OffsetNumber offset);
RetrieveIndexResult Datum
gistgettuple(IndexScanDesc s, ScanDirection dir) gistgettuple(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res; RetrieveIndexResult res;
/* if we have it cached in the scan desc, just return the value */ /* if we have it cached in the scan desc, just return the value */
if ((res = gistscancache(s, dir)) != (RetrieveIndexResult) NULL) if ((res = gistscancache(s, dir)) != (RetrieveIndexResult) NULL)
return res; PG_RETURN_POINTER(res);
/* not cached, so we'll have to do some work */ /* not cached, so we'll have to do some work */
if (ItemPointerIsValid(&(s->currentItemData))) if (ItemPointerIsValid(&(s->currentItemData)))
res = gistnext(s, dir); res = gistnext(s, dir);
else else
res = gistfirst(s, dir); res = gistfirst(s, dir);
return res; PG_RETURN_POINTER(res);
} }
static RetrieveIndexResult static RetrieveIndexResult

@ -48,12 +48,13 @@ typedef GISTScanListData *GISTScanList;
/* pointer to list of local scans on GiSTs */ /* pointer to list of local scans on GiSTs */
static GISTScanList GISTScans = (GISTScanList) NULL; static GISTScanList GISTScans = (GISTScanList) NULL;
IndexScanDesc Datum
gistbeginscan(Relation r, gistbeginscan(PG_FUNCTION_ARGS)
bool fromEnd,
uint16 nkeys,
ScanKey key)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
uint16 nkeys = PG_GETARG_UINT16(2);
ScanKey key = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc s; IndexScanDesc s;
/* /*
@ -65,21 +66,18 @@ gistbeginscan(Relation r,
s = RelationGetIndexScan(r, fromEnd, nkeys, key); s = RelationGetIndexScan(r, fromEnd, nkeys, key);
gistregscan(s); gistregscan(s);
return s; PG_RETURN_POINTER(s);
} }
void Datum
gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key) gistrescan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
ScanKey key = (ScanKey) PG_GETARG_POINTER(2);
GISTScanOpaque p; GISTScanOpaque p;
int i; int i;
if (!IndexScanIsValid(s))
{
elog(ERROR, "gistrescan: invalid scan.");
return;
}
/* /*
* Clear all the pointers. * Clear all the pointers.
*/ */
@ -155,11 +153,14 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
s->keyData[i].sk_func = p->giststate->consistentFn; s->keyData[i].sk_func = p->giststate->consistentFn;
} }
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
gistmarkpos(IndexScanDesc s) gistmarkpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p; GISTScanOpaque p;
GISTSTACK *o, GISTSTACK *o,
*n, *n,
@ -188,11 +189,14 @@ gistmarkpos(IndexScanDesc s)
gistfreestack(p->s_markstk); gistfreestack(p->s_markstk);
p->s_markstk = o; p->s_markstk = o;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
gistrestrpos(IndexScanDesc s) gistrestrpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p; GISTScanOpaque p;
GISTSTACK *o, GISTSTACK *o,
*n, *n,
@ -221,11 +225,14 @@ gistrestrpos(IndexScanDesc s)
gistfreestack(p->s_stack); gistfreestack(p->s_stack);
p->s_stack = o; p->s_stack = o;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
gistendscan(IndexScanDesc s) gistendscan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
GISTScanOpaque p; GISTScanOpaque p;
p = (GISTScanOpaque) s->opaque; p = (GISTScanOpaque) s->opaque;
@ -239,6 +246,8 @@ gistendscan(IndexScanDesc s)
gistdropscan(s); gistdropscan(s);
/* XXX don't unset read lock -- two-phase locking */ /* XXX don't unset read lock -- two-phase locking */
PG_RETURN_POINTER(NULL); /* no real return value */
} }
static void static void

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.37 2000/04/12 17:14:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.38 2000/06/13 07:34:28 tgl Exp $
* *
* NOTES * NOTES
* This file contains only the public interface routines. * This file contains only the public interface routines.
@ -36,17 +36,20 @@ bool BuildingHash = false;
* since the index won't be visible until this transaction commits * since the index won't be visible until this transaction commits
* and since building is guaranteed to be single-threaded. * and since building is guaranteed to be single-threaded.
*/ */
void Datum
hashbuild(Relation heap, hashbuild(PG_FUNCTION_ARGS)
Relation index,
int natts,
AttrNumber *attnum,
IndexStrategy istrat,
uint16 pcount,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo)
{ {
Relation heap = (Relation) PG_GETARG_POINTER(0);
Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
#ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc hscan; HeapScanDesc hscan;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
@ -262,6 +265,8 @@ hashbuild(Relation heap,
/* all done */ /* all done */
BuildingHash = false; BuildingHash = false;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
@ -271,20 +276,26 @@ hashbuild(Relation heap,
* for the new tuple, put it there, and return an InsertIndexResult * for the new tuple, put it there, and return an InsertIndexResult
* to the caller. * to the caller.
*/ */
InsertIndexResult Datum
hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) hashinsert(PG_FUNCTION_ARGS)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
InsertIndexResult res;
HashItem hitem; HashItem hitem;
IndexTuple itup; IndexTuple itup;
InsertIndexResult res;
/* generate an index tuple */ /* generate an index tuple */
itup = index_formtuple(RelationGetDescr(rel), datum, nulls); itup = index_formtuple(RelationGetDescr(rel), datum, nulls);
itup->t_tid = *ht_ctid; itup->t_tid = *ht_ctid;
if (itup->t_info & INDEX_NULL_MASK) if (itup->t_info & INDEX_NULL_MASK)
return (InsertIndexResult) NULL; PG_RETURN_POINTER((InsertIndexResult) NULL);
hitem = _hash_formitem(itup); hitem = _hash_formitem(itup);
@ -293,16 +304,18 @@ hashinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relatio
pfree(hitem); pfree(hitem);
pfree(itup); pfree(itup);
return res; PG_RETURN_POINTER(res);
} }
/* /*
* hashgettuple() -- Get the next tuple in the scan. * hashgettuple() -- Get the next tuple in the scan.
*/ */
char * Datum
hashgettuple(IndexScanDesc scan, ScanDirection dir) hashgettuple(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res; RetrieveIndexResult res;
/* /*
@ -316,19 +329,20 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir)
else else
res = _hash_first(scan, dir); res = _hash_first(scan, dir);
return (char *) res; PG_RETURN_POINTER(res);
} }
/* /*
* hashbeginscan() -- start a scan on a hash index * hashbeginscan() -- start a scan on a hash index
*/ */
char * Datum
hashbeginscan(Relation rel, hashbeginscan(PG_FUNCTION_ARGS)
bool fromEnd,
uint16 keysz,
ScanKey scankey)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
uint16 keysz = PG_GETARG_UINT16(2);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc scan; IndexScanDesc scan;
HashScanOpaque so; HashScanOpaque so;
@ -341,15 +355,20 @@ hashbeginscan(Relation rel,
/* register scan in case we change pages it's using */ /* register scan in case we change pages it's using */
_hash_regscan(scan); _hash_regscan(scan);
return (char *) scan; PG_RETURN_POINTER(scan);
} }
/* /*
* hashrescan() -- rescan an index relation * hashrescan() -- rescan an index relation
*/ */
void Datum
hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) hashrescan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
bool fromEnd = PG_GETARG_BOOL(1);
#endif
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr; ItemPointer iptr;
HashScanOpaque so; HashScanOpaque so;
@ -376,15 +395,17 @@ hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
scankey, scankey,
scan->numberOfKeys * sizeof(ScanKeyData)); scan->numberOfKeys * sizeof(ScanKeyData));
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
* hashendscan() -- close down a scan * hashendscan() -- close down a scan
*/ */
void Datum
hashendscan(IndexScanDesc scan) hashendscan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
HashScanOpaque so; HashScanOpaque so;
@ -411,26 +432,21 @@ hashendscan(IndexScanDesc scan)
/* be tidy */ /* be tidy */
pfree(scan->opaque); pfree(scan->opaque);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
* hashmarkpos() -- save current scan position * hashmarkpos() -- save current scan position
* *
*/ */
void Datum
hashmarkpos(IndexScanDesc scan) hashmarkpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
HashScanOpaque so; HashScanOpaque so;
/*
* see if we ever call this code. if we do, then so_mrkbuf a useful
* element in the scan->opaque structure. if this procedure is never
* called, so_mrkbuf should be removed from the scan->opaque
* structure.
*/
elog(NOTICE, "Hashmarkpos() called.");
so = (HashScanOpaque) scan->opaque; so = (HashScanOpaque) scan->opaque;
/* release lock on old marked data, if any */ /* release lock on old marked data, if any */
@ -449,25 +465,20 @@ hashmarkpos(IndexScanDesc scan)
HASH_READ); HASH_READ);
scan->currentMarkData = scan->currentItemData; scan->currentMarkData = scan->currentItemData;
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
* hashrestrpos() -- restore scan to last saved position * hashrestrpos() -- restore scan to last saved position
*/ */
void Datum
hashrestrpos(IndexScanDesc scan) hashrestrpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
HashScanOpaque so; HashScanOpaque so;
/*
* see if we ever call this code. if we do, then so_mrkbuf a useful
* element in the scan->opaque structure. if this procedure is never
* called, so_mrkbuf should be removed from the scan->opaque
* structure.
*/
elog(NOTICE, "Hashrestrpos() called.");
so = (HashScanOpaque) scan->opaque; so = (HashScanOpaque) scan->opaque;
/* release lock on current data, if any */ /* release lock on current data, if any */
@ -487,15 +498,22 @@ hashrestrpos(IndexScanDesc scan)
scan->currentItemData = scan->currentMarkData; scan->currentItemData = scan->currentMarkData;
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* stubs */ /* stubs */
void Datum
hashdelete(Relation rel, ItemPointer tid) hashdelete(PG_FUNCTION_ARGS)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
/* adjust any active scans that will be affected by this deletion */ /* adjust any active scans that will be affected by this deletion */
_hash_adjscans(rel, tid); _hash_adjscans(rel, tid);
/* delete the data from the page */ /* delete the data from the page */
_hash_pagedel(rel, tid); _hash_pagedel(rel, tid);
PG_RETURN_POINTER(NULL); /* no real return value */
} }

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.44 2000/05/30 04:24:32 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.45 2000/06/13 07:34:35 tgl Exp $
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
* index_open - open an index relation by relationId * index_open - open an index relation by relationId
@ -195,13 +195,12 @@ index_insert(Relation relation,
* ---------------- * ----------------
*/ */
specificResult = (InsertIndexResult) specificResult = (InsertIndexResult)
DatumGetPointer(OidFunctionCall6(procedure, DatumGetPointer(OidFunctionCall5(procedure,
PointerGetDatum(relation), PointerGetDatum(relation),
PointerGetDatum(datum), PointerGetDatum(datum),
PointerGetDatum(nulls), PointerGetDatum(nulls),
PointerGetDatum(heap_t_ctid), PointerGetDatum(heap_t_ctid),
PointerGetDatum(heapRel), PointerGetDatum(heapRel)));
PointerGetDatum(NULL)));
/* must be pfree'ed */ /* must be pfree'ed */
return specificResult; return specificResult;

@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.55 2000/05/31 00:28:14 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.56 2000/06/13 07:34:38 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -42,17 +42,20 @@ static void _bt_restscan(IndexScanDesc scan);
* since the index won't be visible until this transaction commits * since the index won't be visible until this transaction commits
* and since building is guaranteed to be single-threaded. * and since building is guaranteed to be single-threaded.
*/ */
void Datum
btbuild(Relation heap, btbuild(PG_FUNCTION_ARGS)
Relation index,
int natts,
AttrNumber *attnum,
IndexStrategy istrat,
uint16 pcount,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo)
{ {
Relation heap = (Relation) PG_GETARG_POINTER(0);
Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
#ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc hscan; HeapScanDesc hscan;
HeapTuple htup; HeapTuple htup;
IndexTuple itup; IndexTuple itup;
@ -332,6 +335,8 @@ btbuild(Relation heap,
/* all done */ /* all done */
BuildingBtree = false; BuildingBtree = false;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
@ -341,12 +346,17 @@ btbuild(Relation heap,
* new tuple, put it there, set its unique OID as appropriate, and * new tuple, put it there, set its unique OID as appropriate, and
* return an InsertIndexResult to the caller. * return an InsertIndexResult to the caller.
*/ */
InsertIndexResult Datum
btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) btinsert(PG_FUNCTION_ARGS)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
InsertIndexResult res;
BTItem btitem; BTItem btitem;
IndexTuple itup; IndexTuple itup;
InsertIndexResult res;
/* generate an index tuple */ /* generate an index tuple */
itup = index_formtuple(RelationGetDescr(rel), datum, nulls); itup = index_formtuple(RelationGetDescr(rel), datum, nulls);
@ -355,7 +365,8 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
/* /*
* See comments in btbuild. * See comments in btbuild.
* *
* if (itup->t_info & INDEX_NULL_MASK) return (InsertIndexResult) NULL; * if (itup->t_info & INDEX_NULL_MASK)
* PG_RETURN_POINTER((InsertIndexResult) NULL);
*/ */
btitem = _bt_formitem(itup); btitem = _bt_formitem(itup);
@ -366,15 +377,17 @@ btinsert(Relation rel, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation
pfree(btitem); pfree(btitem);
pfree(itup); pfree(itup);
return res; PG_RETURN_POINTER(res);
} }
/* /*
* btgettuple() -- Get the next tuple in the scan. * btgettuple() -- Get the next tuple in the scan.
*/ */
char * Datum
btgettuple(IndexScanDesc scan, ScanDirection dir) btgettuple(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res; RetrieveIndexResult res;
/* /*
@ -403,18 +416,23 @@ btgettuple(IndexScanDesc scan, ScanDirection dir)
if (res) if (res)
{ {
((BTScanOpaque) scan->opaque)->curHeapIptr = res->heap_iptr; ((BTScanOpaque) scan->opaque)->curHeapIptr = res->heap_iptr;
LockBuffer(((BTScanOpaque) scan->opaque)->btso_curbuf, BUFFER_LOCK_UNLOCK); LockBuffer(((BTScanOpaque) scan->opaque)->btso_curbuf,
BUFFER_LOCK_UNLOCK);
} }
return (char *) res; PG_RETURN_POINTER(res);
} }
/* /*
* btbeginscan() -- start a scan on a btree index * btbeginscan() -- start a scan on a btree index
*/ */
char * Datum
btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) btbeginscan(PG_FUNCTION_ARGS)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
uint16 keysz = PG_GETARG_UINT16(2);
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc scan; IndexScanDesc scan;
/* get the scan */ /* get the scan */
@ -423,15 +441,20 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey)
/* register scan in case we change pages it's using */ /* register scan in case we change pages it's using */
_bt_regscan(scan); _bt_regscan(scan);
return (char *) scan; PG_RETURN_POINTER(scan);
} }
/* /*
* btrescan() -- rescan an index relation * btrescan() -- rescan an index relation
*/ */
void Datum
btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) btrescan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
#ifdef NOT_USED /* XXX surely it's wrong to ignore this? */
bool fromEnd = PG_GETARG_BOOL(1);
#endif
ScanKey scankey = (ScanKey) PG_GETARG_POINTER(2);
ItemPointer iptr; ItemPointer iptr;
BTScanOpaque so; BTScanOpaque so;
@ -479,6 +502,7 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey)
so->numberOfKeys * sizeof(ScanKeyData)); so->numberOfKeys * sizeof(ScanKeyData));
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void void
@ -504,9 +528,10 @@ btmovescan(IndexScanDesc scan, Datum v)
/* /*
* btendscan() -- close down a scan * btendscan() -- close down a scan
*/ */
void Datum
btendscan(IndexScanDesc scan) btendscan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
BTScanOpaque so; BTScanOpaque so;
@ -534,14 +559,17 @@ btendscan(IndexScanDesc scan)
pfree(so); pfree(so);
_bt_dropscan(scan); _bt_dropscan(scan);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
* btmarkpos() -- save current scan position * btmarkpos() -- save current scan position
*/ */
void Datum
btmarkpos(IndexScanDesc scan) btmarkpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
BTScanOpaque so; BTScanOpaque so;
@ -563,14 +591,17 @@ btmarkpos(IndexScanDesc scan)
scan->currentMarkData = scan->currentItemData; scan->currentMarkData = scan->currentItemData;
so->mrkHeapIptr = so->curHeapIptr; so->mrkHeapIptr = so->curHeapIptr;
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
* btrestrpos() -- restore scan to last saved position * btrestrpos() -- restore scan to last saved position
*/ */
void Datum
btrestrpos(IndexScanDesc scan) btrestrpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);
ItemPointer iptr; ItemPointer iptr;
BTScanOpaque so; BTScanOpaque so;
@ -593,17 +624,24 @@ btrestrpos(IndexScanDesc scan)
scan->currentItemData = scan->currentMarkData; scan->currentItemData = scan->currentMarkData;
so->curHeapIptr = so->mrkHeapIptr; so->curHeapIptr = so->mrkHeapIptr;
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* stubs */ /* stubs */
void Datum
btdelete(Relation rel, ItemPointer tid) btdelete(PG_FUNCTION_ARGS)
{ {
Relation rel = (Relation) PG_GETARG_POINTER(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
/* adjust any active scans that will be affected by this deletion */ /* adjust any active scans that will be affected by this deletion */
_bt_adjscans(rel, tid); _bt_adjscans(rel, tid);
/* delete the data from the page */ /* delete the data from the page */
_bt_pagedel(rel, tid); _bt_pagedel(rel, tid);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
static void static void

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.20 2000/01/26 05:56:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.21 2000/06/13 07:34:48 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -28,21 +28,23 @@ static RetrieveIndexResult rtnext(IndexScanDesc s, ScanDirection dir);
static ItemPointer rtheapptr(Relation r, ItemPointer itemp); static ItemPointer rtheapptr(Relation r, ItemPointer itemp);
RetrieveIndexResult Datum
rtgettuple(IndexScanDesc s, ScanDirection dir) rtgettuple(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1);
RetrieveIndexResult res; RetrieveIndexResult res;
/* if we have it cached in the scan desc, just return the value */ /* if we have it cached in the scan desc, just return the value */
if ((res = rtscancache(s, dir)) != (RetrieveIndexResult) NULL) if ((res = rtscancache(s, dir)) != (RetrieveIndexResult) NULL)
return res; PG_RETURN_POINTER(res);
/* not cached, so we'll have to do some work */ /* not cached, so we'll have to do some work */
if (ItemPointerIsValid(&(s->currentItemData))) if (ItemPointerIsValid(&(s->currentItemData)))
res = rtnext(s, dir); res = rtnext(s, dir);
else else
res = rtfirst(s, dir); res = rtfirst(s, dir);
return res; PG_RETURN_POINTER(res);
} }
static RetrieveIndexResult static RetrieveIndexResult

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.25 2000/01/26 05:56:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.26 2000/06/13 07:34:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -102,13 +102,15 @@ rt_poly_union(POLYGON *a, POLYGON *b)
return p; return p;
} }
void Datum
rt_poly_size(POLYGON *a, float *size) rt_poly_size(PG_FUNCTION_ARGS)
{ {
POLYGON *a = PG_GETARG_POLYGON_P(0);
/* NB: size is an output argument */
float *size = (float *) PG_GETARG_POINTER(1);
double xdim, double xdim,
ydim; ydim;
size = (float *) palloc(sizeof(float));
if (a == (POLYGON *) NULL || if (a == (POLYGON *) NULL ||
a->boundbox.high.x <= a->boundbox.low.x || a->boundbox.high.x <= a->boundbox.low.x ||
a->boundbox.high.y <= a->boundbox.low.y) a->boundbox.high.y <= a->boundbox.low.y)
@ -121,7 +123,7 @@ rt_poly_size(POLYGON *a, float *size)
*size = (float) (xdim * ydim); *size = (float) (xdim * ydim);
} }
return; PG_RETURN_POINTER(NULL); /* no real return value */
} }
POLYGON * POLYGON *

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.47 2000/05/30 04:24:34 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.48 2000/06/13 07:34:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -59,17 +59,20 @@ static int nospace(Page p, IndexTuple it);
static void initRtstate(RTSTATE *rtstate, Relation index); static void initRtstate(RTSTATE *rtstate, Relation index);
void Datum
rtbuild(Relation heap, rtbuild(PG_FUNCTION_ARGS)
Relation index,
int natts,
AttrNumber *attnum,
IndexStrategy istrat,
uint16 pcount,
Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo)
{ {
Relation heap = (Relation) PG_GETARG_POINTER(0);
Relation index = (Relation) PG_GETARG_POINTER(1);
int32 natts = PG_GETARG_INT32(2);
AttrNumber *attnum = (AttrNumber *) PG_GETARG_POINTER(3);
#ifdef NOT_USED
IndexStrategy istrat = (IndexStrategy) PG_GETARG_POINTER(4);
uint16 pcount = PG_GETARG_UINT16(5);
Datum *params = (Datum *) PG_GETARG_POINTER(6);
#endif
FuncIndexInfo *finfo = (FuncIndexInfo *) PG_GETARG_POINTER(7);
PredInfo *predInfo = (PredInfo *) PG_GETARG_POINTER(8);
HeapScanDesc scan; HeapScanDesc scan;
AttrNumber i; AttrNumber i;
HeapTuple htup; HeapTuple htup;
@ -277,6 +280,8 @@ rtbuild(Relation heap,
/* be tidy */ /* be tidy */
pfree(nulls); pfree(nulls);
pfree(d); pfree(d);
PG_RETURN_POINTER(NULL); /* no real return value */
} }
/* /*
@ -285,9 +290,16 @@ rtbuild(Relation heap,
* This is the public interface routine for tuple insertion in rtrees. * This is the public interface routine for tuple insertion in rtrees.
* It doesn't do any work; just locks the relation and passes the buck. * It doesn't do any work; just locks the relation and passes the buck.
*/ */
InsertIndexResult Datum
rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) rtinsert(PG_FUNCTION_ARGS)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
Datum *datum = (Datum *) PG_GETARG_POINTER(1);
char *nulls = (char *) PG_GETARG_POINTER(2);
ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3);
#ifdef NOT_USED
Relation heapRel = (Relation) PG_GETARG_POINTER(4);
#endif
InsertIndexResult res; InsertIndexResult res;
IndexTuple itup; IndexTuple itup;
RTSTATE rtState; RTSTATE rtState;
@ -305,7 +317,7 @@ rtinsert(Relation r, Datum *datum, char *nulls, ItemPointer ht_ctid, Relation he
res = rtdoinsert(r, itup, &rtState); res = rtdoinsert(r, itup, &rtState);
return res; PG_RETURN_POINTER(res);
} }
static InsertIndexResult static InsertIndexResult
@ -982,9 +994,11 @@ freestack(RTSTACK *s)
} }
} }
char * Datum
rtdelete(Relation r, ItemPointer tid) rtdelete(PG_FUNCTION_ARGS)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
BlockNumber blkno; BlockNumber blkno;
OffsetNumber offnum; OffsetNumber offnum;
Buffer buf; Buffer buf;
@ -1011,7 +1025,7 @@ rtdelete(Relation r, ItemPointer tid)
WriteBuffer(buf); WriteBuffer(buf);
return (char *) NULL; PG_RETURN_POINTER(NULL); /* no real return value */
} }
static void static void

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.32 2000/04/12 17:14:51 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.33 2000/06/13 07:34:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -51,12 +51,13 @@ typedef RTScanListData *RTScanList;
/* pointer to list of local scans on rtrees */ /* pointer to list of local scans on rtrees */
static RTScanList RTScans = (RTScanList) NULL; static RTScanList RTScans = (RTScanList) NULL;
IndexScanDesc Datum
rtbeginscan(Relation r, rtbeginscan(PG_FUNCTION_ARGS)
bool fromEnd,
uint16 nkeys,
ScanKey key)
{ {
Relation r = (Relation) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
uint16 nkeys = PG_GETARG_UINT16(2);
ScanKey key = (ScanKey) PG_GETARG_POINTER(3);
IndexScanDesc s; IndexScanDesc s;
/* /*
@ -68,22 +69,19 @@ rtbeginscan(Relation r,
s = RelationGetIndexScan(r, fromEnd, nkeys, key); s = RelationGetIndexScan(r, fromEnd, nkeys, key);
rtregscan(s); rtregscan(s);
return s; PG_RETURN_POINTER(s);
} }
void Datum
rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key) rtrescan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
bool fromEnd = PG_GETARG_BOOL(1);
ScanKey key = (ScanKey) PG_GETARG_POINTER(2);
RTreeScanOpaque p; RTreeScanOpaque p;
RegProcedure internal_proc; RegProcedure internal_proc;
int i; int i;
if (!IndexScanIsValid(s))
{
elog(ERROR, "rtrescan: invalid scan.");
return;
}
/* /*
* Clear all the pointers. * Clear all the pointers.
*/ */
@ -157,11 +155,14 @@ rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key)
} }
} }
} }
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
rtmarkpos(IndexScanDesc s) rtmarkpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p; RTreeScanOpaque p;
RTSTACK *o, RTSTACK *o,
*n, *n,
@ -190,11 +191,14 @@ rtmarkpos(IndexScanDesc s)
freestack(p->s_markstk); freestack(p->s_markstk);
p->s_markstk = o; p->s_markstk = o;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
rtrestrpos(IndexScanDesc s) rtrestrpos(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p; RTreeScanOpaque p;
RTSTACK *o, RTSTACK *o,
*n, *n,
@ -223,11 +227,14 @@ rtrestrpos(IndexScanDesc s)
freestack(p->s_stack); freestack(p->s_stack);
p->s_stack = o; p->s_stack = o;
PG_RETURN_POINTER(NULL); /* no real return value */
} }
void Datum
rtendscan(IndexScanDesc s) rtendscan(PG_FUNCTION_ARGS)
{ {
IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0);
RTreeScanOpaque p; RTreeScanOpaque p;
p = (RTreeScanOpaque) s->opaque; p = (RTreeScanOpaque) s->opaque;
@ -241,6 +248,8 @@ rtendscan(IndexScanDesc s)
rtdropscan(s); rtdropscan(s);
/* XXX don't unset read lock -- two-phase locking */ /* XXX don't unset read lock -- two-phase locking */
PG_RETURN_POINTER(NULL); /* no real return value */
} }
static void static void

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.51 2000/05/28 17:55:54 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.52 2000/06/13 07:34:52 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -409,8 +409,8 @@ TypeCreate(char *typeName,
/* /*
* For array types, the input procedures may take 3 args (data * For array types, the input procedures may take 3 args (data
* value, element OID, atttypmod); the pg_proc argtype * value, element OID, atttypmod); the pg_proc argtype
* signature is 0,0,INT4OID. The output procedures may take 2 * signature is 0,OIDOID,INT4OID. The output procedures may
* args (data value, element OID). * take 2 args (data value, element OID).
*/ */
if (OidIsValid(elementObjectId)) if (OidIsValid(elementObjectId))
{ {
@ -420,11 +420,13 @@ TypeCreate(char *typeName,
{ {
/* output proc */ /* output proc */
nargs = 2; nargs = 2;
argList[1] = OIDOID;
} }
else else
{ {
/* input proc */ /* input proc */
nargs = 3; nargs = 3;
argList[1] = OIDOID;
argList[2] = INT4OID; argList[2] = INT4OID;
} }
tup = SearchSysCacheTuple(PROCNAME, tup = SearchSysCacheTuple(PROCNAME,

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.70 2000/05/28 17:55:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.71 2000/06/13 07:34:58 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -105,6 +105,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
econtext, econtext,
isNull, isNull,
isDone); isDone);
/* If refexpr yields NULL, result is always NULL, for now anyway */
if (*isNull) if (*isNull)
return (Datum) NULL; return (Datum) NULL;
} }
@ -132,6 +133,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
econtext, econtext,
isNull, isNull,
&dummy); &dummy);
/* If any index expr yields NULL, result is NULL */
if (*isNull) if (*isNull)
return (Datum) NULL; return (Datum) NULL;
} }
@ -148,6 +150,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
econtext, econtext,
isNull, isNull,
&dummy); &dummy);
/* If any index expr yields NULL, result is NULL */
if (*isNull) if (*isNull)
return (Datum) NULL; return (Datum) NULL;
} }
@ -165,7 +168,7 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
econtext, econtext,
isNull, isNull,
&dummy); &dummy);
/* For now, can't cope with inserting NULL into an array */
if (*isNull) if (*isNull)
return (Datum) NULL; return (Datum) NULL;
@ -175,30 +178,43 @@ ExecEvalArrayRef(ArrayRef *arrayRef,
if (array_scanner == NULL) if (array_scanner == NULL)
return sourceData; /* XXX do something else? */ return sourceData; /* XXX do something else? */
/*
* XXX shouldn't we copy the array value before modifying it??
*
* Or perhaps these array routines should deliver a modified copy
* instead of changing the source in-place.
*/
if (lIndex == NULL) if (lIndex == NULL)
return (Datum) array_set(array_scanner, i, upper.indx, return PointerGetDatum(array_set(array_scanner, i,
(char *) sourceData, upper.indx,
sourceData,
arrayRef->refelembyval, arrayRef->refelembyval,
arrayRef->refelemlength, arrayRef->refelemlength,
arrayRef->refattrlength, isNull); arrayRef->refattrlength,
return (Datum) array_assgn(array_scanner, i, upper.indx, isNull));
lower.indx, return PointerGetDatum(array_assgn(array_scanner, i,
(ArrayType *) sourceData, upper.indx, lower.indx,
(ArrayType *) DatumGetPointer(sourceData),
arrayRef->refelembyval, arrayRef->refelembyval,
arrayRef->refelemlength, isNull); arrayRef->refelemlength,
isNull));
} }
execConstByVal = arrayRef->refelembyval; execConstByVal = arrayRef->refelembyval;
execConstLen = arrayRef->refelemlength; execConstLen = arrayRef->refelemlength;
if (lIndex == NULL) if (lIndex == NULL)
return (Datum) array_ref(array_scanner, i, upper.indx, return array_ref(array_scanner, i,
upper.indx,
arrayRef->refelembyval, arrayRef->refelembyval,
arrayRef->refelemlength, arrayRef->refelemlength,
arrayRef->refattrlength, isNull); arrayRef->refattrlength,
return (Datum) array_clip(array_scanner, i, upper.indx, lower.indx, isNull);
return PointerGetDatum(array_clip(array_scanner, i,
upper.indx, lower.indx,
arrayRef->refelembyval, arrayRef->refelembyval,
arrayRef->refelemlength, isNull); arrayRef->refelemlength,
isNull));
} }

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.40 2000/05/28 17:56:00 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.41 2000/06/13 07:35:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -450,7 +450,10 @@ make_const(Value *value)
} }
else else
{ {
val = PointerGetDatum(numeric_in(strVal(value), 0, -1)); val = DirectFunctionCall3(numeric_in,
CStringGetDatum(strVal(value)),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1));
typeid = NUMERICOID; typeid = NUMERICOID;
typelen = -1; /* variable len */ typelen = -1; /* variable len */

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.56 2000/06/09 01:11:08 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.57 2000/06/13 07:35:03 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -68,7 +68,7 @@ static void _LOArrayRange(int *st, int *endp, int bsize, int srcfd,
int destfd, ArrayType *array, int isSrcLO, bool *isNull); int destfd, ArrayType *array, int isSrcLO, bool *isNull);
static void _ReadArray(int *st, int *endp, int bsize, int srcfd, int destfd, static void _ReadArray(int *st, int *endp, int bsize, int srcfd, int destfd,
ArrayType *array, int isDestLO, bool *isNull); ArrayType *array, int isDestLO, bool *isNull);
static int ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest); static int ArrayCastAndSet(Datum src, bool typbyval, int typlen, char *dest);
static int SanityCheckInput(int ndim, int n, int *dim, int *lb, int *indx); static int SanityCheckInput(int ndim, int n, int *dim, int *lb, int *indx);
static int array_read(char *destptr, int eltsize, int nitems, char *srcptr); static int array_read(char *destptr, int eltsize, int nitems, char *srcptr);
static char *array_seek(char *ptr, int eltsize, int nitems); static char *array_seek(char *ptr, int eltsize, int nitems);
@ -76,16 +76,17 @@ static char *array_seek(char *ptr, int eltsize, int nitems);
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
* array_in : * array_in :
* converts an array from the external format in "string" to * converts an array from the external format in "string" to
* it internal format. * its internal format.
* return value : * return value :
* the internal representation of the input array * the internal representation of the input array
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
char * Datum
array_in(char *string, /* input array in external form */ array_in(PG_FUNCTION_ARGS)
Oid element_type, /* type OID of an array element */
int32 typmod)
{ {
char *string = PG_GETARG_CSTRING(0); /* external form */
Oid element_type = PG_GETARG_OID(1); /* type of an array element */
int32 typmod = PG_GETARG_INT32(2); /* typmod for array elements */
int typlen; int typlen;
bool typbyval, bool typbyval,
done; done;
@ -101,7 +102,7 @@ array_in(char *string, /* input array in external form */
nitems; nitems;
int32 nbytes; int32 nbytes;
char *dataPtr; char *dataPtr;
ArrayType *retval = NULL; ArrayType *retval;
int ndim, int ndim,
dim[MAXDIM], dim[MAXDIM],
lBound[MAXDIM]; lBound[MAXDIM];
@ -183,11 +184,10 @@ array_in(char *string, /* input array in external form */
nitems = getNitems(ndim, dim); nitems = getNitems(ndim, dim);
if (nitems == 0) if (nitems == 0)
{ {
char *emptyArray = palloc(sizeof(ArrayType)); retval = (ArrayType *) palloc(sizeof(ArrayType));
MemSet(retval, 0, sizeof(ArrayType));
MemSet(emptyArray, 0, sizeof(ArrayType)); *(int32 *) retval = sizeof(ArrayType);
*(int32 *) emptyArray = sizeof(ArrayType); return PointerGetDatum(retval);
return emptyArray;
} }
if (*p == '{') if (*p == '{')
@ -235,9 +235,10 @@ array_in(char *string, /* input array in external form */
memmove(ARR_DATA_PTR(retval), dataPtr, bytes); memmove(ARR_DATA_PTR(retval), dataPtr, bytes);
#endif #endif
elog(ERROR, "large object arrays not supported"); elog(ERROR, "large object arrays not supported");
PG_RETURN_NULL();
} }
pfree(string_save); pfree(string_save);
return (char *) retval; return PointerGetDatum(retval);
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@ -578,7 +579,7 @@ _CopyArrayEls(char **values,
{ {
int inc; int inc;
inc = ArrayCastAndSet(values[i], typbyval, typlen, p); inc = ArrayCastAndSet((Datum) values[i], typbyval, typlen, p);
p += inc; p += inc;
if (!typbyval) if (!typbyval)
pfree(values[i]); pfree(values[i]);
@ -592,9 +593,11 @@ _CopyArrayEls(char **values,
* containing the array in its external format. * containing the array in its external format.
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
char * Datum
array_out(ArrayType *v, Oid element_type) array_out(PG_FUNCTION_ARGS)
{ {
ArrayType *v = (ArrayType *) PG_GETARG_VARLENA_P(0);
Oid element_type = PG_GETARG_OID(1);
int typlen; int typlen;
bool typbyval; bool typbyval;
char typdelim; char typdelim;
@ -602,7 +605,6 @@ array_out(ArrayType *v, Oid element_type)
typelem; typelem;
FmgrInfo outputproc; FmgrInfo outputproc;
char typalign; char typalign;
char *p, char *p,
*tmp, *tmp,
*retval, *retval,
@ -617,30 +619,31 @@ array_out(ArrayType *v, Oid element_type)
l, l,
#endif #endif
indx[MAXDIM]; indx[MAXDIM];
bool dummy_bool;
int ndim, int ndim,
*dim; *dim;
if (v == (ArrayType *) NULL) if (v == (ArrayType *) NULL)
return (char *) NULL; PG_RETURN_CSTRING((char *) NULL);
if (ARR_IS_LO(v) == true) if (ARR_IS_LO(v) == true)
{ {
char *p, text *p;
*save_p; int plen,
int nbytes; nbytes;
p = (text *) DatumGetPointer(DirectFunctionCall1(array_dims,
PointerGetDatum(v)));
plen = VARSIZE(p) - VARHDRSZ;
/* get a wide string to print to */ /* get a wide string to print to */
p = array_dims(v, &dummy_bool); nbytes = strlen(ARR_DATA_PTR(v)) + strlen(ASSGN) + plen + 1;
nbytes = strlen(ARR_DATA_PTR(v)) + VARHDRSZ + *(int *) p; retval = (char *) palloc(nbytes);
save_p = (char *) palloc(nbytes); memcpy(retval, VARDATA(p), plen);
strcpy(retval + plen, ASSGN);
strcpy(save_p, p + sizeof(int)); strcat(retval, ARR_DATA_PTR(v));
strcat(save_p, ASSGN);
strcat(save_p, ARR_DATA_PTR(v));
pfree(p); pfree(p);
return save_p; PG_RETURN_CSTRING(retval);
} }
system_cache_lookup(element_type, false, &typlen, &typbyval, system_cache_lookup(element_type, false, &typlen, &typbyval,
@ -653,12 +656,11 @@ array_out(ArrayType *v, Oid element_type)
if (nitems == 0) if (nitems == 0)
{ {
char *emptyArray = palloc(3); retval = (char *) palloc(3);
retval[0] = '{';
emptyArray[0] = '{'; retval[1] = '}';
emptyArray[1] = '}'; retval[2] = '\0';
emptyArray[2] = '\0'; PG_RETURN_CSTRING(retval);
return emptyArray;
} }
p = ARR_DATA_PTR(v); p = ARR_DATA_PTR(v);
@ -776,58 +778,61 @@ array_out(ArrayType *v, Oid element_type)
} while (j != -1); } while (j != -1);
pfree(values); pfree(values);
return retval; PG_RETURN_CSTRING(retval);
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* array_dims : * array_dims :
* returns the dimension of the array pointed to by "v" * returns the dimensions of the array pointed to by "v", as a "text"
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
*/ */
char * Datum
array_dims(ArrayType *v, bool *isNull) array_dims(PG_FUNCTION_ARGS)
{ {
char *p, ArrayType *v = (ArrayType *) PG_GETARG_VARLENA_P(0);
*save_p; text *result;
char *p;
int nbytes, int nbytes,
i; i;
int *dimv, int *dimv,
*lb; *lb;
if (v == (ArrayType *) NULL) nbytes = ARR_NDIM(v) * 33 + 1;
RETURN_NULL;
nbytes = ARR_NDIM(v) * 33;
/* /*
* 33 since we assume 15 digits per number + ':' +'[]' * 33 since we assume 15 digits per number + ':' +'[]'
*
* +1 allows for temp trailing null
*/ */
save_p = p = (char *) palloc(nbytes + VARHDRSZ);
MemSet(save_p, 0, nbytes + VARHDRSZ); result = (text *) palloc(nbytes + VARHDRSZ);
MemSet(result, 0, nbytes + VARHDRSZ);
p = VARDATA(result);
dimv = ARR_DIMS(v); dimv = ARR_DIMS(v);
lb = ARR_LBOUND(v); lb = ARR_LBOUND(v);
p += VARHDRSZ;
for (i = 0; i < ARR_NDIM(v); i++) for (i = 0; i < ARR_NDIM(v); i++)
{ {
sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1); sprintf(p, "[%d:%d]", lb[i], dimv[i] + lb[i] - 1);
p += strlen(p); p += strlen(p);
} }
nbytes = strlen(save_p + VARHDRSZ) + VARHDRSZ; VARSIZE(result) = strlen(VARDATA(result)) + VARHDRSZ;
memmove(save_p, &nbytes, VARHDRSZ);
return save_p; PG_RETURN_TEXT_P(result);
} }
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
* array_ref : * array_ref :
* This routing takes an array pointer and an index array and returns * This routine takes an array pointer and an index array and returns
* a pointer to the referred element if element is passed by * a pointer to the referred element if element is passed by
* reference otherwise returns the value of the referred element. * reference otherwise returns the value of the referred element.
*--------------------------------------------------------------------------- *---------------------------------------------------------------------------
*/ */
Datum Datum
array_ref(ArrayType *array, array_ref(ArrayType *array,
int n, int nSubscripts,
int *indx, int *indx,
int reftype, bool elmbyval,
int elmlen, int elmlen,
int arraylen, int arraylen,
bool *isNull) bool *isNull)
@ -839,10 +844,11 @@ array_ref(ArrayType *array,
offset, offset,
nbytes; nbytes;
struct varlena *v = NULL; struct varlena *v = NULL;
char *retval = NULL; Datum result;
char *retval;
if (array == (ArrayType *) NULL) if (array == (ArrayType *) NULL)
RETURN_NULL; RETURN_NULL(Datum);
if (arraylen > 0) if (arraylen > 0)
{ {
@ -852,17 +858,17 @@ array_ref(ArrayType *array,
if (indx[0] * elmlen > arraylen) if (indx[0] * elmlen > arraylen)
elog(ERROR, "array_ref: array bound exceeded"); elog(ERROR, "array_ref: array bound exceeded");
retval = (char *) array + indx[0] * elmlen; retval = (char *) array + indx[0] * elmlen;
return _ArrayCast(retval, reftype, elmlen); return _ArrayCast(retval, elmbyval, elmlen);
} }
dim = ARR_DIMS(array); dim = ARR_DIMS(array);
lb = ARR_LBOUND(array); lb = ARR_LBOUND(array);
ndim = ARR_NDIM(array); ndim = ARR_NDIM(array);
nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim); nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim);
if (!SanityCheckInput(ndim, n, dim, lb, indx)) if (!SanityCheckInput(ndim, nSubscripts, dim, lb, indx))
RETURN_NULL; RETURN_NULL(Datum);
offset = GetOffset(n, dim, lb, indx); offset = GetOffset(nSubscripts, dim, lb, indx);
if (ARR_IS_LO(array)) if (ARR_IS_LO(array))
{ {
@ -874,7 +880,7 @@ array_ref(ArrayType *array,
lo_name = (char *) ARR_DATA_PTR(array); lo_name = (char *) ARR_DATA_PTR(array);
#ifdef LOARRAY #ifdef LOARRAY
if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_READ : O_RDONLY)) < 0) if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_READ : O_RDONLY)) < 0)
RETURN_NULL; RETURN_NULL(Datum);
#endif #endif
if (ARR_IS_CHUNKED(array)) if (ARR_IS_CHUNKED(array))
v = _ReadChunkArray1El(indx, elmlen, fd, array, isNull); v = _ReadChunkArray1El(indx, elmlen, fd, array, isNull);
@ -884,7 +890,7 @@ array_ref(ArrayType *array,
Int32GetDatum(fd), Int32GetDatum(fd),
Int32GetDatum(offset), Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(Datum);
#ifdef LOARRAY #ifdef LOARRAY
v = (struct varlena *) v = (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread, DatumGetPointer(DirectFunctionCall2(loread,
@ -893,20 +899,20 @@ array_ref(ArrayType *array,
#endif #endif
} }
if (*isNull) if (*isNull)
RETURN_NULL; RETURN_NULL(Datum);
if (VARSIZE(v) - VARHDRSZ < elmlen) if (VARSIZE(v) - VARHDRSZ < elmlen)
RETURN_NULL; RETURN_NULL(Datum);
DirectFunctionCall1(lo_close, Int32GetDatum(fd)); DirectFunctionCall1(lo_close, Int32GetDatum(fd));
retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen); result = _ArrayCast((char *) VARDATA(v), elmbyval, elmlen);
if (reftype == 0) if (! elmbyval)
{ /* not by value */ { /* not by value */
char *tempdata = palloc(elmlen); char *tempdata = palloc(elmlen);
memmove(tempdata, retval, elmlen); memmove(tempdata, DatumGetPointer(result), elmlen);
retval = tempdata; result = PointerGetDatum(tempdata);
} }
pfree(v); pfree(v);
return (Datum) retval; return result;
} }
if (elmlen > 0) if (elmlen > 0)
@ -914,32 +920,25 @@ array_ref(ArrayType *array,
offset = offset * elmlen; offset = offset * elmlen;
/* off the end of the array */ /* off the end of the array */
if (nbytes - offset < 1) if (nbytes - offset < 1)
RETURN_NULL; RETURN_NULL(Datum);
retval = ARR_DATA_PTR(array) + offset; retval = ARR_DATA_PTR(array) + offset;
return _ArrayCast(retval, reftype, elmlen); return _ArrayCast(retval, elmbyval, elmlen);
} }
else else
{ {
bool done = false;
char *temp;
int bytes = nbytes; int bytes = nbytes;
temp = ARR_DATA_PTR(array); retval = ARR_DATA_PTR(array);
i = 0; i = 0;
while (bytes > 0 && !done) while (bytes > 0)
{ {
if (i == offset) if (i == offset)
{ return PointerGetDatum(retval);
retval = temp; bytes -= INTALIGN(*(int32 *) retval);
done = true; retval += INTALIGN(*(int32 *) retval);
}
bytes -= INTALIGN(*(int32 *) temp);
temp += INTALIGN(*(int32 *) temp);
i++; i++;
} }
if (!done) RETURN_NULL(Datum);
RETURN_NULL;
return (Datum) retval;
} }
} }
@ -950,13 +949,13 @@ array_ref(ArrayType *array,
* and returns a pointer to it. * and returns a pointer to it.
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
*/ */
Datum ArrayType *
array_clip(ArrayType *array, array_clip(ArrayType *array,
int n, int nSubscripts,
int *upperIndx, int *upperIndx,
int *lowerIndx, int *lowerIndx,
int reftype, bool elmbyval,
int len, int elmlen,
bool *isNull) bool *isNull)
{ {
int i, int i,
@ -970,22 +969,20 @@ array_clip(ArrayType *array,
/* timer_start(); */ /* timer_start(); */
if (array == (ArrayType *) NULL) if (array == (ArrayType *) NULL)
RETURN_NULL; RETURN_NULL(ArrayType *);
dim = ARR_DIMS(array); dim = ARR_DIMS(array);
lb = ARR_LBOUND(array); lb = ARR_LBOUND(array);
ndim = ARR_NDIM(array); ndim = ARR_NDIM(array);
nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim); nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim);
if (!SanityCheckInput(ndim, n, dim, lb, upperIndx)) if (!SanityCheckInput(ndim, nSubscripts, dim, lb, upperIndx) ||
RETURN_NULL; !SanityCheckInput(ndim, nSubscripts, dim, lb, lowerIndx))
RETURN_NULL(ArrayType *);
if (!SanityCheckInput(ndim, n, dim, lb, lowerIndx)) for (i = 0; i < nSubscripts; i++)
RETURN_NULL;
for (i = 0; i < n; i++)
if (lowerIndx[i] > upperIndx[i]) if (lowerIndx[i] > upperIndx[i])
elog(ERROR, "lowerIndex cannot be larger than upperIndx"); elog(ERROR, "lowerIndex cannot be larger than upperIndx");
mda_get_range(n, span, lowerIndx, upperIndx); mda_get_range(nSubscripts, span, lowerIndx, upperIndx);
if (ARR_IS_LO(array)) if (ARR_IS_LO(array))
{ {
@ -999,23 +996,23 @@ array_clip(ArrayType *array,
isDestLO = true, isDestLO = true,
rsize; rsize;
if (len < 0) if (elmlen < 0)
elog(ERROR, "array_clip: array of variable length objects not supported"); elog(ERROR, "array_clip: array of variable length objects not implemented");
#ifdef LOARRAY #ifdef LOARRAY
lo_name = (char *) ARR_DATA_PTR(array); lo_name = (char *) ARR_DATA_PTR(array);
if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_READ : O_RDONLY)) < 0) if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_READ : O_RDONLY)) < 0)
RETURN_NULL; RETURN_NULL(ArrayType *);
newname = _array_newLO(&newfd, Unix); newname = _array_newLO(&newfd, Unix);
#endif #endif
bytes = strlen(newname) + 1 + ARR_OVERHEAD(n); bytes = strlen(newname) + 1 + ARR_OVERHEAD(nSubscripts);
newArr = (ArrayType *) palloc(bytes); newArr = (ArrayType *) palloc(bytes);
memmove(newArr, array, sizeof(ArrayType)); memmove(newArr, array, sizeof(ArrayType));
memmove(newArr, &bytes, sizeof(int)); memmove(newArr, &bytes, sizeof(int));
memmove(ARR_DIMS(newArr), span, n * sizeof(int)); memmove(ARR_DIMS(newArr), span, nSubscripts * sizeof(int));
memmove(ARR_LBOUND(newArr), lowerIndx, n * sizeof(int)); memmove(ARR_LBOUND(newArr), lowerIndx, nSubscripts * sizeof(int));
strcpy(ARR_DATA_PTR(newArr), newname); strcpy(ARR_DATA_PTR(newArr), newname);
rsize = compute_size(lowerIndx, upperIndx, n, len); rsize = compute_size(lowerIndx, upperIndx, nSubscripts, elmlen);
if (rsize < MAX_BUFF_SIZE) if (rsize < MAX_BUFF_SIZE)
{ {
char *buff; char *buff;
@ -1026,12 +1023,12 @@ array_clip(ArrayType *array,
isDestLO = false; isDestLO = false;
if (ARR_IS_CHUNKED(array)) if (ARR_IS_CHUNKED(array))
{ {
_ReadChunkArray(lowerIndx, upperIndx, len, fd, &(buff[VARHDRSZ]), _ReadChunkArray(lowerIndx, upperIndx, elmlen, fd, &(buff[VARHDRSZ]),
array, 0, isNull); array, 0, isNull);
} }
else else
{ {
_ReadArray(lowerIndx, upperIndx, len, fd, (int) &(buff[VARHDRSZ]), _ReadArray(lowerIndx, upperIndx, elmlen, fd, (int) &(buff[VARHDRSZ]),
array, array,
0, isNull); 0, isNull);
} }
@ -1048,11 +1045,11 @@ array_clip(ArrayType *array,
{ {
if (ARR_IS_CHUNKED(array)) if (ARR_IS_CHUNKED(array))
{ {
_ReadChunkArray(lowerIndx, upperIndx, len, fd, (char *) newfd, array, _ReadChunkArray(lowerIndx, upperIndx, elmlen, fd, (char *) newfd, array,
1, isNull); 1, isNull);
} }
else else
_ReadArray(lowerIndx, upperIndx, len, fd, newfd, array, 1, isNull); _ReadArray(lowerIndx, upperIndx, elmlen, fd, newfd, array, 1, isNull);
} }
#ifdef LOARRAY #ifdef LOARRAY
LOclose(fd); LOclose(fd);
@ -1064,42 +1061,42 @@ array_clip(ArrayType *array,
newArr = NULL; newArr = NULL;
} }
/* timer_end(); */ /* timer_end(); */
return (Datum) newArr; return newArr;
} }
if (len > 0) if (elmlen > 0)
{ {
bytes = getNitems(n, span); bytes = getNitems(nSubscripts, span);
bytes = bytes * len + ARR_OVERHEAD(n); bytes = bytes * elmlen + ARR_OVERHEAD(nSubscripts);
} }
else else
{ {
bytes = _ArrayClipCount(lowerIndx, upperIndx, array); bytes = _ArrayClipCount(lowerIndx, upperIndx, array);
bytes += ARR_OVERHEAD(n); bytes += ARR_OVERHEAD(nSubscripts);
} }
newArr = (ArrayType *) palloc(bytes); newArr = (ArrayType *) palloc(bytes);
memmove(newArr, array, sizeof(ArrayType)); memmove(newArr, array, sizeof(ArrayType));
memmove(newArr, &bytes, sizeof(int)); memmove(newArr, &bytes, sizeof(int));
memmove(ARR_DIMS(newArr), span, n * sizeof(int)); memmove(ARR_DIMS(newArr), span, nSubscripts * sizeof(int));
memmove(ARR_LBOUND(newArr), lowerIndx, n * sizeof(int)); memmove(ARR_LBOUND(newArr), lowerIndx, nSubscripts * sizeof(int));
_ArrayRange(lowerIndx, upperIndx, len, ARR_DATA_PTR(newArr), array, 1); _ArrayRange(lowerIndx, upperIndx, elmlen, ARR_DATA_PTR(newArr), array, 1);
return (Datum) newArr; return newArr;
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* array_set : * array_set :
* This routine sets the value of an array location (specified by an index array) * This routine sets the value of an array location (specified by
* to a new value specified by "dataPtr". * an index array) to a new value specified by "dataValue".
* result : * result :
* returns a pointer to the modified array. * returns a pointer to the modified array.
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
*/ */
char * ArrayType *
array_set(ArrayType *array, array_set(ArrayType *array,
int n, int nSubscripts,
int *indx, int *indx,
char *dataPtr, Datum dataValue,
int reftype, bool elmbyval,
int elmlen, int elmlen,
int arraylen, int arraylen,
bool *isNull) bool *isNull)
@ -1112,7 +1109,7 @@ array_set(ArrayType *array,
char *pos; char *pos;
if (array == (ArrayType *) NULL) if (array == (ArrayType *) NULL)
RETURN_NULL; RETURN_NULL(ArrayType *);
if (arraylen > 0) if (arraylen > 0)
{ {
@ -1122,20 +1119,20 @@ array_set(ArrayType *array,
if (indx[0] * elmlen > arraylen) if (indx[0] * elmlen > arraylen)
elog(ERROR, "array_ref: array bound exceeded"); elog(ERROR, "array_ref: array bound exceeded");
pos = (char *) array + indx[0] * elmlen; pos = (char *) array + indx[0] * elmlen;
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, pos); ArrayCastAndSet(dataValue, elmbyval, elmlen, pos);
return (char *) array; return array;
} }
dim = ARR_DIMS(array); dim = ARR_DIMS(array);
lb = ARR_LBOUND(array); lb = ARR_LBOUND(array);
ndim = ARR_NDIM(array); ndim = ARR_NDIM(array);
nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim); nbytes = (*(int32 *) array) - ARR_OVERHEAD(ndim);
if (!SanityCheckInput(ndim, n, dim, lb, indx)) if (!SanityCheckInput(ndim, nSubscripts, dim, lb, indx))
{ {
elog(ERROR, "array_set: array bound exceeded"); elog(ERROR, "array_set: array bound exceeded");
return (char *) array; return array;
} }
offset = GetOffset(n, dim, lb, indx); offset = GetOffset(nSubscripts, dim, lb, indx);
if (ARR_IS_LO(array)) if (ARR_IS_LO(array))
{ {
@ -1149,35 +1146,33 @@ array_set(ArrayType *array,
lo_name = ARR_DATA_PTR(array); lo_name = ARR_DATA_PTR(array);
if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0) if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0)
return (char *) array; return array;
#endif #endif
if (DatumGetInt32(DirectFunctionCall3(lo_lseek, if (DatumGetInt32(DirectFunctionCall3(lo_lseek,
Int32GetDatum(fd), Int32GetDatum(fd),
Int32GetDatum(offset), Int32GetDatum(offset),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
return (char *) array; return array;
v = (struct varlena *) palloc(elmlen + VARHDRSZ); v = (struct varlena *) palloc(elmlen + VARHDRSZ);
VARSIZE(v) = elmlen + VARHDRSZ; VARSIZE(v) = elmlen + VARHDRSZ;
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, VARDATA(v)); ArrayCastAndSet(dataValue, elmbyval, elmlen, VARDATA(v));
#ifdef LOARRAY #ifdef LOARRAY
n = DatumGetInt32(DirectFunctionCall2(lowrite, if (DatumGetInt32(DirectFunctionCall2(lowrite,
Int32GetDatum(fd), Int32GetDatum(fd),
PointerGetDatum(v))); PointerGetDatum(v)))
!= elmlen)
RETURN_NULL(ArrayType *);
#endif #endif
/*
* if (n < VARSIZE(v) - VARHDRSZ) RETURN_NULL;
*/
pfree(v); pfree(v);
DirectFunctionCall1(lo_close, Int32GetDatum(fd)); DirectFunctionCall1(lo_close, Int32GetDatum(fd));
return (char *) array; return array;
} }
if (elmlen > 0) if (elmlen > 0)
{ {
offset = offset * elmlen; offset = offset * elmlen;
/* off the end of the array */ /* off the end of the array */
if (nbytes - offset < 1) if (nbytes - offset < 1)
return (char *) array; return array;
pos = ARR_DATA_PTR(array) + offset; pos = ARR_DATA_PTR(array) + offset;
} }
else else
@ -1194,18 +1189,18 @@ array_set(ArrayType *array,
elt_ptr = array_seek(ARR_DATA_PTR(array), -1, offset); elt_ptr = array_seek(ARR_DATA_PTR(array), -1, offset);
oldlen = INTALIGN(*(int32 *) elt_ptr); oldlen = INTALIGN(*(int32 *) elt_ptr);
newlen = INTALIGN(*(int32 *) dataPtr); newlen = INTALIGN(*(int32 *) DatumGetPointer(dataValue));
if (oldlen == newlen) if (oldlen == newlen)
{ {
/* new element with same size, overwrite old data */ /* new element with same size, overwrite old data */
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, elt_ptr); ArrayCastAndSet(dataValue, elmbyval, elmlen, elt_ptr);
return (char *) array; return array;
} }
/* new element with different size, reallocate the array */ /* new element with different size, reallocate the array */
oldsize = array->size; oldsize = array->size;
lth0 = ARR_OVERHEAD(n); lth0 = ARR_OVERHEAD(nSubscripts);
lth1 = (int) (elt_ptr - ARR_DATA_PTR(array)); lth1 = (int) (elt_ptr - ARR_DATA_PTR(array));
lth2 = (int) (oldsize - lth0 - lth1 - oldlen); lth2 = (int) (oldsize - lth0 - lth1 - oldlen);
newsize = lth0 + lth1 + newlen + lth2; newsize = lth0 + lth1 + newlen + lth2;
@ -1213,16 +1208,16 @@ array_set(ArrayType *array,
newarray = (ArrayType *) palloc(newsize); newarray = (ArrayType *) palloc(newsize);
memmove((char *) newarray, (char *) array, lth0 + lth1); memmove((char *) newarray, (char *) array, lth0 + lth1);
newarray->size = newsize; newarray->size = newsize;
newlen = ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, newlen = ArrayCastAndSet(dataValue, elmbyval, elmlen,
(char *) newarray + lth0 + lth1); (char *) newarray + lth0 + lth1);
memmove((char *) newarray + lth0 + lth1 + newlen, memmove((char *) newarray + lth0 + lth1 + newlen,
(char *) array + lth0 + lth1 + oldlen, lth2); (char *) array + lth0 + lth1 + oldlen, lth2);
/* ??? who should free this storage ??? */ /* ??? who should free this storage ??? */
return (char *) newarray; return newarray;
} }
ArrayCastAndSet(dataPtr, (bool) reftype, elmlen, pos); ArrayCastAndSet(dataValue, elmbyval, elmlen, pos);
return (char *) array; return array;
} }
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
@ -1234,14 +1229,14 @@ array_set(ArrayType *array,
* returns a pointer to the modified array. * returns a pointer to the modified array.
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
*/ */
char * ArrayType *
array_assgn(ArrayType *array, array_assgn(ArrayType *array,
int n, int nSubscripts,
int *upperIndx, int *upperIndx,
int *lowerIndx, int *lowerIndx,
ArrayType *newArr, ArrayType *newArr,
int reftype, bool elmbyval,
int len, int elmlen,
bool *isNull) bool *isNull)
{ {
int i, int i,
@ -1250,19 +1245,19 @@ array_assgn(ArrayType *array,
*lb; *lb;
if (array == (ArrayType *) NULL) if (array == (ArrayType *) NULL)
RETURN_NULL; RETURN_NULL(ArrayType *);
if (len < 0) if (elmlen < 0)
elog(ERROR, "array_assgn:updates on arrays of variable length elements not allowed"); elog(ERROR, "array_assgn: updates on arrays of variable length elements not implemented");
dim = ARR_DIMS(array); dim = ARR_DIMS(array);
lb = ARR_LBOUND(array); lb = ARR_LBOUND(array);
ndim = ARR_NDIM(array); ndim = ARR_NDIM(array);
if (!SanityCheckInput(ndim, n, dim, lb, upperIndx) || if (!SanityCheckInput(ndim, nSubscripts, dim, lb, upperIndx) ||
!SanityCheckInput(ndim, n, dim, lb, lowerIndx)) !SanityCheckInput(ndim, nSubscripts, dim, lb, lowerIndx))
return (char *) array; RETURN_NULL(ArrayType *);
for (i = 0; i < n; i++) for (i = 0; i < nSubscripts; i++)
if (lowerIndx[i] > upperIndx[i]) if (lowerIndx[i] > upperIndx[i])
elog(ERROR, "lowerIndex larger than upperIndx"); elog(ERROR, "lowerIndex larger than upperIndx");
@ -1276,28 +1271,28 @@ array_assgn(ArrayType *array,
lo_name = (char *) ARR_DATA_PTR(array); lo_name = (char *) ARR_DATA_PTR(array);
if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0) if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0)
return (char *) array; return array;
#endif #endif
if (ARR_IS_LO(newArr)) if (ARR_IS_LO(newArr))
{ {
#ifdef LOARRAY #ifdef LOARRAY
lo_name = (char *) ARR_DATA_PTR(newArr); lo_name = (char *) ARR_DATA_PTR(newArr);
if ((newfd = LOopen(lo_name, ARR_IS_INV(newArr) ? INV_READ : O_RDONLY)) < 0) if ((newfd = LOopen(lo_name, ARR_IS_INV(newArr) ? INV_READ : O_RDONLY)) < 0)
return (char *) array; return array;
#endif #endif
_LOArrayRange(lowerIndx, upperIndx, len, fd, newfd, array, 1, isNull); _LOArrayRange(lowerIndx, upperIndx, elmlen, fd, newfd, array, 1, isNull);
DirectFunctionCall1(lo_close, Int32GetDatum(newfd)); DirectFunctionCall1(lo_close, Int32GetDatum(newfd));
} }
else else
{ {
_LOArrayRange(lowerIndx, upperIndx, len, fd, (int) ARR_DATA_PTR(newArr), _LOArrayRange(lowerIndx, upperIndx, elmlen, fd, (int) ARR_DATA_PTR(newArr),
array, 0, isNull); array, 0, isNull);
} }
DirectFunctionCall1(lo_close, Int32GetDatum(fd)); DirectFunctionCall1(lo_close, Int32GetDatum(fd));
return (char *) array; return array;
} }
_ArrayRange(lowerIndx, upperIndx, len, ARR_DATA_PTR(newArr), array, 0); _ArrayRange(lowerIndx, upperIndx, elmlen, ARR_DATA_PTR(newArr), array, 0);
return (char *) array; return array;
} }
/* /*
@ -1353,7 +1348,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
elog(ERROR, "array_map: invalid nargs: %d", fcinfo->nargs); elog(ERROR, "array_map: invalid nargs: %d", fcinfo->nargs);
if (PG_ARGISNULL(0)) if (PG_ARGISNULL(0))
elog(ERROR, "array_map: null input array"); elog(ERROR, "array_map: null input array");
v = (ArrayType *) PG_GETARG_POINTER(0); v = (ArrayType *) PG_GETARG_VARLENA_P(0);
/* Large objects not yet supported */ /* Large objects not yet supported */
if (ARR_IS_LO(v) == true) if (ARR_IS_LO(v) == true)
@ -1466,19 +1461,20 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
* array_eq : * array_eq :
* compares two arrays for equality * compares two arrays for equality
* result : * result :
* returns 1 if the arrays are equal, 0 otherwise. * returns true if the arrays are equal, false otherwise.
*----------------------------------------------------------------------------- *-----------------------------------------------------------------------------
*/ */
int Datum
array_eq(ArrayType *array1, ArrayType *array2) array_eq(PG_FUNCTION_ARGS)
{ {
if ((array1 == NULL) || (array2 == NULL)) ArrayType *array1 = (ArrayType *) PG_GETARG_VARLENA_P(0);
return 0; ArrayType *array2 = (ArrayType *) PG_GETARG_VARLENA_P(1);
if (*(int *) array1 != *(int *) array2)
return 0; if (*(int32 *) array1 != *(int32 *) array2)
if (memcmp(array1, array2, *(int *) array1)) PG_RETURN_BOOL(false);
return 0; if (memcmp(array1, array2, *(int32 *) array1) != 0)
return 1; PG_RETURN_BOOL(false);
PG_RETURN_BOOL(true);
} }
/***************************************************************************/ /***************************************************************************/
@ -1545,7 +1541,7 @@ _ArrayCast(char *value, bool byval, int len)
static int static int
ArrayCastAndSet(char *src, ArrayCastAndSet(Datum src,
bool typbyval, bool typbyval,
int typlen, int typlen,
char *dest) char *dest)
@ -1565,18 +1561,18 @@ ArrayCastAndSet(char *src,
*(int16 *) dest = DatumGetInt16(src); *(int16 *) dest = DatumGetInt16(src);
break; break;
case 4: case 4:
*(int32 *) dest = (int32) src; *(int32 *) dest = DatumGetInt32(src);
break; break;
} }
} }
else else
memmove(dest, src, typlen); memmove(dest, DatumGetPointer(src), typlen);
inc = typlen; inc = typlen;
} }
else else
{ {
memmove(dest, src, *(int32 *) src); memmove(dest, DatumGetPointer(src), *(int32 *) DatumGetPointer(src));
inc = (INTALIGN(*(int32 *) src)); inc = (INTALIGN(*(int32 *) DatumGetPointer(src)));
} }
return inc; return inc;
} }

@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by * workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.37 2000/06/05 07:28:51 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.38 2000/06/13 07:35:03 tgl Exp $
*/ */
#include <limits.h> #include <limits.h>
@ -535,31 +535,31 @@ cash_div_flt4(Cash *c, float4 *f)
/* cash_mul_int4() /* cash_mul_int4()
* Multiply cash by int4. * Multiply cash by int4.
*/ */
Cash * Datum
cash_mul_int4(Cash *c, int4 i) cash_mul_int4(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c = PG_GETARG_CASH(0);
int32 i = PG_GETARG_INT32(1);
Cash result;
if (!PointerIsValid(c)) result = c * i;
return NULL; PG_RETURN_CASH(result);
}
if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't multiply cash");
*result = ((i) * (*c));
return result;
} /* cash_mul_int4() */
/* int4_mul_cash() /* int4_mul_cash()
* Multiply int4 by cash. * Multiply int4 by cash.
*/ */
Cash * Datum
int4_mul_cash(int4 i, Cash *c) int4_mul_cash(PG_FUNCTION_ARGS)
{ {
return cash_mul_int4(c, i); int32 i = PG_GETARG_INT32(0);
} /* int4_mul_cash() */ Cash c = PG_GETARG_CASH(1);
Cash result;
result = i * c;
PG_RETURN_CASH(result);
}
/* cash_div_int4() /* cash_div_int4()
@ -568,24 +568,20 @@ int4_mul_cash(int4 i, Cash *c)
* XXX Don't know if rounding or truncating is correct behavior. * XXX Don't know if rounding or truncating is correct behavior.
* Round for now. - tgl 97/04/15 * Round for now. - tgl 97/04/15
*/ */
Cash * Datum
cash_div_int4(Cash *c, int4 i) cash_div_int4(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c = PG_GETARG_CASH(0);
int32 i = PG_GETARG_INT32(1);
if (!PointerIsValid(c)) Cash result;
return NULL;
if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't divide cash");
if (i == 0) if (i == 0)
elog(ERROR, "cash_idiv: divide by 0 error"); elog(ERROR, "cash_div_int4: divide by 0 error");
*result = rint(*c / i); result = rint(c / i);
return result; PG_RETURN_CASH(result);
} /* cash_div_int4() */ }
/* cash_mul_int2() /* cash_mul_int2()

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.26 2000/06/09 01:11:08 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.27 2000/06/13 07:35:03 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -517,7 +517,7 @@ _ReadChunkArray(int *st,
Int32GetDatum(fp), Int32GetDatum(fp),
Int32GetDatum(srcOff), Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(int);
jj = n - 1; jj = n - 1;
for (i = 0; i < n; chunk_off[i++] = 0) for (i = 0; i < n; chunk_off[i++] = 0)
@ -541,7 +541,7 @@ _ReadChunkArray(int *st,
Int32GetDatum((int32) destfp), Int32GetDatum((int32) destfp),
Int32GetDatum(bptr), Int32GetDatum(bptr),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(int);
} }
else else
destfp = baseDestFp + bptr; destfp = baseDestFp + bptr;
@ -556,7 +556,7 @@ _ReadChunkArray(int *st,
Int32GetDatum(fp), Int32GetDatum(fp),
Int32GetDatum(srcOff), Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(int);
} }
for (i = n - 1, to_read = bsize; i >= 0; for (i = n - 1, to_read = bsize; i >= 0;
to_read *= min(C[i], array_span[i]), i--) to_read *= min(C[i], array_span[i]), i--)
@ -571,7 +571,7 @@ _ReadChunkArray(int *st,
Int32GetDatum(fp), Int32GetDatum(fp),
Int32GetDatum(srcOff), Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(int);
} }
block_seek += cdist[j]; block_seek += cdist[j];
bptr += adist[j] * bsize; bptr += adist[j] * bsize;
@ -581,13 +581,13 @@ _ReadChunkArray(int *st,
Int32GetDatum((int32) destfp), Int32GetDatum((int32) destfp),
Int32GetDatum(bptr), Int32GetDatum(bptr),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(int);
} }
else else
destfp = baseDestFp + bptr; destfp = baseDestFp + bptr;
temp = _LOtransfer((char **) &destfp, to_read, 1, (char **) &fp, 1, isDestLO); temp = _LOtransfer((char **) &destfp, to_read, 1, (char **) &fp, 1, isDestLO);
if (temp < to_read) if (temp < to_read)
RETURN_NULL; RETURN_NULL(int);
srcOff += to_read; srcOff += to_read;
words_read += to_read; words_read += to_read;
bptr += to_read; bptr += to_read;
@ -702,7 +702,7 @@ _ReadChunkArray1El(int *st,
Int32GetDatum(fp), Int32GetDatum(fp),
Int32GetDatum(srcOff), Int32GetDatum(srcOff),
Int32GetDatum(SEEK_SET))) < 0) Int32GetDatum(SEEK_SET))) < 0)
RETURN_NULL; RETURN_NULL(struct varlena *);
#ifdef LOARRAY #ifdef LOARRAY
return (struct varlena *) return (struct varlena *)
DatumGetPointer(DirectFunctionCall2(loread, DatumGetPointer(DirectFunctionCall2(loread,

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.59 2000/06/08 22:37:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.60 2000/06/13 07:35:04 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -48,12 +48,11 @@
*/ */
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <float.h> /* faked on sunos4 */ #include <float.h> /* faked on sunos4 */
#include <math.h> #include <math.h>
#include "postgres.h" #include "postgres.h"
#ifdef HAVE_LIMITS_H #ifdef HAVE_LIMITS_H
#include <limits.h> #include <limits.h>
#ifndef MAXINT #ifndef MAXINT
@ -64,6 +63,7 @@
#include <values.h> #include <values.h>
#endif #endif
#endif #endif
#include "fmgr.h" #include "fmgr.h"
#include "utils/builtins.h" #include "utils/builtins.h"
@ -844,15 +844,14 @@ dtoi2(PG_FUNCTION_ARGS)
/* /*
* i4tod - converts an int4 number to a float8 number * i4tod - converts an int4 number to a float8 number
*/ */
float64 Datum
i4tod(int32 num) i4tod(PG_FUNCTION_ARGS)
{ {
float64 result; int32 num = PG_GETARG_INT32(0);
float8 result;
result = (float64) palloc(sizeof(float64data)); result = num;
PG_RETURN_FLOAT8(result);
*result = num;
return result;
} }
@ -909,15 +908,14 @@ ftoi2(PG_FUNCTION_ARGS)
/* /*
* i4tof - converts an int4 number to a float8 number * i4tof - converts an int4 number to a float8 number
*/ */
float32 Datum
i4tof(int32 num) i4tof(PG_FUNCTION_ARGS)
{ {
float32 result; int32 num = PG_GETARG_INT32(0);
float4 result;
result = (float32) palloc(sizeof(float32data)); result = num;
PG_RETURN_FLOAT4(result);
*result = num;
return result;
} }

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.c * formatting.c
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.11 2000/06/09 03:18:34 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.12 2000/06/13 07:35:04 tgl Exp $
* *
* *
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc * Portions Copyright (c) 1999-2000, PostgreSQL, Inc
@ -3848,13 +3848,11 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
* ---------- * ----------
*/ */
#define NUM_TOCHAR_prepare { \ #define NUM_TOCHAR_prepare { \
if (!PointerIsValid(fmt)) \
return NULL; \
\ \
len = VARSIZE(fmt) - VARHDRSZ; \ len = VARSIZE(fmt) - VARHDRSZ; \
\ \
if (!len) \ if (len <= 0) \
return textin(""); \ return PointerGetDatum(textin("")); \
\ \
result = (text *) palloc( (len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \ result = (text *) palloc( (len * NUM_MAX_ITEM_SIZ) + 1 + VARHDRSZ); \
format = NUM_cache(len, &Num, VARDATA(fmt), &flag); \ format = NUM_cache(len, &Num, VARDATA(fmt), &flag); \
@ -3891,26 +3889,24 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
* NUMERIC to_number() (convert string to numeric) * NUMERIC to_number() (convert string to numeric)
* ------------------- * -------------------
*/ */
Numeric Datum
numeric_to_number(text *value, text *fmt) numeric_to_number(PG_FUNCTION_ARGS)
{ {
text *value = PG_GETARG_TEXT_P(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
Numeric result; Datum result;
FormatNode *format; FormatNode *format;
char *numstr; char *numstr;
int flag = 0; int flag = 0;
int len = 0; int len = 0;
int scale, int scale,
precision; precision;
if ((!PointerIsValid(value)) || (!PointerIsValid(fmt)))
return NULL;
len = VARSIZE(fmt) - VARHDRSZ; len = VARSIZE(fmt) - VARHDRSZ;
if (!len) if (len <= 0)
return numeric_in(NULL, 0, 0); PG_RETURN_NULL();
format = NUM_cache(len, &Num, VARDATA(fmt), &flag); format = NUM_cache(len, &Num, VARDATA(fmt), &flag);
@ -3925,7 +3921,10 @@ numeric_to_number(text *value, text *fmt)
if (flag) if (flag)
pfree(format); pfree(format);
result = numeric_in(numstr, 0, ((precision << 16) | scale) + VARHDRSZ); result = DirectFunctionCall3(numeric_in,
CStringGetDatum(numstr),
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(((precision << 16) | scale) + VARHDRSZ));
pfree(numstr); pfree(numstr);
return result; return result;
} }
@ -3934,9 +3933,11 @@ numeric_to_number(text *value, text *fmt)
* NUMERIC to_char() * NUMERIC to_char()
* ------------------ * ------------------
*/ */
text * Datum
numeric_to_char(Numeric value, text *fmt) numeric_to_char(PG_FUNCTION_ARGS)
{ {
Numeric value = PG_GETARG_NUMERIC(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
FormatNode *format; FormatNode *format;
text *result, text *result,
@ -3948,7 +3949,7 @@ numeric_to_char(Numeric value, text *fmt)
char *numstr, char *numstr,
*orgnum, *orgnum,
*p; *p;
Numeric x = NULL; Numeric x;
NUM_TOCHAR_prepare; NUM_TOCHAR_prepare;
@ -3958,10 +3959,11 @@ numeric_to_char(Numeric value, text *fmt)
*/ */
if (IS_ROMAN(&Num)) if (IS_ROMAN(&Num))
{ {
x = numeric_round(value, 0); x = DatumGetNumeric(DirectFunctionCall2(numeric_round,
NumericGetDatum(value),
Int32GetDatum(0)));
numstr = orgnum = int_to_roman(numeric_int4(x)); numstr = orgnum = int_to_roman(numeric_int4(x));
pfree(x); pfree(x);
} }
else else
{ {
@ -3969,8 +3971,10 @@ numeric_to_char(Numeric value, text *fmt)
if (IS_MULTI(&Num)) if (IS_MULTI(&Num))
{ {
Numeric a = int4_numeric(10); Numeric a = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Numeric b = int4_numeric(Num.multi); Int32GetDatum(10)));
Numeric b = DatumGetNumeric(DirectFunctionCall1(int4_numeric,
Int32GetDatum(Num.multi)));
x = numeric_power(a, b); x = numeric_power(a, b);
val = numeric_mul(value, x); val = numeric_mul(value, x);
@ -3980,8 +3984,11 @@ numeric_to_char(Numeric value, text *fmt)
Num.pre += Num.multi; Num.pre += Num.multi;
} }
x = numeric_round(val, Num.post); x = DatumGetNumeric(DirectFunctionCall2(numeric_round,
orgnum = numeric_out(x); NumericGetDatum(val),
Int32GetDatum(Num.post)));
orgnum = DatumGetCString(DirectFunctionCall1(numeric_out,
NumericGetDatum(x)));
pfree(x); pfree(x);
if (*orgnum == '-') if (*orgnum == '-')
@ -4014,16 +4021,18 @@ numeric_to_char(Numeric value, text *fmt)
} }
NUM_TOCHAR_finish; NUM_TOCHAR_finish;
return result; PG_RETURN_TEXT_P(result);
} }
/* --------------- /* ---------------
* INT4 to_char() * INT4 to_char()
* --------------- * ---------------
*/ */
text * Datum
int4_to_char(int32 value, text *fmt) int4_to_char(PG_FUNCTION_ARGS)
{ {
int32 value = PG_GETARG_INT32(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
FormatNode *format; FormatNode *format;
text *result, text *result,
@ -4044,7 +4053,6 @@ int4_to_char(int32 value, text *fmt)
if (IS_ROMAN(&Num)) if (IS_ROMAN(&Num))
{ {
numstr = orgnum = int_to_roman(value); numstr = orgnum = int_to_roman(value);
} }
else else
{ {
@ -4097,16 +4105,18 @@ int4_to_char(int32 value, text *fmt)
} }
NUM_TOCHAR_finish; NUM_TOCHAR_finish;
return result; PG_RETURN_TEXT_P(result);
} }
/* --------------- /* ---------------
* INT8 to_char() * INT8 to_char()
* --------------- * ---------------
*/ */
text * Datum
int8_to_char(int64 *value, text *fmt) int8_to_char(PG_FUNCTION_ARGS)
{ {
int64 value = PG_GETARG_INT64(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
FormatNode *format; FormatNode *format;
text *result, text *result,
@ -4126,8 +4136,9 @@ int8_to_char(int64 *value, text *fmt)
*/ */
if (IS_ROMAN(&Num)) if (IS_ROMAN(&Num))
{ {
numstr = orgnum = int_to_roman(int84(value)); /* Currently don't support int8 conversion to roman... */
numstr = orgnum = int_to_roman(DatumGetInt32(
DirectFunctionCall1(int84, Int64GetDatum(value))));
} }
else else
{ {
@ -4135,11 +4146,15 @@ int8_to_char(int64 *value, text *fmt)
{ {
double multi = pow((double) 10, (double) Num.multi); double multi = pow((double) 10, (double) Num.multi);
orgnum = int8out(int8mul(value, dtoi8((float64) &multi))); value = DatumGetInt64(DirectFunctionCall2(int8mul,
Int64GetDatum(value),
DirectFunctionCall1(dtoi8,
Float8GetDatum(multi))));
Num.pre += Num.multi; Num.pre += Num.multi;
} }
else
orgnum = int8out(value); orgnum = DatumGetCString(DirectFunctionCall1(int8out,
Int64GetDatum(value)));
len = strlen(orgnum); len = strlen(orgnum);
if (*orgnum == '-') if (*orgnum == '-')
@ -4178,16 +4193,18 @@ int8_to_char(int64 *value, text *fmt)
} }
NUM_TOCHAR_finish; NUM_TOCHAR_finish;
return result; PG_RETURN_TEXT_P(result);
} }
/* ----------------- /* -----------------
* FLOAT4 to_char() * FLOAT4 to_char()
* ----------------- * -----------------
*/ */
text * Datum
float4_to_char(float32 value, text *fmt) float4_to_char(PG_FUNCTION_ARGS)
{ {
float4 value = PG_GETARG_FLOAT4(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
FormatNode *format; FormatNode *format;
text *result, text *result,
@ -4204,30 +4221,30 @@ float4_to_char(float32 value, text *fmt)
if (IS_ROMAN(&Num)) if (IS_ROMAN(&Num))
{ {
numstr = orgnum = int_to_roman((int) rint(*value)); numstr = orgnum = int_to_roman((int) rint(value));
} }
else else
{ {
float32 val = value; float4 val = value;
if (IS_MULTI(&Num)) if (IS_MULTI(&Num))
{ {
float multi = pow((double) 10, (double) Num.multi); float multi = pow((double) 10, (double) Num.multi);
val = float4mul(value, (float32) &multi); val = value * multi;
Num.pre += Num.multi; Num.pre += Num.multi;
} }
orgnum = (char *) palloc(MAXFLOATWIDTH + 1); orgnum = (char *) palloc(MAXFLOATWIDTH + 1);
len = sprintf(orgnum, "%.0f", fabs(*val)); len = sprintf(orgnum, "%.0f", fabs(val));
if (Num.pre > len) if (Num.pre > len)
plen = Num.pre - len; plen = Num.pre - len;
if (len >= FLT_DIG) if (len >= FLT_DIG)
Num.post = 0; Num.post = 0;
else if (Num.post + len > FLT_DIG) else if (Num.post + len > FLT_DIG)
Num.post = FLT_DIG - len; Num.post = FLT_DIG - len;
sprintf(orgnum, "%.*f", Num.post, *val); sprintf(orgnum, "%.*f", Num.post, val);
if (*orgnum == '-') if (*orgnum == '-')
{ /* < 0 */ { /* < 0 */
@ -4256,16 +4273,18 @@ float4_to_char(float32 value, text *fmt)
} }
NUM_TOCHAR_finish; NUM_TOCHAR_finish;
return result; PG_RETURN_TEXT_P(result);
} }
/* ----------------- /* -----------------
* FLOAT8 to_char() * FLOAT8 to_char()
* ----------------- * -----------------
*/ */
text * Datum
float8_to_char(float64 value, text *fmt) float8_to_char(PG_FUNCTION_ARGS)
{ {
float8 value = PG_GETARG_FLOAT8(0);
text *fmt = PG_GETARG_TEXT_P(1);
NUMDesc Num; NUMDesc Num;
FormatNode *format; FormatNode *format;
text *result, text *result,
@ -4282,29 +4301,29 @@ float8_to_char(float64 value, text *fmt)
if (IS_ROMAN(&Num)) if (IS_ROMAN(&Num))
{ {
numstr = orgnum = int_to_roman((int) rint(*value)); numstr = orgnum = int_to_roman((int) rint(value));
} }
else else
{ {
float64 val = value; float8 val = value;
if (IS_MULTI(&Num)) if (IS_MULTI(&Num))
{ {
double multi = pow((double) 10, (double) Num.multi); double multi = pow((double) 10, (double) Num.multi);
val = float8mul(value, (float64) &multi); val = value * multi;
Num.pre += Num.multi; Num.pre += Num.multi;
} }
orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1); orgnum = (char *) palloc(MAXDOUBLEWIDTH + 1);
len = sprintf(orgnum, "%.0f", fabs(*val)); len = sprintf(orgnum, "%.0f", fabs(val));
if (Num.pre > len) if (Num.pre > len)
plen = Num.pre - len; plen = Num.pre - len;
if (len >= DBL_DIG) if (len >= DBL_DIG)
Num.post = 0; Num.post = 0;
else if (Num.post + len > DBL_DIG) else if (Num.post + len > DBL_DIG)
Num.post = DBL_DIG - len; Num.post = DBL_DIG - len;
sprintf(orgnum, "%.*f", Num.post, *val); sprintf(orgnum, "%.*f", Num.post, val);
if (*orgnum == '-') if (*orgnum == '-')
{ /* < 0 */ { /* < 0 */
@ -4333,5 +4352,5 @@ float8_to_char(float64 value, text *fmt)
} }
NUM_TOCHAR_finish; NUM_TOCHAR_finish;
return result; PG_RETURN_TEXT_P(result);
} }

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.50 2000/04/12 17:15:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.51 2000/06/13 07:35:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -4361,22 +4361,21 @@ box_circle(BOX *box)
} /* box_circle() */ } /* box_circle() */
POLYGON * Datum
circle_poly(int npts, CIRCLE *circle) circle_poly(PG_FUNCTION_ARGS)
{ {
int32 npts = PG_GETARG_INT32(0);
CIRCLE *circle = PG_GETARG_CIRCLE_P(1);
POLYGON *poly; POLYGON *poly;
int size; int size;
int i; int i;
double angle; double angle;
if (!PointerIsValid(circle))
return NULL;
if (FPzero(circle->radius) || (npts < 2)) if (FPzero(circle->radius) || (npts < 2))
elog(ERROR, "Unable to convert circle to polygon"); elog(ERROR, "Unable to convert circle to polygon");
size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * npts); size = offsetof(POLYGON, p[0]) +(sizeof(poly->p[0]) * npts);
poly = palloc(size); poly = (POLYGON *) palloc(size);
MemSet((char *) poly, 0, size); /* zero any holes */ MemSet((char *) poly, 0, size); /* zero any holes */
poly->size = size; poly->size = size;
@ -4391,7 +4390,7 @@ circle_poly(int npts, CIRCLE *circle)
make_bound_box(poly); make_bound_box(poly);
return poly; PG_RETURN_POLYGON_P(poly);
} }
/* poly_circle - convert polygon to circle /* poly_circle - convert polygon to circle

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.19 2000/05/28 17:56:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.20 2000/06/13 07:35:07 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -57,17 +57,15 @@
/* int8in() /* int8in()
*/ */
int64 * Datum
int8in(char *str) int8in(PG_FUNCTION_ARGS)
{ {
int64 *result = palloc(sizeof(int64)); char *str = PG_GETARG_CSTRING(0);
int64 result;
char *ptr = str; char *ptr = str;
int64 tmp = 0; int64 tmp = 0;
int sign = 1; int sign = 1;
if (!PointerIsValid(str))
elog(ERROR, "Bad (null) int8 external representation");
/* /*
* Do our own scan, rather than relying on sscanf which might be * Do our own scan, rather than relying on sscanf which might be
* broken for long long. * broken for long long.
@ -91,34 +89,28 @@ int8in(char *str)
if (*ptr) /* trailing junk? */ if (*ptr) /* trailing junk? */
elog(ERROR, "Bad int8 external representation \"%s\"", str); elog(ERROR, "Bad int8 external representation \"%s\"", str);
*result = (sign < 0) ? -tmp : tmp; result = (sign < 0) ? -tmp : tmp;
return result; PG_RETURN_INT64(result);
} /* int8in() */ }
/* int8out() /* int8out()
*/ */
char * Datum
int8out(int64 *val) int8out(PG_FUNCTION_ARGS)
{ {
int64 val = PG_GETARG_INT64(0);
char *result; char *result;
int len; int len;
char buf[MAXINT8LEN + 1]; char buf[MAXINT8LEN + 1];
if (!PointerIsValid(val)) if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0)
return NULL;
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, *val)) < 0)
elog(ERROR, "Unable to format int8"); elog(ERROR, "Unable to format int8");
result = palloc(len + 1); result = pstrdup(buf);
PG_RETURN_CSTRING(result);
strcpy(result, buf); }
return result;
} /* int8out() */
/*---------------------------------------------------------- /*----------------------------------------------------------
@ -128,511 +120,403 @@ int8out(int64 *val)
/* int8relop() /* int8relop()
* Is val1 relop val2? * Is val1 relop val2?
*/ */
bool Datum
int8eq(int64 *val1, int64 *val2) int8eq(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 == *val2; PG_RETURN_BOOL(val1 == val2);
} /* int8eq() */ }
bool Datum
int8ne(int64 *val1, int64 *val2) int8ne(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 != *val2; PG_RETURN_BOOL(val1 != val2);
} /* int8ne() */ }
bool Datum
int8lt(int64 *val1, int64 *val2) int8lt(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 < *val2; PG_RETURN_BOOL(val1 < val2);
} /* int8lt() */ }
bool Datum
int8gt(int64 *val1, int64 *val2) int8gt(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 > *val2; PG_RETURN_BOOL(val1 > val2);
} /* int8gt() */ }
bool Datum
int8le(int64 *val1, int64 *val2) int8le(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 <= *val2; PG_RETURN_BOOL(val1 <= val2);
} /* int8le() */ }
bool Datum
int8ge(int64 *val1, int64 *val2) int8ge(PG_FUNCTION_ARGS)
{ {
if (!val1 || !val2) int64 val1 = PG_GETARG_INT64(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return *val1 >= *val2;
} /* int8ge() */
PG_RETURN_BOOL(val1 >= val2);
}
/* int84relop() /* int84relop()
* Is 64-bit val1 relop 32-bit val2? * Is 64-bit val1 relop 32-bit val2?
*/ */
bool Datum
int84eq(int64 *val1, int32 val2) int84eq(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 == val2; PG_RETURN_BOOL(val1 == val2);
} /* int84eq() */ }
bool Datum
int84ne(int64 *val1, int32 val2) int84ne(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 != val2; PG_RETURN_BOOL(val1 != val2);
} /* int84ne() */ }
bool Datum
int84lt(int64 *val1, int32 val2) int84lt(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 < val2; PG_RETURN_BOOL(val1 < val2);
} /* int84lt() */ }
bool Datum
int84gt(int64 *val1, int32 val2) int84gt(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 > val2; PG_RETURN_BOOL(val1 > val2);
} /* int84gt() */ }
bool Datum
int84le(int64 *val1, int32 val2) int84le(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 <= val2; PG_RETURN_BOOL(val1 <= val2);
} /* int84le() */ }
bool Datum
int84ge(int64 *val1, int32 val2) int84ge(PG_FUNCTION_ARGS)
{ {
if (!val1) int64 val1 = PG_GETARG_INT64(0);
return 0; int32 val2 = PG_GETARG_INT32(1);
return *val1 >= val2;
} /* int84ge() */
PG_RETURN_BOOL(val1 >= val2);
}
/* int48relop() /* int48relop()
* Is 32-bit val1 relop 64-bit val2? * Is 32-bit val1 relop 64-bit val2?
*/ */
bool Datum
int48eq(int32 val1, int64 *val2) int48eq(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 == *val2; PG_RETURN_BOOL(val1 == val2);
} /* int48eq() */ }
bool Datum
int48ne(int32 val1, int64 *val2) int48ne(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 != *val2; PG_RETURN_BOOL(val1 != val2);
} /* int48ne() */ }
bool Datum
int48lt(int32 val1, int64 *val2) int48lt(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 < *val2; PG_RETURN_BOOL(val1 < val2);
} /* int48lt() */ }
bool Datum
int48gt(int32 val1, int64 *val2) int48gt(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 > *val2; PG_RETURN_BOOL(val1 > val2);
} /* int48gt() */ }
bool Datum
int48le(int32 val1, int64 *val2) int48le(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 <= *val2; PG_RETURN_BOOL(val1 <= val2);
} /* int48le() */ }
bool Datum
int48ge(int32 val1, int64 *val2) int48ge(PG_FUNCTION_ARGS)
{ {
if (!val2) int32 val1 = PG_GETARG_INT32(0);
return 0; int64 val2 = PG_GETARG_INT64(1);
return val1 >= *val2; PG_RETURN_BOOL(val1 >= val2);
} /* int48ge() */ }
/*---------------------------------------------------------- /*----------------------------------------------------------
* Arithmetic operators on 64-bit integers. * Arithmetic operators on 64-bit integers.
*---------------------------------------------------------*/ *---------------------------------------------------------*/
int64 * Datum
int8um(int64 *val) int8um(PG_FUNCTION_ARGS)
{ {
int64 temp = 0; int64 val = PG_GETARG_INT64(0);
int64 *result = palloc(sizeof(int64));
if (!PointerIsValid(val)) PG_RETURN_INT64(- val);
return NULL; }
result = int8mi(&temp, val); Datum
int8pl(PG_FUNCTION_ARGS)
return result;
} /* int8um() */
int64 *
int8pl(int64 *val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) PG_RETURN_INT64(val1 + val2);
return NULL; }
*result = *val1 + *val2; Datum
int8mi(PG_FUNCTION_ARGS)
return result;
} /* int8pl() */
int64 *
int8mi(int64 *val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) PG_RETURN_INT64(val1 - val2);
return NULL; }
*result = *val1 - *val2; Datum
int8mul(PG_FUNCTION_ARGS)
return result;
} /* int8mi() */
int64 *
int8mul(int64 *val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) PG_RETURN_INT64(val1 * val2);
return NULL; }
*result = *val1 * *val2; Datum
int8div(PG_FUNCTION_ARGS)
return result;
} /* int8mul() */
int64 *
int8div(int64 *val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) PG_RETURN_INT64(val1 / val2);
return NULL; }
*result = *val1 / *val2;
return result;
} /* int8div() */
/* int8abs() /* int8abs()
* Absolute value * Absolute value
*/ */
int64 * Datum
int8abs(int64 *arg1) int8abs(PG_FUNCTION_ARGS)
{ {
int64 *result; int64 arg1 = PG_GETARG_INT64(0);
if (!PointerIsValid(arg1)) PG_RETURN_INT64((arg1 < 0) ? -arg1 : arg1);
return NULL;
result = palloc(sizeof(*result));
*result = ((*arg1 < 0) ? -*arg1 : *arg1);
return result;
} }
/* int8mod() /* int8mod()
* Modulo operation. * Modulo operation.
*/ */
int64 * Datum
int8mod(int64 *val1, int64 *val2) int8mod(PG_FUNCTION_ARGS)
{ {
int64 *result; int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
int64 result;
/* use the divide operation to check params and allocate storage */ result = val1 / val2;
result = int8div(val1, val2); result *= val2;
*result *= *val2; result = val1 - result;
*result = *val1 - *result;
return result; PG_RETURN_INT64(result);
} /* int8mod() */ }
/* int8fac() /* int8fac()
* Factorial * Factorial
*/ */
int64 * Datum
int8fac(int64 *arg1) int8fac(PG_FUNCTION_ARGS)
{ {
int64 *result; int64 arg1 = PG_GETARG_INT64(0);
int64 result;
int64 i; int64 i;
if (!PointerIsValid(arg1)) if (arg1 < 1)
return NULL; result = 0;
result = palloc(sizeof(*result));
if (*arg1 < 1)
*result = 0;
else else
for (i = *arg1, *result = 1; i > 0; --i) for (i = arg1, result = 1; i > 0; --i)
*result *= i; result *= i;
return result; PG_RETURN_INT64(result);
} }
int64 * Datum
int8larger(int64 *val1, int64 *val2) int8larger(PG_FUNCTION_ARGS)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
int64 result;
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) result = ((val1 > val2) ? val1 : val2);
return NULL;
*result = ((*val1 > *val2) ? *val1 : *val2); PG_RETURN_INT64(result);
}
return result; Datum
} /* int8larger() */ int8smaller(PG_FUNCTION_ARGS)
int64 *
int8smaller(int64 *val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int64 val2 = PG_GETARG_INT64(1);
int64 result;
if ((!PointerIsValid(val1)) || (!PointerIsValid(val2))) result = ((val1 < val2) ? val1 : val2);
return NULL;
*result = ((*val1 < *val2) ? *val1 : *val2); PG_RETURN_INT64(result);
}
return result; Datum
} /* int8smaller() */ int84pl(PG_FUNCTION_ARGS)
int64 *
int84pl(int64 *val1, int32 val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int32 val2 = PG_GETARG_INT32(1);
if (!PointerIsValid(val1)) PG_RETURN_INT64(val1 + val2);
return NULL; }
*result = *val1 + (int64) val2; Datum
int84mi(PG_FUNCTION_ARGS)
return result;
} /* int84pl() */
int64 *
int84mi(int64 *val1, int32 val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int32 val2 = PG_GETARG_INT32(1);
if (!PointerIsValid(val1)) PG_RETURN_INT64(val1 - val2);
return NULL; }
*result = *val1 - (int64) val2; Datum
int84mul(PG_FUNCTION_ARGS)
return result;
} /* int84mi() */
int64 *
int84mul(int64 *val1, int32 val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int32 val2 = PG_GETARG_INT32(1);
if (!PointerIsValid(val1)) PG_RETURN_INT64(val1 * val2);
return NULL; }
*result = *val1 * (int64) val2; Datum
int84div(PG_FUNCTION_ARGS)
return result;
} /* int84mul() */
int64 *
int84div(int64 *val1, int32 val2)
{ {
int64 *result = palloc(sizeof(int64)); int64 val1 = PG_GETARG_INT64(0);
int32 val2 = PG_GETARG_INT32(1);
if (!PointerIsValid(val1)) PG_RETURN_INT64(val1 / val2);
return NULL; }
*result = *val1 / (int64) val2; Datum
int48pl(PG_FUNCTION_ARGS)
return result;
} /* int84div() */
int64 *
int48pl(int32 val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int32 val1 = PG_GETARG_INT32(0);
int64 val2 = PG_GETARG_INT64(1);
if (!PointerIsValid(val2)) PG_RETURN_INT64(val1 + val2);
return NULL; }
*result = (int64) val1 + *val2; Datum
int48mi(PG_FUNCTION_ARGS)
return result;
} /* int48pl() */
int64 *
int48mi(int32 val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int32 val1 = PG_GETARG_INT32(0);
int64 val2 = PG_GETARG_INT64(1);
if (!PointerIsValid(val2)) PG_RETURN_INT64(val1 - val2);
return NULL; }
*result = (int64) val1 - *val2; Datum
int48mul(PG_FUNCTION_ARGS)
return result;
} /* int48mi() */
int64 *
int48mul(int32 val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int32 val1 = PG_GETARG_INT32(0);
int64 val2 = PG_GETARG_INT64(1);
if (!PointerIsValid(val2)) PG_RETURN_INT64(val1 * val2);
return NULL; }
*result = (int64) val1 **val2; Datum
int48div(PG_FUNCTION_ARGS)
return result;
} /* int48mul() */
int64 *
int48div(int32 val1, int64 *val2)
{ {
int64 *result = palloc(sizeof(int64)); int32 val1 = PG_GETARG_INT32(0);
int64 val2 = PG_GETARG_INT64(1);
if (!PointerIsValid(val2)) PG_RETURN_INT64(val1 / val2);
return NULL; }
*result = (int64) val1 / *val2;
return result;
} /* int48div() */
/*---------------------------------------------------------- /*----------------------------------------------------------
* Conversion operators. * Conversion operators.
*---------------------------------------------------------*/ *---------------------------------------------------------*/
int64 * Datum
int48(int32 val) int48(PG_FUNCTION_ARGS)
{ {
int64 *result = palloc(sizeof(int64)); int32 val = PG_GETARG_INT32(0);
*result = val; PG_RETURN_INT64((int64) val);
}
return result; Datum
} /* int48() */ int84(PG_FUNCTION_ARGS)
int32
int84(int64 *val)
{ {
int64 val = PG_GETARG_INT64(0);
int32 result; int32 result;
if (!PointerIsValid(val)) if ((val < INT_MIN) || (val > INT_MAX))
elog(ERROR, "Invalid (null) int64, can't convert int8 to int4");
if ((*val < INT_MIN) || (*val > INT_MAX))
elog(ERROR, "int8 conversion to int4 is out of range"); elog(ERROR, "int8 conversion to int4 is out of range");
result = *val; result = (int32) val;
return result; PG_RETURN_INT32(result);
} /* int84() */ }
#if NOT_USED Datum
int64 * i8tod(PG_FUNCTION_ARGS)
int2vector (int16 val)
{ {
int64 *result; int64 val = PG_GETARG_INT64(0);
float8 result;
result = palloc(sizeof(int64)); result = val;
*result = val; PG_RETURN_FLOAT8(result);
}
return result;
} /* int2vector() */
int16
int82(int64 *val)
{
int16 result;
if (!PointerIsValid(val))
elog(ERROR, "Invalid (null) int8, can't convert to int2");
if ((*val < SHRT_MIN) || (*val > SHRT_MAX))
elog(ERROR, "int8 conversion to int2 is out of range");
result = *val;
return result;
} /* int82() */
#endif
float64
i8tod(int64 *val)
{
float64 result = palloc(sizeof(float64data));
if (!PointerIsValid(val))
elog(ERROR, "Invalid (null) int8, can't convert to float8");
*result = *val;
return result;
} /* i8tod() */
/* dtoi8() /* dtoi8()
* Convert double float to 8-byte integer. * Convert double float to 8-byte integer.
@ -644,62 +528,63 @@ i8tod(int64 *val)
* does the right thing on my i686/linux-rh4.2 box. * does the right thing on my i686/linux-rh4.2 box.
* - thomas 1998-06-16 * - thomas 1998-06-16
*/ */
int64 * Datum
dtoi8(float64 val) dtoi8(PG_FUNCTION_ARGS)
{ {
int64 *result = palloc(sizeof(int64)); float8 val = PG_GETARG_FLOAT8(0);
int64 result;
if (!PointerIsValid(val)) if ((val < (-pow(2.0, 63.0) + 1)) || (val > (pow(2.0, 63.0) - 1)))
elog(ERROR, "Invalid (null) float8, can't convert to int8");
if ((*val < (-pow(2, 63) + 1)) || (*val > (pow(2, 63) - 1)))
elog(ERROR, "Floating point conversion to int64 is out of range"); elog(ERROR, "Floating point conversion to int64 is out of range");
*result = *val; result = (int64) val;
return result; PG_RETURN_INT64(result);
} /* dtoi8() */ }
/* text_int8() /* text_int8()
*/ */
int64 * Datum
text_int8(text *str) text_int8(PG_FUNCTION_ARGS)
{ {
text *str = PG_GETARG_TEXT_P(0);
int len; int len;
char *s; char *s;
Datum result;
if (!PointerIsValid(str))
elog(ERROR, "Bad (null) int8 external representation");
len = (VARSIZE(str) - VARHDRSZ); len = (VARSIZE(str) - VARHDRSZ);
s = palloc(len + 1); s = palloc(len + 1);
memmove(s, VARDATA(str), len); memcpy(s, VARDATA(str), len);
*(s + len) = '\0'; *(s + len) = '\0';
return int8in(s); result = DirectFunctionCall1(int8in, CStringGetDatum(s));
} /* text_int8() */
pfree(s);
return result;
}
/* int8_text() /* int8_text()
*/ */
text * Datum
int8_text(int64 *val) int8_text(PG_FUNCTION_ARGS)
{ {
/* val is int64, but easier to leave it as Datum */
Datum val = PG_GETARG_DATUM(0);
char *s;
int len;
text *result; text *result;
int len; s = DatumGetCString(DirectFunctionCall1(int8out, val));
char *s;
if (!PointerIsValid(val))
return NULL;
s = int8out(val);
len = strlen(s); len = strlen(s);
result = palloc(VARHDRSZ + len); result = (text *) palloc(VARHDRSZ + len);
VARSIZE(result) = len + VARHDRSZ; VARSIZE(result) = len + VARHDRSZ;
memmove(VARDATA(result), s, len); memcpy(VARDATA(result), s, len);
return result; pfree(s);
} /* int8_text() */
PG_RETURN_TEXT_P(result);
}

@ -5,7 +5,7 @@
* *
* 1998 Jan Wieck * 1998 Jan Wieck
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.28 2000/06/05 07:28:52 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.29 2000/06/13 07:35:07 tgl Exp $
* *
* ---------- * ----------
*/ */
@ -33,9 +33,6 @@
* Local definitions * Local definitions
* ---------- * ----------
*/ */
#define PG_GETARG_NUMERIC(n) ((Numeric) DatumGetPointer(fcinfo->arg[n]))
#define PG_RETURN_NUMERIC(x) return PointerGetDatum(x)
#ifndef MIN #ifndef MIN
#define MIN(a,b) (((a)<(b)) ? (a) : (b)) #define MIN(a,b) (((a)<(b)) ? (a) : (b))
#endif #endif
@ -189,28 +186,23 @@ static void sub_abs(NumericVar *var1, NumericVar *var2, NumericVar *result);
* Input function for numeric data type * Input function for numeric data type
* ---------- * ----------
*/ */
Numeric Datum
numeric_in(char *str, int dummy, int32 typmod) numeric_in(PG_FUNCTION_ARGS)
{ {
char *str = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
NumericVar value; NumericVar value;
Numeric res; Numeric res;
/* ----------
* Check for NULL
* ----------
*/
if (str == NULL)
return NULL;
if (strcmp(str, "NULL") == 0)
return NULL;
/* ---------- /* ----------
* Check for NaN * Check for NaN
* ---------- * ----------
*/ */
if (strcmp(str, "NaN") == 0) if (strcmp(str, "NaN") == 0)
return make_result(&const_nan); PG_RETURN_NUMERIC(make_result(&const_nan));
/* ---------- /* ----------
* Use set_var_from_str() to parse the input string * Use set_var_from_str() to parse the input string
@ -225,7 +217,7 @@ numeric_in(char *str, int dummy, int32 typmod)
res = make_result(&value); res = make_result(&value);
free_var(&value); free_var(&value);
return res; PG_RETURN_NUMERIC(res);
} }
@ -235,25 +227,19 @@ numeric_in(char *str, int dummy, int32 typmod)
* Output function for numeric data type * Output function for numeric data type
* ---------- * ----------
*/ */
char * Datum
numeric_out(Numeric num) numeric_out(PG_FUNCTION_ARGS)
{ {
Numeric num = PG_GETARG_NUMERIC(0);
NumericVar x; NumericVar x;
char *str; char *str;
/* ----------
* Handle NULL
* ----------
*/
if (num == NULL)
return pstrdup("NULL");
/* ---------- /* ----------
* Handle NaN * Handle NaN
* ---------- * ----------
*/ */
if (NUMERIC_IS_NAN(num)) if (NUMERIC_IS_NAN(num))
return pstrdup("NaN"); PG_RETURN_CSTRING(pstrdup("NaN"));
/* ---------- /* ----------
* Get the number in the variable format. * Get the number in the variable format.
@ -271,7 +257,7 @@ numeric_out(Numeric num)
free_var(&x); free_var(&x);
return str; PG_RETURN_CSTRING(str);
} }
@ -283,9 +269,11 @@ numeric_out(Numeric num)
* scale of the attribute have to be applied on the value. * scale of the attribute have to be applied on the value.
* ---------- * ----------
*/ */
Numeric Datum
numeric(Numeric num, int32 typmod) numeric(PG_FUNCTION_ARGS)
{ {
Numeric num = PG_GETARG_NUMERIC(0);
int32 typmod = PG_GETARG_INT32(1);
Numeric new; Numeric new;
int32 tmp_typmod; int32 tmp_typmod;
int precision; int precision;
@ -293,19 +281,12 @@ numeric(Numeric num, int32 typmod)
int maxweight; int maxweight;
NumericVar var; NumericVar var;
/* ----------
* Handle NULL
* ----------
*/
if (num == NULL)
return NULL;
/* ---------- /* ----------
* Handle NaN * Handle NaN
* ---------- * ----------
*/ */
if (NUMERIC_IS_NAN(num)) if (NUMERIC_IS_NAN(num))
return make_result(&const_nan); PG_RETURN_NUMERIC(make_result(&const_nan));
/* ---------- /* ----------
* If the value isn't a valid type modifier, simply return a * If the value isn't a valid type modifier, simply return a
@ -316,7 +297,7 @@ numeric(Numeric num, int32 typmod)
{ {
new = (Numeric) palloc(num->varlen); new = (Numeric) palloc(num->varlen);
memcpy(new, num, num->varlen); memcpy(new, num, num->varlen);
return new; PG_RETURN_NUMERIC(new);
} }
/* ---------- /* ----------
@ -341,7 +322,7 @@ numeric(Numeric num, int32 typmod)
new->n_rscale = scale; new->n_rscale = scale;
new->n_sign_dscale = NUMERIC_SIGN(new) | new->n_sign_dscale = NUMERIC_SIGN(new) |
((uint16) scale & NUMERIC_DSCALE_MASK); ((uint16) scale & NUMERIC_DSCALE_MASK);
return new; PG_RETURN_NUMERIC(new);
} }
/* ---------- /* ----------
@ -357,7 +338,7 @@ numeric(Numeric num, int32 typmod)
free_var(&var); free_var(&var);
return new; PG_RETURN_NUMERIC(new);
} }
@ -502,26 +483,21 @@ numeric_sign(Numeric num)
* point --- Oracle interprets rounding that way. * point --- Oracle interprets rounding that way.
* ---------- * ----------
*/ */
Numeric Datum
numeric_round(Numeric num, int32 scale) numeric_round(PG_FUNCTION_ARGS)
{ {
Numeric num = PG_GETARG_NUMERIC(0);
int32 scale = PG_GETARG_INT32(1);
Numeric res; Numeric res;
NumericVar arg; NumericVar arg;
int i; int i;
/* ----------
* Handle NULL
* ----------
*/
if (num == NULL)
return NULL;
/* ---------- /* ----------
* Handle NaN * Handle NaN
* ---------- * ----------
*/ */
if (NUMERIC_IS_NAN(num)) if (NUMERIC_IS_NAN(num))
return make_result(&const_nan); PG_RETURN_NUMERIC(make_result(&const_nan));
/* ---------- /* ----------
* Limit the scale value to avoid possible overflow in calculations below. * Limit the scale value to avoid possible overflow in calculations below.
@ -587,7 +563,7 @@ numeric_round(Numeric num, int32 scale)
res = make_result(&arg); res = make_result(&arg);
free_var(&arg); free_var(&arg);
return res; PG_RETURN_NUMERIC(res);
} }
@ -599,25 +575,20 @@ numeric_round(Numeric num, int32 scale)
* point --- Oracle interprets truncation that way. * point --- Oracle interprets truncation that way.
* ---------- * ----------
*/ */
Numeric Datum
numeric_trunc(Numeric num, int32 scale) numeric_trunc(PG_FUNCTION_ARGS)
{ {
Numeric num = PG_GETARG_NUMERIC(0);
int32 scale = PG_GETARG_INT32(1);
Numeric res; Numeric res;
NumericVar arg; NumericVar arg;
/* ----------
* Handle NULL
* ----------
*/
if (num == NULL)
return NULL;
/* ---------- /* ----------
* Handle NaN * Handle NaN
* ---------- * ----------
*/ */
if (NUMERIC_IS_NAN(num)) if (NUMERIC_IS_NAN(num))
return make_result(&const_nan); PG_RETURN_NUMERIC(make_result(&const_nan));
/* ---------- /* ----------
* Limit the scale value to avoid possible overflow in calculations below. * Limit the scale value to avoid possible overflow in calculations below.
@ -650,7 +621,7 @@ numeric_trunc(Numeric num, int32 scale)
res = make_result(&arg); res = make_result(&arg);
free_var(&arg); free_var(&arg);
return res; PG_RETURN_NUMERIC(res);
} }
@ -1708,9 +1679,10 @@ numeric_power(Numeric num1, Numeric num2)
*/ */
Numeric Datum
int4_numeric(int32 val) int4_numeric(PG_FUNCTION_ARGS)
{ {
int32 val = PG_GETARG_INT32(0);
Numeric res; Numeric res;
NumericVar result; NumericVar result;
char *tmp; char *tmp;
@ -1725,7 +1697,7 @@ int4_numeric(int32 val)
free_var(&result); free_var(&result);
pfree(tmp); pfree(tmp);
return res; PG_RETURN_NUMERIC(res);
} }
@ -1769,7 +1741,8 @@ int8_numeric(int64 *val)
init_var(&result); init_var(&result);
tmp = int8out(val); tmp = DatumGetCString(DirectFunctionCall1(int8out,
PointerGetDatum(val)));
set_var_from_str(tmp, &result); set_var_from_str(tmp, &result);
res = make_result(&result); res = make_result(&result);
@ -1785,7 +1758,7 @@ numeric_int8(Numeric num)
{ {
NumericVar x; NumericVar x;
char *str; char *str;
int64 *result; Datum result;
if (num == NULL) if (num == NULL)
return NULL; return NULL;
@ -1804,10 +1777,11 @@ numeric_int8(Numeric num)
free_var(&x); free_var(&x);
result = int8in(str); result = DirectFunctionCall1(int8in, CStringGetDatum(str));
pfree(str); pfree(str);
return result; return (int64 *) (result);
} }
@ -1904,7 +1878,8 @@ numeric_float8(Numeric num)
return result; return result;
} }
tmp = numeric_out(num); tmp = DatumGetCString(DirectFunctionCall1(numeric_out,
NumericGetDatum(num)));
result = float8in(tmp); result = float8in(tmp);
pfree(tmp); pfree(tmp);
@ -1954,7 +1929,8 @@ numeric_float4(Numeric num)
return result; return result;
} }
tmp = numeric_out(num); tmp = DatumGetCString(DirectFunctionCall1(numeric_out,
NumericGetDatum(num)));
result = float4in(tmp); result = float4in(tmp);
pfree(tmp); pfree(tmp);

@ -1,7 +1,7 @@
/* /*
* Edmund Mergl <E.Mergl@bawue.de> * Edmund Mergl <E.Mergl@bawue.de>
* *
* $Id: oracle_compat.c,v 1.24 2000/04/12 17:15:51 momjian Exp $ * $Id: oracle_compat.c,v 1.25 2000/06/13 07:35:07 tgl Exp $
* *
*/ */
@ -150,9 +150,12 @@ initcap(text *string)
* *
********************************************************************/ ********************************************************************/
text * Datum
lpad(text *string1, int4 len, text *string2) lpad(PG_FUNCTION_ARGS)
{ {
text *string1 = PG_GETARG_TEXT_P(0);
int32 len = PG_GETARG_INT32(1);
text *string2 = PG_GETARG_TEXT_P(2);
text *ret; text *ret;
char *ptr1, char *ptr1,
*ptr2, *ptr2,
@ -160,12 +163,10 @@ lpad(text *string1, int4 len, text *string2)
int m, int m,
n; n;
if ((string1 == (text *) NULL) || if (((VARSIZE(string1) - VARHDRSZ) < 0) ||
(len <= (VARSIZE(string1) - VARHDRSZ)) || ((m = len - (VARSIZE(string1) - VARHDRSZ)) <= 0) ||
((m = len - VARSIZE(string1) + VARHDRSZ) <= 0) ||
(string2 == (text *) NULL) ||
((VARSIZE(string2) - VARHDRSZ) <= 0)) ((VARSIZE(string2) - VARHDRSZ) <= 0))
return string1; PG_RETURN_TEXT_P(string1);
ret = (text *) palloc(VARHDRSZ + len); ret = (text *) palloc(VARHDRSZ + len);
VARSIZE(ret) = VARHDRSZ + len; VARSIZE(ret) = VARHDRSZ + len;
@ -176,7 +177,7 @@ lpad(text *string1, int4 len, text *string2)
while (m--) while (m--)
{ {
*ptr_ret++ = *ptr2; *ptr_ret++ = *ptr2;
ptr2 = ptr2 == VARDATA(string2) + VARSIZE(string2) - VARHDRSZ - 1 ? VARDATA(string2) : ++ptr2; ptr2 = (ptr2 == VARDATA(string2) + VARSIZE(string2) - VARHDRSZ - 1) ? VARDATA(string2) : ++ptr2;
} }
n = VARSIZE(string1) - VARHDRSZ; n = VARSIZE(string1) - VARHDRSZ;
@ -185,7 +186,7 @@ lpad(text *string1, int4 len, text *string2)
while (n--) while (n--)
*ptr_ret++ = *ptr1++; *ptr_ret++ = *ptr1++;
return ret; PG_RETURN_TEXT_P(ret);
} }
@ -204,9 +205,12 @@ lpad(text *string1, int4 len, text *string2)
* *
********************************************************************/ ********************************************************************/
text * Datum
rpad(text *string1, int4 len, text *string2) rpad(PG_FUNCTION_ARGS)
{ {
text *string1 = PG_GETARG_TEXT_P(0);
int32 len = PG_GETARG_INT32(1);
text *string2 = PG_GETARG_TEXT_P(2);
text *ret; text *ret;
char *ptr1, char *ptr1,
*ptr2, *ptr2,
@ -214,12 +218,10 @@ rpad(text *string1, int4 len, text *string2)
int m, int m,
n; n;
if ((string1 == (text *) NULL) || if (((VARSIZE(string1) - VARHDRSZ) < 0) ||
(len <= (VARSIZE(string1) - VARHDRSZ)) || ((m = len - (VARSIZE(string1) - VARHDRSZ)) <= 0) ||
((m = len - VARSIZE(string1) + VARHDRSZ) <= 0) ||
(string2 == (text *) NULL) ||
((VARSIZE(string2) - VARHDRSZ) <= 0)) ((VARSIZE(string2) - VARHDRSZ) <= 0))
return string1; PG_RETURN_TEXT_P(string1);
ret = (text *) palloc(VARHDRSZ + len); ret = (text *) palloc(VARHDRSZ + len);
VARSIZE(ret) = VARHDRSZ + len; VARSIZE(ret) = VARHDRSZ + len;
@ -236,10 +238,10 @@ rpad(text *string1, int4 len, text *string2)
while (m--) while (m--)
{ {
*ptr_ret++ = *ptr2; *ptr_ret++ = *ptr2;
ptr2 = ptr2 == VARDATA(string2) + VARSIZE(string2) - VARHDRSZ - 1 ? VARDATA(string2) : ++ptr2; ptr2 = (ptr2 == VARDATA(string2) + VARSIZE(string2) - VARHDRSZ - 1) ? VARDATA(string2) : ++ptr2;
} }
return ret; PG_RETURN_TEXT_P(ret);
} }
@ -551,22 +553,25 @@ ascii(text *string)
} /* ascii() */ } /* ascii() */
text * Datum
ichar(int4 cvalue) ichar(PG_FUNCTION_ARGS)
{ {
int32 cvalue = PG_GETARG_INT32(0);
text *result; text *result;
result = (text *) palloc(VARHDRSZ + 1); result = (text *) palloc(VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ + 1; VARSIZE(result) = VARHDRSZ + 1;
*VARDATA(result) = (char) cvalue; *VARDATA(result) = (char) cvalue;
return result; PG_RETURN_TEXT_P(result);
} /* ichar() */ }
text * Datum
repeat(text *string, int4 count) repeat(PG_FUNCTION_ARGS)
{ {
text *string = PG_GETARG_TEXT_P(0);
int32 count = PG_GETARG_INT32(1);
text *result; text *result;
int slen, int slen,
tlen; tlen;
@ -589,5 +594,5 @@ repeat(text *string, int4 count)
cp += slen; cp += slen;
} }
return result; PG_RETURN_TEXT_P(result);
} /* repeat() */ }

@ -3,7 +3,7 @@
* out of its tuple * out of its tuple
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.53 2000/06/12 19:40:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.54 2000/06/13 07:35:08 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
@ -551,18 +551,19 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
* fallback to 'unknown (UID=n)' * fallback to 'unknown (UID=n)'
* ---------- * ----------
*/ */
NameData * Datum
pg_get_userbyid(int32 uid) pg_get_userbyid(PG_FUNCTION_ARGS)
{ {
int32 uid = PG_GETARG_INT32(0);
Name result;
HeapTuple usertup; HeapTuple usertup;
Form_pg_shadow user_rec; Form_pg_shadow user_rec;
NameData *result;
/* ---------- /* ----------
* Allocate space for the result * Allocate space for the result
* ---------- * ----------
*/ */
result = (NameData *) palloc(NAMEDATALEN); result = (Name) palloc(NAMEDATALEN);
memset(NameStr(*result), 0, NAMEDATALEN); memset(NameStr(*result), 0, NAMEDATALEN);
/* ---------- /* ----------
@ -570,16 +571,17 @@ pg_get_userbyid(int32 uid)
* ---------- * ----------
*/ */
usertup = SearchSysCacheTuple(SHADOWSYSID, usertup = SearchSysCacheTuple(SHADOWSYSID,
ObjectIdGetDatum(uid), 0, 0, 0); ObjectIdGetDatum(uid),
0, 0, 0);
if (HeapTupleIsValid(usertup)) if (HeapTupleIsValid(usertup))
{ {
user_rec = (Form_pg_shadow) GETSTRUCT(usertup); user_rec = (Form_pg_shadow) GETSTRUCT(usertup);
StrNCpy(NameStr(*result), NameStr(user_rec->usename), NAMEDATALEN); StrNCpy(NameStr(*result), NameStr(user_rec->usename), NAMEDATALEN);
} }
else else
sprintf((char *) result, "unknown (UID=%d)", uid); sprintf(NameStr(*result), "unknown (UID=%d)", uid);
return result; PG_RETURN_NAME(result);
} }
/* ---------- /* ----------

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.63 2000/06/05 07:28:52 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.64 2000/06/13 07:35:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -61,20 +61,21 @@ extern char *convertstr(char *, int, int);
/* /*
* bpcharin - * bpcharin -
* converts a string of char() type to the internal representation. * converts a string of char() type to the internal representation.
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here * len is the length specified in () plus VARHDRSZ bytes.
* because we pass typelem as the second argument for array_in.)
*/ */
char * Datum
bpcharin(char *s, int dummy, int32 atttypmod) bpcharin(PG_FUNCTION_ARGS)
{ {
char *result, char *s = PG_GETARG_CSTRING(0);
*r; #ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
BpChar *result;
char *r;
int len; int len;
int i; int i;
if (s == NULL)
return (char *) NULL;
if (atttypmod < (int32) VARHDRSZ) if (atttypmod < (int32) VARHDRSZ)
{ {
/* If typmod is -1 (or invalid), use the actual string length */ /* If typmod is -1 (or invalid), use the actual string length */
@ -84,7 +85,7 @@ bpcharin(char *s, int dummy, int32 atttypmod)
else else
len = atttypmod - VARHDRSZ; len = atttypmod - VARHDRSZ;
result = (char *) palloc(atttypmod); result = (BpChar *) palloc(atttypmod);
VARSIZE(result) = atttypmod; VARSIZE(result) = atttypmod;
r = VARDATA(result); r = VARDATA(result);
for (i = 0; i < len; i++, r++, s++) for (i = 0; i < len; i++, r++, s++)
@ -95,85 +96,78 @@ bpcharin(char *s, int dummy, int32 atttypmod)
} }
#ifdef CYR_RECODE #ifdef CYR_RECODE
convertstr(result + VARHDRSZ, len, 0); convertstr(VARDATA(result), len, 0);
#endif #endif
/* blank pad the string if necessary */ /* blank pad the string if necessary */
for (; i < len; i++) for (; i < len; i++)
*r++ = ' '; *r++ = ' ';
return result;
PG_RETURN_BPCHAR_P(result);
} }
char * Datum
bpcharout(char *s) bpcharout(PG_FUNCTION_ARGS)
{ {
BpChar *s = PG_GETARG_BPCHAR_P(0);
char *result; char *result;
int len; int len;
if (s == NULL)
{
result = (char *) palloc(2);
result[0] = '-';
result[1] = '\0';
}
else
{
len = VARSIZE(s) - VARHDRSZ; len = VARSIZE(s) - VARHDRSZ;
result = (char *) palloc(len + 1); result = (char *) palloc(len + 1);
StrNCpy(result, VARDATA(s), len + 1); /* these are blank-padded */ StrNCpy(result, VARDATA(s), len + 1); /* copy and add null term */
}
#ifdef CYR_RECODE #ifdef CYR_RECODE
convertstr(result, len, 1); convertstr(result, len, 1);
#endif #endif
return result; PG_RETURN_CSTRING(result);
} }
/* bpchar() /* bpchar()
* Converts a char() type to a specific internal length. * Converts a char() type to a specific internal length.
* len is the length specified in () plus VARHDRSZ bytes. * len is the length specified in () plus VARHDRSZ bytes.
*/ */
char * Datum
bpchar(char *s, int32 len) bpchar(PG_FUNCTION_ARGS)
{ {
char *result, BpChar *str = PG_GETARG_BPCHAR_P(0);
*r; int32 len = PG_GETARG_INT32(1);
BpChar *result;
char *r,
*s;
int rlen, int rlen,
slen; slen;
int i; int i;
if (s == NULL)
return (char *) NULL;
/* No work if typmod is invalid or supplied data matches it already */ /* No work if typmod is invalid or supplied data matches it already */
if (len < (int32) VARHDRSZ || len == VARSIZE(s)) if (len < (int32) VARHDRSZ || len == VARSIZE(str))
return s; PG_RETURN_BPCHAR_P(str);
rlen = len - VARHDRSZ; rlen = len - VARHDRSZ;
#ifdef STRINGDEBUG #ifdef STRINGDEBUG
printf("bpchar- convert string length %d (%d) ->%d (%d)\n", printf("bpchar- convert string length %d (%d) ->%d (%d)\n",
VARSIZE(s) - VARHDRSZ, VARSIZE(s), rlen, len); VARSIZE(str) - VARHDRSZ, VARSIZE(str), rlen, len);
#endif #endif
result = (char *) palloc(len); result = (BpChar *) palloc(len);
VARSIZE(result) = len; VARSIZE(result) = len;
r = VARDATA(result); r = VARDATA(result);
#ifdef MULTIBYTE
#ifdef MULTIBYTE
/* /*
* truncate multi-byte string in a way not to break multi-byte * truncate multi-byte string in a way not to break multi-byte
* boundary * boundary
*/ */
if (VARSIZE(s) > len) if (VARSIZE(str) > len)
slen = pg_mbcliplen(VARDATA(s), VARSIZE(s) - VARHDRSZ, rlen); slen = pg_mbcliplen(VARDATA(str), VARSIZE(str) - VARHDRSZ, rlen);
else else
slen = VARSIZE(s) - VARHDRSZ; slen = VARSIZE(str) - VARHDRSZ;
#else #else
slen = VARSIZE(s) - VARHDRSZ; slen = VARSIZE(str) - VARHDRSZ;
#endif #endif
s = VARDATA(s); s = VARDATA(str);
#ifdef STRINGDEBUG #ifdef STRINGDEBUG
printf("bpchar- string is '"); printf("bpchar- string is '");
@ -181,13 +175,9 @@ bpchar(char *s, int32 len)
for (i = 0; (i < rlen) && (i < slen); i++) for (i = 0; (i < rlen) && (i < slen); i++)
{ {
if (*s == '\0')
break;
#ifdef STRINGDEBUG #ifdef STRINGDEBUG
printf("%c", *s); printf("%c", *s);
#endif #endif
*r++ = *s++; *r++ = *s++;
} }
@ -199,19 +189,21 @@ bpchar(char *s, int32 len)
for (; i < rlen; i++) for (; i < rlen; i++)
*r++ = ' '; *r++ = ' ';
return result; PG_RETURN_BPCHAR_P(result);
} /* bpchar() */ }
/* _bpchar() /* _bpchar()
* Converts an array of char() type to a specific internal length. * Converts an array of char() elements to a specific internal length.
* len is the length specified in () plus VARHDRSZ bytes. * len is the length specified in () plus VARHDRSZ bytes.
*/ */
ArrayType * Datum
_bpchar(ArrayType *v, int32 len) _bpchar(PG_FUNCTION_ARGS)
{ {
ArrayType *v = (ArrayType *) PG_GETARG_VARLENA_P(0);
int32 len = PG_GETARG_INT32(1);
FunctionCallInfoData locfcinfo; FunctionCallInfoData locfcinfo;
Datum result; /*
/* Since bpchar() is a built-in function, we should only need to * Since bpchar() is a built-in function, we should only need to
* look it up once per run. * look it up once per run.
*/ */
static FmgrInfo bpchar_finfo; static FmgrInfo bpchar_finfo;
@ -226,9 +218,7 @@ _bpchar(ArrayType *v, int32 len)
locfcinfo.arg[0] = PointerGetDatum(v); locfcinfo.arg[0] = PointerGetDatum(v);
locfcinfo.arg[1] = Int32GetDatum(len); locfcinfo.arg[1] = Int32GetDatum(len);
result = array_map(&locfcinfo, BPCHAROID, BPCHAROID); return array_map(&locfcinfo, BPCHAROID, BPCHAROID);
return (ArrayType *) DatumGetPointer(result);
} }
@ -240,7 +230,7 @@ _bpchar(ArrayType *v, int32 len)
Datum Datum
bpchar_char(PG_FUNCTION_ARGS) bpchar_char(PG_FUNCTION_ARGS)
{ {
struct varlena *s = PG_GETARG_BPCHAR_P(0); BpChar *s = PG_GETARG_BPCHAR_P(0);
PG_RETURN_CHAR(*VARDATA(s)); PG_RETURN_CHAR(*VARDATA(s));
} }
@ -252,9 +242,9 @@ Datum
char_bpchar(PG_FUNCTION_ARGS) char_bpchar(PG_FUNCTION_ARGS)
{ {
char c = PG_GETARG_CHAR(0); char c = PG_GETARG_CHAR(0);
struct varlena *result; BpChar *result;
result = (struct varlena *) palloc(VARHDRSZ + 1); result = (BpChar *) palloc(VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ + 1; VARSIZE(result) = VARHDRSZ + 1;
*(VARDATA(result)) = c; *(VARDATA(result)) = c;
@ -338,75 +328,67 @@ name_bpchar(NameData *s)
/* /*
* varcharin - * varcharin -
* converts a string of varchar() type to the internal representation. * converts a string of varchar() type to the internal representation.
* len is the length specified in () plus VARHDRSZ bytes. (XXX dummy is here * len is the length specified in () plus VARHDRSZ bytes.
* because we pass typelem as the second argument for array_in.)
*/ */
char * Datum
varcharin(char *s, int dummy, int32 atttypmod) varcharin(PG_FUNCTION_ARGS)
{ {
char *result; char *s = PG_GETARG_CSTRING(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 atttypmod = PG_GETARG_INT32(2);
VarChar *result;
int len; int len;
if (s == NULL)
return (char *) NULL;
len = strlen(s) + VARHDRSZ; len = strlen(s) + VARHDRSZ;
if (atttypmod >= (int32) VARHDRSZ && len > atttypmod) if (atttypmod >= (int32) VARHDRSZ && len > atttypmod)
len = atttypmod; /* clip the string at max length */ len = atttypmod; /* clip the string at max length */
result = (char *) palloc(len); result = (VarChar *) palloc(len);
VARSIZE(result) = len; VARSIZE(result) = len;
strncpy(VARDATA(result), s, len - VARHDRSZ); memcpy(VARDATA(result), s, len - VARHDRSZ);
#ifdef CYR_RECODE #ifdef CYR_RECODE
convertstr(result + VARHDRSZ, len, 0); convertstr(VARDATA(result), len, 0);
#endif #endif
return result; PG_RETURN_VARCHAR_P(result);
} }
char * Datum
varcharout(char *s) varcharout(PG_FUNCTION_ARGS)
{ {
VarChar *s = PG_GETARG_VARCHAR_P(0);
char *result; char *result;
int len; int len;
if (s == NULL)
{
result = (char *) palloc(2);
result[0] = '-';
result[1] = '\0';
}
else
{
len = VARSIZE(s) - VARHDRSZ; len = VARSIZE(s) - VARHDRSZ;
result = (char *) palloc(len + 1); result = (char *) palloc(len + 1);
StrNCpy(result, VARDATA(s), len + 1); StrNCpy(result, VARDATA(s), len + 1); /* copy and add null term */
}
#ifdef CYR_RECODE #ifdef CYR_RECODE
convertstr(result, len, 1); convertstr(result, len, 1);
#endif #endif
return result; PG_RETURN_CSTRING(result);
} }
/* varchar() /* varchar()
* Converts a varchar() type to the specified size. * Converts a varchar() type to the specified size.
* slen is the length specified in () plus VARHDRSZ bytes. * slen is the length specified in () plus VARHDRSZ bytes.
*/ */
char * Datum
varchar(char *s, int32 slen) varchar(PG_FUNCTION_ARGS)
{ {
char *result; VarChar *s = PG_GETARG_VARCHAR_P(0);
int32 slen = PG_GETARG_INT32(1);
VarChar *result;
int len; int len;
if (s == NULL)
return (char *) NULL;
len = VARSIZE(s); len = VARSIZE(s);
if (slen < (int32) VARHDRSZ || len <= slen) if (slen < (int32) VARHDRSZ || len <= slen)
return (char *) s; PG_RETURN_VARCHAR_P(s);
/* only reach here if we need to truncate string... */ /* only reach here if we need to truncate string... */
@ -422,23 +404,25 @@ varchar(char *s, int32 slen)
len = slen - VARHDRSZ; len = slen - VARHDRSZ;
#endif #endif
result = (char *) palloc(slen); result = (VarChar *) palloc(slen);
VARSIZE(result) = slen; VARSIZE(result) = slen;
strncpy(VARDATA(result), VARDATA(s), len); memcpy(VARDATA(result), VARDATA(s), len);
return result; PG_RETURN_VARCHAR_P(result);
} /* varchar() */ }
/* _varchar() /* _varchar()
* Converts an array of varchar() type to the specified size. * Converts an array of varchar() elements to the specified size.
* len is the length specified in () plus VARHDRSZ bytes. * len is the length specified in () plus VARHDRSZ bytes.
*/ */
ArrayType * Datum
_varchar(ArrayType *v, int32 len) _varchar(PG_FUNCTION_ARGS)
{ {
ArrayType *v = (ArrayType *) PG_GETARG_VARLENA_P(0);
int32 len = PG_GETARG_INT32(1);
FunctionCallInfoData locfcinfo; FunctionCallInfoData locfcinfo;
Datum result; /*
/* Since varchar() is a built-in function, we should only need to * Since varchar() is a built-in function, we should only need to
* look it up once per run. * look it up once per run.
*/ */
static FmgrInfo varchar_finfo; static FmgrInfo varchar_finfo;
@ -453,9 +437,7 @@ _varchar(ArrayType *v, int32 len)
locfcinfo.arg[0] = PointerGetDatum(v); locfcinfo.arg[0] = PointerGetDatum(v);
locfcinfo.arg[1] = Int32GetDatum(len); locfcinfo.arg[1] = Int32GetDatum(len);
result = array_map(&locfcinfo, VARCHAROID, VARCHAROID); return array_map(&locfcinfo, VARCHAROID, VARCHAROID);
return (ArrayType *) DatumGetPointer(result);
} }

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.58 2000/04/12 17:15:52 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.59 2000/06/13 07:35:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -323,21 +323,19 @@ textcat(text *t1, text *t2)
* Formerly returned the entire string; now returns a portion. * Formerly returned the entire string; now returns a portion.
* - Thomas Lockhart 1998-12-10 * - Thomas Lockhart 1998-12-10
*/ */
text * Datum
text_substr(text *string, int32 m, int32 n) text_substr(PG_FUNCTION_ARGS)
{ {
text *string = PG_GETARG_TEXT_P(0);
int32 m = PG_GETARG_INT32(1);
int32 n = PG_GETARG_INT32(2);
text *ret; text *ret;
int len; int len;
#ifdef MULTIBYTE #ifdef MULTIBYTE
int i; int i;
char *p; char *p;
#endif #endif
if (string == (text *) NULL)
return string;
len = VARSIZE(string) - VARHDRSZ; len = VARSIZE(string) - VARHDRSZ;
#ifdef MULTIBYTE #ifdef MULTIBYTE
len = pg_mbstrlen_with_len(VARDATA(string), len); len = pg_mbstrlen_with_len(VARDATA(string), len);
@ -374,13 +372,14 @@ text_substr(text *string, int32 m, int32 n)
p += pg_mblen(p); p += pg_mblen(p);
n = p - (VARDATA(string) + m); n = p - (VARDATA(string) + m);
#endif #endif
ret = (text *) palloc(VARHDRSZ + n); ret = (text *) palloc(VARHDRSZ + n);
VARSIZE(ret) = VARHDRSZ + n; VARSIZE(ret) = VARHDRSZ + n;
memcpy(VARDATA(ret), VARDATA(string) + m, n); memcpy(VARDATA(ret), VARDATA(string) + m, n);
return ret; PG_RETURN_TEXT_P(ret);
} /* text_substr() */ }
/* /*
* textpos - * textpos -
@ -636,19 +635,17 @@ byteaoctetlen(bytea *v)
* byteaGetByte * byteaGetByte
* *
* this routine treats "bytea" as an array of bytes. * this routine treats "bytea" as an array of bytes.
* It returns the Nth byte (a number between 0 and 255) or * It returns the Nth byte (a number between 0 and 255).
* it dies if the length of this array is less than n.
*------------------------------------------------------------- *-------------------------------------------------------------
*/ */
int32 Datum
byteaGetByte(bytea *v, int32 n) byteaGetByte(PG_FUNCTION_ARGS)
{ {
bytea *v = PG_GETARG_BYTEA_P(0);
int32 n = PG_GETARG_INT32(1);
int len; int len;
int byte; int byte;
if (!PointerIsValid(v))
return 0;
len = VARSIZE(v) - VARHDRSZ; len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len) if (n < 0 || n >= len)
@ -657,7 +654,7 @@ byteaGetByte(bytea *v, int32 n)
byte = ((unsigned char *) VARDATA(v))[n]; byte = ((unsigned char *) VARDATA(v))[n];
return (int32) byte; PG_RETURN_INT32(byte);
} }
/*------------------------------------------------------------- /*-------------------------------------------------------------
@ -665,21 +662,19 @@ byteaGetByte(bytea *v, int32 n)
* *
* This routine treats a "bytea" type like an array of bits. * This routine treats a "bytea" type like an array of bits.
* It returns the value of the Nth bit (0 or 1). * It returns the value of the Nth bit (0 or 1).
* If 'n' is out of range, it dies!
* *
*------------------------------------------------------------- *-------------------------------------------------------------
*/ */
int32 Datum
byteaGetBit(bytea *v, int32 n) byteaGetBit(PG_FUNCTION_ARGS)
{ {
bytea *v = PG_GETARG_BYTEA_P(0);
int32 n = PG_GETARG_INT32(1);
int byteNo, int byteNo,
bitNo; bitNo;
int len; int len;
int byte; int byte;
if (!PointerIsValid(v))
return 0;
len = VARSIZE(v) - VARHDRSZ; len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len * 8) if (n < 0 || n >= len * 8)
@ -692,9 +687,9 @@ byteaGetBit(bytea *v, int32 n)
byte = ((unsigned char *) VARDATA(v))[byteNo]; byte = ((unsigned char *) VARDATA(v))[byteNo];
if (byte & (1 << bitNo)) if (byte & (1 << bitNo))
return (int32) 1; PG_RETURN_INT32(1);
else else
return (int32) 0; PG_RETURN_INT32(0);
} }
/*------------------------------------------------------------- /*-------------------------------------------------------------
@ -705,15 +700,15 @@ byteaGetBit(bytea *v, int32 n)
* *
*------------------------------------------------------------- *-------------------------------------------------------------
*/ */
bytea * Datum
byteaSetByte(bytea *v, int32 n, int32 newByte) byteaSetByte(PG_FUNCTION_ARGS)
{ {
bytea *v = PG_GETARG_BYTEA_P(0);
int32 n = PG_GETARG_INT32(1);
int32 newByte = PG_GETARG_INT32(2);
int len; int len;
bytea *res; bytea *res;
if (!PointerIsValid(v))
return 0;
len = VARSIZE(v) - VARHDRSZ; len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len) if (n < 0 || n >= len)
@ -731,7 +726,7 @@ byteaSetByte(bytea *v, int32 n, int32 newByte)
*/ */
((unsigned char *) VARDATA(res))[n] = newByte; ((unsigned char *) VARDATA(res))[n] = newByte;
return res; PG_RETURN_BYTEA_P(res);
} }
/*------------------------------------------------------------- /*-------------------------------------------------------------
@ -742,9 +737,12 @@ byteaSetByte(bytea *v, int32 n, int32 newByte)
* *
*------------------------------------------------------------- *-------------------------------------------------------------
*/ */
bytea * Datum
byteaSetBit(bytea *v, int32 n, int32 newBit) byteaSetBit(PG_FUNCTION_ARGS)
{ {
bytea *v = PG_GETARG_BYTEA_P(0);
int32 n = PG_GETARG_INT32(1);
int32 newBit = PG_GETARG_INT32(2);
bytea *res; bytea *res;
int len; int len;
int oldByte, int oldByte,
@ -752,9 +750,6 @@ byteaSetBit(bytea *v, int32 n, int32 newBit)
int byteNo, int byteNo,
bitNo; bitNo;
if (!PointerIsValid(v))
return NULL;
len = VARSIZE(v) - VARHDRSZ; len = VARSIZE(v) - VARHDRSZ;
if (n < 0 || n >= len * 8) if (n < 0 || n >= len * 8)
@ -771,24 +766,24 @@ byteaSetBit(bytea *v, int32 n, int32 newBit)
elog(ERROR, "byteaSetBit: new bit must be 0 or 1"); elog(ERROR, "byteaSetBit: new bit must be 0 or 1");
/* /*
* get the byte where the bit we want is stored. * Make a copy of the original varlena.
*/ */
oldByte = byteaGetByte(v, byteNo); res = (bytea *) palloc(VARSIZE(v));
memcpy((char *) res, (char *) v, VARSIZE(v));
/* /*
* calculate the new value for that byte * Update the byte.
*/ */
oldByte = ((unsigned char *) VARDATA(res))[byteNo];
if (newBit == 0) if (newBit == 0)
newByte = oldByte & (~(1 << bitNo)); newByte = oldByte & (~(1 << bitNo));
else else
newByte = oldByte | (1 << bitNo); newByte = oldByte | (1 << bitNo);
/* ((unsigned char *) VARDATA(res))[byteNo] = newByte;
* NOTE: 'byteaSetByte' creates a copy of 'v' & sets the byte.
*/
res = byteaSetByte(v, byteNo, newByte);
return res; PG_RETURN_BYTEA_P(res);
} }

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.48 2000/06/08 22:37:33 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.49 2000/06/13 07:35:09 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -28,6 +28,7 @@
#include "catalog/catname.h" #include "catalog/catname.h"
#include "catalog/pg_shadow.h" #include "catalog/pg_shadow.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/syscache.h" #include "utils/syscache.h"
static char *GetPidFname(void); static char *GetPidFname(void);
@ -98,25 +99,26 @@ SetDatabaseName(const char *name)
} }
#ifndef MULTIBYTE #ifndef MULTIBYTE
/* even if MULTIBYTE is not enabled, this function is neccesary /* even if MULTIBYTE is not enabled, these functions are necessary
* since pg_proc.h has entries for them. * since pg_proc.h has references to them.
*/ */
const char *
getdatabaseencoding() Datum
getdatabaseencoding(PG_FUNCTION_ARGS)
{ {
return ("SQL_ASCII"); PG_RETURN_NAME("SQL_ASCII");
} }
const char * Datum
pg_encoding_to_char(int encoding) PG_encoding_to_char(PG_FUNCTION_ARGS)
{ {
return ("SQL_ASCII"); PG_RETURN_NAME("SQL_ASCII");
} }
int Datum
pg_char_to_encoding(const char *encoding_string) PG_char_to_encoding(PG_FUNCTION_ARGS)
{ {
return (0); PG_RETURN_INT32(0);
} }
#endif #endif

@ -2,7 +2,7 @@
* This file contains some public functions * This file contains some public functions
* usable for both the backend and the frontend. * usable for both the backend and the frontend.
* Tatsuo Ishii * Tatsuo Ishii
* $Id: common.c,v 1.8 2000/01/18 05:14:24 ishii Exp $ */ * $Id: common.c,v 1.9 2000/06/13 07:35:15 tgl Exp $ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -14,8 +14,10 @@
#endif #endif
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "utils/builtins.h"
/* /*
* convert encoding char to encoding symbol value. * convert encoding char to encoding symbol value.
@ -38,6 +40,15 @@ pg_char_to_encoding(const char *s)
return (p->encoding); return (p->encoding);
} }
/* Same, as an fmgr-callable function */
Datum
PG_char_to_encoding(PG_FUNCTION_ARGS)
{
Name s = PG_GETARG_NAME(0);
PG_RETURN_INT32(pg_char_to_encoding(NameStr(*s)));
}
/* /*
* check to see if encoding name is valid * check to see if encoding name is valid
*/ */
@ -77,6 +88,15 @@ pg_encoding_to_char(int encoding)
return (p->name); return (p->name);
} }
/* Same, as an fmgr-callable function */
Datum
PG_encoding_to_char(PG_FUNCTION_ARGS)
{
int32 encoding = PG_GETARG_INT32(0);
PG_RETURN_NAME(pg_encoding_to_char(encoding));
}
/* returns the byte length of a multi-byte word for an encoding */ /* returns the byte length of a multi-byte word for an encoding */
int int
pg_encoding_mblen(int encoding, const unsigned char *mbstr) pg_encoding_mblen(int encoding, const unsigned char *mbstr)

@ -3,12 +3,14 @@
* client encoding and server internal encoding. * client encoding and server internal encoding.
* (currently mule internal code (mic) is used) * (currently mule internal code (mic) is used)
* Tatsuo Ishii * Tatsuo Ishii
* $Id: mbutils.c,v 1.9 1999/09/11 22:28:00 tgl Exp $ */ * $Id: mbutils.c,v 1.10 2000/06/13 07:35:12 tgl Exp $ */
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
#include "utils/builtins.h"
static int client_encoding = -1; static int client_encoding = -1;
static void (*client_to_mic) ();/* something to MIC */ static void (*client_to_mic) ();/* something to MIC */
@ -266,10 +268,10 @@ GetDatabaseEncoding()
} }
/* for builtin-function */ /* for builtin-function */
const char * Datum
getdatabaseencoding() getdatabaseencoding(PG_FUNCTION_ARGS)
{ {
return (pg_encoding_to_char(DatabaseEncoding)); PG_RETURN_NAME(pg_encoding_to_char(DatabaseEncoding));
} }
/* set and get template1 database encoding */ /* set and get template1 database encoding */

@ -182,14 +182,9 @@ typedef struct intrange
int flag; int flag;
} INTRANGE; } INTRANGE;
extern void gistbuild(Relation heap, extern Datum gistbuild(PG_FUNCTION_ARGS);
Relation index, int natts, extern Datum gistinsert(PG_FUNCTION_ARGS);
AttrNumber *attnum, IndexStrategy istrat, extern Datum gistdelete(PG_FUNCTION_ARGS);
uint16 pint, Datum *params,
FuncIndexInfo *finfo,
PredInfo *predInfo);
extern InsertIndexResult gistinsert(Relation r, Datum *datum,
char *nulls, ItemPointer ht_ctid, Relation heapRel);
extern void _gistdump(Relation r); extern void _gistdump(Relation r);
extern void gistfreestack(GISTSTACK *s); extern void gistfreestack(GISTSTACK *s);
extern void initGISTstate(GISTSTATE *giststate, Relation index); extern void initGISTstate(GISTSTATE *giststate, Relation index);
@ -198,6 +193,6 @@ extern void gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr,
extern StrategyNumber RelationGetGISTStrategy(Relation, AttrNumber, RegProcedure); extern StrategyNumber RelationGetGISTStrategy(Relation, AttrNumber, RegProcedure);
/* gistget.c */ /* gistget.c */
extern RetrieveIndexResult gistgettuple(IndexScanDesc s, ScanDirection dir); extern Datum gistgettuple(PG_FUNCTION_ARGS);
#endif /* GIST_H */ #endif /* GIST_H */

@ -10,15 +10,15 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#ifndef GISTSCAN_H #ifndef GISTSCAN_H
#define GISTSCAN_H
#include "access/relscan.h" #include "access/relscan.h"
extern IndexScanDesc gistbeginscan(Relation r, bool fromEnd, extern Datum gistbeginscan(PG_FUNCTION_ARGS);
uint16 nkeys, ScanKey key); extern Datum gistrescan(PG_FUNCTION_ARGS);
extern void gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key); extern Datum gistmarkpos(PG_FUNCTION_ARGS);
extern void gistmarkpos(IndexScanDesc s); extern Datum gistrestrpos(PG_FUNCTION_ARGS);
extern void gistrestrpos(IndexScanDesc s); extern Datum gistendscan(PG_FUNCTION_ARGS);
extern void gistendscan(IndexScanDesc s);
extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum);
#endif /* GISTSCAN_H */ #endif /* GISTSCAN_H */

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: hash.h,v 1.32 2000/06/05 07:28:57 tgl Exp $ * $Id: hash.h,v 1.33 2000/06/13 07:35:17 tgl Exp $
* *
* NOTES * NOTES
* modeled after Margo Seltzer's hash implementation for unix. * modeled after Margo Seltzer's hash implementation for unix.
@ -248,19 +248,15 @@ typedef HashItemData *HashItem;
/* public routines */ /* public routines */
extern void hashbuild(Relation heap, Relation index, int natts, extern Datum hashbuild(PG_FUNCTION_ARGS);
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount, extern Datum hashinsert(PG_FUNCTION_ARGS);
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo); extern Datum hashgettuple(PG_FUNCTION_ARGS);
extern InsertIndexResult hashinsert(Relation rel, Datum *datum, char *nulls, extern Datum hashbeginscan(PG_FUNCTION_ARGS);
ItemPointer ht_ctid, Relation heapRel); extern Datum hashrescan(PG_FUNCTION_ARGS);
extern char *hashgettuple(IndexScanDesc scan, ScanDirection dir); extern Datum hashendscan(PG_FUNCTION_ARGS);
extern char *hashbeginscan(Relation rel, bool fromEnd, uint16 keysz, extern Datum hashmarkpos(PG_FUNCTION_ARGS);
ScanKey scankey); extern Datum hashrestrpos(PG_FUNCTION_ARGS);
extern void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); extern Datum hashdelete(PG_FUNCTION_ARGS);
extern void hashendscan(IndexScanDesc scan);
extern void hashmarkpos(IndexScanDesc scan);
extern void hashrestrpos(IndexScanDesc scan);
extern void hashdelete(Relation rel, ItemPointer tid);
/* /*
* Datatype-specific hash functions in hashfunc.c. * Datatype-specific hash functions in hashfunc.c.

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: nbtree.h,v 1.36 2000/06/08 22:37:38 momjian Exp $ * $Id: nbtree.h,v 1.37 2000/06/13 07:35:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -227,21 +227,16 @@ extern void _bt_pagedel(Relation rel, ItemPointer tid);
*/ */
extern bool BuildingBtree; /* in nbtree.c */ extern bool BuildingBtree; /* in nbtree.c */
extern void btbuild(Relation heap, Relation index, int natts, extern Datum btbuild(PG_FUNCTION_ARGS);
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount, extern Datum btinsert(PG_FUNCTION_ARGS);
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo); extern Datum btgettuple(PG_FUNCTION_ARGS);
extern InsertIndexResult btinsert(Relation rel, Datum *datum, char *nulls, extern Datum btbeginscan(PG_FUNCTION_ARGS);
ItemPointer ht_ctid, Relation heapRel); extern Datum btrescan(PG_FUNCTION_ARGS);
extern char *btgettuple(IndexScanDesc scan, ScanDirection dir);
extern char *btbeginscan(Relation rel, bool fromEnd, uint16 keysz,
ScanKey scankey);
extern void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey);
extern void btmovescan(IndexScanDesc scan, Datum v); extern void btmovescan(IndexScanDesc scan, Datum v);
extern void btendscan(IndexScanDesc scan); extern Datum btendscan(PG_FUNCTION_ARGS);
extern void btmarkpos(IndexScanDesc scan); extern Datum btmarkpos(PG_FUNCTION_ARGS);
extern void btrestrpos(IndexScanDesc scan); extern Datum btrestrpos(PG_FUNCTION_ARGS);
extern void btdelete(Relation rel, ItemPointer tid); extern Datum btdelete(PG_FUNCTION_ARGS);
/* /*
* prototypes for functions in nbtscan.c * prototypes for functions in nbtscan.c

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: rtree.h,v 1.17 2000/01/26 05:57:51 momjian Exp $ * $Id: rtree.h,v 1.18 2000/06/13 07:35:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -104,28 +104,21 @@ typedef RTreeScanOpaqueData *RTreeScanOpaque;
/* defined in rtree.c */ /* defined in rtree.c */
extern void freestack(RTSTACK *s); extern void freestack(RTSTACK *s);
/* rget.c */
extern RetrieveIndexResult rtgettuple(IndexScanDesc s, ScanDirection dir);
/* /*
* RTree code. * RTree code.
* Defined in access/index-rtree/ * Defined in access/index-rtree/
*/ */
extern InsertIndexResult rtinsert(Relation r, Datum *datum, char *nulls, extern Datum rtinsert(PG_FUNCTION_ARGS);
ItemPointer ht_ctid, Relation heapRel); extern Datum rtdelete(PG_FUNCTION_ARGS);
extern char *rtdelete(Relation r, ItemPointer tid);
extern RetrieveIndexResult rtgettuple(IndexScanDesc s, ScanDirection dir); extern Datum rtgettuple(PG_FUNCTION_ARGS);
extern IndexScanDesc rtbeginscan(Relation r, bool fromEnd, uint16 nkeys, extern Datum rtbeginscan(PG_FUNCTION_ARGS);
ScanKey key);
extern void rtendscan(IndexScanDesc s); extern Datum rtendscan(PG_FUNCTION_ARGS);
extern void rtmarkpos(IndexScanDesc s); extern Datum rtmarkpos(PG_FUNCTION_ARGS);
extern void rtrestrpos(IndexScanDesc s); extern Datum rtrestrpos(PG_FUNCTION_ARGS);
extern void rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key); extern Datum rtrescan(PG_FUNCTION_ARGS);
extern void rtbuild(Relation heap, Relation index, int natts, extern Datum rtbuild(PG_FUNCTION_ARGS);
AttrNumber *attnum, IndexStrategy istrat, uint16 pcount,
Datum *params, FuncIndexInfo *finfo, PredInfo *predInfo);
extern void _rtdump(Relation r); extern void _rtdump(Relation r);
/* rtscan.c */ /* rtscan.c */

@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: catversion.h,v 1.30 2000/06/12 22:36:12 momjian Exp $ * $Id: catversion.h,v 1.31 2000/06/13 07:35:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200006121 #define CATALOG_VERSION_NO 200006131
#endif #endif

@ -7,12 +7,12 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_proc.h,v 1.138 2000/06/11 20:07:51 tgl Exp $ * $Id: pg_proc.h,v 1.139 2000/06/13 07:35:19 tgl Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
* information from the DATA() statements. utils/Gen_fmgrtab.sh * information from the DATA() statements. utils/Gen_fmgrtab.sh
* generates fmgr.h and fmgrtab.c the same way. * generates fmgroids.h and fmgrtab.c the same way.
* *
* XXX do NOT break up DATA() statements into multiple lines! * XXX do NOT break up DATA() statements into multiple lines!
* the scripts are not as smart as you might think... * the scripts are not as smart as you might think...
@ -217,7 +217,7 @@ DESCR("btree cost estimator");
/* OIDS 100 - 199 */ /* OIDS 100 - 199 */
DATA(insert OID = 100 ( int8fac PGUID 11 f t t t 1 f 20 "20" 100 0 0 100 int8fac - )); DATA(insert OID = 100 ( int8fac PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8fac - ));
DESCR("factorial"); DESCR("factorial");
DATA(insert OID = 101 ( eqsel PGUID 12 f t f t 5 f 701 "26 26 21 0 23" 100 0 0 100 eqsel - )); DATA(insert OID = 101 ( eqsel PGUID 12 f t f t 5 f 701 "26 26 21 0 23" 100 0 0 100 eqsel - ));
DESCR("restriction selectivity of = and related operators"); DESCR("restriction selectivity of = and related operators");
@ -412,7 +412,7 @@ DATA(insert OID = 197 ( rt_poly_union PGUID 11 f t t t 2 f 604 "604 604" 100
DESCR("r-tree"); DESCR("r-tree");
DATA(insert OID = 198 ( rt_poly_inter PGUID 11 f t t t 2 f 604 "604 604" 100 0 0 100 rt_poly_inter - )); DATA(insert OID = 198 ( rt_poly_inter PGUID 11 f t t t 2 f 604 "604 604" 100 0 0 100 rt_poly_inter - ));
DESCR("r-tree"); DESCR("r-tree");
DATA(insert OID = 199 ( rt_poly_size PGUID 11 f t t t 2 f 23 "604 23" 100 0 0 100 rt_poly_size - )); DATA(insert OID = 199 ( rt_poly_size PGUID 12 f t t t 2 f 23 "604 700" 100 0 0 100 rt_poly_size - ));
DESCR("r-tree"); DESCR("r-tree");
/* OIDS 200 - 299 */ /* OIDS 200 - 299 */
@ -662,51 +662,51 @@ DATA(insert OID = 314 ( int2 PGUID 12 f t t t 1 f 21 "23" 100 0 0 100 i
DESCR("convert int4 to int2"); DESCR("convert int4 to int2");
DATA(insert OID = 315 ( int2vectoreq PGUID 12 f t t t 2 f 16 "22 22" 100 0 0 100 int2vectoreq - )); DATA(insert OID = 315 ( int2vectoreq PGUID 12 f t t t 2 f 16 "22 22" 100 0 0 100 int2vectoreq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 316 ( float8 PGUID 11 f t t t 1 f 701 "23" 100 0 0 100 i4tod - )); DATA(insert OID = 316 ( float8 PGUID 12 f t t t 1 f 701 "23" 100 0 0 100 i4tod - ));
DESCR("convert int4 to float8"); DESCR("convert int4 to float8");
DATA(insert OID = 317 ( int4 PGUID 11 f t t t 1 f 23 "701" 100 0 0 100 dtoi4 - )); DATA(insert OID = 317 ( int4 PGUID 11 f t t t 1 f 23 "701" 100 0 0 100 dtoi4 - ));
DESCR("convert float8 to int4"); DESCR("convert float8 to int4");
DATA(insert OID = 318 ( float4 PGUID 11 f t t t 1 f 700 "23" 100 0 0 100 i4tof - )); DATA(insert OID = 318 ( float4 PGUID 12 f t t t 1 f 700 "23" 100 0 0 100 i4tof - ));
DESCR("convert int4 to float4"); DESCR("convert int4 to float4");
DATA(insert OID = 319 ( int4 PGUID 11 f t t t 1 f 23 "700" 100 0 0 100 ftoi4 - )); DATA(insert OID = 319 ( int4 PGUID 11 f t t t 1 f 23 "700" 100 0 0 100 ftoi4 - ));
DESCR("convert float4 to int4"); DESCR("convert float4 to int4");
DATA(insert OID = 320 ( rtinsert PGUID 11 f t f t 5 f 23 "0" 100 0 0 100 rtinsert - )); DATA(insert OID = 320 ( rtinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 rtinsert - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 321 ( rtdelete PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 rtdelete - )); DATA(insert OID = 321 ( rtdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtdelete - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 322 ( rtgettuple PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 rtgettuple - )); DATA(insert OID = 322 ( rtgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 rtgettuple - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 323 ( rtbuild PGUID 11 f t f t 9 f 23 "0" 100 0 0 100 rtbuild - )); DATA(insert OID = 323 ( rtbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 rtbuild - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 324 ( rtbeginscan PGUID 11 f t f t 4 f 23 "0" 100 0 0 100 rtbeginscan - )); DATA(insert OID = 324 ( rtbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 rtbeginscan - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 325 ( rtendscan PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - )); DATA(insert OID = 325 ( rtendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtendscan - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 326 ( rtmarkpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - )); DATA(insert OID = 326 ( rtmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtmarkpos - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 327 ( rtrestrpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - )); DATA(insert OID = 327 ( rtrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 rtrestrpos - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 328 ( rtrescan PGUID 11 f t f t 3 f 23 "0" 100 0 0 100 rtrescan - )); DATA(insert OID = 328 ( rtrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 rtrescan - ));
DESCR("r-tree(internal)"); DESCR("r-tree(internal)");
DATA(insert OID = 330 ( btgettuple PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 btgettuple - )); DATA(insert OID = 330 ( btgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 btgettuple - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 331 ( btinsert PGUID 11 f t f t 5 f 23 "0" 100 0 0 100 btinsert - )); DATA(insert OID = 331 ( btinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 btinsert - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 332 ( btdelete PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 btdelete - )); DATA(insert OID = 332 ( btdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 btdelete - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 333 ( btbeginscan PGUID 11 f t f t 4 f 23 "0" 100 0 0 100 btbeginscan - )); DATA(insert OID = 333 ( btbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 btbeginscan - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 334 ( btrescan PGUID 11 f t f t 3 f 23 "0" 100 0 0 100 btrescan - )); DATA(insert OID = 334 ( btrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 btrescan - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 335 ( btendscan PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 btendscan - )); DATA(insert OID = 335 ( btendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btendscan - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 336 ( btmarkpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - )); DATA(insert OID = 336 ( btmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btmarkpos - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 337 ( btrestrpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - )); DATA(insert OID = 337 ( btrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 btrestrpos - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 338 ( btbuild PGUID 11 f t f t 9 f 23 "0" 100 0 0 100 btbuild - )); DATA(insert OID = 338 ( btbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 btbuild - ));
DESCR("btree(internal)"); DESCR("btree(internal)");
DATA(insert OID = 339 ( poly_same PGUID 11 f t t t 2 f 16 "604 604" 100 0 1 0 poly_same - )); DATA(insert OID = 339 ( poly_same PGUID 11 f t t t 2 f 16 "604 604" 100 0 1 0 poly_same - ));
@ -798,23 +798,23 @@ DESCR("convert char() to name");
DATA(insert OID = 438 ( hashcostestimate PGUID 12 f t f t 7 f 0 "0 0 0 0 0 0 0" 100 0 0 100 hashcostestimate - )); DATA(insert OID = 438 ( hashcostestimate PGUID 12 f t f t 7 f 0 "0 0 0 0 0 0 0" 100 0 0 100 hashcostestimate - ));
DESCR("hash index cost estimator"); DESCR("hash index cost estimator");
DATA(insert OID = 440 ( hashgettuple PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 hashgettuple - )); DATA(insert OID = 440 ( hashgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 hashgettuple - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 441 ( hashinsert PGUID 11 f t f t 5 f 23 "0" 100 0 0 100 hashinsert - )); DATA(insert OID = 441 ( hashinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 hashinsert - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 442 ( hashdelete PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 hashdelete - )); DATA(insert OID = 442 ( hashdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 hashdelete - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 443 ( hashbeginscan PGUID 11 f t f t 4 f 23 "0" 100 0 0 100 hashbeginscan - )); DATA(insert OID = 443 ( hashbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 hashbeginscan - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 444 ( hashrescan PGUID 11 f t f t 3 f 23 "0" 100 0 0 100 hashrescan - )); DATA(insert OID = 444 ( hashrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 hashrescan - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 445 ( hashendscan PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - )); DATA(insert OID = 445 ( hashendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashendscan - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 446 ( hashmarkpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - )); DATA(insert OID = 446 ( hashmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashmarkpos - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 447 ( hashrestrpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - )); DATA(insert OID = 447 ( hashrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 hashrestrpos - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 448 ( hashbuild PGUID 11 f t f t 9 f 23 "0" 100 0 0 100 hashbuild - )); DATA(insert OID = 448 ( hashbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 hashbuild - ));
DESCR("hash(internal)"); DESCR("hash(internal)");
DATA(insert OID = 449 ( hashint2 PGUID 12 f t t t 1 f 23 "21" 100 0 0 100 hashint2 - )); DATA(insert OID = 449 ( hashint2 PGUID 12 f t t t 1 f 23 "21" 100 0 0 100 hashint2 - ));
DESCR("hash"); DESCR("hash");
@ -841,53 +841,53 @@ DESCR("larger of two");
DATA(insert OID = 459 ( text_smaller PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - )); DATA(insert OID = 459 ( text_smaller PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 text_smaller - ));
DESCR("smaller of two"); DESCR("smaller of two");
DATA(insert OID = 460 ( int8in PGUID 11 f t t t 1 f 20 "0" 100 0 0 100 int8in - )); DATA(insert OID = 460 ( int8in PGUID 12 f t t t 1 f 20 "0" 100 0 0 100 int8in - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 461 ( int8out PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 int8out - )); DATA(insert OID = 461 ( int8out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int8out - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 462 ( int8um PGUID 11 f t t t 1 f 20 "20" 100 0 0 100 int8um - )); DATA(insert OID = 462 ( int8um PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8um - ));
DESCR("negate"); DESCR("negate");
DATA(insert OID = 463 ( int8pl PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - )); DATA(insert OID = 463 ( int8pl PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8pl - ));
DESCR("addition"); DESCR("addition");
DATA(insert OID = 464 ( int8mi PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - )); DATA(insert OID = 464 ( int8mi PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mi - ));
DESCR("subtraction"); DESCR("subtraction");
DATA(insert OID = 465 ( int8mul PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - )); DATA(insert OID = 465 ( int8mul PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mul - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 466 ( int8div PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - )); DATA(insert OID = 466 ( int8div PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8div - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 467 ( int8eq PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - )); DATA(insert OID = 467 ( int8eq PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8eq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 468 ( int8ne PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - )); DATA(insert OID = 468 ( int8ne PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ne - ));
DESCR("not equal"); DESCR("not equal");
DATA(insert OID = 469 ( int8lt PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - )); DATA(insert OID = 469 ( int8lt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8lt - ));
DESCR("less-than"); DESCR("less-than");
DATA(insert OID = 470 ( int8gt PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - )); DATA(insert OID = 470 ( int8gt PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8gt - ));
DESCR("greater-than"); DESCR("greater-than");
DATA(insert OID = 471 ( int8le PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - )); DATA(insert OID = 471 ( int8le PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8le - ));
DESCR("less-than-or-equal"); DESCR("less-than-or-equal");
DATA(insert OID = 472 ( int8ge PGUID 11 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - )); DATA(insert OID = 472 ( int8ge PGUID 12 f t t t 2 f 16 "20 20" 100 0 0 100 int8ge - ));
DESCR("greater-than-or-equal"); DESCR("greater-than-or-equal");
DATA(insert OID = 474 ( int84eq PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - )); DATA(insert OID = 474 ( int84eq PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84eq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 475 ( int84ne PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - )); DATA(insert OID = 475 ( int84ne PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ne - ));
DESCR("not equal"); DESCR("not equal");
DATA(insert OID = 476 ( int84lt PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - )); DATA(insert OID = 476 ( int84lt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84lt - ));
DESCR("less-than"); DESCR("less-than");
DATA(insert OID = 477 ( int84gt PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - )); DATA(insert OID = 477 ( int84gt PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84gt - ));
DESCR("greater-than"); DESCR("greater-than");
DATA(insert OID = 478 ( int84le PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - )); DATA(insert OID = 478 ( int84le PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84le - ));
DESCR("less-than-or-equal"); DESCR("less-than-or-equal");
DATA(insert OID = 479 ( int84ge PGUID 11 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - )); DATA(insert OID = 479 ( int84ge PGUID 12 f t t t 2 f 16 "20 23" 100 0 0 100 int84ge - ));
DESCR("greater-than-or-equal"); DESCR("greater-than-or-equal");
DATA(insert OID = 480 ( int4 PGUID 11 f t t t 1 f 23 "20" 100 0 0 100 int84 - )); DATA(insert OID = 480 ( int4 PGUID 12 f t t t 1 f 23 "20" 100 0 0 100 int84 - ));
DESCR("convert int8 to int4"); DESCR("convert int8 to int4");
DATA(insert OID = 481 ( int8 PGUID 11 f t t t 1 f 20 "23" 100 0 0 100 int48 - )); DATA(insert OID = 481 ( int8 PGUID 12 f t t t 1 f 20 "23" 100 0 0 100 int48 - ));
DESCR("convert int4 to int8"); DESCR("convert int4 to int8");
DATA(insert OID = 482 ( float8 PGUID 11 f t t t 1 f 701 "20" 100 0 0 100 i8tod - )); DATA(insert OID = 482 ( float8 PGUID 12 f t t t 1 f 701 "20" 100 0 0 100 i8tod - ));
DESCR("convert int8 to float8"); DESCR("convert int8 to float8");
DATA(insert OID = 483 ( int8 PGUID 11 f t t t 1 f 20 "701" 100 0 0 100 dtoi8 - )); DATA(insert OID = 483 ( int8 PGUID 12 f t t t 1 f 20 "701" 100 0 0 100 dtoi8 - ));
DESCR("convert float8 to int8"); DESCR("convert float8 to int8");
/* OIDS 500 - 599 */ /* OIDS 500 - 599 */
@ -913,10 +913,10 @@ DESCR("greater-than-or-equal");
DATA(insert OID = 659 ( namene PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namene - )); DATA(insert OID = 659 ( namene PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namene - ));
DESCR("not equal"); DESCR("not equal");
DATA(insert OID = 668 ( bpchar PGUID 11 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - )); DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - ));
DESCR("truncate char()"); DESCR("adjust char() to typmod length");
DATA(insert OID = 669 ( varchar PGUID 11 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - )); DATA(insert OID = 669 ( varchar PGUID 12 f t t t 2 f 1043 "1043 23" 100 0 0 100 varchar - ));
DESCR("truncate varchar()"); DESCR("adjust varchar() to typmod length");
DATA(insert OID = 676 ( mktinterval PGUID 12 f t f t 2 f 704 "702 702" 100 0 0 100 mktinterval - )); DATA(insert OID = 676 ( mktinterval PGUID 12 f t f t 2 f 704 "702 702" 100 0 0 100 mktinterval - ));
DESCR("convert to tinterval"); DESCR("convert to tinterval");
@ -949,13 +949,13 @@ DESCR("equal");
DATA(insert OID = 720 ( octet_length PGUID 11 f t t t 1 f 23 "17" 100 0 0 100 byteaoctetlen - )); DATA(insert OID = 720 ( octet_length PGUID 11 f t t t 1 f 23 "17" 100 0 0 100 byteaoctetlen - ));
DESCR(""); DESCR("");
DATA(insert OID = 721 ( get_byte PGUID 11 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - )); DATA(insert OID = 721 ( get_byte PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetByte - ));
DESCR(""); DESCR("");
DATA(insert OID = 722 ( set_byte PGUID 11 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetByte - )); DATA(insert OID = 722 ( set_byte PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetByte - ));
DESCR(""); DESCR("");
DATA(insert OID = 723 ( get_bit PGUID 11 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - )); DATA(insert OID = 723 ( get_bit PGUID 12 f t t t 2 f 23 "17 23" 100 0 0 100 byteaGetBit - ));
DESCR(""); DESCR("");
DATA(insert OID = 724 ( set_bit PGUID 11 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetBit - )); DATA(insert OID = 724 ( set_bit PGUID 12 f t t t 3 f 17 "17 23 23" 100 0 0 100 byteaSetBit - ));
DESCR(""); DESCR("");
DATA(insert OID = 725 ( dist_pl PGUID 11 f t t t 2 f 701 "600 628" 100 0 0 100 dist_pl - )); DATA(insert OID = 725 ( dist_pl PGUID 11 f t t t 2 f 701 "600 628" 100 0 0 100 dist_pl - ));
@ -981,26 +981,18 @@ DESCR("greater-than");
DATA(insert OID = 743 ( text_ge PGUID 11 f t t t 2 f 16 "25 25" 100 0 0 0 text_ge - )); DATA(insert OID = 743 ( text_ge PGUID 11 f t t t 2 f 16 "25 25" 100 0 0 0 text_ge - ));
DESCR("greater-than-or-equal"); DESCR("greater-than-or-equal");
DATA(insert OID = 744 ( array_eq PGUID 11 f t t t 2 f 16 "0 0" 100 0 0 100 array_eq -)); DATA(insert OID = 744 ( array_eq PGUID 12 f t t t 2 f 16 "0 0" 100 0 0 100 array_eq -));
DESCR("equal"); DESCR("array equal");
DATA(insert OID = 745 ( array_assgn PGUID 11 f t t t 8 f 23 "0 23 0 0 0 23 23 0" 100 0 0 100 array_assgn -)); DATA(insert OID = 747 ( array_dims PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 array_dims -));
DESCR("array dimensions");
DATA(insert OID = 750 ( array_in PGUID 12 f t t t 3 f 23 "0 26 23" 100 0 0 100 array_in - ));
DESCR("array"); DESCR("array");
DATA(insert OID = 746 ( array_clip PGUID 11 f t t t 7 f 23 "0 23 0 0 23 23 0" 100 0 0 100 array_clip -)); DATA(insert OID = 751 ( array_out PGUID 12 f t t t 2 f 23 "0 26" 100 0 0 100 array_out - ));
DESCR("array");
DATA(insert OID = 747 ( array_dims PGUID 11 f t t t 1 f 25 "0" 100 0 0 100 array_dims -));
DESCR("array(internal)");
DATA(insert OID = 748 ( array_set PGUID 11 f t t t 8 f 23 "0 23 0 0 23 23 23 0" 100 0 0 100 array_set -));
DESCR("array");
DATA(insert OID = 749 ( array_ref PGUID 11 f t t t 7 f 23 "0 23 0 23 23 23 0" 100 0 0 100 array_ref -));
DESCR("array");
DATA(insert OID = 750 ( array_in PGUID 11 f t t t 3 f 23 "0 0 23" 100 0 0 100 array_in - ));
DESCR("array");
DATA(insert OID = 751 ( array_out PGUID 11 f t t t 2 f 23 "0 0" 100 0 0 100 array_out - ));
DESCR("array"); DESCR("array");
DATA(insert OID = 752 ( filename_in PGUID 11 f t t t 1 f 605 "0" 100 0 0 100 filename_in - )); DATA(insert OID = 752 ( filename_in PGUID 11 f t t t 1 f 605 "0" 100 0 0 100 filename_in - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 753 ( filename_out PGUID 11 f t t t 2 f 23 "0 0" 100 0 0 100 filename_out - )); DATA(insert OID = 753 ( filename_out PGUID 11 f t t t 2 f 23 "0 26" 100 0 0 100 filename_out - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 760 ( smgrin PGUID 12 f t f t 1 f 210 "0" 100 0 0 100 smgrin - )); DATA(insert OID = 760 ( smgrin PGUID 12 f t f t 1 f 210 "0" 100 0 0 100 smgrin - ));
@ -1032,23 +1024,23 @@ DESCR("smaller of two");
DATA(insert OID = 772 ( gistcostestimate PGUID 12 f t f t 7 f 0 "0 0 0 0 0 0 0" 100 0 0 100 gistcostestimate - )); DATA(insert OID = 772 ( gistcostestimate PGUID 12 f t f t 7 f 0 "0 0 0 0 0 0 0" 100 0 0 100 gistcostestimate - ));
DESCR("gist cost estimator"); DESCR("gist cost estimator");
DATA(insert OID = 774 ( gistgettuple PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 gistgettuple - )); DATA(insert OID = 774 ( gistgettuple PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 gistgettuple - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 775 ( gistinsert PGUID 11 f t f t 5 f 23 "0" 100 0 0 100 gistinsert - )); DATA(insert OID = 775 ( gistinsert PGUID 12 f t f t 5 f 23 "0 0 0 0 0" 100 0 0 100 gistinsert - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 776 ( gistdelete PGUID 11 f t f t 2 f 23 "0" 100 0 0 100 gistdelete - )); DATA(insert OID = 776 ( gistdelete PGUID 12 f t f t 2 f 23 "0 0" 100 0 0 100 gistdelete - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 777 ( gistbeginscan PGUID 11 f t f t 4 f 23 "0" 100 0 0 100 gistbeginscan - )); DATA(insert OID = 777 ( gistbeginscan PGUID 12 f t f t 4 f 23 "0 0 0 0" 100 0 0 100 gistbeginscan - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 778 ( gistrescan PGUID 11 f t f t 3 f 23 "0" 100 0 0 100 gistrescan - )); DATA(insert OID = 778 ( gistrescan PGUID 12 f t f t 3 f 23 "0 0 0" 100 0 0 100 gistrescan - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 779 ( gistendscan PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - )); DATA(insert OID = 779 ( gistendscan PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistendscan - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 780 ( gistmarkpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - )); DATA(insert OID = 780 ( gistmarkpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistmarkpos - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 781 ( gistrestrpos PGUID 11 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - )); DATA(insert OID = 781 ( gistrestrpos PGUID 12 f t f t 1 f 23 "0" 100 0 0 100 gistrestrpos - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 782 ( gistbuild PGUID 11 f t f t 9 f 23 "0" 100 0 0 100 gistbuild - )); DATA(insert OID = 782 ( gistbuild PGUID 12 f t f t 9 f 23 "0 0 0 0 0 0 0 0 0" 100 0 0 100 gistbuild - ));
DESCR("gist(internal)"); DESCR("gist(internal)");
DATA(insert OID = 784 ( tintervaleq PGUID 12 f t f t 2 f 16 "704 704" 100 0 0 100 tintervaleq - )); DATA(insert OID = 784 ( tintervaleq PGUID 12 f t f t 2 f 16 "704 704" 100 0 0 100 tintervaleq - ));
@ -1096,17 +1088,17 @@ DESCR("matches LIKE expression");
DATA(insert OID = 851 ( textnlike PGUID 11 f t t t 2 f 16 "25 25" 100 0 1 0 textnlike - )); DATA(insert OID = 851 ( textnlike PGUID 11 f t t t 2 f 16 "25 25" 100 0 1 0 textnlike - ));
DESCR("does not match LIKE expression"); DESCR("does not match LIKE expression");
DATA(insert OID = 852 ( int48eq PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - )); DATA(insert OID = 852 ( int48eq PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48eq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 853 ( int48ne PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - )); DATA(insert OID = 853 ( int48ne PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ne - ));
DESCR("not equal"); DESCR("not equal");
DATA(insert OID = 854 ( int48lt PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - )); DATA(insert OID = 854 ( int48lt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48lt - ));
DESCR("less-than"); DESCR("less-than");
DATA(insert OID = 855 ( int48gt PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - )); DATA(insert OID = 855 ( int48gt PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48gt - ));
DESCR("greater-than"); DESCR("greater-than");
DATA(insert OID = 856 ( int48le PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - )); DATA(insert OID = 856 ( int48le PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48le - ));
DESCR("less-than-or-equal"); DESCR("less-than-or-equal");
DATA(insert OID = 857 ( int48ge PGUID 11 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - )); DATA(insert OID = 857 ( int48ge PGUID 12 f t t t 2 f 16 "23 20" 100 0 0 100 int48ge - ));
DESCR("greater-than-or-equal"); DESCR("greater-than-or-equal");
DATA(insert OID = 858 ( namelike PGUID 11 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - )); DATA(insert OID = 858 ( namelike PGUID 11 f t t t 2 f 16 "19 25" 100 0 0 100 namelike - ));
@ -1119,13 +1111,13 @@ DESCR("convert char to char()");
DATA(insert OID = 861 ( char PGUID 12 f t t t 1 f 18 "1042" 100 0 0 100 bpchar_char - )); DATA(insert OID = 861 ( char PGUID 12 f t t t 1 f 18 "1042" 100 0 0 100 bpchar_char - ));
DESCR("convert char() to char"); DESCR("convert char() to char");
DATA(insert OID = 862 ( int4_mul_cash PGUID 11 f t t t 2 f 790 "23 790" 100 0 0 100 int4_mul_cash - )); DATA(insert OID = 862 ( int4_mul_cash PGUID 12 f t t t 2 f 790 "23 790" 100 0 0 100 int4_mul_cash - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 863 ( int2_mul_cash PGUID 12 f t t t 2 f 790 "21 790" 100 0 0 100 int2_mul_cash - )); DATA(insert OID = 863 ( int2_mul_cash PGUID 12 f t t t 2 f 790 "21 790" 100 0 0 100 int2_mul_cash - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 864 ( cash_mul_int4 PGUID 11 f t t t 2 f 790 "790 23" 100 0 0 100 cash_mul_int4 - )); DATA(insert OID = 864 ( cash_mul_int4 PGUID 12 f t t t 2 f 790 "790 23" 100 0 0 100 cash_mul_int4 - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 865 ( cash_div_int4 PGUID 11 f t t t 2 f 790 "790 23" 100 0 0 100 cash_div_int4 - )); DATA(insert OID = 865 ( cash_div_int4 PGUID 12 f t t t 2 f 790 "790 23" 100 0 0 100 cash_div_int4 - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 866 ( cash_mul_int2 PGUID 12 f t t t 2 f 790 "790 21" 100 0 0 100 cash_mul_int2 - )); DATA(insert OID = 866 ( cash_mul_int2 PGUID 12 f t t t 2 f 790 "790 21" 100 0 0 100 cash_mul_int2 - ));
DESCR("multiply"); DESCR("multiply");
@ -1187,9 +1179,9 @@ DESCR("modulus");
DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - )); DATA(insert OID = 943 ( mod PGUID 12 f t t t 2 f 23 "23 21" 100 0 0 100 int42mod - ));
DESCR("modulus"); DESCR("modulus");
DATA(insert OID = 945 ( int8mod PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); DATA(insert OID = 945 ( int8mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
DESCR("modulus"); DESCR("modulus");
DATA(insert OID = 947 ( mod PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - )); DATA(insert OID = 947 ( mod PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8mod - ));
DESCR("modulus"); DESCR("modulus");
DATA(insert OID = 944 ( char PGUID 12 f t t t 1 f 18 "25" 100 0 0 100 text_char - )); DATA(insert OID = 944 ( char PGUID 12 f t t t 1 f 18 "25" 100 0 0 100 text_char - ));
@ -1304,13 +1296,13 @@ DATA(insert OID = 1037 ( aclcontains PGUID 11 f t f t 2 f 16 "1034 1033" 100
DESCR("matches regex., case-sensitive"); DESCR("matches regex., case-sensitive");
DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 f 23 "26" 100 0 0 100 seteval - )); DATA(insert OID = 1038 ( seteval PGUID 12 f t f t 1 f 23 "26" 100 0 0 100 seteval - ));
DESCR(""); DESCR("");
DATA(insert OID = 1044 ( bpcharin PGUID 11 f t t t 3 f 1042 "0 0 23" 100 0 0 100 bpcharin - )); DATA(insert OID = 1044 ( bpcharin PGUID 12 f t t t 3 f 1042 "0 26 23" 100 0 0 100 bpcharin - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1045 ( bpcharout PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - )); DATA(insert OID = 1045 ( bpcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 bpcharout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1046 ( varcharin PGUID 11 f t t t 3 f 1043 "0 0 23" 100 0 0 100 varcharin - )); DATA(insert OID = 1046 ( varcharin PGUID 12 f t t t 3 f 1043 "0 26 23" 100 0 0 100 varcharin - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1047 ( varcharout PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 varcharout - )); DATA(insert OID = 1047 ( varcharout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 varcharout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1048 ( bpchareq PGUID 11 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - )); DATA(insert OID = 1048 ( bpchareq PGUID 11 f t t t 2 f 16 "1042 1042" 100 0 0 100 bpchareq - ));
DESCR("equal"); DESCR("equal");
@ -1500,12 +1492,12 @@ DESCR("truncate timestamp to specified units");
DATA(insert OID = 1218 ( date_trunc PGUID 12 f t f t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - )); DATA(insert OID = 1218 ( date_trunc PGUID 12 f t f t 2 f 1186 "25 1186" 100 0 0 100 interval_trunc - ));
DESCR("truncate interval to specified units"); DESCR("truncate interval to specified units");
DATA(insert OID = 1230 ( int8abs PGUID 11 f t t t 1 f 20 "20" 100 0 0 100 int8abs - )); DATA(insert OID = 1230 ( int8abs PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1236 ( int8larger PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - )); DATA(insert OID = 1236 ( int8larger PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8larger - ));
DESCR("larger of two"); DESCR("larger of two");
DATA(insert OID = 1237 ( int8smaller PGUID 11 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - )); DATA(insert OID = 1237 ( int8smaller PGUID 12 f t t t 2 f 20 "20 20" 100 0 0 100 int8smaller - ));
DESCR("smaller of two"); DESCR("smaller of two");
DATA(insert OID = 1238 ( texticregexeq PGUID 11 f t t t 2 f 16 "25 25" 100 0 1 0 texticregexeq - )); DATA(insert OID = 1238 ( texticregexeq PGUID 11 f t t t 2 f 16 "25 25" 100 0 1 0 texticregexeq - ));
@ -1530,32 +1522,32 @@ DESCR("SQL92 interval comparison");
DATA(insert OID = 1272 ( datetime_pl PGUID 12 f t f t 2 f 1184 "1082 1083" 100 0 0 100 datetime_timestamp - )); DATA(insert OID = 1272 ( datetime_pl PGUID 12 f t f t 2 f 1184 "1082 1083" 100 0 0 100 datetime_timestamp - ));
DESCR("convert date and time to timestamp"); DESCR("convert date and time to timestamp");
DATA(insert OID = 1274 ( int84pl PGUID 11 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - )); DATA(insert OID = 1274 ( int84pl PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84pl - ));
DESCR("addition"); DESCR("addition");
DATA(insert OID = 1275 ( int84mi PGUID 11 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - )); DATA(insert OID = 1275 ( int84mi PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mi - ));
DESCR("subtraction"); DESCR("subtraction");
DATA(insert OID = 1276 ( int84mul PGUID 11 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - )); DATA(insert OID = 1276 ( int84mul PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84mul - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 1277 ( int84div PGUID 11 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - )); DATA(insert OID = 1277 ( int84div PGUID 12 f t t t 2 f 20 "20 23" 100 0 0 100 int84div - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 1278 ( int48pl PGUID 11 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - )); DATA(insert OID = 1278 ( int48pl PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48pl - ));
DESCR("addition"); DESCR("addition");
DATA(insert OID = 1279 ( int48mi PGUID 11 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - )); DATA(insert OID = 1279 ( int48mi PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mi - ));
DESCR("subtraction"); DESCR("subtraction");
DATA(insert OID = 1280 ( int48mul PGUID 11 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - )); DATA(insert OID = 1280 ( int48mul PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48mul - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 1281 ( int48div PGUID 11 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - )); DATA(insert OID = 1281 ( int48div PGUID 12 f t t t 2 f 20 "23 20" 100 0 0 100 int48div - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 1288 ( text PGUID 11 f t t t 1 f 25 "20" 100 0 0 100 int8_text - )); DATA(insert OID = 1288 ( text PGUID 12 f t t t 1 f 25 "20" 100 0 0 100 int8_text - ));
DESCR("convert int8 to text"); DESCR("convert int8 to text");
DATA(insert OID = 1289 ( int8 PGUID 11 f t t t 1 f 20 "25" 100 0 0 100 text_int8 - )); DATA(insert OID = 1289 ( int8 PGUID 12 f t t t 1 f 20 "25" 100 0 0 100 text_int8 - ));
DESCR("convert text to int8"); DESCR("convert text to int8");
DATA(insert OID = 1290 ( _bpchar PGUID 11 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - )); DATA(insert OID = 1290 ( _bpchar PGUID 12 f t t t 2 f 1014 "1014 23" 100 0 0 100 _bpchar - ));
DESCR("truncate _char()"); DESCR("adjust char()[] to typmod length");
DATA(insert OID = 1291 ( _varchar PGUID 11 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - )); DATA(insert OID = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _varchar - ));
DESCR("truncate _varchar()"); DESCR("adjust varchar()[] to typmod length");
DATA(insert OID = 1292 ( tideq PGUID 11 f t f t 2 f 16 "27 27" 100 0 0 100 tideq - )); DATA(insert OID = 1292 ( tideq PGUID 11 f t f t 2 f 16 "27 27" 100 0 0 100 tideq - ));
DESCR("equal"); DESCR("equal");
@ -1731,13 +1723,13 @@ DATA(insert OID = 1391 ( factorial PGUID 12 f t t t 1 f 23 "21" 100 0 0 100
DESCR("factorial"); DESCR("factorial");
DATA(insert OID = 1392 ( factorial PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4fac - )); DATA(insert OID = 1392 ( factorial PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4fac - ));
DESCR("factorial"); DESCR("factorial");
DATA(insert OID = 1393 ( factorial PGUID 11 f t t t 1 f 20 "20" 100 0 0 100 int8fac - )); DATA(insert OID = 1393 ( factorial PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8fac - ));
DESCR("factorial"); DESCR("factorial");
DATA(insert OID = 1394 ( abs PGUID 11 f t t t 1 f 700 "700" 100 0 0 100 float4abs - )); DATA(insert OID = 1394 ( abs PGUID 11 f t t t 1 f 700 "700" 100 0 0 100 float4abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1395 ( abs PGUID 11 f t t t 1 f 701 "701" 100 0 0 100 float8abs - )); DATA(insert OID = 1395 ( abs PGUID 11 f t t t 1 f 701 "701" 100 0 0 100 float8abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1396 ( abs PGUID 11 f t t t 1 f 20 "20" 100 0 0 100 int8abs - )); DATA(insert OID = 1396 ( abs PGUID 12 f t t t 1 f 20 "20" 100 0 0 100 int8abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1397 ( abs PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4abs - )); DATA(insert OID = 1397 ( abs PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 int4abs - ));
DESCR("absolute value"); DESCR("absolute value");
@ -1903,7 +1895,7 @@ DATA(insert OID = 1473 ( circle PGUID 11 f t t t 2 f 718 "600 701" 100 0 1 0
DESCR("convert point and radius to circle"); DESCR("convert point and radius to circle");
DATA(insert OID = 1474 ( circle PGUID 11 f t t t 1 f 718 "604" 100 0 1 0 poly_circle - )); DATA(insert OID = 1474 ( circle PGUID 11 f t t t 1 f 718 "604" 100 0 1 0 poly_circle - ));
DESCR("convert polygon to circle"); DESCR("convert polygon to circle");
DATA(insert OID = 1475 ( polygon PGUID 11 f t t t 2 f 604 "23 718" 100 0 1 0 circle_poly - )); DATA(insert OID = 1475 ( polygon PGUID 12 f t t t 2 f 604 "23 718" 100 0 1 0 circle_poly - ));
DESCR("convert vertex count and circle to polygon"); DESCR("convert vertex count and circle to polygon");
DATA(insert OID = 1476 ( dist_pc PGUID 11 f t t t 2 f 701 "600 718" 100 0 1 0 dist_pc - )); DATA(insert OID = 1476 ( dist_pc PGUID 11 f t t t 2 f 701 "600 718" 100 0 1 0 dist_pc - ));
DESCR("distance between point and circle"); DESCR("distance between point and circle");
@ -2067,12 +2059,12 @@ DESCR("convert int4 to varchar");
DATA(insert OID = 1620 ( ascii PGUID 11 f t t t 1 f 23 "25" 100 0 0 100 ascii - )); DATA(insert OID = 1620 ( ascii PGUID 11 f t t t 1 f 23 "25" 100 0 0 100 ascii - ));
DESCR("convert first char to int4"); DESCR("convert first char to int4");
DATA(insert OID = 1621 ( ichar PGUID 11 f t t t 1 f 25 "23" 100 0 0 100 ichar - )); DATA(insert OID = 1621 ( ichar PGUID 12 f t t t 1 f 25 "23" 100 0 0 100 ichar - ));
DESCR("convert int4 to char"); DESCR("convert int4 to char");
DATA(insert OID = 1622 ( repeat PGUID 11 f t t t 2 f 25 "25 23" 100 0 0 100 repeat - )); DATA(insert OID = 1622 ( repeat PGUID 12 f t t t 2 f 25 "25 23" 100 0 0 100 repeat - ));
DESCR("replicate string int4 times"); DESCR("replicate string int4 times");
DATA(insert OID = 1623 ( varchar PGUID 11 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - )); DATA(insert OID = 1623 ( varchar PGUID 12 f t t t 1 f 1043 "20" 100 0 0 100 int8_text - ));
DESCR("convert int8 to varchar"); DESCR("convert int8 to varchar");
DATA(insert OID = 1624 ( mul_d_interval PGUID 12 f t t t 2 f 1186 "701 1186" 100 0 0 100 mul_d_interval - )); DATA(insert OID = 1624 ( mul_d_interval PGUID 12 f t t t 2 f 1186 "701 1186" 100 0 0 100 mul_d_interval - ));
@ -2120,15 +2112,15 @@ DATA(insert OID = 871 ( upper PGUID 11 f t t t 1 f 25 "25" 100 0 0 100 up
DESCR("uppercase"); DESCR("uppercase");
DATA(insert OID = 872 ( initcap PGUID 11 f t t t 1 f 25 "25" 100 0 0 100 initcap - )); DATA(insert OID = 872 ( initcap PGUID 11 f t t t 1 f 25 "25" 100 0 0 100 initcap - ));
DESCR("capitalize each word"); DESCR("capitalize each word");
DATA(insert OID = 873 ( lpad PGUID 11 f t t t 3 f 25 "25 23 25" 100 0 0 100 lpad - )); DATA(insert OID = 873 ( lpad PGUID 12 f t t t 3 f 25 "25 23 25" 100 0 0 100 lpad - ));
DESCR("left-pad string to length"); DESCR("left-pad string to length");
DATA(insert OID = 874 ( rpad PGUID 11 f t t t 3 f 25 "25 23 25" 100 0 0 100 rpad - )); DATA(insert OID = 874 ( rpad PGUID 12 f t t t 3 f 25 "25 23 25" 100 0 0 100 rpad - ));
DESCR("right-pad string to length"); DESCR("right-pad string to length");
DATA(insert OID = 875 ( ltrim PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - )); DATA(insert OID = 875 ( ltrim PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 ltrim - ));
DESCR("left-pad string to length"); DESCR("left-pad string to length");
DATA(insert OID = 876 ( rtrim PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - )); DATA(insert OID = 876 ( rtrim PGUID 11 f t t t 2 f 25 "25 25" 100 0 0 100 rtrim - ));
DESCR("right-pad string to length"); DESCR("right-pad string to length");
DATA(insert OID = 877 ( substr PGUID 11 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - )); DATA(insert OID = 877 ( substr PGUID 12 f t t t 3 f 25 "25 23 23" 100 0 0 100 text_substr - ));
DESCR("return portion of string"); DESCR("return portion of string");
DATA(insert OID = 878 ( translate PGUID 11 f t t t 3 f 25 "25 25 25" 100 0 0 100 translate - )); DATA(insert OID = 878 ( translate PGUID 11 f t t t 3 f 25 "25 25 25" 100 0 0 100 translate - ));
DESCR("modify string by substring replacement"); DESCR("modify string by substring replacement");
@ -2148,13 +2140,13 @@ DATA(insert OID = 885 ( btrim PGUID 14 f t t t 1 f 25 "25" 100 0 0 100 "s
DESCR("trim both ends of string"); DESCR("trim both ends of string");
/* for multi-byte support */ /* for multi-byte support */
DATA(insert OID = 1039 ( getdatabaseencoding PGUID 11 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - )); DATA(insert OID = 1039 ( getdatabaseencoding PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getdatabaseencoding - ));
DESCR("encoding name of current database"); DESCR("encoding name of current database");
DATA(insert OID = 1295 ( pg_char_to_encoding PGUID 11 f t f t 1 f 23 "19" 100 0 0 100 pg_char_to_encoding - )); DATA(insert OID = 1295 ( pg_char_to_encoding PGUID 12 f t f t 1 f 23 "19" 100 0 0 100 PG_char_to_encoding - ));
DESCR("convert encoding name to encoding id"); DESCR("convert encoding name to encoding id");
DATA(insert OID = 1597 ( pg_encoding_to_char PGUID 11 f t f t 1 f 19 "23" 100 0 0 100 pg_encoding_to_char - )); DATA(insert OID = 1597 ( pg_encoding_to_char PGUID 12 f t f t 1 f 19 "23" 100 0 0 100 PG_encoding_to_char - ));
DESCR("convert encoding id to encoding name"); DESCR("convert encoding id to encoding name");
/* System-view support functions */ /* System-view support functions */
@ -2162,7 +2154,7 @@ DATA(insert OID = 1640 ( pg_get_ruledef PGUID 11 f t f t 1 f 25 "19" 100 0 0
DESCR("source text of a rule"); DESCR("source text of a rule");
DATA(insert OID = 1641 ( pg_get_viewdef PGUID 11 f t f t 1 f 25 "19" 100 0 0 100 pg_get_viewdef - )); DATA(insert OID = 1641 ( pg_get_viewdef PGUID 11 f t f t 1 f 25 "19" 100 0 0 100 pg_get_viewdef - ));
DESCR("select statement of a view"); DESCR("select statement of a view");
DATA(insert OID = 1642 ( pg_get_userbyid PGUID 11 f t f t 1 f 19 "23" 100 0 0 100 pg_get_userbyid - )); DATA(insert OID = 1642 ( pg_get_userbyid PGUID 12 f t f t 1 f 19 "23" 100 0 0 100 pg_get_userbyid - ));
DESCR("user name by UID (with fallback)"); DESCR("user name by UID (with fallback)");
DATA(insert OID = 1643 ( pg_get_indexdef PGUID 12 f t f t 1 f 25 "26" 100 0 0 100 pg_get_indexdef - )); DATA(insert OID = 1643 ( pg_get_indexdef PGUID 12 f t f t 1 f 25 "26" 100 0 0 100 pg_get_indexdef - ));
DESCR("index description"); DESCR("index description");
@ -2321,23 +2313,23 @@ DATA(insert OID = 1693 ( btboolcmp PGUID 12 f t t t 2 f 23 "16 16" 100 0 0
DESCR("btree less-equal-greater"); DESCR("btree less-equal-greater");
/* OID's 1700 - 1799 NUMERIC data type */ /* OID's 1700 - 1799 NUMERIC data type */
DATA(insert OID = 1701 ( numeric_in PGUID 11 f t t t 3 f 1700 "0 0 23" 100 0 0 100 numeric_in - )); DATA(insert OID = 1701 ( numeric_in PGUID 12 f t t t 3 f 1700 "0 26 23" 100 0 0 100 numeric_in - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1702 ( numeric_out PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 numeric_out - )); DATA(insert OID = 1702 ( numeric_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 numeric_out - ));
DESCR("(internal)");
DATA(insert OID = 1703 ( numeric PGUID 11 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1703 ( numeric PGUID 12 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric - ));
DESCR("adjust numeric to typmod precision/scale");
DATA(insert OID = 1704 ( numeric_abs PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); DATA(insert OID = 1704 ( numeric_abs PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1705 ( abs PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_abs - )); DATA(insert OID = 1705 ( abs PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_abs - ));
DESCR("absolute value"); DESCR("absolute value");
DATA(insert OID = 1706 ( sign PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_sign - )); DATA(insert OID = 1706 ( sign PGUID 11 f t t t 1 f 1700 "1700" 100 0 0 100 numeric_sign - ));
DESCR("sign of value"); DESCR("sign of value");
DATA(insert OID = 1707 ( round PGUID 11 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric_round - )); DATA(insert OID = 1707 ( round PGUID 12 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric_round - ));
DESCR("value rounded to 'scale'"); DESCR("value rounded to 'scale'");
DATA(insert OID = 1708 ( round PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select numeric_round($1,0)" - )); DATA(insert OID = 1708 ( round PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select numeric_round($1,0)" - ));
DESCR("value rounded to 'scale' of zero"); DESCR("value rounded to 'scale' of zero");
DATA(insert OID = 1709 ( trunc PGUID 11 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric_trunc - )); DATA(insert OID = 1709 ( trunc PGUID 12 f t t t 2 f 1700 "1700 23" 100 0 0 100 numeric_trunc - ));
DESCR("value truncated to 'scale'"); DESCR("value truncated to 'scale'");
DATA(insert OID = 1710 ( trunc PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select trunc($1,0)" - )); DATA(insert OID = 1710 ( trunc PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select trunc($1,0)" - ));
DESCR("value truncated to 'scale' of zero"); DESCR("value truncated to 'scale' of zero");
@ -2389,7 +2381,7 @@ DATA(insert OID = 1738 ( pow PGUID 11 f t t t 2 f 1700 "1700 1700" 100 0 0 1
DESCR("m raised to the power of n"); DESCR("m raised to the power of n");
DATA(insert OID = 1739 ( numeric_power PGUID 11 f t t t 2 f 1700 "1700 1700" 100 0 0 100 numeric_power - )); DATA(insert OID = 1739 ( numeric_power PGUID 11 f t t t 2 f 1700 "1700 1700" 100 0 0 100 numeric_power - ));
DESCR("m raised to the power of n"); DESCR("m raised to the power of n");
DATA(insert OID = 1740 ( numeric PGUID 11 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - )); DATA(insert OID = 1740 ( numeric PGUID 12 f t t t 1 f 1700 "23" 100 0 0 100 int4_numeric - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1741 ( log PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select log(10, $1)" - )); DATA(insert OID = 1741 ( log PGUID 14 f t t t 1 f 1700 "1700" 100 0 0 100 "select log(10, $1)" - ));
DESCR("logarithm base 10 of n"); DESCR("logarithm base 10 of n");
@ -2427,17 +2419,17 @@ DESCR("(internal)");
/* formatting */ /* formatting */
DATA(insert OID = 1770 ( to_char PGUID 12 f t f t 2 f 25 "1184 25" 100 0 0 100 timestamp_to_char - )); DATA(insert OID = 1770 ( to_char PGUID 12 f t f t 2 f 25 "1184 25" 100 0 0 100 timestamp_to_char - ));
DESCR("format timestamp to text"); DESCR("format timestamp to text");
DATA(insert OID = 1772 ( to_char PGUID 11 f t f t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - )); DATA(insert OID = 1772 ( to_char PGUID 12 f t f t 2 f 25 "1700 25" 100 0 0 100 numeric_to_char - ));
DESCR("format numeric to text"); DESCR("format numeric to text");
DATA(insert OID = 1773 ( to_char PGUID 11 f t f t 2 f 25 "23 25" 100 0 0 100 int4_to_char - )); DATA(insert OID = 1773 ( to_char PGUID 12 f t f t 2 f 25 "23 25" 100 0 0 100 int4_to_char - ));
DESCR("format int4 to text"); DESCR("format int4 to text");
DATA(insert OID = 1774 ( to_char PGUID 11 f t f t 2 f 25 "20 25" 100 0 0 100 int8_to_char - )); DATA(insert OID = 1774 ( to_char PGUID 12 f t f t 2 f 25 "20 25" 100 0 0 100 int8_to_char - ));
DESCR("format int8 to text"); DESCR("format int8 to text");
DATA(insert OID = 1775 ( to_char PGUID 11 f t f t 2 f 25 "700 25" 100 0 0 100 float4_to_char - )); DATA(insert OID = 1775 ( to_char PGUID 12 f t f t 2 f 25 "700 25" 100 0 0 100 float4_to_char - ));
DESCR("format float4 to text"); DESCR("format float4 to text");
DATA(insert OID = 1776 ( to_char PGUID 11 f t f t 2 f 25 "701 25" 100 0 0 100 float8_to_char - )); DATA(insert OID = 1776 ( to_char PGUID 12 f t f t 2 f 25 "701 25" 100 0 0 100 float8_to_char - ));
DESCR("format float8 to text"); DESCR("format float8 to text");
DATA(insert OID = 1777 ( to_number PGUID 11 f t f t 2 f 1700 "25 25" 100 0 0 100 numeric_to_number - )); DATA(insert OID = 1777 ( to_number PGUID 12 f t f t 2 f 1700 "25 25" 100 0 0 100 numeric_to_number - ));
DESCR("convert text to numeric"); DESCR("convert text to numeric");
DATA(insert OID = 1778 ( to_timestamp PGUID 12 f t f t 2 f 1184 "25 25" 100 0 0 100 to_timestamp - )); DATA(insert OID = 1778 ( to_timestamp PGUID 12 f t f t 2 f 1184 "25 25" 100 0 0 100 to_timestamp - ));
DESCR("convert text to timestamp"); DESCR("convert text to timestamp");

@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: fmgr.h,v 1.4 2000/06/05 07:29:02 tgl Exp $ * $Id: fmgr.h,v 1.5 2000/06/13 07:35:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -99,37 +99,49 @@ extern void fmgr_info(Oid functionId, FmgrInfo *finfo);
*/ */
#define PG_ARGISNULL(n) (fcinfo->argnull[n]) #define PG_ARGISNULL(n) (fcinfo->argnull[n])
#if 1
/* VERY TEMPORARY until some TOAST support is committed ... */
#define PG_DETOAST_DATUM(datum) \
((struct varlena *) DatumGetPointer(datum))
#else
/* Eventually it will look more like this... */
#define PG_DETOAST_DATUM(datum) \
(VARATT_IS_EXTENDED(DatumGetPointer(datum)) ? \
(struct varlena *) heap_tuple_untoast_attr((varattrib *) DatumGetPointer(datum)) : \
(struct varlena *) DatumGetPointer(datum))
#endif
/* Macros for fetching arguments of standard types */ /* Macros for fetching arguments of standard types */
#define PG_GETARG_DATUM(n) (fcinfo->arg[n]) #define PG_GETARG_DATUM(n) (fcinfo->arg[n])
#define PG_GETARG_INT32(n) DatumGetInt32(fcinfo->arg[n]) #define PG_GETARG_INT32(n) DatumGetInt32(PG_GETARG_DATUM(n))
#define PG_GETARG_UINT32(n) DatumGetUInt32(fcinfo->arg[n]) #define PG_GETARG_UINT32(n) DatumGetUInt32(PG_GETARG_DATUM(n))
#define PG_GETARG_INT16(n) DatumGetInt16(fcinfo->arg[n]) #define PG_GETARG_INT16(n) DatumGetInt16(PG_GETARG_DATUM(n))
#define PG_GETARG_CHAR(n) DatumGetChar(fcinfo->arg[n]) #define PG_GETARG_UINT16(n) DatumGetUInt16(PG_GETARG_DATUM(n))
#define PG_GETARG_BOOL(n) DatumGetBool(fcinfo->arg[n]) #define PG_GETARG_CHAR(n) DatumGetChar(PG_GETARG_DATUM(n))
#define PG_GETARG_OID(n) DatumGetObjectId(fcinfo->arg[n]) #define PG_GETARG_BOOL(n) DatumGetBool(PG_GETARG_DATUM(n))
#define PG_GETARG_POINTER(n) DatumGetPointer(fcinfo->arg[n]) #define PG_GETARG_OID(n) DatumGetObjectId(PG_GETARG_DATUM(n))
#define PG_GETARG_CSTRING(n) DatumGetCString(fcinfo->arg[n]) #define PG_GETARG_POINTER(n) DatumGetPointer(PG_GETARG_DATUM(n))
#define PG_GETARG_NAME(n) DatumGetName(fcinfo->arg[n]) #define PG_GETARG_CSTRING(n) DatumGetCString(PG_GETARG_DATUM(n))
#define PG_GETARG_NAME(n) DatumGetName(PG_GETARG_DATUM(n))
/* these macros hide the pass-by-reference-ness of the datatype: */ /* these macros hide the pass-by-reference-ness of the datatype: */
#define PG_GETARG_FLOAT4(n) DatumGetFloat4(fcinfo->arg[n]) #define PG_GETARG_FLOAT4(n) DatumGetFloat4(PG_GETARG_DATUM(n))
#define PG_GETARG_FLOAT8(n) DatumGetFloat8(fcinfo->arg[n]) #define PG_GETARG_FLOAT8(n) DatumGetFloat8(PG_GETARG_DATUM(n))
#define PG_GETARG_INT64(n) DatumGetInt64(fcinfo->arg[n]) #define PG_GETARG_INT64(n) DatumGetInt64(PG_GETARG_DATUM(n))
/* use this if you want the raw, possibly-toasted input datum: */ /* use this if you want the raw, possibly-toasted input datum: */
#define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n)) #define PG_GETARG_RAW_VARLENA_P(n) ((struct varlena *) PG_GETARG_POINTER(n))
/* use this if you want the input datum de-toasted: */ /* use this if you want the input datum de-toasted: */
#if 1 #define PG_GETARG_VARLENA_P(n) PG_DETOAST_DATUM(PG_GETARG_DATUM(n))
/* VERY TEMPORARY until some TOAST support is committed ... */ /* DatumGetFoo macros for varlena types will typically look like this: */
#define PG_GETARG_VARLENA_P(n) PG_GETARG_RAW_VARLENA_P(n) #define DatumGetByteaP(X) ((bytea *) PG_DETOAST_DATUM(X))
#else #define DatumGetTextP(X) ((text *) PG_DETOAST_DATUM(X))
/* Eventually it will look more like this... */ #define DatumGetBpCharP(X) ((BpChar *) PG_DETOAST_DATUM(X))
#define PG_GETARG_VARLENA_P(n) \ #define DatumGetVarCharP(X) ((VarChar *) PG_DETOAST_DATUM(X))
(VARATT_IS_EXTENDED(PG_GETARG_RAW_VARLENA_P(n)) ? \
(struct varlena *) heap_tuple_untoast_attr((varattrib *) PG_GETARG_RAW_VARLENA_P(n)) : \
PG_GETARG_RAW_VARLENA_P(n))
#endif
/* GETARG macros for varlena types will typically look like this: */ /* GETARG macros for varlena types will typically look like this: */
#define PG_GETARG_TEXT_P(n) ((text *) PG_GETARG_VARLENA_P(n)) #define PG_GETARG_BYTEA_P(n) DatumGetByteaP(PG_GETARG_DATUM(n))
#define PG_GETARG_TEXT_P(n) DatumGetTextP(PG_GETARG_DATUM(n))
#define PG_GETARG_BPCHAR_P(n) DatumGetBpCharP(PG_GETARG_DATUM(n))
#define PG_GETARG_VARCHAR_P(n) DatumGetVarCharP(PG_GETARG_DATUM(n))
/* To return a NULL do this: */ /* To return a NULL do this: */
#define PG_RETURN_NULL() \ #define PG_RETURN_NULL() \
@ -151,7 +163,10 @@ extern void fmgr_info(Oid functionId, FmgrInfo *finfo);
#define PG_RETURN_FLOAT8(x) return Float8GetDatum(x) #define PG_RETURN_FLOAT8(x) return Float8GetDatum(x)
#define PG_RETURN_INT64(x) return Int64GetDatum(x) #define PG_RETURN_INT64(x) return Int64GetDatum(x)
/* RETURN macros for other pass-by-ref types will typically look like this: */ /* RETURN macros for other pass-by-ref types will typically look like this: */
#define PG_RETURN_BYTEA_P(x) PG_RETURN_POINTER(x)
#define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x) #define PG_RETURN_TEXT_P(x) PG_RETURN_POINTER(x)
#define PG_RETURN_BPCHAR_P(x) PG_RETURN_POINTER(x)
#define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x)
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------

@ -1,4 +1,4 @@
/* $Id: pg_wchar.h,v 1.14 2000/04/20 22:40:18 tgl Exp $ */ /* $Id: pg_wchar.h,v 1.15 2000/06/13 07:35:27 tgl Exp $ */
#ifndef PG_WCHAR_H #ifndef PG_WCHAR_H
#define PG_WCHAR_H #define PG_WCHAR_H
@ -122,11 +122,11 @@ extern unsigned char *pg_client_to_server(unsigned char *, int);
extern unsigned char *pg_server_to_client(unsigned char *, int); extern unsigned char *pg_server_to_client(unsigned char *, int);
extern int pg_valid_client_encoding(const char *); extern int pg_valid_client_encoding(const char *);
/* moved to miscadmin.h /* internally-used versions of functions. The PG_xxx forms of these
* pg_proc.h now have them. * functions have fmgr-compatible interfaves.
*/
extern const char *pg_encoding_to_char(int); extern const char *pg_encoding_to_char(int);
extern int pg_char_to_encoding(const char *); extern int pg_char_to_encoding(const char *);
*/
extern int GetDatabaseEncoding(void); extern int GetDatabaseEncoding(void);
extern void SetDatabaseEncoding(int); extern void SetDatabaseEncoding(int);

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: miscadmin.h,v 1.58 2000/06/08 22:37:35 momjian Exp $ * $Id: miscadmin.h,v 1.59 2000/06/13 07:35:24 tgl Exp $
* *
* NOTES * NOTES
* some of the information in this file will be moved to * some of the information in this file will be moved to
@ -131,13 +131,6 @@ extern char *ExpandDatabasePath(const char *path);
extern void SetDatabaseName(const char *name); extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path); extern void SetDatabasePath(const char *path);
/* even if MULTIBYTE is not enabled, this function is neccesary
* since pg_proc.h does have.
*/
extern const char *getdatabaseencoding(void);
extern const char *pg_encoding_to_char(int);
extern int pg_char_to_encoding(const char *);
extern char *getpgusername(void); extern char *getpgusername(void);
extern void SetPgUserName(void); extern void SetPgUserName(void);
extern int GetUserId(void); extern int GetUserId(void);

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1995, Regents of the University of California * Portions Copyright (c) 1995, Regents of the University of California
* *
* $Id: postgres.h,v 1.40 2000/06/02 15:57:40 momjian Exp $ * $Id: postgres.h,v 1.41 2000/06/13 07:35:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -49,7 +49,7 @@
typedef int4 aclitem; typedef int4 aclitem;
#define InvalidOid 0 #define InvalidOid ((Oid) 0)
#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
/* unfortunately, both regproc and RegProcedure are used */ /* unfortunately, both regproc and RegProcedure are used */
@ -76,12 +76,15 @@ struct varlena
#define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat) #define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
#define VARHDRSZ ((int32) sizeof(int32)) #define VARHDRSZ ((int32) sizeof(int32))
/*
* These widely-used datatypes are just a varlena header and the data bytes.
* There is no terminating null or anything like that --- the data length is
* always VARSIZE(ptr) - VARHDRSZ.
*/
typedef struct varlena bytea; typedef struct varlena bytea;
typedef struct varlena text; typedef struct varlena text;
typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */
typedef int2 int2vector[INDEX_MAX_KEYS]; typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
typedef Oid oidvector[INDEX_MAX_KEYS];
/* /*
* Proposed new layout for variable length attributes * Proposed new layout for variable length attributes
@ -155,6 +158,11 @@ extern varattrib *heap_tuple_untoast_attr(varattrib * attr);
#endif /* TUPLE_TOASTER_ACTIVE */ #endif /* TUPLE_TOASTER_ACTIVE */
/* fixed-length array types (these are not varlena's!) */
typedef int2 int2vector[INDEX_MAX_KEYS];
typedef Oid oidvector[INDEX_MAX_KEYS];
/* We want NameData to have length NAMEDATALEN and int alignment, /* We want NameData to have length NAMEDATALEN and int alignment,
* because that's how the data type 'name' is defined in pg_type. * because that's how the data type 'name' is defined in pg_type.
* Use a union to make sure the compiler agrees. * Use a union to make sure the compiler agrees.
@ -176,6 +184,7 @@ typedef NameData *Name;
typedef uint32 TransactionId; typedef uint32 TransactionId;
#define InvalidTransactionId 0 #define InvalidTransactionId 0
typedef uint32 CommandId; typedef uint32 CommandId;
#define FirstCommandId 0 #define FirstCommandId 0
@ -228,7 +237,7 @@ typedef uint32 CommandId;
* --------------- * ---------------
*/ */
#ifdef CYR_RECODE #ifdef CYR_RECODE
extern void SetCharSet(); extern void SetCharSet(void);
#endif /* CYR_RECODE */ #endif /* CYR_RECODE */
#endif /* POSTGRES_H */ #endif /* POSTGRES_H */

@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: array.h,v 1.24 2000/05/29 21:02:32 tgl Exp $ * $Id: array.h,v 1.25 2000/06/13 07:35:30 tgl Exp $
* *
* NOTES * NOTES
* XXX the data array should be MAXALIGN'd -- notice that the array * XXX the data array should be MAXALIGN'd -- notice that the array
@ -99,7 +99,8 @@ typedef struct
*------------------------------------------------------------------------ *------------------------------------------------------------------------
*/ */
#define RETURN_NULL do {*isNull = true; return(0); } while (0) #define RETURN_NULL(type) do { *isNull = true; return (type) 0; } while (0)
#define NAME_LEN 30 #define NAME_LEN 30
#define MAX_BUFF_SIZE BLCKSZ #define MAX_BUFF_SIZE BLCKSZ
@ -112,23 +113,29 @@ typedef struct
/* /*
* prototypes for functions defined in arrayfuncs.c * prototypes for functions defined in arrayfuncs.c
*/ */
extern char *array_in(char *string, Oid element_type, int32 typmod); extern Datum array_in(PG_FUNCTION_ARGS);
extern char *array_out(ArrayType *v, Oid element_type); extern Datum array_out(PG_FUNCTION_ARGS);
extern char *array_dims(ArrayType *v, bool *isNull); extern Datum array_eq(PG_FUNCTION_ARGS);
extern Datum array_ref(ArrayType *array, int n, int *indx, int reftype, extern Datum array_dims(PG_FUNCTION_ARGS);
int elmlen, int arraylen, bool *isNull);
extern Datum array_clip(ArrayType *array, int n, int *upperIndx, extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx,
int *lowerIndx, int reftype, int len, bool *isNull); bool elmbyval, int elmlen,
extern char *array_set(ArrayType *array, int n, int *indx, char *dataPtr, int arraylen, bool *isNull);
int reftype, int elmlen, int arraylen, bool *isNull); extern ArrayType *array_set(ArrayType *array, int nSubscripts, int *indx,
extern char *array_assgn(ArrayType *array, int n, int *upperIndx, Datum dataValue,
int *lowerIndx, ArrayType *newArr, int reftype, bool elmbyval, int elmlen,
int len, bool *isNull); int arraylen, bool *isNull);
extern ArrayType *array_clip(ArrayType *array, int nSubscripts,
int *upperIndx, int *lowerIndx,
bool elmbyval, int elmlen, bool *isNull);
extern ArrayType *array_assgn(ArrayType *array, int nSubscripts,
int *upperIndx, int *lowerIndx,
ArrayType *newArr,
bool elmbyval, int elmlen, bool *isNull);
extern Datum array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType); extern Datum array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType);
extern int array_eq(ArrayType *array1, ArrayType *array2);
extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd, extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd,
int isSrcLO, int isDestLO); int isSrcLO, int isDestLO);
extern char *_array_newLO(int *fd, int flag); extern char *_array_newLO(int *fd, int flag);

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: builtins.h,v 1.115 2000/06/09 01:11:14 tgl Exp $ * $Id: builtins.h,v 1.116 2000/06/13 07:35:30 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -190,7 +190,7 @@ extern BOX *rt_box_union(BOX *a, BOX *b);
extern BOX *rt_box_inter(BOX *a, BOX *b); extern BOX *rt_box_inter(BOX *a, BOX *b);
extern void rt_box_size(BOX *a, float *size); extern void rt_box_size(BOX *a, float *size);
extern void rt_bigbox_size(BOX *a, float *size); extern void rt_bigbox_size(BOX *a, float *size);
extern void rt_poly_size(POLYGON *a, float *size); extern Datum rt_poly_size(PG_FUNCTION_ARGS);
extern POLYGON *rt_poly_union(POLYGON *a, POLYGON *b); extern POLYGON *rt_poly_union(POLYGON *a, POLYGON *b);
extern POLYGON *rt_poly_inter(POLYGON *a, POLYGON *b); extern POLYGON *rt_poly_inter(POLYGON *a, POLYGON *b);
@ -244,12 +244,12 @@ extern bool float8le(float64 arg1, float64 arg2);
extern bool float8gt(float64 arg1, float64 arg2); extern bool float8gt(float64 arg1, float64 arg2);
extern bool float8ge(float64 arg1, float64 arg2); extern bool float8ge(float64 arg1, float64 arg2);
extern float64 ftod(float32 num); extern float64 ftod(float32 num);
extern float64 i4tod(int32 num); extern Datum i4tod(PG_FUNCTION_ARGS);
extern Datum i2tod(PG_FUNCTION_ARGS); extern Datum i2tod(PG_FUNCTION_ARGS);
extern float32 dtof(float64 num); extern float32 dtof(float64 num);
extern int32 dtoi4(float64 num); extern int32 dtoi4(float64 num);
extern Datum dtoi2(PG_FUNCTION_ARGS); extern Datum dtoi2(PG_FUNCTION_ARGS);
extern float32 i4tof(int32 num); extern Datum i4tof(PG_FUNCTION_ARGS);
extern Datum i2tof(PG_FUNCTION_ARGS); extern Datum i2tof(PG_FUNCTION_ARGS);
extern int32 ftoi4(float32 num); extern int32 ftoi4(float32 num);
extern Datum ftoi2(PG_FUNCTION_ARGS); extern Datum ftoi2(PG_FUNCTION_ARGS);
@ -354,7 +354,7 @@ extern Datum regproctooid(PG_FUNCTION_ARGS);
extern text *pg_get_ruledef(NameData *rname); extern text *pg_get_ruledef(NameData *rname);
extern text *pg_get_viewdef(NameData *rname); extern text *pg_get_viewdef(NameData *rname);
extern Datum pg_get_indexdef(PG_FUNCTION_ARGS); extern Datum pg_get_indexdef(PG_FUNCTION_ARGS);
extern NameData *pg_get_userbyid(int32 uid); extern Datum pg_get_userbyid(PG_FUNCTION_ARGS);
extern char *deparse_expression(Node *expr, List *rangetables, extern char *deparse_expression(Node *expr, List *rangetables,
bool forceprefix); bool forceprefix);
@ -412,16 +412,10 @@ extern Datum currtid_byrelname(PG_FUNCTION_ARGS);
/* varchar.c */ /* varchar.c */
/* bpchar and varchar are just a varlena header and some characters */ extern Datum bpcharin(PG_FUNCTION_ARGS);
#define PG_GETARG_BPCHAR_P(n) ((struct varlena *) PG_GETARG_VARLENA_P(n)) extern Datum bpcharout(PG_FUNCTION_ARGS);
#define PG_RETURN_BPCHAR_P(x) PG_RETURN_POINTER(x) extern Datum bpchar(PG_FUNCTION_ARGS);
#define PG_GETARG_VARCHAR_P(n) ((struct varlena *) PG_GETARG_VARLENA_P(n)) extern Datum _bpchar(PG_FUNCTION_ARGS);
#define PG_RETURN_VARCHAR_P(x) PG_RETURN_POINTER(x)
extern char *bpcharin(char *s, int dummy, int32 atttypmod);
extern char *bpcharout(char *s);
extern char *bpchar(char *s, int32 slen);
extern ArrayType *_bpchar(ArrayType *v, int32 slen);
extern Datum char_bpchar(PG_FUNCTION_ARGS); extern Datum char_bpchar(PG_FUNCTION_ARGS);
extern Datum bpchar_char(PG_FUNCTION_ARGS); extern Datum bpchar_char(PG_FUNCTION_ARGS);
extern char *name_bpchar(NameData *s); extern char *name_bpchar(NameData *s);
@ -437,10 +431,10 @@ extern int32 bpcharlen(char *arg);
extern int32 bpcharoctetlen(char *arg); extern int32 bpcharoctetlen(char *arg);
extern uint32 hashbpchar(struct varlena * key); extern uint32 hashbpchar(struct varlena * key);
extern char *varcharin(char *s, int dummy, int32 atttypmod); extern Datum varcharin(PG_FUNCTION_ARGS);
extern char *varcharout(char *s); extern Datum varcharout(PG_FUNCTION_ARGS);
extern char *varchar(char *s, int32 slen); extern Datum varchar(PG_FUNCTION_ARGS);
extern ArrayType *_varchar(ArrayType *v, int32 slen); extern Datum _varchar(PG_FUNCTION_ARGS);
extern bool varchareq(char *arg1, char *arg2); extern bool varchareq(char *arg1, char *arg2);
extern bool varcharne(char *arg1, char *arg2); extern bool varcharne(char *arg1, char *arg2);
extern bool varcharlt(char *arg1, char *arg2); extern bool varcharlt(char *arg1, char *arg2);
@ -468,17 +462,17 @@ extern text *text_smaller(text *arg1, text *arg2);
extern int32 textlen(text *arg); extern int32 textlen(text *arg);
extern int32 textoctetlen(text *arg); extern int32 textoctetlen(text *arg);
extern int32 textpos(text *arg1, text *arg2); extern int32 textpos(text *arg1, text *arg2);
extern text *text_substr(text *string, int32 m, int32 n); extern Datum text_substr(PG_FUNCTION_ARGS);
extern text *name_text(NameData *s); extern text *name_text(NameData *s);
extern NameData *text_name(text *s); extern NameData *text_name(text *s);
extern bytea *byteain(char *inputText); extern bytea *byteain(char *inputText);
extern char *byteaout(bytea *vlena); extern char *byteaout(bytea *vlena);
extern int32 byteaoctetlen(bytea *v); extern int32 byteaoctetlen(bytea *v);
extern int32 byteaGetByte(bytea *v, int32 n); extern Datum byteaGetByte(PG_FUNCTION_ARGS);
extern int32 byteaGetBit(bytea *v, int32 n); extern Datum byteaGetBit(PG_FUNCTION_ARGS);
extern bytea *byteaSetByte(bytea *v, int32 n, int32 newByte); extern Datum byteaSetByte(PG_FUNCTION_ARGS);
extern bytea *byteaSetBit(bytea *v, int32 n, int32 newBit); extern Datum byteaSetBit(PG_FUNCTION_ARGS);
/* like.c */ /* like.c */
extern bool namelike(NameData *n, struct varlena * p); extern bool namelike(NameData *n, struct varlena * p);
@ -491,15 +485,14 @@ extern bool textnlike(struct varlena * s, struct varlena * p);
extern text *lower(text *string); extern text *lower(text *string);
extern text *upper(text *string); extern text *upper(text *string);
extern text *initcap(text *string); extern text *initcap(text *string);
extern text *lpad(text *string1, int4 len, text *string2); extern Datum lpad(PG_FUNCTION_ARGS);
extern text *rpad(text *string1, int4 len, text *string2); extern Datum rpad(PG_FUNCTION_ARGS);
extern text *btrim(text *string, text *set); extern text *btrim(text *string, text *set);
extern text *ltrim(text *string, text *set); extern text *ltrim(text *string, text *set);
extern text *rtrim(text *string, text *set); extern text *rtrim(text *string, text *set);
extern text *substr(text *string, int4 m, int4 n);
extern text *translate(text *string, text *from, text *to); extern text *translate(text *string, text *from, text *to);
extern text *ichar(int4 arg1); extern Datum ichar(PG_FUNCTION_ARGS);
extern text *repeat(text *string, int4 count); extern Datum repeat(PG_FUNCTION_ARGS);
extern int4 ascii(text *string); extern int4 ascii(text *string);
/* acl.c */ /* acl.c */
@ -547,14 +540,14 @@ extern int4 macaddr_cmp(macaddr *a1, macaddr *a2);
extern text *macaddr_manuf(macaddr *addr); extern text *macaddr_manuf(macaddr *addr);
/* numeric.c */ /* numeric.c */
extern Numeric numeric_in(char *str, int dummy, int32 typmod); extern Datum numeric_in(PG_FUNCTION_ARGS);
extern char *numeric_out(Numeric num); extern Datum numeric_out(PG_FUNCTION_ARGS);
extern Numeric numeric(Numeric num, int32 typmod); extern Datum numeric(PG_FUNCTION_ARGS);
extern Numeric numeric_abs(Numeric num); extern Numeric numeric_abs(Numeric num);
extern Numeric numeric_uminus(Numeric num); extern Numeric numeric_uminus(Numeric num);
extern Numeric numeric_sign(Numeric num); extern Numeric numeric_sign(Numeric num);
extern Numeric numeric_round(Numeric num, int32 scale); extern Datum numeric_round(PG_FUNCTION_ARGS);
extern Numeric numeric_trunc(Numeric num, int32 scale); extern Datum numeric_trunc(PG_FUNCTION_ARGS);
extern Numeric numeric_ceil(Numeric num); extern Numeric numeric_ceil(Numeric num);
extern Numeric numeric_floor(Numeric num); extern Numeric numeric_floor(Numeric num);
extern int32 numeric_cmp(Numeric num1, Numeric num2); extern int32 numeric_cmp(Numeric num1, Numeric num2);
@ -578,7 +571,7 @@ extern Numeric numeric_exp(Numeric num);
extern Numeric numeric_ln(Numeric num); extern Numeric numeric_ln(Numeric num);
extern Numeric numeric_log(Numeric num1, Numeric num2); extern Numeric numeric_log(Numeric num1, Numeric num2);
extern Numeric numeric_power(Numeric num1, Numeric num2); extern Numeric numeric_power(Numeric num1, Numeric num2);
extern Numeric int4_numeric(int32 val); extern Datum int4_numeric(PG_FUNCTION_ARGS);
extern int32 numeric_int4(Numeric num); extern int32 numeric_int4(Numeric num);
extern Numeric int8_numeric(int64 *val); extern Numeric int8_numeric(int64 *val);
extern int64 *numeric_int8(Numeric num); extern int64 *numeric_int8(Numeric num);
@ -618,4 +611,11 @@ extern Datum RI_FKey_setnull_upd(PG_FUNCTION_ARGS);
extern Datum RI_FKey_setdefault_del(PG_FUNCTION_ARGS); extern Datum RI_FKey_setdefault_del(PG_FUNCTION_ARGS);
extern Datum RI_FKey_setdefault_upd(PG_FUNCTION_ARGS); extern Datum RI_FKey_setdefault_upd(PG_FUNCTION_ARGS);
/* even if MULTIBYTE is not enabled, these functions are necessary
* since pg_proc.h has references to them.
*/
extern Datum getdatabaseencoding(PG_FUNCTION_ARGS);
extern Datum PG_encoding_to_char(PG_FUNCTION_ARGS);
extern Datum PG_char_to_encoding(PG_FUNCTION_ARGS);
#endif /* BUILTINS_H */ #endif /* BUILTINS_H */

@ -33,9 +33,9 @@ extern Cash *cash_mul_flt4(Cash *c, float4 *f);
extern Cash *cash_div_flt4(Cash *c, float4 *f); extern Cash *cash_div_flt4(Cash *c, float4 *f);
extern Cash *flt4_mul_cash(float4 *f, Cash *c); extern Cash *flt4_mul_cash(float4 *f, Cash *c);
extern Cash *cash_mul_int4(Cash *c, int4 i); extern Datum cash_mul_int4(PG_FUNCTION_ARGS);
extern Cash *cash_div_int4(Cash *c, int4 i); extern Datum cash_div_int4(PG_FUNCTION_ARGS);
extern Cash *int4_mul_cash(int4 i, Cash *c); extern Datum int4_mul_cash(PG_FUNCTION_ARGS);
extern Datum cash_mul_int2(PG_FUNCTION_ARGS); extern Datum cash_mul_int2(PG_FUNCTION_ARGS);
extern Datum int2_mul_cash(PG_FUNCTION_ARGS); extern Datum int2_mul_cash(PG_FUNCTION_ARGS);

@ -2,7 +2,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* formatting.h * formatting.h
* *
* $Id: formatting.h,v 1.5 2000/06/09 01:11:15 tgl Exp $ * $Id: formatting.h,v 1.6 2000/06/13 07:35:30 tgl Exp $
* *
* *
* Portions Copyright (c) 1999-2000, PostgreSQL, Inc * Portions Copyright (c) 1999-2000, PostgreSQL, Inc
@ -24,11 +24,11 @@
extern Datum timestamp_to_char(PG_FUNCTION_ARGS); extern Datum timestamp_to_char(PG_FUNCTION_ARGS);
extern Datum to_timestamp(PG_FUNCTION_ARGS); extern Datum to_timestamp(PG_FUNCTION_ARGS);
extern Datum to_date(PG_FUNCTION_ARGS); extern Datum to_date(PG_FUNCTION_ARGS);
extern Numeric numeric_to_number(text *value, text *fmt); extern Datum numeric_to_number(PG_FUNCTION_ARGS);
extern text *numeric_to_char(Numeric value, text *fmt); extern Datum numeric_to_char(PG_FUNCTION_ARGS);
extern text *int4_to_char(int32 value, text *fmt); extern Datum int4_to_char(PG_FUNCTION_ARGS);
extern text *int8_to_char(int64 *value, text *fmt); extern Datum int8_to_char(PG_FUNCTION_ARGS);
extern text *float4_to_char(float32 value, text *fmt); extern Datum float4_to_char(PG_FUNCTION_ARGS);
extern text *float8_to_char(float64 value, text *fmt); extern Datum float8_to_char(PG_FUNCTION_ARGS);
#endif #endif

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: geo_decls.h,v 1.28 2000/06/05 07:29:07 tgl Exp $ * $Id: geo_decls.h,v 1.29 2000/06/13 07:35:30 tgl Exp $
* *
* NOTE * NOTE
* These routines do *not* use the float types from adt/. * These routines do *not* use the float types from adt/.
@ -135,6 +135,49 @@ typedef struct
double radius; double radius;
} CIRCLE; } CIRCLE;
/*
* fmgr interface macros
*
* Path and Polygon are toastable varlena types, the others are just
* fixed-size pass-by-reference types.
*/
#define DatumGetPointP(X) ((Point *) DatumGetPointer(X))
#define PointPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_POINT_P(n) DatumGetPointP(PG_GETARG_DATUM(n))
#define PG_RETURN_POINT_P(x) return PointPGetDatum(x)
#define DatumGetLsegP(X) ((LSEG *) DatumGetPointer(X))
#define LsegPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_LSEG_P(n) DatumGetLsegP(PG_GETARG_DATUM(n))
#define PG_RETURN_LSEG_P(x) return LsegPGetDatum(x)
#define DatumGetPathP(X) ((PATH *) PG_DETOAST_DATUM(X))
#define PathPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_PATH_P(n) DatumGetPathP(PG_GETARG_DATUM(n))
#define PG_RETURN_PATH_P(x) return PathPGetDatum(x)
#define DatumGetLineP(X) ((LINE *) DatumGetPointer(X))
#define LinePGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_LINE_P(n) DatumGetLineP(PG_GETARG_DATUM(n))
#define PG_RETURN_LINE_P(x) return LinePGetDatum(x)
#define DatumGetBoxP(X) ((BOX *) DatumGetPointer(X))
#define BoxPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_BOX_P(n) DatumGetBoxP(PG_GETARG_DATUM(n))
#define PG_RETURN_BOX_P(x) return BoxPGetDatum(x)
#define DatumGetPolygonP(X) ((POLYGON *) PG_DETOAST_DATUM(X))
#define PolygonPGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_POLYGON_P(n) DatumGetPolygonP(PG_GETARG_DATUM(n))
#define PG_RETURN_POLYGON_P(x) return PolygonPGetDatum(x)
#define DatumGetCircleP(X) ((CIRCLE *) DatumGetPointer(X))
#define CirclePGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_CIRCLE_P(n) DatumGetCircleP(PG_GETARG_DATUM(n))
#define PG_RETURN_CIRCLE_P(x) return CirclePGetDatum(x)
/* /*
* in geo_ops.h * in geo_ops.h
*/ */
@ -354,7 +397,7 @@ extern CIRCLE *circle(Point *center, float8 *radius);
extern CIRCLE *box_circle(BOX *box); extern CIRCLE *box_circle(BOX *box);
extern BOX *circle_box(CIRCLE *circle); extern BOX *circle_box(CIRCLE *circle);
extern CIRCLE *poly_circle(POLYGON *poly); extern CIRCLE *poly_circle(POLYGON *poly);
extern POLYGON *circle_poly(int npts, CIRCLE *circle); extern Datum circle_poly(PG_FUNCTION_ARGS);
/* private routines */ /* private routines */
extern double *circle_area(CIRCLE *circle); extern double *circle_area(CIRCLE *circle);

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: int8.h,v 1.21 2000/05/28 17:56:20 tgl Exp $ * $Id: int8.h,v 1.22 2000/06/13 07:35:30 tgl Exp $
* *
* NOTES * NOTES
* These data types are supported on all 64-bit architectures, and may * These data types are supported on all 64-bit architectures, and may
@ -24,64 +24,61 @@
#ifndef INT8_H #ifndef INT8_H
#define INT8_H #define INT8_H
#include "fmgr.h"
extern int64 *int8in(char *str);
extern char *int8out(int64 *val);
extern bool int8eq(int64 *val1, int64 *val2); extern Datum int8in(PG_FUNCTION_ARGS);
extern bool int8ne(int64 *val1, int64 *val2); extern Datum int8out(PG_FUNCTION_ARGS);
extern bool int8lt(int64 *val1, int64 *val2);
extern bool int8gt(int64 *val1, int64 *val2);
extern bool int8le(int64 *val1, int64 *val2);
extern bool int8ge(int64 *val1, int64 *val2);
extern bool int84eq(int64 *val1, int32 val2); extern Datum int8eq(PG_FUNCTION_ARGS);
extern bool int84ne(int64 *val1, int32 val2); extern Datum int8ne(PG_FUNCTION_ARGS);
extern bool int84lt(int64 *val1, int32 val2); extern Datum int8lt(PG_FUNCTION_ARGS);
extern bool int84gt(int64 *val1, int32 val2); extern Datum int8gt(PG_FUNCTION_ARGS);
extern bool int84le(int64 *val1, int32 val2); extern Datum int8le(PG_FUNCTION_ARGS);
extern bool int84ge(int64 *val1, int32 val2); extern Datum int8ge(PG_FUNCTION_ARGS);
extern bool int48eq(int32 val1, int64 *val2); extern Datum int84eq(PG_FUNCTION_ARGS);
extern bool int48ne(int32 val1, int64 *val2); extern Datum int84ne(PG_FUNCTION_ARGS);
extern bool int48lt(int32 val1, int64 *val2); extern Datum int84lt(PG_FUNCTION_ARGS);
extern bool int48gt(int32 val1, int64 *val2); extern Datum int84gt(PG_FUNCTION_ARGS);
extern bool int48le(int32 val1, int64 *val2); extern Datum int84le(PG_FUNCTION_ARGS);
extern bool int48ge(int32 val1, int64 *val2); extern Datum int84ge(PG_FUNCTION_ARGS);
extern int64 *int8um(int64 *val); extern Datum int48eq(PG_FUNCTION_ARGS);
extern int64 *int8pl(int64 *val1, int64 *val2); extern Datum int48ne(PG_FUNCTION_ARGS);
extern int64 *int8mi(int64 *val1, int64 *val2); extern Datum int48lt(PG_FUNCTION_ARGS);
extern int64 *int8mul(int64 *val1, int64 *val2); extern Datum int48gt(PG_FUNCTION_ARGS);
extern int64 *int8div(int64 *val1, int64 *val2); extern Datum int48le(PG_FUNCTION_ARGS);
extern int64 *int8abs(int64 *val1); extern Datum int48ge(PG_FUNCTION_ARGS);
extern int64 *int8fac(int64 *val1);
extern int64 *int8mod(int64 *val1, int64 *val2);
extern int64 *int8larger(int64 *val1, int64 *val2);
extern int64 *int8smaller(int64 *val1, int64 *val2);
extern int64 *int84pl(int64 *val1, int32 val2); extern Datum int8um(PG_FUNCTION_ARGS);
extern int64 *int84mi(int64 *val1, int32 val2); extern Datum int8pl(PG_FUNCTION_ARGS);
extern int64 *int84mul(int64 *val1, int32 val2); extern Datum int8mi(PG_FUNCTION_ARGS);
extern int64 *int84div(int64 *val1, int32 val2); extern Datum int8mul(PG_FUNCTION_ARGS);
extern Datum int8div(PG_FUNCTION_ARGS);
extern Datum int8abs(PG_FUNCTION_ARGS);
extern Datum int8fac(PG_FUNCTION_ARGS);
extern Datum int8mod(PG_FUNCTION_ARGS);
extern Datum int8larger(PG_FUNCTION_ARGS);
extern Datum int8smaller(PG_FUNCTION_ARGS);
extern int64 *int48pl(int32 val1, int64 *val2); extern Datum int84pl(PG_FUNCTION_ARGS);
extern int64 *int48mi(int32 val1, int64 *val2); extern Datum int84mi(PG_FUNCTION_ARGS);
extern int64 *int48mul(int32 val1, int64 *val2); extern Datum int84mul(PG_FUNCTION_ARGS);
extern int64 *int48div(int32 val1, int64 *val2); extern Datum int84div(PG_FUNCTION_ARGS);
extern int64 *int48(int32 val); extern Datum int48pl(PG_FUNCTION_ARGS);
extern int32 int84(int64 *val); extern Datum int48mi(PG_FUNCTION_ARGS);
extern Datum int48mul(PG_FUNCTION_ARGS);
extern Datum int48div(PG_FUNCTION_ARGS);
#ifdef NOT_USED extern Datum int48(PG_FUNCTION_ARGS);
extern int16 int82(int64 *val); extern Datum int84(PG_FUNCTION_ARGS);
#endif extern Datum i8tod(PG_FUNCTION_ARGS);
extern Datum dtoi8(PG_FUNCTION_ARGS);
extern float64 i8tod(int64 *val); extern Datum int8_text(PG_FUNCTION_ARGS);
extern int64 *dtoi8(float64 val); extern Datum text_int8(PG_FUNCTION_ARGS);
extern text *int8_text(int64 *val);
extern int64 *text_int8(text *str);
#endif /* INT8_H */ #endif /* INT8_H */

@ -5,7 +5,7 @@
* *
* 1998 Jan Wieck * 1998 Jan Wieck
* *
* $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.9 2000/04/12 17:16:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.10 2000/06/13 07:35:31 tgl Exp $
* *
* ---------- * ----------
*/ */
@ -71,4 +71,13 @@ typedef NumericData *Numeric;
#define NUMERIC_HDRSZ (sizeof(int32) + sizeof(uint16) * 3) #define NUMERIC_HDRSZ (sizeof(int32) + sizeof(uint16) * 3)
/*
* fmgr interface macros
*/
#define DatumGetNumeric(X) ((Numeric) PG_DETOAST_DATUM(X))
#define NumericGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
#endif /* _PG_NUMERIC_H_ */ #endif /* _PG_NUMERIC_H_ */

@ -40,5 +40,5 @@ CREATE FUNCTION ttdummy ()
CREATE FUNCTION set_ttdummy (int4) CREATE FUNCTION set_ttdummy (int4)
RETURNS int4 RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';

@ -28,9 +28,9 @@ CREATE FUNCTION user_relns()
LANGUAGE 'sql'; LANGUAGE 'sql';
CREATE FUNCTION pt_in_widget(point, widget) CREATE FUNCTION pt_in_widget(point, widget)
RETURNS int4 RETURNS bool
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';
CREATE FUNCTION overpaid(emp) CREATE FUNCTION overpaid(emp)
RETURNS bool RETURNS bool
@ -38,9 +38,9 @@ CREATE FUNCTION overpaid(emp)
LANGUAGE 'newC'; LANGUAGE 'newC';
CREATE FUNCTION boxarea(box) CREATE FUNCTION boxarea(box)
RETURNS int4 RETURNS float8
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';
CREATE FUNCTION interpt_pp(path, path) CREATE FUNCTION interpt_pp(path, path)
RETURNS point RETURNS point

@ -33,4 +33,4 @@ CREATE FUNCTION ttdummy ()
CREATE FUNCTION set_ttdummy (int4) CREATE FUNCTION set_ttdummy (int4)
RETURNS int4 RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';

@ -21,17 +21,17 @@ CREATE FUNCTION user_relns()
relkind <> ''i'' ' relkind <> ''i'' '
LANGUAGE 'sql'; LANGUAGE 'sql';
CREATE FUNCTION pt_in_widget(point, widget) CREATE FUNCTION pt_in_widget(point, widget)
RETURNS int4 RETURNS bool
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';
CREATE FUNCTION overpaid(emp) CREATE FUNCTION overpaid(emp)
RETURNS bool RETURNS bool
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'newC'; LANGUAGE 'newC';
CREATE FUNCTION boxarea(box) CREATE FUNCTION boxarea(box)
RETURNS int4 RETURNS float8
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c'; LANGUAGE 'newC';
CREATE FUNCTION interpt_pp(path, path) CREATE FUNCTION interpt_pp(path, path)
RETURNS point RETURNS point
AS '_OBJWD_/regress_DLSUFFIX_' AS '_OBJWD_/regress_DLSUFFIX_'

@ -1,5 +1,5 @@
/* /*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.39 2000/06/11 20:07:44 tgl Exp $ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.40 2000/06/13 07:35:34 tgl Exp $
*/ */
#include <float.h> /* faked on sunos */ #include <float.h> /* faked on sunos */
@ -23,7 +23,7 @@ extern PATH *poly2path(POLYGON *poly);
extern Point *interpt_pp(PATH *p1, PATH *p2); extern Point *interpt_pp(PATH *p1, PATH *p2);
extern void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2); extern void regress_lseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
extern Datum overpaid(PG_FUNCTION_ARGS); extern Datum overpaid(PG_FUNCTION_ARGS);
extern int boxarea(BOX *box); extern Datum boxarea(PG_FUNCTION_ARGS);
extern char *reverse_name(char *string); extern char *reverse_name(char *string);
/* /*
@ -203,7 +203,7 @@ typedef struct
WIDGET *widget_in(char *str); WIDGET *widget_in(char *str);
char *widget_out(WIDGET * widget); char *widget_out(WIDGET * widget);
int pt_in_widget(Point *point, WIDGET * widget); extern Datum pt_in_widget(PG_FUNCTION_ARGS);
#define NARGS 3 #define NARGS 3
@ -249,30 +249,27 @@ WIDGET *widget;
return result; return result;
} }
int Datum
pt_in_widget(point, widget) pt_in_widget(PG_FUNCTION_ARGS)
Point *point;
WIDGET *widget;
{ {
extern double point_dt(); Point *point = PG_GETARG_POINT_P(0);
WIDGET *widget = (WIDGET *) PG_GETARG_POINTER(1);
return point_dt(point, &widget->center) < widget->radius; PG_RETURN_BOOL(point_dt(point, &widget->center) < widget->radius);
} }
#define ABS(X) ((X) > 0 ? (X) : -(X)) #define ABS(X) ((X) >= 0 ? (X) : -(X))
int
boxarea(box)
BOX *box;
Datum
boxarea(PG_FUNCTION_ARGS)
{ {
int width, BOX *box = PG_GETARG_BOX_P(0);
double width,
height; height;
width = ABS(box->high.x - box->low.x); width = ABS(box->high.x - box->low.x);
height = ABS(box->high.y - box->low.y); height = ABS(box->high.y - box->low.y);
return width * height; PG_RETURN_FLOAT8(width * height);
} }
char * char *
@ -419,7 +416,7 @@ funny_dup17(PG_FUNCTION_ARGS)
} }
extern Datum ttdummy(PG_FUNCTION_ARGS); extern Datum ttdummy(PG_FUNCTION_ARGS);
int32 set_ttdummy(int32 on); extern Datum set_ttdummy(PG_FUNCTION_ARGS);
#define TTDUMMY_INFINITY 999999 #define TTDUMMY_INFINITY 999999
@ -622,27 +619,27 @@ ttdummy(PG_FUNCTION_ARGS)
return PointerGetDatum(rettuple); return PointerGetDatum(rettuple);
} }
int32 Datum
set_ttdummy(int32 on) set_ttdummy(PG_FUNCTION_ARGS)
{ {
int32 on = PG_GETARG_INT32(0);
if (ttoff) /* OFF currently */ if (ttoff) /* OFF currently */
{ {
if (on == 0) if (on == 0)
return 0; PG_RETURN_INT32(0);
/* turn ON */ /* turn ON */
ttoff = false; ttoff = false;
return 0; PG_RETURN_INT32(0);
} }
/* ON currently */ /* ON currently */
if (on != 0) if (on != 0)
return 1; PG_RETURN_INT32(1);
/* turn OFF */ /* turn OFF */
ttoff = true; ttoff = true;
return 1; PG_RETURN_INT32(1);
} }