More functions updated to new fmgr style --- money, name, tid datatypes.

We're reaching the mopup stage here (good thing too, this is getting
tedious).
This commit is contained in:
Tom Lane 2000-08-03 16:35:08 +00:00
parent 1bd3a8f58b
commit c298d74d49
22 changed files with 316 additions and 314 deletions

View File

@ -368,7 +368,8 @@ set_timetravel(PG_FUNCTION_ARGS)
TTOff = malloc(sizeof(char *)); TTOff = malloc(sizeof(char *));
else else
TTOff = realloc(TTOff, (nTTOff + 1) * sizeof(char *)); TTOff = realloc(TTOff, (nTTOff + 1) * sizeof(char *));
s = rname = nameout(relname); s = rname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(relname)));
d = TTOff[nTTOff] = malloc(strlen(rname) + 1); d = TTOff[nTTOff] = malloc(strlen(rname) + 1);
while (*s) while (*s)
*d++ = tolower(*s++); *d++ = tolower(*s++);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.10 2000/07/31 22:39:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.11 2000/08/03 16:33:40 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
@ -785,12 +785,14 @@ toast_save_datum(Relation rel, Oid mainoid, int16 attno, Datum value)
toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock); toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
if (toastrel == NULL) if (toastrel == NULL)
elog(ERROR, "Failed to open secondary relation of %s", elog(ERROR, "Failed to open secondary relation of %s",
nameout(&(rel->rd_rel->relname))); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(rel->rd_rel->relname)))));
toasttupDesc = toastrel->rd_att; toasttupDesc = toastrel->rd_att;
toastidx = index_open(rel->rd_rel->reltoastidxid); toastidx = index_open(rel->rd_rel->reltoastidxid);
if (toastidx == NULL) if (toastidx == NULL)
elog(ERROR, "Failed to open index for secondary relation of %s", elog(ERROR, "Failed to open index for secondary relation of %s",
nameout(&(rel->rd_rel->relname))); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(rel->rd_rel->relname)))));
/* ---------- /* ----------
* Split up the item into chunks * Split up the item into chunks

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.140 2000/07/14 22:17:40 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.141 2000/08/03 16:33:52 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
@ -409,8 +409,8 @@ CheckAttributeNames(TupleDesc tupdesc)
{ {
for (j = 0; j < (int) (sizeof(HeapAtt) / sizeof(HeapAtt[0])); j++) for (j = 0; j < (int) (sizeof(HeapAtt) / sizeof(HeapAtt[0])); j++)
{ {
if (nameeq(&(HeapAtt[j]->attname), if (strcmp(NameStr(HeapAtt[j]->attname),
&(tupdesc->attrs[i]->attname))) NameStr(tupdesc->attrs[i]->attname)) == 0)
{ {
elog(ERROR, "Attribute '%s' has a name conflict" elog(ERROR, "Attribute '%s' has a name conflict"
"\n\tName matches an existing system attribute", "\n\tName matches an existing system attribute",
@ -433,8 +433,8 @@ CheckAttributeNames(TupleDesc tupdesc)
{ {
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
{ {
if (nameeq(&(tupdesc->attrs[j]->attname), if (strcmp(NameStr(tupdesc->attrs[j]->attname),
&(tupdesc->attrs[i]->attname))) NameStr(tupdesc->attrs[i]->attname)) == 0)
{ {
elog(ERROR, "Attribute '%s' is repeated", elog(ERROR, "Attribute '%s' is repeated",
NameStr(tupdesc->attrs[j]->attname)); NameStr(tupdesc->attrs[j]->attname));
@ -1633,7 +1633,8 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
ccsrc = deparse_expression(expr, lcons(lcons(rte, NIL), NIL), false); ccsrc = deparse_expression(expr, lcons(lcons(rte, NIL), NIL), false);
values[Anum_pg_relcheck_rcrelid - 1] = RelationGetRelid(rel); values[Anum_pg_relcheck_rcrelid - 1] = RelationGetRelid(rel);
values[Anum_pg_relcheck_rcname - 1] = PointerGetDatum(namein(ccname)); values[Anum_pg_relcheck_rcname - 1] = DirectFunctionCall1(namein,
CStringGetDatum(ccname));
values[Anum_pg_relcheck_rcbin - 1] = DirectFunctionCall1(textin, values[Anum_pg_relcheck_rcbin - 1] = DirectFunctionCall1(textin,
CStringGetDatum(ccbin)); CStringGetDatum(ccbin));
values[Anum_pg_relcheck_rcsrc - 1] = DirectFunctionCall1(textin, values[Anum_pg_relcheck_rcsrc - 1] = DirectFunctionCall1(textin,

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.91 2000/07/18 03:57:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.92 2000/08/03 16:34:01 tgl Exp $
* *
* NOTES * NOTES
* The PerformAddAttribute() code, like most of the relation * The PerformAddAttribute() code, like most of the relation
@ -565,7 +565,7 @@ AlterTableAlterColumn(const char *relationName,
*/ */
tuple = SearchSysCacheTuple(ATTNAME, tuple = SearchSysCacheTuple(ATTNAME,
ObjectIdGetDatum(myrelid), ObjectIdGetDatum(myrelid),
NameGetDatum(namein((char *) colName)), PointerGetDatum(colName),
0, 0); 0, 0);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.58 2000/07/05 23:11:11 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.59 2000/08/03 16:34:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -98,7 +98,8 @@ createdb(const char *dbname, const char *dbpath, int encoding)
pg_database_dsc = RelationGetDescr(pg_database_rel); pg_database_dsc = RelationGetDescr(pg_database_rel);
/* Form tuple */ /* Form tuple */
new_record[Anum_pg_database_datname - 1] = NameGetDatum(namein(dbname)); new_record[Anum_pg_database_datname - 1] = DirectFunctionCall1(namein,
CStringGetDatum(dbname));
new_record[Anum_pg_database_datdba - 1] = Int32GetDatum(user_id); new_record[Anum_pg_database_datdba - 1] = Int32GetDatum(user_id);
new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding); new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin, new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin,

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.35 2000/07/14 22:17:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.36 2000/08/03 16:34:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -576,7 +576,8 @@ GetDefaultOpClass(Oid atttypid)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
return NULL; return NULL;
return nameout(&((Form_pg_opclass) GETSTRUCT(tuple))->opcname); return DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&((Form_pg_opclass) GETSTRUCT(tuple))->opcname)));
} }
/* /*

View File

@ -201,7 +201,7 @@ nextval(PG_FUNCTION_ARGS)
rescnt = 0; rescnt = 0;
#ifndef NO_SECURITY #ifndef NO_SECURITY
if (pg_aclcheck(seqname, getpgusername(), ACL_WR) != ACLCHECK_OK) if (pg_aclcheck(seqname, GetPgUserName(), ACL_WR) != ACLCHECK_OK)
elog(ERROR, "%s.nextval: you don't have permissions to set sequence %s", elog(ERROR, "%s.nextval: you don't have permissions to set sequence %s",
seqname, seqname); seqname, seqname);
#endif #endif
@ -298,7 +298,7 @@ currval(PG_FUNCTION_ARGS)
int32 result; int32 result;
#ifndef NO_SECURITY #ifndef NO_SECURITY
if (pg_aclcheck(seqname, getpgusername(), ACL_RD) != ACLCHECK_OK) if (pg_aclcheck(seqname, GetPgUserName(), ACL_RD) != ACLCHECK_OK)
elog(ERROR, "%s.currval: you don't have permissions to read sequence %s", elog(ERROR, "%s.currval: you don't have permissions to read sequence %s",
seqname, seqname); seqname, seqname);
#endif #endif
@ -328,7 +328,7 @@ setval(PG_FUNCTION_ARGS)
Form_pg_sequence seq; Form_pg_sequence seq;
#ifndef NO_SECURITY #ifndef NO_SECURITY
if (pg_aclcheck(seqname, getpgusername(), ACL_WR) != ACLCHECK_OK) if (pg_aclcheck(seqname, GetPgUserName(), ACL_WR) != ACLCHECK_OK)
elog(ERROR, "%s.setval: you don't have permissions to set sequence %s", elog(ERROR, "%s.setval: you don't have permissions to set sequence %s",
seqname, seqname); seqname, seqname);
#endif #endif

View File

@ -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/commands/trigger.c,v 1.73 2000/07/29 03:26:40 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.74 2000/08/03 16:34:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -195,7 +195,8 @@ CreateTrigger(CreateTrigStmt *stmt)
MemSet(nulls, ' ', Natts_pg_trigger * sizeof(char)); MemSet(nulls, ' ', Natts_pg_trigger * sizeof(char));
values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel)); values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel));
values[Anum_pg_trigger_tgname - 1] = NameGetDatum(namein(stmt->trigname)); values[Anum_pg_trigger_tgname - 1] = DirectFunctionCall1(namein,
CStringGetDatum(stmt->trigname));
values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid); values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid);
values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
values[Anum_pg_trigger_tgenabled - 1] = BoolGetDatum(true); values[Anum_pg_trigger_tgenabled - 1] = BoolGetDatum(true);
@ -441,7 +442,8 @@ RelationRemoveTriggers(Relation rel)
refrel = heap_open(pg_trigger->tgrelid, NoLock); refrel = heap_open(pg_trigger->tgrelid, NoLock);
stmt.relname = pstrdup(RelationGetRelationName(refrel)); stmt.relname = pstrdup(RelationGetRelationName(refrel));
stmt.trigname = nameout(&pg_trigger->tgname); stmt.trigname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&pg_trigger->tgname)));
heap_close(refrel, NoLock); heap_close(refrel, NoLock);
@ -552,7 +554,8 @@ RelationBuildTriggers(Relation relation)
build->tgoid = htup->t_data->t_oid; build->tgoid = htup->t_data->t_oid;
build->tgname = MemoryContextStrdup(CacheMemoryContext, build->tgname = MemoryContextStrdup(CacheMemoryContext,
nameout(&pg_trigger->tgname)); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&pg_trigger->tgname))));
build->tgfoid = pg_trigger->tgfoid; build->tgfoid = pg_trigger->tgfoid;
build->tgfunc.fn_oid = InvalidOid; /* mark FmgrInfo as uninitialized */ build->tgfunc.fn_oid = InvalidOid; /* mark FmgrInfo as uninitialized */
build->tgtype = pg_trigger->tgtype; build->tgtype = pg_trigger->tgtype;
@ -1217,8 +1220,8 @@ deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid)
} }
elog(ERROR, elog(ERROR,
"deferredTriggerGetPreviousEvent(): event for tuple %s not found", "deferredTriggerGetPreviousEvent(): event for tuple %s not found",
tidout(ctid)); DatumGetCString(DirectFunctionCall1(tidout, PointerGetDatum(ctid))));
return NULL; return NULL;
} }
@ -2020,13 +2023,15 @@ DeferredTriggerSaveEvent(Relation rel, int event,
TRIGGER_DEFERRED_ROW_INSERTED) TRIGGER_DEFERRED_ROW_INSERTED)
elog(ERROR, "triggered data change violation " elog(ERROR, "triggered data change violation "
"on relation \"%s\"", "on relation \"%s\"",
nameout(&(rel->rd_rel->relname))); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(rel->rd_rel->relname)))));
if (prev_event->dte_item[i].dti_state & if (prev_event->dte_item[i].dti_state &
TRIGGER_DEFERRED_KEY_CHANGED) TRIGGER_DEFERRED_KEY_CHANGED)
elog(ERROR, "triggered data change violation " elog(ERROR, "triggered data change violation "
"on relation \"%s\"", "on relation \"%s\"",
nameout(&(rel->rd_rel->relname))); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(rel->rd_rel->relname)))));
} }
/* ---------- /* ----------
@ -2060,7 +2065,8 @@ DeferredTriggerSaveEvent(Relation rel, int event,
if (prev_event->dte_event & TRIGGER_DEFERRED_KEY_CHANGED) if (prev_event->dte_event & TRIGGER_DEFERRED_KEY_CHANGED)
elog(ERROR, "triggered data change violation " elog(ERROR, "triggered data change violation "
"on relation \"%s\"", "on relation \"%s\"",
nameout(&(rel->rd_rel->relname))); DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(rel->rd_rel->relname)))));
break; break;
} }

View File

@ -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
* *
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.65 2000/07/22 04:16:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.66 2000/08/03 16:34:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -121,7 +121,8 @@ write_password_file(Relation rel)
"%s" "%s"
CRYPT_PWD_FILE_SEPSTR CRYPT_PWD_FILE_SEPSTR
"%s\n", "%s\n",
nameout(DatumGetName(datum_n)), DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(DatumGetName(datum_n)))),
null_p ? "" : null_p ? "" :
DatumGetCString(DirectFunctionCall1(textout, datum_p)), DatumGetCString(DirectFunctionCall1(textout, datum_p)),
null_v ? "\\N" : null_v ? "\\N" :
@ -246,8 +247,8 @@ CreateUser(CreateUserStmt *stmt)
/* /*
* Build a tuple to insert * Build a tuple to insert
*/ */
new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user)); /* this truncated new_record[Anum_pg_shadow_usename - 1] = DirectFunctionCall1(namein,
* properly */ CStringGetDatum(stmt->user));
new_record[Anum_pg_shadow_usesysid - 1] = Int32GetDatum(havesysid ? stmt->sysid : max_id + 1); new_record[Anum_pg_shadow_usesysid - 1] = Int32GetDatum(havesysid ? stmt->sysid : max_id + 1);
AssertState(BoolIsValid(stmt->createdb)); AssertState(BoolIsValid(stmt->createdb));
@ -374,7 +375,8 @@ AlterUser(AlterUserStmt *stmt)
/* /*
* Build a tuple to update, perusing the information just obtained * Build a tuple to update, perusing the information just obtained
*/ */
new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user)); new_record[Anum_pg_shadow_usename - 1] = DirectFunctionCall1(namein,
CStringGetDatum(stmt->user));
new_record_nulls[Anum_pg_shadow_usename - 1] = ' '; new_record_nulls[Anum_pg_shadow_usename - 1] = ' ';
/* sysid - leave as is */ /* sysid - leave as is */
@ -556,7 +558,9 @@ DropUser(DropUserStmt *stmt)
datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null); datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null);
heap_close(pg_shadow_rel, AccessExclusiveLock); heap_close(pg_shadow_rel, AccessExclusiveLock);
elog(ERROR, "DROP USER: user \"%s\" owns database \"%s\", cannot be removed%s", elog(ERROR, "DROP USER: user \"%s\" owns database \"%s\", cannot be removed%s",
user, nameout(DatumGetName(datum)), user,
DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(DatumGetName(datum)))),
(length(stmt->users) > 1) ? " (no users removed)" : "" (length(stmt->users) > 1) ? " (no users removed)" : ""
); );
} }
@ -587,11 +591,9 @@ DropUser(DropUserStmt *stmt)
{ {
AlterGroupStmt ags; AlterGroupStmt ags;
/* the group name from which to try to drop the user: */
datum = heap_getattr(tmp_tuple, Anum_pg_group_groname, pg_dsc, &null); datum = heap_getattr(tmp_tuple, Anum_pg_group_groname, pg_dsc, &null);
ags.name = DatumGetCString(DirectFunctionCall1(nameout, datum));
ags.name = nameout(DatumGetName(datum)); /* the group name from
* which to try to drop
* the user */
ags.action = -1; ags.action = -1;
ags.listUsers = lcons((void *) makeInteger(usesysid), NIL); ags.listUsers = lcons((void *) makeInteger(usesysid), NIL);
AlterGroup(&ags, "DROP USER"); AlterGroup(&ags, "DROP USER");

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.90 2000/07/27 23:15:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.91 2000/08/03 16:34:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2006,7 +2006,7 @@ string_to_datum(const char *str, Oid datatype)
* varchar constants too... * varchar constants too...
*/ */
if (datatype == NAMEOID) if (datatype == NAMEOID)
return PointerGetDatum(namein((char *) str)); return DirectFunctionCall1(namein, CStringGetDatum(str));
else else
return DirectFunctionCall1(textin, CStringGetDatum(str)); return DirectFunctionCall1(textin, CStringGetDatum(str));
} }

