TTOff = malloc(sizeof(char *));
else
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);
while (*s)
*d++ = tolower(*s++);
*
*
* 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
toastrel = heap_open(rel->rd_rel->reltoastrelid, RowExclusiveLock);
if (toastrel == NULL)
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;
toastidx = index_open(rel->rd_rel->reltoastidxid);
if (toastidx == NULL)
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
*
*
* 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
{
for (j = 0; j < (int) (sizeof(HeapAtt) / sizeof(HeapAtt[0])); j++)
{
- if (nameeq(&(HeapAtt[j]->attname),
- &(tupdesc->attrs[i]->attname)))
+ if (strcmp(NameStr(HeapAtt[j]->attname),
+ NameStr(tupdesc->attrs[i]->attname)) == 0)
{
elog(ERROR, "Attribute '%s' has a name conflict"
"\n\tName matches an existing system attribute",
{
for (j = 0; j < i; j++)
{
- if (nameeq(&(tupdesc->attrs[j]->attname),
- &(tupdesc->attrs[i]->attname)))
+ if (strcmp(NameStr(tupdesc->attrs[j]->attname),
+ NameStr(tupdesc->attrs[i]->attname)) == 0)
{
elog(ERROR, "Attribute '%s' is repeated",
NameStr(tupdesc->attrs[j]->attname));
ccsrc = deparse_expression(expr, lcons(lcons(rte, NIL), NIL), false);
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,
CStringGetDatum(ccbin));
values[Anum_pg_relcheck_rcsrc - 1] = DirectFunctionCall1(textin,
*
*
* 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
* The PerformAddAttribute() code, like most of the relation
*/
tuple = SearchSysCacheTuple(ATTNAME,
ObjectIdGetDatum(myrelid),
- NameGetDatum(namein((char *) colName)),
+ PointerGetDatum(colName),
0, 0);
if (!HeapTupleIsValid(tuple))
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
pg_database_dsc = RelationGetDescr(pg_database_rel);
/* 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_encoding - 1] = Int32GetDatum(encoding);
new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin,
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
if (!HeapTupleIsValid(tuple))
return NULL;
- return nameout(&((Form_pg_opclass) GETSTRUCT(tuple))->opcname);
+ return DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&((Form_pg_opclass) GETSTRUCT(tuple))->opcname)));
}
/*
rescnt = 0;
#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",
seqname, seqname);
#endif
int32 result;
#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",
seqname, seqname);
#endif
Form_pg_sequence seq;
#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",
seqname, seqname);
#endif
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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 $
*
*-------------------------------------------------------------------------
*/
MemSet(nulls, ' ', Natts_pg_trigger * sizeof(char));
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_tgtype - 1] = Int16GetDatum(tgtype);
values[Anum_pg_trigger_tgenabled - 1] = BoolGetDatum(true);
refrel = heap_open(pg_trigger->tgrelid, NoLock);
stmt.relname = pstrdup(RelationGetRelationName(refrel));
- stmt.trigname = nameout(&pg_trigger->tgname);
+ stmt.trigname = DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&pg_trigger->tgname)));
heap_close(refrel, NoLock);
build->tgoid = htup->t_data->t_oid;
build->tgname = MemoryContextStrdup(CacheMemoryContext,
- nameout(&pg_trigger->tgname));
+ DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&pg_trigger->tgname))));
build->tgfoid = pg_trigger->tgfoid;
build->tgfunc.fn_oid = InvalidOid; /* mark FmgrInfo as uninitialized */
build->tgtype = pg_trigger->tgtype;
}
elog(ERROR,
- "deferredTriggerGetPreviousEvent(): event for tuple %s not found",
- tidout(ctid));
+ "deferredTriggerGetPreviousEvent(): event for tuple %s not found",
+ DatumGetCString(DirectFunctionCall1(tidout, PointerGetDatum(ctid))));
return NULL;
}
TRIGGER_DEFERRED_ROW_INSERTED)
elog(ERROR, "triggered data change violation "
"on relation \"%s\"",
- nameout(&(rel->rd_rel->relname)));
+ DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(rel->rd_rel->relname)))));
if (prev_event->dte_item[i].dti_state &
TRIGGER_DEFERRED_KEY_CHANGED)
elog(ERROR, "triggered data change violation "
"on relation \"%s\"",
- nameout(&(rel->rd_rel->relname)));
+ DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(rel->rd_rel->relname)))));
}
/* ----------
if (prev_event->dte_event & TRIGGER_DEFERRED_KEY_CHANGED)
elog(ERROR, "triggered data change violation "
"on relation \"%s\"",
- nameout(&(rel->rd_rel->relname)));
+ DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(rel->rd_rel->relname)))));
break;
}
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
"%s"
CRYPT_PWD_FILE_SEPSTR
"%s\n",
- nameout(DatumGetName(datum_n)),
+ DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(DatumGetName(datum_n)))),
null_p ? "" :
DatumGetCString(DirectFunctionCall1(textout, datum_p)),
null_v ? "\\N" :
/*
* Build a tuple to insert
*/
- new_record[Anum_pg_shadow_usename - 1] = PointerGetDatum(namein(stmt->user)); /* this truncated
- * properly */
+ new_record[Anum_pg_shadow_usename - 1] = DirectFunctionCall1(namein,
+ CStringGetDatum(stmt->user));
new_record[Anum_pg_shadow_usesysid - 1] = Int32GetDatum(havesysid ? stmt->sysid : max_id + 1);
AssertState(BoolIsValid(stmt->createdb));
/*
* 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] = ' ';
/* sysid - leave as is */
datum = heap_getattr(tmp_tuple, Anum_pg_database_datname, pg_dsc, &null);
heap_close(pg_shadow_rel, AccessExclusiveLock);
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)" : ""
);
}
{
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);
-
- ags.name = nameout(DatumGetName(datum)); /* the group name from
- * which to try to drop
- * the user */
+ ags.name = DatumGetCString(DirectFunctionCall1(nameout, datum));
ags.action = -1;
ags.listUsers = lcons((void *) makeInteger(usesysid), NIL);
AlterGroup(&ags, "DROP USER");
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* varchar constants too...
*/
if (datatype == NAMEOID)
- return PointerGetDatum(namein((char *) str));
+ return DirectFunctionCall1(namein, CStringGetDatum(str));
else
return DirectFunctionCall1(textin, CStringGetDatum(str));
}
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
int pkattno = indexStruct->indkey[i];
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->isRel = false;
* workings can be found in the book "Software Solutions in C" by
* 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>
* XXX UNHACK Allow the currency symbol to be multi-byte.
* - thomas 1998-03-01
*/
-Cash *
-cash_in(const char *str)
+Datum
+cash_in(PG_FUNCTION_ARGS)
{
- Cash *result;
-
+ char *str = PG_GETARG_CSTRING(0);
+ Cash result;
Cash value = 0;
Cash dec = 0;
Cash sgn = 1;
if (*s != '\0')
elog(ERROR, "Bad money external representation %s", str);
- if (!PointerIsValid(result = palloc(sizeof(Cash))))
- elog(ERROR, "Memory allocation failed, can't input cash '%s'", str);
-
- *result = (value * sgn);
+ result = (value * sgn);
#ifdef CASHDEBUG
- printf("cashin- result is %d\n", *result);
+ printf("cashin- result is %d\n", result);
#endif
- return result;
-} /* cash_in() */
+ PG_RETURN_CASH(result);
+}
/* cash_out()
* XXX HACK This code appears to assume US conventions for
* positive-valued amounts. - tgl 97/04/14
*/
-const char *
-cash_out(Cash *in_value)
+Datum
+cash_out(PG_FUNCTION_ARGS)
{
- Cash value = *in_value;
+ Cash value = PG_GETARG_CASH(0);
char *result;
char buf[CASH_BUFSZ];
int minus = 0;
strcpy(result, buf + count);
}
- return result;
-} /* cash_out() */
+ PG_RETURN_CSTRING(result);
+}
-bool
-cash_eq(Cash *c1, Cash *c2)
+Datum
+cash_eq(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 == *c2;
-} /* cash_eq() */
+ PG_RETURN_BOOL(c1 == c2);
+}
-bool
-cash_ne(Cash *c1, Cash *c2)
+Datum
+cash_ne(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 != *c2;
-} /* cash_ne() */
+ PG_RETURN_BOOL(c1 != c2);
+}
-bool
-cash_lt(Cash *c1, Cash *c2)
+Datum
+cash_lt(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 < *c2;
-} /* cash_lt() */
+ PG_RETURN_BOOL(c1 < c2);
+}
-bool
-cash_le(Cash *c1, Cash *c2)
+Datum
+cash_le(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 <= *c2;
-} /* cash_le() */
+ PG_RETURN_BOOL(c1 <= c2);
+}
-bool
-cash_gt(Cash *c1, Cash *c2)
+Datum
+cash_gt(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 > *c2;
-} /* cash_gt() */
+ PG_RETURN_BOOL(c1 > c2);
+}
-bool
-cash_ge(Cash *c1, Cash *c2)
+Datum
+cash_ge(PG_FUNCTION_ARGS)
{
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return FALSE;
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
- return *c1 >= *c2;
-} /* cash_ge() */
+ PG_RETURN_BOOL(c1 >= c2);
+}
/* cash_pl()
* Add two cash values.
*/
-Cash *
-cash_pl(Cash *c1, Cash *c2)
+Datum
+cash_pl(PG_FUNCTION_ARGS)
{
- Cash *result;
-
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return NULL;
-
- if (!PointerIsValid(result = palloc(sizeof(Cash))))
- elog(ERROR, "Memory allocation failed, can't add cash");
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
+ Cash result;
- *result = (*c1 + *c2);
+ result = c1 + c2;
- return result;
-} /* cash_pl() */
+ PG_RETURN_CASH(result);
+}
/* cash_mi()
* Subtract two cash values.
*/
-Cash *
-cash_mi(Cash *c1, Cash *c2)
+Datum
+cash_mi(PG_FUNCTION_ARGS)
{
- Cash *result;
-
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return NULL;
-
- if (!PointerIsValid(result = palloc(sizeof(Cash))))
- elog(ERROR, "Memory allocation failed, can't subtract cash");
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
+ Cash result;
- *result = (*c1 - *c2);
+ result = c1 - c2;
- return result;
-} /* cash_mi() */
+ PG_RETURN_CASH(result);
+}
/* cash_mul_flt8()
/* cashlarger()
* Return larger of two cash values.
*/
-Cash *
-cashlarger(Cash *c1, Cash *c2)
+Datum
+cashlarger(PG_FUNCTION_ARGS)
{
- Cash *result;
-
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return NULL;
-
- if (!PointerIsValid(result = palloc(sizeof(Cash))))
- elog(ERROR, "Memory allocation failed, can't return larger cash");
-
- *result = ((*c1 > *c2) ? *c1 : *c2);
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
+ Cash result;
- return result;
-} /* cashlarger() */
+ result = (c1 > c2) ? c1 : c2;
+ PG_RETURN_CASH(result);
+}
/* cashsmaller()
* Return smaller of two cash values.
*/
-Cash *
-cashsmaller(Cash *c1, Cash *c2)
+Datum
+cashsmaller(PG_FUNCTION_ARGS)
{
- Cash *result;
-
- if (!PointerIsValid(c1) || !PointerIsValid(c2))
- return NULL;
-
- if (!PointerIsValid(result = palloc(sizeof(Cash))))
- elog(ERROR, "Memory allocation failed, can't return smaller cash");
+ Cash c1 = PG_GETARG_CASH(0);
+ Cash c2 = PG_GETARG_CASH(1);
+ Cash result;
- *result = ((*c1 < *c2) ? *c1 : *c2);
+ result = (c1 < c2) ? c1 : c2;
- return result;
-} /* cashsmaller() */
+ PG_RETURN_CASH(result);
+}
/* cash_words()
*
*
* 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 "miscadmin.h"
#include "utils/builtins.h"
/*****************************************************************************
* [Old] Currently if strlen(s) < NAMEDATALEN, the extra chars are nulls
* Now, always NULL terminated
*/
-NameData *
-namein(const char *s)
+Datum
+namein(PG_FUNCTION_ARGS)
{
+ char *s = PG_GETARG_CSTRING(0);
NameData *result;
int len;
- if (s == NULL)
- return NULL;
result = (NameData *) palloc(NAMEDATALEN);
/* always keep it null-padded */
StrNCpy(NameStr(*result), s, NAMEDATALEN);
*(NameStr(*result) + len) = '\0';
len++;
}
- return result;
+ PG_RETURN_NAME(result);
}
/*
- * nameout - converts internal reprsentation to "..."
+ * nameout - converts internal representation to "..."
*/
-char *
-nameout(const NameData *s)
+Datum
+nameout(PG_FUNCTION_ARGS)
{
- if (s == NULL)
- return "-";
- else
- return pstrdup(NameStr(*s));
+ Name s = PG_GETARG_NAME(0);
+
+ PG_RETURN_CSTRING(pstrdup(NameStr(*s)));
}
* namege - returns 1 iff a <= b
*
*/
-bool
-nameeq(const NameData *arg1, const NameData *arg2)
+Datum
+nameeq(PG_FUNCTION_ARGS)
{
- if (!arg1 || !arg2)
- return 0;
- else
- return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) == 0);
+ Name arg1 = PG_GETARG_NAME(0);
+ Name arg2 = PG_GETARG_NAME(1);
+
+ PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) == 0);
}
-bool
-namene(const NameData *arg1, const NameData *arg2)
+Datum
+namene(PG_FUNCTION_ARGS)
{
- if (arg1 == NULL || arg2 == NULL)
- return (bool) 0;
- return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) != 0);
+ Name arg1 = PG_GETARG_NAME(0);
+ Name arg2 = PG_GETARG_NAME(1);
+
+ PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) != 0);
}
-bool
-namelt(const NameData *arg1, const NameData *arg2)
+Datum
+namelt(PG_FUNCTION_ARGS)
{
- if (arg1 == NULL || arg2 == NULL)
- return (bool) 0;
- return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) < 0);
+ Name arg1 = PG_GETARG_NAME(0);
+ Name arg2 = PG_GETARG_NAME(1);
+
+ PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) < 0);
}
-bool
-namele(const NameData *arg1, const NameData *arg2)
+Datum
+namele(PG_FUNCTION_ARGS)
{
- if (arg1 == NULL || arg2 == NULL)
- return (bool) 0;
- return (bool) (strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) <= 0);
+ Name arg1 = PG_GETARG_NAME(0);
+ Name arg2 = PG_GETARG_NAME(1);
+
+ PG_RETURN_BOOL(strncmp(NameStr(*arg1), NameStr(*arg2), NAMEDATALEN) <= 0);
}
-bool
-namegt(const NameData *arg1, const NameData *arg2)
+Datum
+namegt(PG_FUNCTION_ARGS)
{
- if (arg1 == NULL || arg2 == NULL)
- return (bool) 0;
+ Name arg1 = PG_GETARG_NAME(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
-namege(const NameData *arg1, const NameData *arg2)
+Datum
+namege(PG_FUNCTION_ARGS)
{
- if (arg1 == NULL || arg2 == NULL)
- return (bool) 0;
+ Name arg1 = PG_GETARG_NAME(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) */
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
break;
case NAMEOID:
- result = namelt((NameData *) datum1, (NameData *) datum2);
+ result = DatumGetBool(DirectFunctionCall2(namelt,
+ datum1, datum2));
break;
default:
* varchar constants too...
*/
if (datatype == NAMEOID)
- return PointerGetDatum(namein((char *) str));
+ return DirectFunctionCall1(namein, CStringGetDatum(str));
else
return DirectFunctionCall1(textin, CStringGetDatum(str));
}
*
*
* 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
* input routine largely stolen from boxin().
#include "access/heapam.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 RDELIM ')'
#define DELIM ','
* tidin
* ----------------------------------------------------------------
*/
-ItemPointer
-tidin(const char *str)
+Datum
+tidin(PG_FUNCTION_ARGS)
{
- const char *p,
+ char *str = PG_GETARG_CSTRING(0);
+ char *p,
*coord[NTIDARGS];
int i;
ItemPointer result;
-
BlockNumber blockNumber;
OffsetNumber offsetNumber;
- if (str == NULL)
- return NULL;
-
for (i = 0, p = str; *p && i < NTIDARGS && *p != RDELIM; p++)
if (*p == DELIM || (*p == LDELIM && !i))
coord[i++] = p + 1;
- /* if (i < NTIDARGS - 1) */
if (i < NTIDARGS)
- {
- elog(ERROR, "%s invalid tid format", str);
- return NULL;
- }
+ elog(ERROR, "invalid tid format: '%s'", str);
blockNumber = (BlockNumber) atoi(coord[0]);
offsetNumber = (OffsetNumber) atoi(coord[1]);
ItemPointerSet(result, blockNumber, offsetNumber);
- return result;
+ PG_RETURN_ITEMPOINTER(result);
}
/* ----------------------------------------------------------------
* tidout
* ----------------------------------------------------------------
*/
-char *
-tidout(ItemPointer itemPtr)
+Datum
+tidout(PG_FUNCTION_ARGS)
{
+ ItemPointer itemPtr = PG_GETARG_ITEMPOINTER(0);
+ BlockId blockId;
BlockNumber blockNumber;
OffsetNumber offsetNumber;
- BlockId blockId;
char buf[32];
- char *str;
static char *invalidTid = "()";
- if (!itemPtr || !ItemPointerIsValid(itemPtr))
- {
- str = palloc(strlen(invalidTid));
- strcpy(str, invalidTid);
- return str;
- }
+ if (!ItemPointerIsValid(itemPtr))
+ PG_RETURN_CSTRING(pstrdup(invalidTid));
blockId = &(itemPtr->ip_blkid);
blockNumber = BlockIdGetBlockNumber(blockId);
offsetNumber = itemPtr->ip_posid;
- sprintf(buf, "(%d,%d)", blockNumber, offsetNumber);
-
- str = (char *) palloc(strlen(buf) + 1);
- strcpy(str, buf);
+ sprintf(buf, "(%d,%d)", (int) blockNumber, (int) offsetNumber);
- return str;
+ PG_RETURN_CSTRING(pstrdup(buf));
}
/*****************************************************************************
* PUBLIC ROUTINES *
*****************************************************************************/
-bool
-tideq(ItemPointer arg1, ItemPointer arg2)
+Datum
+tideq(PG_FUNCTION_ARGS)
{
- if ((!arg1) || (!arg2))
- return false;
+ ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+ ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
- return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
- BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
- arg1->ip_posid == arg2->ip_posid);
+ PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
+ BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
+ arg1->ip_posid == arg2->ip_posid);
}
#ifdef NOT_USED
-bool
-tidne(ItemPointer arg1, ItemPointer arg2)
+Datum
+tidne(PG_FUNCTION_ARGS)
{
- if ((!arg1) || (!arg2))
- return false;
- return (BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
- BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
- arg1->ip_posid != arg2->ip_posid);
+ ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+ ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+ PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
+ BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
+ arg1->ip_posid != arg2->ip_posid);
}
#endif
currtid_byreloid(PG_FUNCTION_ARGS)
{
Oid reloid = PG_GETARG_OID(0);
- ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
+ ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result,
ret;
Relation rel;
else
elog(ERROR, "Relation %u not found", reloid);
- PG_RETURN_POINTER(result);
+ PG_RETURN_ITEMPOINTER(result);
}
Datum
currtid_byrelname(PG_FUNCTION_ARGS)
{
text *relname = PG_GETARG_TEXT_P(0);
- ItemPointer tid = (ItemPointer) PG_GETARG_POINTER(1);
+ ItemPointer tid = PG_GETARG_ITEMPOINTER(1);
ItemPointer result,
ret;
char *str;
pfree(str);
- PG_RETURN_POINTER(result);
+ PG_RETURN_ITEMPOINTER(result);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*
* SetPgUserName must be called before InitPostgres, since the setuid()
* 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 *
-getpgusername()
+GetPgUserName(void)
{
return UserName;
}
void
-SetPgUserName()
+SetPgUserName(void)
{
#ifndef NO_SECURITY
char *p;
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* The script catalog/genbki.sh reads this file and generates .bki
DESCR("(internal)");
DATA(insert OID = 33 ( charout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 charout - ));
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)");
-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)");
DATA(insert OID = 38 ( int2in PGUID 12 f t t t 1 f 21 "0" 100 0 0 100 int2in - ));
DESCR("(internal)");
DESCR("(internal)");
DATA(insert OID = 47 ( textout PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 textout - ));
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)");
-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)");
DATA(insert OID = 50 ( xidin PGUID 12 f t t t 1 f 28 "0" 100 0 0 100 xidin - ));
DESCR("(internal)");
DESCR("equal");
DATA(insert OID = 61 ( chareq PGUID 12 f t t t 2 f 16 "18 18" 100 0 0 100 chareq - ));
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");
DATA(insert OID = 63 ( int2eq PGUID 12 f t t t 2 f 16 "21 21" 100 0 0 100 int2eq - ));
DESCR("equal");
DESCR("(internal)");
DATA(insert OID = 653 ( int44out PGUID 12 f t t t 1 f 23 "0" 100 0 0 100 int44out - ));
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");
-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");
-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");
-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");
-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");
DATA(insert OID = 668 ( bpchar PGUID 12 f t t t 2 f 1042 "1042 23" 100 0 0 100 bpchar - ));
DESCR("greater-than");
/* 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");
DATA(insert OID = 711 ( userfntest PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 userfntest - ));
DESCR("");
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");
-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)");
-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)");
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");
-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");
-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");
-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");
-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");
-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");
-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");
-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");
-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");
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");
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");
-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");
-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");
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 = 1291 ( _varchar PGUID 12 f t t t 2 f 1015 "1015 23" 100 0 0 100 _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 12 f t f t 2 f 16 "27 27" 100 0 0 100 tideq - ));
DESCR("equal");
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");
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* some of the information in this file will be moved to
extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path);
-extern char *getpgusername(void);
+extern char *GetPgUserName(void);
extern void SetPgUserName(void);
extern int GetUserId(void);
extern void SetUserId(void);
extern int FindExec(char *full_path, const char *argv0, const char *binary_name);
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 -- *
* POSTGRES processing mode definitions. *
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
extern Datum int4smaller(PG_FUNCTION_ARGS);
/* name.c */
-extern NameData *namein(const char *s);
-extern char *nameout(const NameData *s);
-extern bool nameeq(const NameData *arg1, const NameData *arg2);
-extern bool namene(const NameData *arg1, const NameData *arg2);
-extern bool namelt(const NameData *arg1, const NameData *arg2);
-extern bool namele(const NameData *arg1, const NameData *arg2);
-extern bool namegt(const NameData *arg1, const NameData *arg2);
-extern bool namege(const NameData *arg1, const NameData *arg2);
+extern Datum namein(PG_FUNCTION_ARGS);
+extern Datum nameout(PG_FUNCTION_ARGS);
+extern Datum nameeq(PG_FUNCTION_ARGS);
+extern Datum namene(PG_FUNCTION_ARGS);
+extern Datum namelt(PG_FUNCTION_ARGS);
+extern Datum namele(PG_FUNCTION_ARGS);
+extern Datum namegt(PG_FUNCTION_ARGS);
+extern Datum namege(PG_FUNCTION_ARGS);
+extern Datum getpgusername(PG_FUNCTION_ARGS);
extern int namecpy(Name n1, Name n2);
extern int namestrcpy(Name name, const char *str);
extern int namestrcmp(Name name, const char *str);
extern char *make_greater_string(const char *str, Oid datatype);
/* tid.c */
-extern ItemPointer tidin(const char *str);
-extern char *tidout(ItemPointer itemPtr);
-extern bool tideq(ItemPointer, ItemPointer);
+extern Datum tidin(PG_FUNCTION_ARGS);
+extern Datum tidout(PG_FUNCTION_ARGS);
+extern Datum tideq(PG_FUNCTION_ARGS);
extern Datum currtid_byreloid(PG_FUNCTION_ARGS);
extern Datum currtid_byrelname(PG_FUNCTION_ARGS);
/* if we store this as 4 bytes, we better make it int, not long, bjm */
typedef signed int Cash;
-extern const char *cash_out(Cash *value);
-extern Cash *cash_in(const char *str);
+extern Datum cash_in(PG_FUNCTION_ARGS);
+extern Datum cash_out(PG_FUNCTION_ARGS);
-extern bool cash_eq(Cash *c1, Cash *c2);
-extern bool cash_ne(Cash *c1, Cash *c2);
-extern bool cash_lt(Cash *c1, Cash *c2);
-extern bool cash_le(Cash *c1, Cash *c2);
-extern bool cash_gt(Cash *c1, Cash *c2);
-extern bool cash_ge(Cash *c1, Cash *c2);
+extern Datum cash_eq(PG_FUNCTION_ARGS);
+extern Datum cash_ne(PG_FUNCTION_ARGS);
+extern Datum cash_lt(PG_FUNCTION_ARGS);
+extern Datum cash_le(PG_FUNCTION_ARGS);
+extern Datum cash_gt(PG_FUNCTION_ARGS);
+extern Datum cash_ge(PG_FUNCTION_ARGS);
-extern Cash *cash_pl(Cash *c1, Cash *c2);
-extern Cash *cash_mi(Cash *c1, Cash *c2);
+extern Datum cash_pl(PG_FUNCTION_ARGS);
+extern Datum cash_mi(PG_FUNCTION_ARGS);
extern Datum cash_mul_flt8(PG_FUNCTION_ARGS);
extern Datum cash_div_flt8(PG_FUNCTION_ARGS);
extern Datum int2_mul_cash(PG_FUNCTION_ARGS);
extern Datum cash_div_int2(PG_FUNCTION_ARGS);
-extern Cash *cashlarger(Cash *c1, Cash *c2);
-extern Cash *cashsmaller(Cash *c1, Cash *c2);
+extern Datum cashlarger(PG_FUNCTION_ARGS);
+extern Datum cashsmaller(PG_FUNCTION_ARGS);
extern Datum cash_words(PG_FUNCTION_ARGS);
* procedural language
*
* 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.
*
proc_source = DatumGetCString(DirectFunctionCall1(textout,
PointerGetDatum(&procStruct->prosrc)));
plpgsql_setinput(proc_source, functype);
- plpgsql_error_funcname = nameout(&(procStruct->proname));
+ plpgsql_error_funcname = DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(procStruct->proname))));
plpgsql_error_lineno = 0;
/* ----------
function->fn_functype = functype;
function->fn_oid = fn_oid;
- function->fn_name = strdup(nameout(&(procStruct->proname)));
+ function->fn_name = DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(procStruct->proname))));
switch (functype)
{
* 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)
{
plpgsql_comperrinfo();
var->dtype = PLPGSQL_DTYPE_VAR;
var->refname = strdup(buf);
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];
fmgr_info(typeStruct->typinput, &(var->datatype->typinput));
var->datatype->typelem = typeStruct->typelem;
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;
fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem;
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;
fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem;
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;
fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->typelem = typeStruct->typelem;
}
attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
+ cp = DatumGetCString(DirectFunctionCall1(nameout,
+ NameGetDatum(&(attrStruct->attname))));
+
typetup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0);
if (!HeapTupleIsValid(typetup))
{
plpgsql_comperrinfo();
elog(ERROR, "cache lookup for type %u of %s.%s failed",
- attrStruct->atttypid, word1,
- nameout(&(attrStruct->attname)));
+ attrStruct->atttypid, word1, cp);
}
typeStruct = (Form_pg_type) GETSTRUCT(typetup);
- cp = strdup(nameout(&(attrStruct->attname)));
-
/* ----------
* Create the internal variable
* We know if the table definitions contain a default value
* procedural language
*
* 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.
*
*/
var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]);
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->isnull = false;
var = (PLpgSQL_var *) (estate.datums[func->tg_relname_varno]);
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->isnull = false;