View File

@ -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: analyze.c,v 1.151 2000/07/15 00:01:41 tgl Exp $ * $Id: analyze.c,v 1.152 2000/08/03 16:35:08 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2078,7 +2078,8 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint)
int pkattno = indexStruct->indkey[i]; int pkattno = indexStruct->indkey[i];
Ident *pkattr = makeNode(Ident); Ident *pkattr = makeNode(Ident);
pkattr->name = nameout(&(pkrel_attrs[pkattno - 1]->attname)); pkattr->name = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(pkrel_attrs[pkattno - 1]->attname))));
pkattr->indirection = NIL; pkattr->indirection = NIL;
pkattr->isRel = false; pkattr->isRel = false;

View File

@ -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.44 2000/08/01 18:29:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.45 2000/08/03 16:34:22 tgl Exp $
*/ */
#include <limits.h> #include <limits.h>
@ -66,11 +66,11 @@ CashGetDatum(Cash value)
* XXX UNHACK Allow the currency symbol to be multi-byte. * XXX UNHACK Allow the currency symbol to be multi-byte.
* - thomas 1998-03-01 * - thomas 1998-03-01
*/ */
Cash * Datum
cash_in(const char *str) cash_in(PG_FUNCTION_ARGS)
{ {
Cash *result; char *str = PG_GETARG_CSTRING(0);
Cash result;
Cash value = 0; Cash value = 0;
Cash dec = 0; Cash dec = 0;
Cash sgn = 1; Cash sgn = 1;
@ -200,17 +200,14 @@ cash_in(const char *str)
if (*s != '\0') if (*s != '\0')
elog(ERROR, "Bad money external representation %s", str); elog(ERROR, "Bad money external representation %s", str);
if (!PointerIsValid(result = palloc(sizeof(Cash)))) result = (value * sgn);
elog(ERROR, "Memory allocation failed, can't input cash '%s'", str);
*result = (value * sgn);
#ifdef CASHDEBUG #ifdef CASHDEBUG
printf("cashin- result is %d\n", *result); printf("cashin- result is %d\n", result);
#endif #endif
return result; PG_RETURN_CASH(result);
} /* cash_in() */ }
/* cash_out() /* cash_out()
@ -218,10 +215,10 @@ cash_in(const char *str)
* XXX HACK This code appears to assume US conventions for * XXX HACK This code appears to assume US conventions for
* positive-valued amounts. - tgl 97/04/14 * positive-valued amounts. - tgl 97/04/14
*/ */
const char * Datum
cash_out(Cash *in_value) cash_out(PG_FUNCTION_ARGS)
{ {
Cash value = *in_value; Cash value = PG_GETARG_CASH(0);
char *result; char *result;
char buf[CASH_BUFSZ]; char buf[CASH_BUFSZ];
int minus = 0; int minus = 0;
@ -323,103 +320,95 @@ cash_out(Cash *in_value)
strcpy(result, buf + count); strcpy(result, buf + count);
} }
return result; PG_RETURN_CSTRING(result);
} /* cash_out() */ }
bool Datum
cash_eq(Cash *c1, Cash *c2) cash_eq(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 == *c2; PG_RETURN_BOOL(c1 == c2);
} /* cash_eq() */ }
bool Datum
cash_ne(Cash *c1, Cash *c2) cash_ne(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 != *c2; PG_RETURN_BOOL(c1 != c2);
} /* cash_ne() */ }
bool Datum
cash_lt(Cash *c1, Cash *c2) cash_lt(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 < *c2; PG_RETURN_BOOL(c1 < c2);
} /* cash_lt() */ }
bool Datum
cash_le(Cash *c1, Cash *c2) cash_le(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 <= *c2; PG_RETURN_BOOL(c1 <= c2);
} /* cash_le() */ }
bool Datum
cash_gt(Cash *c1, Cash *c2) cash_gt(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 > *c2; PG_RETURN_BOOL(c1 > c2);
} /* cash_gt() */ }
bool Datum
cash_ge(Cash *c1, Cash *c2) cash_ge(PG_FUNCTION_ARGS)
{ {
if (!PointerIsValid(c1) || !PointerIsValid(c2)) Cash c1 = PG_GETARG_CASH(0);
return FALSE; Cash c2 = PG_GETARG_CASH(1);
return *c1 >= *c2; PG_RETURN_BOOL(c1 >= c2);
} /* cash_ge() */ }
/* cash_pl() /* cash_pl()
* Add two cash values. * Add two cash values.
*/ */
Cash * Datum
cash_pl(Cash *c1, Cash *c2) cash_pl(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c1 = PG_GETARG_CASH(0);
Cash c2 = PG_GETARG_CASH(1);
Cash result;
if (!PointerIsValid(c1) || !PointerIsValid(c2)) result = c1 + c2;
return NULL;
if (!PointerIsValid(result = palloc(sizeof(Cash)))) PG_RETURN_CASH(result);
elog(ERROR, "Memory allocation failed, can't add cash"); }
*result = (*c1 + *c2);
return result;
} /* cash_pl() */
/* cash_mi() /* cash_mi()
* Subtract two cash values. * Subtract two cash values.
*/ */
Cash * Datum
cash_mi(Cash *c1, Cash *c2) cash_mi(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c1 = PG_GETARG_CASH(0);
Cash c2 = PG_GETARG_CASH(1);
Cash result;
if (!PointerIsValid(c1) || !PointerIsValid(c2)) result = c1 - c2;
return NULL;
if (!PointerIsValid(result = palloc(sizeof(Cash)))) PG_RETURN_CASH(result);
elog(ERROR, "Memory allocation failed, can't subtract cash"); }
*result = (*c1 - *c2);
return result;
} /* cash_mi() */
/* cash_mul_flt8() /* cash_mul_flt8()
@ -626,41 +615,32 @@ cash_div_int2(PG_FUNCTION_ARGS)
/* cashlarger() /* cashlarger()
* Return larger of two cash values. * Return larger of two cash values.
*/ */
Cash * Datum
cashlarger(Cash *c1, Cash *c2) cashlarger(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c1 = PG_GETARG_CASH(0);
Cash c2 = PG_GETARG_CASH(1);
Cash result;
if (!PointerIsValid(c1) || !PointerIsValid(c2)) result = (c1 > c2) ? c1 : c2;
return NULL;
if (!PointerIsValid(result = palloc(sizeof(Cash))))
elog(ERROR, "Memory allocation failed, can't return larger cash");
*result = ((*c1 > *c2) ? *c1 : *c2);
return result;
} /* cashlarger() */
PG_RETURN_CASH(result);
}
/* cashsmaller() /* cashsmaller()
* Return smaller of two cash values. * Return smaller of two cash values.
*/ */
Cash * Datum
cashsmaller(Cash *c1, Cash *c2) cashsmaller(PG_FUNCTION_ARGS)
{ {
Cash *result; Cash c1 = PG_GETARG_CASH(0);
Cash c2 = PG_GETARG_CASH(1);
Cash result;
if (!PointerIsValid(c1) || !PointerIsValid(c2)) result = (c1 < c2) ? c1 : c2;
return NULL;
if (!PointerIsValid(result = palloc(sizeof(Cash)))) PG_RETURN_CASH(result);
elog(ERROR, "Memory allocation failed, can't return smaller cash"); }
*result = ((*c1 < *c2) ? *c1 : *c2);
return result;
} /* cashsmaller() */
/* cash_words() /* cash_words()

View File

@ -12,11 +12,13 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.28 2000/04/12 17:15:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.29 2000/08/03 16:34:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres.h" #include "postgres.h"
#include "miscadmin.h"
#include "utils/builtins.h" #include "utils/builtins.h"
/***************************************************************************** /*****************************************************************************
@ -31,14 +33,13 @@
* [Old] Currently if strlen(s) < NAMEDATALEN, the extra chars are nulls * [Old] Currently if strlen(s) < NAMEDATALEN, the extra chars are nulls
* Now, always NULL terminated * Now, always NULL terminated
*/ */
NameData * Datum
namein(const char *s) namein(PG_FUNCTION_ARGS)
{ {
char *s = PG_GETARG_CSTRING(0);
NameData *result; NameData *result;
int len; int len;
if (s == NULL)
return NULL;
result = (NameData *) palloc(NAMEDATALEN); result = (NameData *) palloc(NAMEDATALEN);
/* always keep it null-padded */ /* always keep it null-padded */
StrNCpy(NameStr(*result), s, NAMEDATALEN); StrNCpy(NameStr(*result), s, NAMEDATALEN);
@ -48,19 +49,18 @@ namein(const char *s)
*(NameStr(*result) + len) = '\0'; *(NameStr(*result) + len) = '\0';
len++; len++;
} }
return result; PG_RETURN_NAME(result);
} }
/* /*
* nameout - converts internal reprsentation to "..." * nameout - converts internal representation to "..."
*/ */
char * Datum
nameout(const NameData *s) nameout(PG_FUNCTION_ARGS)
{ {
if (s == NULL) Name s = PG_GETARG_NAME(0);
return "-";
else PG_RETURN_CSTRING(pstrdup(NameStr(*s)));
return pstrdup(NameStr(*s));
} }
@ -82,57 +82,67 @@ nameout(const NameData *s)
* namege - returns 1 iff a <= b * namege - returns 1 iff a <= b
* *
*/ */
bool Datum
nameeq(const NameData *arg1, const NameData *arg2) nameeq(PG_FUNCTION_ARGS)
{ {
if (!arg1 || !arg2) Name arg1 = PG_GETARG_NAME(0);
return 0; Name arg2 = PG_GETARG_NAME(1);
else
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) == 0); PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) == 0);
} }
bool Datum
namene(const NameData *arg1, const NameData *arg2) namene(PG_FUNCTION_ARGS)
{ {
if (arg1 == NULL || arg2 == NULL) Name arg1 = PG_GETARG_NAME(0);
return (bool) 0; Name arg2 = PG_GETARG_NAME(1);
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) != 0);
PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) != 0);
} }
bool Datum
namelt(const NameData *arg1, const NameData *arg2) namelt(PG_FUNCTION_ARGS)
{ {
if (arg1 == NULL || arg2 == NULL) Name arg1 = PG_GETARG_NAME(0);
return (bool) 0; Name arg2 = PG_GETARG_NAME(1);
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) < 0);
PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) < 0);
} }
bool Datum
namele(const NameData *arg1, const NameData *arg2) namele(PG_FUNCTION_ARGS)
{ {
if (arg1 == NULL || arg2 == NULL) Name arg1 = PG_GETARG_NAME(0);
return (bool) 0; Name arg2 = PG_GETARG_NAME(1);
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) <= 0);
PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) <= 0);
} }
bool Datum
namegt(const NameData *arg1, const NameData *arg2) namegt(PG_FUNCTION_ARGS)
{ {
if (arg1 == NULL || arg2 == NULL) Name arg1 = PG_GETARG_NAME(0);
return (bool) 0; Name arg2 = PG_GETARG_NAME(1);
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) > 0); PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) > 0);
} }
bool Datum
namege(const NameData *arg1, const NameData *arg2) namege(PG_FUNCTION_ARGS)
{ {
if (arg1 == NULL || arg2 == NULL) Name arg1 = PG_GETARG_NAME(0);
return (bool) 0; Name arg2 = PG_GETARG_NAME(1);
return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) >= 0); PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) >= 0);
} }
/* SQL-function interface to GetPgUserName() */
Datum
getpgusername(PG_FUNCTION_ARGS)
{
PG_RETURN_DATUM(DirectFunctionCall1(namein,
CStringGetDatum(GetPgUserName())));
}
/* (see char.c for comparison/operation routines) */ /* (see char.c for comparison/operation routines) */

View File

@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.77 2000/08/03 00:58:22 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.78 2000/08/03 16:34:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1889,7 +1889,8 @@ string_lessthan(const char *str1, const char *str2, Oid datatype)
break; break;
case NAMEOID: case NAMEOID:
result = namelt((NameData *) datum1, (NameData *) datum2); result = DatumGetBool(DirectFunctionCall2(namelt,
datum1, datum2));
break; break;
default: default:
@ -1933,7 +1934,7 @@ string_to_datum(const char *str, Oid datatype)
* varchar constants too... * varchar constants too...
*/ */
if (datatype == NAMEOID) if (datatype == NAMEOID)
return PointerGetDatum(namein((char *) str)); return DirectFunctionCall1(namein, CStringGetDatum(str));
else else
return DirectFunctionCall1(textin, CStringGetDatum(str)); return DirectFunctionCall1(textin, CStringGetDatum(str));
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.21 2000/07/05 23:11:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.22 2000/08/03 16:34:23 tgl Exp $
* *
* NOTES * NOTES
* input routine largely stolen from boxin(). * input routine largely stolen from boxin().
@ -21,6 +21,11 @@
#include "access/heapam.h" #include "access/heapam.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#define DatumGetItemPointer(X) ((ItemPointer) DatumGetPointer(X))
#define ItemPointerGetDatum(X) PointerGetDatum(X)
#define PG_GETARG_ITEMPOINTER(n) DatumGetItemPointer(PG_GETARG_DATUM(n))
#define PG_RETURN_ITEMPOINTER(x) return ItemPointerGetDatum(x)
#define LDELIM '(' #define LDELIM '('
#define RDELIM ')' #define RDELIM ')'
#define DELIM ',' #define DELIM ','
@ -30,30 +35,23 @@
* tidin * tidin
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
ItemPointer Datum
tidin(const char *str) tidin(PG_FUNCTION_ARGS)
{ {
const char *p, char *str = PG_GETARG_CSTRING(0);
char *p,
*coord[NTIDARGS]; *coord[NTIDARGS];
int i; int i;
ItemPointer result; ItemPointer result;
BlockNumber blockNumber; BlockNumber blockNumber;
OffsetNumber offsetNumber; OffsetNumber offsetNumber;
if (str == NULL)
return NULL;
for (i = 0, p = str; *p && i < NTIDARGS && *p != RDELIM; p++) for (i = 0, p = str; *p && i < NTIDARGS && *p != RDELIM; p++)
if (*p == DELIM || (*p == LDELIM && !i)) if (*p == DELIM || (*p == LDELIM && !i))
coord[i++] = p + 1; coord[i++] = p + 1;
/* if (i < NTIDARGS - 1) */
if (i < NTIDARGS) if (i < NTIDARGS)
{ elog(ERROR, "invalid tid format: '%s'", str);
elog(ERROR, "%s invalid tid format", str);
return NULL;
}
blockNumber = (BlockNumber) atoi(coord[0]); blockNumber = (BlockNumber) atoi(coord[0]);
offsetNumber = (OffsetNumber) atoi(coord[1]); offsetNumber = (OffsetNumber) atoi(coord[1]);
@ -62,67 +60,61 @@ tidin(const char *str)
ItemPointerSet(result, blockNumber, offsetNumber); ItemPointerSet(result, blockNumber, offsetNumber);
return result; PG_RETURN_ITEMPOINTER(result);
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* tidout * tidout
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
char * Datum
tidout(ItemPointer itemPtr) tidout(PG_FUNCTION_ARGS)
{ {
ItemPointer itemPtr = PG_GETARG_ITEMPOINTER(0);
BlockId blockId;
BlockNumber blockNumber; BlockNumber blockNumber;
OffsetNumber offsetNumber; OffsetNumber offsetNumber;
BlockId blockId;
char buf[32]; char buf[32];
char *str;
static char *invalidTid = "()"; static char *invalidTid = "()";
if (!itemPtr || !ItemPointerIsValid(itemPtr)) if (!ItemPointerIsValid(itemPtr))
{ PG_RETURN_CSTRING(pstrdup(invalidTid));
str = palloc(strlen(invalidTid));
strcpy(str, invalidTid);
return str;
}
blockId = &(itemPtr->ip_blkid); blockId = &(itemPtr->ip_blkid);
blockNumber = BlockIdGetBlockNumber(blockId); blockNumber = BlockIdGetBlockNumber(blockId);
offsetNumber = itemPtr->ip_posid; offsetNumber = itemPtr->ip_posid;
sprintf(buf, "(%d,%d)", blockNumber, offsetNumber); sprintf(buf, "(%d,%d)", (int) blockNumber, (int) offsetNumber);
str = (char *) palloc(strlen(buf) + 1); PG_RETURN_CSTRING(pstrdup(buf));
strcpy(str, buf);
return str;
} }
/***************************************************************************** /*****************************************************************************
* PUBLIC ROUTINES * * PUBLIC ROUTINES *
*****************************************************************************/ *****************************************************************************/
bool Datum
tideq(ItemPointer arg1, ItemPointer arg2) tideq(PG_FUNCTION_ARGS)
{ {
if ((!arg1) || (!arg2)) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
return false; ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) == PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
BlockIdGetBlockNumber(&(arg2->ip_blkid)) && BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
arg1->ip_posid == arg2->ip_posid); arg1->ip_posid == arg2->ip_posid);
} }
#ifdef NOT_USED #ifdef NOT_USED
bool Datum
tidne(ItemPointer arg1, ItemPointer arg2) tidne(PG_FUNCTION_ARGS)
{ {
if ((!arg1) || (!arg2)) ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
return false; ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
BlockIdGetBlockNumber(&(arg2->ip_blkid)) || PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
arg1->ip_posid != arg2->ip_posid); BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
arg1->ip_posid != arg2->ip_posid);
} }
#endif #endif
@ -135,7 +127,7 @@ Datum
currtid_byreloid(PG_FUNCTION_ARGS) currtid_byreloid(PG_FUNCTION_ARGS)
{ {
Oid reloid = PG_GETARG_OID(0); Oid reloid = PG_GETARG_OID(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1); ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result, ItemPointer result,
ret; ret;
Relation rel; Relation rel;
@ -152,14 +144,14 @@ currtid_byreloid(PG_FUNCTION_ARGS)
else else
elog(ERROR, "Relation %u not found", reloid); elog(ERROR, "Relation %u not found", reloid);
PG_RETURN_POINTER(result); PG_RETURN_ITEMPOINTER(result);
} }
Datum Datum
currtid_byrelname(PG_FUNCTION_ARGS) currtid_byrelname(PG_FUNCTION_ARGS)
{ {
text *relname = PG_GETARG_TEXT_P(0); text *relname = PG_GETARG_TEXT_P(0);
ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1); ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result, ItemPointer result,
ret; ret;
char *str; char *str;
@ -182,5 +174,5 @@ currtid_byrelname(PG_FUNCTION_ARGS)
pfree(str); pfree(str);
PG_RETURN_POINTER(result); PG_RETURN_ITEMPOINTER(result);
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.52 2000/07/14 16:41:44 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.53 2000/08/03 16:34:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -277,20 +277,16 @@ convertstr(unsigned char *buff, int len, int dest)
* *
* SetPgUserName must be called before InitPostgres, since the setuid() * SetPgUserName must be called before InitPostgres, since the setuid()
* is done there. * is done there.
*
* Replace GetPgUserName() with a lower-case version
* to allow use in new case-insensitive SQL (referenced
* in pg_proc.h). Define GetPgUserName() as a macro - tgl 97/04/26
* ---------------- * ----------------
*/ */
char * char *
getpgusername() GetPgUserName(void)
{ {
return UserName; return UserName;
} }
void void
SetPgUserName() SetPgUserName(void)
{ {
#ifndef NO_SECURITY #ifndef NO_SECURITY
char *p; char *p;

View File

@ -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: pg_proc.h,v 1.155 2000/08/01 18:29:30 tgl Exp $ * $Id: pg_proc.h,v 1.156 2000/08/03 16:34:31 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
@ -109,9 +109,9 @@ DATA(insert OID = 1245 ( charin PGUID 12 f t t t 1 f 18 "0" 100 0 0 100 ch
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - )); DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 34 ( namein PGUID 11 f t t t 1 f 19 "0" 100 0 0 100 namein - )); DATA(insert OID = 34 ( namein PGUID 12 f t t t 1 f 19 "0" 100 0 0 100 namein - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 35 ( nameout PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 nameout - )); DATA(insert OID = 35 ( nameout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 nameout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - )); DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - ));
DESCR("(internal)"); DESCR("(internal)");
@ -133,9 +133,9 @@ DATA(insert OID = 46 ( textin PGUID 12 f t t t 1 f 25 "0" 100 0 0 100 te
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - )); DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 48 ( tidin PGUID 11 f t t t 1 f 27 "0" 100 0 0 100 tidin - )); DATA(insert OID = 48 ( tidin PGUID 12 f t t t 1 f 27 "0" 100 0 0 100 tidin - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 49 ( tidout PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 tidout - )); DATA(insert OID = 49 ( tidout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 tidout - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - )); DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - ));
DESCR("(internal)"); DESCR("(internal)");
@ -157,7 +157,7 @@ DATA(insert OID = 60 ( booleq PGUID 12 f t t t 2 f 16 "16 16" 100 0 0 100
DESCR("equal"); DESCR("equal");
DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - )); DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 62 ( nameeq PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - )); DATA(insert OID = 62 ( nameeq PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 nameeq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - )); DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - ));
DESCR("equal"); DESCR("equal");
@ -896,15 +896,15 @@ DATA(insert OID = 1287 ( int44in PGUID 12 f t t t 1 f 22 "0" 100 0 0 100 i
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - )); DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 655 ( namelt PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - )); DATA(insert OID = 655 ( namelt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namelt - ));
DESCR("less-than"); DESCR("less-than");
DATA(insert OID = 656 ( namele PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namele - )); DATA(insert OID = 656 ( namele PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namele - ));
DESCR("less-than-or-equal"); DESCR("less-than-or-equal");
DATA(insert OID = 657 ( namegt PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - )); DATA(insert OID = 657 ( namegt PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namegt - ));
DESCR("greater-than"); DESCR("greater-than");
DATA(insert OID = 658 ( namege PGUID 11 f t t t 2 f 16 "19 19" 100 0 0 100 namege - )); DATA(insert OID = 658 ( namege PGUID 12 f t t t 2 f 16 "19 19" 100 0 0 100 namege - ));
DESCR("greater-than-or-equal"); 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 12 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 12 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 - ));
@ -928,7 +928,7 @@ DATA(insert OID = 681 ( oidvectorgt PGUID 12 f t t t 2 f 16 "30 30" 100 0 0
DESCR("greater-than"); DESCR("greater-than");
/* OIDS 700 - 799 */ /* OIDS 700 - 799 */
DATA(insert OID = 710 ( getpgusername PGUID 11 f t f t 0 f 19 "0" 100 0 0 100 getpgusername - )); DATA(insert OID = 710 ( getpgusername PGUID 12 f t f t 0 f 19 "0" 100 0 0 100 getpgusername - ));
DESCR("Return username"); DESCR("Return username");
DATA(insert OID = 711 ( userfntest PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 userfntest - )); DATA(insert OID = 711 ( userfntest PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 userfntest - ));
DESCR(""); DESCR("");
@ -1108,35 +1108,35 @@ DESCR("multiply");
DATA(insert OID = 867 ( cash_div_int2 PGUID 12 f t t t 2 f 790 "790 21" 100 0 0 100 cash_div_int2 - )); DATA(insert OID = 867 ( cash_div_int2 PGUID 12 f t t t 2 f 790 "790 21" 100 0 0 100 cash_div_int2 - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 886 ( cash_in PGUID 11 f t t t 1 f 790 "0" 100 0 0 100 cash_in - )); DATA(insert OID = 886 ( cash_in PGUID 12 f t t t 1 f 790 "0" 100 0 0 100 cash_in - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 887 ( cash_out PGUID 11 f t t t 1 f 23 "0" 100 0 0 100 cash_out - )); DATA(insert OID = 887 ( cash_out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 cash_out - ));
DESCR("(internal)"); DESCR("(internal)");
DATA(insert OID = 1273 ( cash_words PGUID 12 f t t t 1 f 25 "790" 100 0 0 100 cash_words - )); DATA(insert OID = 1273 ( cash_words PGUID 12 f t t t 1 f 25 "790" 100 0 0 100 cash_words - ));
DESCR("output amount as words"); DESCR("output amount as words");
DATA(insert OID = 888 ( cash_eq PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_eq - )); DATA(insert OID = 888 ( cash_eq PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_eq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 889 ( cash_ne PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_ne - )); DATA(insert OID = 889 ( cash_ne PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_ne - ));
DESCR("not equal"); DESCR("not equal");
DATA(insert OID = 890 ( cash_lt PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_lt - )); DATA(insert OID = 890 ( cash_lt PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_lt - ));
DESCR("less-than"); DESCR("less-than");
DATA(insert OID = 891 ( cash_le PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_le - )); DATA(insert OID = 891 ( cash_le PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_le - ));
DESCR("less-than-or-equal"); DESCR("less-than-or-equal");
DATA(insert OID = 892 ( cash_gt PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_gt - )); DATA(insert OID = 892 ( cash_gt PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_gt - ));
DESCR("greater-than"); DESCR("greater-than");
DATA(insert OID = 893 ( cash_ge PGUID 11 f t t t 2 f 16 "790 790" 100 0 0 100 cash_ge - )); DATA(insert OID = 893 ( cash_ge PGUID 12 f t t t 2 f 16 "790 790" 100 0 0 100 cash_ge - ));
DESCR("greater-than-or-equal"); DESCR("greater-than-or-equal");
DATA(insert OID = 894 ( cash_pl PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100 cash_pl - )); DATA(insert OID = 894 ( cash_pl PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cash_pl - ));
DESCR("add"); DESCR("add");
DATA(insert OID = 895 ( cash_mi PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100 cash_mi - )); DATA(insert OID = 895 ( cash_mi PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cash_mi - ));
DESCR("subtract"); DESCR("subtract");
DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - )); DATA(insert OID = 896 ( cash_mul_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_mul_flt8 - ));
DESCR("multiply"); DESCR("multiply");
DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - )); DATA(insert OID = 897 ( cash_div_flt8 PGUID 12 f t t t 2 f 790 "790 701" 100 0 0 100 cash_div_flt8 - ));
DESCR("divide"); DESCR("divide");
DATA(insert OID = 898 ( cashlarger PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100 cashlarger - )); DATA(insert OID = 898 ( cashlarger PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cashlarger - ));
DESCR("larger of two"); DESCR("larger of two");
DATA(insert OID = 899 ( cashsmaller PGUID 11 f t t t 2 f 790 "790 790" 100 0 0 100 cashsmaller - )); DATA(insert OID = 899 ( cashsmaller PGUID 12 f t t t 2 f 790 "790 790" 100 0 0 100 cashsmaller - ));
DESCR("smaller of two"); DESCR("smaller of two");
DATA(insert OID = 919 ( flt8_mul_cash PGUID 12 f t t t 2 f 790 "701 790" 100 0 0 100 flt8_mul_cash - )); DATA(insert OID = 919 ( flt8_mul_cash PGUID 12 f t t t 2 f 790 "701 790" 100 0 0 100 flt8_mul_cash - ));
@ -1520,7 +1520,7 @@ DESCR("adjust char()[] to typmod length");
DATA(insert OID = 1291 ( _varchar PGUID 12 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("adjust varchar()[] to typmod length"); 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 12 f t f t 2 f 16 "27 27" 100 0 0 100 tideq - ));
DESCR("equal"); DESCR("equal");
DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - )); DATA(insert OID = 1293 ( currtid PGUID 12 f t f t 2 f 27 "26 27" 100 0 0 100 currtid_byreloid - ));
DESCR("latest tid of a tuple"); DESCR("latest tid of a tuple");

View File

@ -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.63 2000/07/09 13:14:13 petere Exp $ * $Id: miscadmin.h,v 1.64 2000/08/03 16:34:43 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
@ -129,16 +129,13 @@ 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);
extern char *getpgusername(void); extern char *GetPgUserName(void);
extern void SetPgUserName(void); extern void SetPgUserName(void);
extern int GetUserId(void); extern int GetUserId(void);
extern void SetUserId(void); extern void SetUserId(void);
extern int FindExec(char *full_path, const char *argv0, const char *binary_name); extern int FindExec(char *full_path, const char *argv0, const char *binary_name);
extern int CheckPathAccess(char *path, char *name, int open_mode); extern int CheckPathAccess(char *path, char *name, int open_mode);
/* lower case version for case-insensitive SQL referenced in pg_proc.h */
#define GetPgUserName() getpgusername()
/***************************************************************************** /*****************************************************************************
* pmod.h -- * * pmod.h -- *
* POSTGRES processing mode definitions. * * POSTGRES processing mode definitions. *

View File

@ -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.128 2000/08/01 18:29:31 tgl Exp $ * $Id: builtins.h,v 1.129 2000/08/03 16:34:50 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -128,14 +128,15 @@ extern Datum int4larger(PG_FUNCTION_ARGS);
extern Datum int4smaller(PG_FUNCTION_ARGS); extern Datum int4smaller(PG_FUNCTION_ARGS);
/* name.c */ /* name.c */
extern NameData *namein(const char *s); extern Datum namein(PG_FUNCTION_ARGS);
extern char *nameout(const NameData *s); extern Datum nameout(PG_FUNCTION_ARGS);
extern bool nameeq(const NameData *arg1, const NameData *arg2); extern Datum nameeq(PG_FUNCTION_ARGS);
extern bool namene(const NameData *arg1, const NameData *arg2); extern Datum namene(PG_FUNCTION_ARGS);
extern bool namelt(const NameData *arg1, const NameData *arg2); extern Datum namelt(PG_FUNCTION_ARGS);
extern bool namele(const NameData *arg1, const NameData *arg2); extern Datum namele(PG_FUNCTION_ARGS);
extern bool namegt(const NameData *arg1, const NameData *arg2); extern Datum namegt(PG_FUNCTION_ARGS);
extern bool namege(const NameData *arg1, const NameData *arg2); extern Datum namege(PG_FUNCTION_ARGS);
extern Datum getpgusername(PG_FUNCTION_ARGS);
extern int namecpy(Name n1, Name n2); extern int namecpy(Name n1, Name n2);
extern int namestrcpy(Name name, const char *str); extern int namestrcpy(Name name, const char *str);
extern int namestrcmp(Name name, const char *str); extern int namestrcmp(Name name, const char *str);
@ -357,9 +358,9 @@ extern Pattern_Prefix_Status pattern_fixed_prefix(char *patt,
extern char *make_greater_string(const char *str, Oid datatype); extern char *make_greater_string(const char *str, Oid datatype);
/* tid.c */ /* tid.c */
extern ItemPointer tidin(const char *str); extern Datum tidin(PG_FUNCTION_ARGS);
extern char *tidout(ItemPointer itemPtr); extern Datum tidout(PG_FUNCTION_ARGS);
extern bool tideq(ItemPointer, ItemPointer); extern Datum tideq(PG_FUNCTION_ARGS);
extern Datum currtid_byreloid(PG_FUNCTION_ARGS); extern Datum currtid_byreloid(PG_FUNCTION_ARGS);
extern Datum currtid_byrelname(PG_FUNCTION_ARGS); extern Datum currtid_byrelname(PG_FUNCTION_ARGS);

View File

@ -12,18 +12,18 @@
/* if we store this as 4 bytes, we better make it int, not long, bjm */ /* if we store this as 4 bytes, we better make it int, not long, bjm */
typedef signed int Cash; typedef signed int Cash;
extern const char *cash_out(Cash *value); extern Datum cash_in(PG_FUNCTION_ARGS);
extern Cash *cash_in(const char *str); extern Datum cash_out(PG_FUNCTION_ARGS);
extern bool cash_eq(Cash *c1, Cash *c2); extern Datum cash_eq(PG_FUNCTION_ARGS);
extern bool cash_ne(Cash *c1, Cash *c2); extern Datum cash_ne(PG_FUNCTION_ARGS);
extern bool cash_lt(Cash *c1, Cash *c2); extern Datum cash_lt(PG_FUNCTION_ARGS);
extern bool cash_le(Cash *c1, Cash *c2); extern Datum cash_le(PG_FUNCTION_ARGS);
extern bool cash_gt(Cash *c1, Cash *c2); extern Datum cash_gt(PG_FUNCTION_ARGS);
extern bool cash_ge(Cash *c1, Cash *c2); extern Datum cash_ge(PG_FUNCTION_ARGS);
extern Cash *cash_pl(Cash *c1, Cash *c2); extern Datum cash_pl(PG_FUNCTION_ARGS);
extern Cash *cash_mi(Cash *c1, Cash *c2); extern Datum cash_mi(PG_FUNCTION_ARGS);
extern Datum cash_mul_flt8(PG_FUNCTION_ARGS); extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
extern Datum cash_div_flt8(PG_FUNCTION_ARGS); extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
@ -41,8 +41,8 @@ extern Datum cash_mul_int2(PG_FUNCTION_ARGS);
extern Datum int2_mul_cash(PG_FUNCTION_ARGS); extern Datum int2_mul_cash(PG_FUNCTION_ARGS);
extern Datum cash_div_int2(PG_FUNCTION_ARGS); extern Datum cash_div_int2(PG_FUNCTION_ARGS);
extern Cash *cashlarger(Cash *c1, Cash *c2); extern Datum cashlarger(PG_FUNCTION_ARGS);
extern Cash *cashsmaller(Cash *c1, Cash *c2); extern Datum cashsmaller(PG_FUNCTION_ARGS);
extern Datum cash_words(PG_FUNCTION_ARGS); extern Datum cash_words(PG_FUNCTION_ARGS);

View File

@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.21 2000/07/05 23:11:58 tgl Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.22 2000/08/03 16:34:57 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
@ -145,7 +145,8 @@ plpgsql_compile(Oid fn_oid, int functype)
proc_source = DatumGetCString(DirectFunctionCall1(textout, proc_source = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&procStruct->prosrc))); PointerGetDatum(&procStruct->prosrc)));
plpgsql_setinput(proc_source, functype); plpgsql_setinput(proc_source, functype);
plpgsql_error_funcname = nameout(&(procStruct->proname)); plpgsql_error_funcname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(procStruct->proname))));
plpgsql_error_lineno = 0; plpgsql_error_lineno = 0;
/* ---------- /* ----------
@ -158,7 +159,8 @@ plpgsql_compile(Oid fn_oid, int functype)
function->fn_functype = functype; function->fn_functype = functype;
function->fn_oid = fn_oid; function->fn_oid = fn_oid;
function->fn_name = strdup(nameout(&(procStruct->proname))); function->fn_name = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(procStruct->proname))));
switch (functype) switch (functype)
{ {
@ -224,7 +226,9 @@ plpgsql_compile(Oid fn_oid, int functype)
* of that type * of that type
* ---------- * ----------
*/ */
sprintf(buf, "%s%%rowtype", nameout(&(typeStruct->typname))); sprintf(buf, "%s%%rowtype",
DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(typeStruct->typname)))));
if (plpgsql_parse_wordrowtype(buf) != T_ROW) if (plpgsql_parse_wordrowtype(buf) != T_ROW)
{ {
plpgsql_comperrinfo(); plpgsql_comperrinfo();
@ -256,7 +260,8 @@ plpgsql_compile(Oid fn_oid, int functype)
var->dtype = PLPGSQL_DTYPE_VAR; var->dtype = PLPGSQL_DTYPE_VAR;
var->refname = strdup(buf); var->refname = strdup(buf);
var->lineno = 0; var->lineno = 0;
var->datatype->typname = strdup(nameout(&(typeStruct->typname))); var->datatype->typname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(typeStruct->typname))));
var->datatype->typoid = procStruct->proargtypes[i]; var->datatype->typoid = procStruct->proargtypes[i];
fmgr_info(typeStruct->typinput, &(var->datatype->typinput)); fmgr_info(typeStruct->typinput, &(var->datatype->typinput));
var->datatype->typelem = typeStruct->typelem; var->datatype->typelem = typeStruct->typelem;
@ -619,7 +624,8 @@ plpgsql_parse_word(char *word)
typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type));
typ->typname = strdup(nameout(&(typeStruct->typname))); typ->typname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(typeStruct->typname))));
typ->typoid = typeTup->t_data->t_oid; typ->typoid = typeTup->t_data->t_oid;
fmgr_info(typeStruct->typinput, &(typ->typinput)); fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem; typ->typelem = typeStruct->typelem;
@ -943,7 +949,8 @@ plpgsql_parse_wordtype(char *word)
typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type));
typ->typname = strdup(nameout(&(typeStruct->typname))); typ->typname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(typeStruct->typname))));
typ->typoid = typeTup->t_data->t_oid; typ->typoid = typeTup->t_data->t_oid;
fmgr_info(typeStruct->typinput, &(typ->typinput)); fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem; typ->typelem = typeStruct->typelem;
@ -1088,7 +1095,8 @@ plpgsql_parse_dblwordtype(char *string)
typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type));
typ->typname = strdup(nameout(&(typeStruct->typname))); typ->typname = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(typeStruct->typname))));
typ->typoid = typetup->t_data->t_oid; typ->typoid = typetup->t_data->t_oid;
fmgr_info(typeStruct->typinput, &(typ->typinput)); fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem; typ->typelem = typeStruct->typelem;
@ -1187,19 +1195,19 @@ plpgsql_parse_wordrowtype(char *string)
} }
attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
cp = DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&(attrStruct->attname))));
typetup = SearchSysCacheTuple(TYPEOID, typetup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0); ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0);
if (!HeapTupleIsValid(typetup)) if (!HeapTupleIsValid(typetup))
{ {
plpgsql_comperrinfo(); plpgsql_comperrinfo();
elog(ERROR, "cache lookup for type %u of %s.%s failed", elog(ERROR, "cache lookup for type %u of %s.%s failed",
attrStruct->atttypid, word1, attrStruct->atttypid, word1, cp);
nameout(&(attrStruct->attname)));
} }
typeStruct = (Form_pg_type) GETSTRUCT(typetup); typeStruct = (Form_pg_type) GETSTRUCT(typetup);
cp = strdup(nameout(&(attrStruct->attname)));
/* ---------- /* ----------
* Create the internal variable * Create the internal variable
* We know if the table definitions contain a default value * We know if the table definitions contain a default value

View File

@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.25 2000/07/12 02:37:39 tgl Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.26 2000/08/03 16:34:57 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
@ -637,7 +637,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
*/ */
var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]); var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]);
var->isnull = false; var->isnull = false;
var->value = (Datum) namein(trigdata->tg_trigger->tgname); var->value = DirectFunctionCall1(namein,
CStringGetDatum(trigdata->tg_trigger->tgname));
var = (PLpgSQL_var *) (estate.datums[func->tg_when_varno]); var = (PLpgSQL_var *) (estate.datums[func->tg_when_varno]);
var->isnull = false; var->isnull = false;
@ -663,7 +664,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]); var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]);
var->isnull = false; var->isnull = false;
var->value = (Datum) namein(RelationGetRelationName(trigdata->tg_relation)); var->value = DirectFunctionCall1(namein,
CStringGetDatum(RelationGetRelationName(trigdata->tg_relation)));
var = (PLpgSQL_var *) (estate.datums[func->tg_nargs_varno]); var = (PLpgSQL_var *) (estate.datums[func->tg_nargs_varno]);
var->isnull = false; var->isnull = false;