*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.21 2000/01/10 16:13:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.22 2000/01/10 17:14:28 momjian Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
int i;
uint32 result = 0;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < INDEX_MAX_KEYS; i++)
result = result ^ (~(uint32) key[i]);
return result;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.29 2000/01/10 16:13:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.30 2000/01/10 17:14:29 momjian Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
{
int i;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < INDEX_MAX_KEYS; i++)
/* we use this because we need the int4gt, etc */
if (!int4eq(a[i], b[i]))
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.26 1999/11/22 17:55:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.27 2000/01/10 17:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Oid xret1 = InvalidOid;
Oid xret2 = InvalidOid;
Oid fret = InvalidOid;
- Oid fnArgs[8];
+ Oid fnArgs[FUNC_MAX_ARGS];
NameData aname;
TupleDesc tupDesc;
- MemSet(fnArgs, 0, 8 * sizeof(Oid));
+ MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
/* sanity checks */
if (!aggName)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.46 2000/01/05 18:23:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.47 2000/01/10 17:14:31 momjian Exp $
*
* NOTES
* these routines moved here from commands/define.c and somewhat cleaned up.
bool rightDefined = false;
bool selfCommutator = false;
char *name[4];
- Oid typeId[8];
+ Oid typeId[FUNC_MAX_ARGS];
int nargs;
NameData oname;
TupleDesc tupDesc;
* have to worry about deleting them later.
* ----------------
*/
- MemSet(typeId, 0, 8 * sizeof(Oid));
+ MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
if (!leftTypeName)
{
typeId[0] = rightTypeId;
*/
if (restrictionName)
{ /* optional */
- MemSet(typeId, 0, 8 * sizeof(Oid));
+ MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
typeId[0] = OIDOID; /* operator OID */
typeId[1] = OIDOID; /* relation OID */
typeId[2] = INT2OID; /* attribute number */
*/
if (joinName)
{ /* optional */
- MemSet(typeId, 0, 8 * sizeof(Oid));
+ MemSet(typeId, 0, FUNC_MAX_ARGS * sizeof(Oid));
typeId[0] = OIDOID; /* operator OID */
typeId[1] = OIDOID; /* relation OID 1 */
typeId[2] = INT2OID; /* attribute number 1 */
setheapoverride(true);
heap_update(pg_operator_desc, &tup->t_self, tup, NULL);
setheapoverride(false);
-
+
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
Relation idescs[Num_pg_operator_indices];
-
+
CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
CatalogCloseIndices(Num_pg_operator_indices, idescs);
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
Relation idescs[Num_pg_operator_indices];
-
+
CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
CatalogCloseIndices(Num_pg_operator_indices, idescs);
if (RelationGetForm(pg_operator_desc)->relhasindex)
{
Relation idescs[Num_pg_operator_indices];
-
+
CatalogOpenIndices(Num_pg_operator_indices, Name_pg_operator_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_operator_indices, pg_operator_desc, tup);
CatalogCloseIndices(Num_pg_operator_indices, idescs);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.36 1999/11/22 17:55:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.37 2000/01/10 17:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
List *x;
List *querytree_list;
List *plan_list;
- Oid typev[8];
+ Oid typev[FUNC_MAX_ARGS];
Oid relid;
Oid toid;
NameData procname;
Assert(PointerIsValid(probin));
parameterCount = 0;
- MemSet(typev, 0, 8 * sizeof(Oid));
+ MemSet(typev, 0, FUNC_MAX_ARGS * sizeof(Oid));
foreach(x, argList)
{
Value *t = lfirst(x);
- if (parameterCount == 8)
- elog(ERROR, "Procedures cannot take more than 8 arguments");
+ if (parameterCount == FUNC_MAX_ARGS)
+ elog(ERROR, "Procedures cannot take more than %d arguments",FUNC_MAX_ARGS);
if (strcmp(strVal(t), "opaque") == 0)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.44 1999/12/16 22:19:39 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.45 2000/01/10 17:14:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool defined;
NameData name;
TupleDesc tupDesc;
- Oid argList[8];
+ Oid argList[FUNC_MAX_ARGS];
static ScanKeyData typeKey[1] = {
{0, Anum_pg_type_typname, F_NAMEEQ}
* First look for a 1-argument func with all argtypes 0. This is
* valid for all four kinds of procedure.
*/
- MemSet(argList, 0, 8 * sizeof(Oid));
+ MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
tup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(procname),
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.7 1999/07/16 04:58:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.8 2000/01/10 17:14:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
j;
parameterCount = 0;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < FUNC_MAX_ARGS; i++)
typev[i] = 0;
for (j = 0; j < elem->inTypes->num; j++)
{
- if (parameterCount == 8)
+ if (parameterCount == FUNC_MAX_ARGS)
{
elog(ERROR,
- "getParamTypes: Ingredients cannot take > 8 arguments");
+ "getParamTypes: Ingredients cannot take > %d arguments",FUNC_MAX_ARGS);
}
t = elem->inTypes->val[j];
if (strcmp(t, "opaque") == 0)
{
TgElement *elem;
char *funcName;
- Oid typev[8], /* eight arguments maximum */
+ Oid typev[FUNC_MAX_ARGS], /* eight arguments maximum */
relid;
int i,
parameterCount;
/*-------------------------------------------------------------------------
*
* comment.c
- *
+ *
* PostgreSQL object comments utility code.
*
* Copyright (c) 1999, PostgreSQL Global Development Group
/*------------------------------------------------------------------
* Static Function Prototypes --
- *
- * The following protoypes are declared static so as not to conflict
- * with any other routines outside this module. These routines are
- * called by the public function CommentObject() routine to create
+ *
+ * The following protoypes are declared static so as not to conflict
+ * with any other routines outside this module. These routines are
+ * called by the public function CommentObject() routine to create
* the appropriate comment for the specific object type.
*------------------------------------------------------------------
*/
/*------------------------------------------------------------------
* CommentObject --
*
- * This routine is used to add the associated comment into
- * pg_description for the object specified by the paramters handed
- * to this routine. If the routine cannot determine an Oid to
- * associated with the parameters handed to this routine, an
+ * This routine is used to add the associated comment into
+ * pg_description for the object specified by the paramters handed
+ * to this routine. If the routine cannot determine an Oid to
+ * associated with the parameters handed to this routine, an
* error is thrown. Otherwise the comment is added to pg_description
* by calling the CreateComments() routine. If the comments were
* empty, CreateComments() will drop any comments associated with
*------------------------------------------------------------------
*/
-void CommentObject(int objtype, char *objname, char *objproperty,
+void CommentObject(int objtype, char *objname, char *objproperty,
List *objlist, char *comment) {
-
+
switch (objtype) {
case (INDEX):
case (SEQUENCE):
break;
default:
elog(ERROR, "An attempt was made to comment on a unkown type: %i",
- objtype);
+ objtype);
}
}
/*------------------------------------------------------------------
* CreateComments --
- *
+ *
* This routine is handed the oid and the command associated
- * with that id and will insert, update, or delete (if the
+ * with that id and will insert, update, or delete (if the
* comment is an empty string or a NULL pointer) the associated
- * comment from the system cataloge, pg_description.
+ * comment from the system cataloge, pg_description.
*
*------------------------------------------------------------------
*/
}
/*** Now, open pg_description and attempt to find the old tuple ***/
-
+
ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
ObjectIdGetDatum(oid));
scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
/*** If a previous tuple exists, either delete or prep replacement ***/
if (HeapTupleIsValid(searchtuple)) {
-
+
/*** If the comment is blank, call heap_delete, else heap_update ***/
if ((comment == NULL) || (strlen(comment) == 0)) {
heap_delete(description, &searchtuple->t_self, NULL);
} else {
- desctuple = heap_modifytuple(searchtuple, description, values,
- nulls, replaces);
+ desctuple = heap_modifytuple(searchtuple, description, values,
+ nulls, replaces);
setheapoverride(true);
heap_update(description, &searchtuple->t_self, desctuple, NULL);
setheapoverride(false);
modified = TRUE;
}
- } else {
+ } else {
desctuple = heap_formtuple(tupDesc, values, nulls);
heap_insert(description, desctuple);
modified = TRUE;
/*** Complete the scan, update indices, if necessary ***/
heap_endscan(scan);
-
+
if (modified) {
if (RelationGetForm(description)->relhasindex) {
Relation idescs[Num_pg_description_indices];
-
- CatalogOpenIndices(Num_pg_description_indices,
+
+ CatalogOpenIndices(Num_pg_description_indices,
Name_pg_description_indices, idescs);
- CatalogIndexInsert(idescs, Num_pg_description_indices, description,
+ CatalogIndexInsert(idescs, Num_pg_description_indices, description,
desctuple);
CatalogCloseIndices(Num_pg_description_indices, idescs);
}
}
-/*------------------------------------------------------------------
+/*------------------------------------------------------------------
* DeleteComments --
*
- * This routine is used to purge any comments
+ * This routine is used to purge any comments
* associated with the Oid handed to this routine,
* regardless of the actual object type. It is
* called, for example, when a relation is destroyed.
tupDesc = description->rd_att;
/*** Now, open pg_description and attempt to find the old tuple ***/
-
+
ScanKeyEntryInitialize(&entry, 0x0, Anum_pg_description_objoid, F_OIDEQ,
ObjectIdGetDatum(oid));
scan = heap_beginscan(description, false, SnapshotNow, 1, &entry);
/*** If a previous tuple exists, delete it ***/
- if (HeapTupleIsValid(searchtuple)) {
+ if (HeapTupleIsValid(searchtuple)) {
heap_delete(description, &searchtuple->t_self, NULL);
- }
-
+ }
+
/*** Complete the scan, update indices, if necessary ***/
heap_endscan(scan);
heap_close(description, RowExclusiveLock);
-
+
}
-
+
/*------------------------------------------------------------------
* CommentRelation --
*
- * This routine is used to add/drop a comment from a relation, where
+ * This routine is used to add/drop a comment from a relation, where
* a relation is a TABLE, SEQUENCE, VIEW or INDEX. The routine simply
- * finds the relation name by searching the system cache, locating
- * the appropriate tuple, and inserting a comment using that
+ * finds the relation name by searching the system cache, locating
+ * the appropriate tuple, and inserting a comment using that
* tuple's oid. Its parameters are the relation name and comments.
*------------------------------------------------------------------
*/
}
break;
}
-
+
/*** Create the comments using the tuple's oid ***/
- CreateComments(oid, comment);
+ CreateComments(oid, comment);
}
* CommentAttribute --
*
* This routine is used to add/drop a comment from an attribute
- * such as a table's column. The routine will check security
+ * such as a table's column. The routine will check security
* restrictions and then attempt to fetch the oid of the associated
* attribute. If successful, a comment is added/dropped, else an
* elog() exception is thrown. The parameters are the relation
- * and attribute names, and the comments
+ * and attribute names, and the comments
*------------------------------------------------------------------
*/
elog(ERROR, "you are not permitted to comment on class '%s\'", relname);
}
#endif
-
+
/*** Now, fetch the attribute oid from the system cache ***/
- relation = heap_openr(relname, AccessShareLock);
+ relation = heap_openr(relname, AccessShareLock);
attrtuple = SearchSysCacheTuple(ATTNAME, ObjectIdGetDatum(relation->rd_id),
PointerGetDatum(attrname), 0, 0);
if (!HeapTupleIsValid(attrtuple)) {
attrname, relname);
}
oid = attrtuple->t_data->t_oid;
-
+
/*** Call CreateComments() to create/drop the comments ***/
CreateComments(oid, comment);
/*** Now, close the heap relation and return ***/
- heap_close(relation, AccessShareLock);
+ heap_close(relation, AccessShareLock);
}
* CommentDatabase --
*
* This routine is used to add/drop any user-comments a user might
- * have regarding the specified database. The routine will check
- * security for owner permissions, and, if succesful, will then
- * attempt to find the oid of the database specified. Once found,
- * a comment is added/dropped using the CreateComments() routine.
+ * have regarding the specified database. The routine will check
+ * security for owner permissions, and, if succesful, will then
+ * attempt to find the oid of the database specified. Once found,
+ * a comment is added/dropped using the CreateComments() routine.
*------------------------------------------------------------------
*/
Oid oid;
bool superuser;
int4 dba, userid;
- char *username;
+ char *username;
/*** First find the tuple in pg_database for the database ***/
F_NAMEEQ, NameGetDatum(database));
scan = heap_beginscan(pg_database, 0, SnapshotNow, 1, &entry);
dbtuple = heap_getnext(scan, 0);
-
+
/*** Validate database exists, and fetch the dba id and oid ***/
if (!HeapTupleIsValid(dbtuple)) {
}
dba = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
oid = dbtuple->t_data->t_oid;
-
+
/*** Now, fetch user information ***/
-
+
username = GetPgUserName();
usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
0, 0, 0);
}
userid = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesysid;
superuser = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesuper;
-
+
/*** Allow if the userid matches the database dba or is a superuser ***/
-
+
#ifndef NO_SECURITY
if (!(superuser || (userid == dba))) {
elog(ERROR, "you are not permitted to comment on database '%s'",
#endif
/*** Create the comments with the pg_database oid ***/
-
+
CreateComments(oid, comment);
-
+
/*** Complete the scan and close any opened relations ***/
-
+
heap_endscan(scan);
heap_close(pg_database, AccessShareLock);
*
* This routine is used to add/drop any user-comments a user might
* have regarding a specified RULE. The rule is specified by name
- * and, if found, and the user has appropriate permissions, a
+ * and, if found, and the user has appropriate permissions, a
* comment will be added/dropped using the CreateComments() routine.
*------------------------------------------------------------------
*/
int aclcheck;
/*** First, validate user ***/
-
- #ifndef NO_SECURITY
+
+ #ifndef NO_SECURITY
user = GetPgUserName();
relation = RewriteGetRuleEventRel(rule);
aclcheck = pg_aclcheck(relation, user, ACL_RU);
#endif
/*** Next, find the rule's oid ***/
-
+
rewritetuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(rule),
0, 0, 0);
if (!HeapTupleIsValid(rewritetuple)) {
}
oid = rewritetuple->t_data->t_oid;
-
+
/*** Call CreateComments() to create/drop the comments ***/
CreateComments(oid, comment);
*
* This routine is used to add/drop any user-comments a user might
* have regarding a TYPE. The type is specified by name
- * and, if found, and the user has appropriate permissions, a
+ * and, if found, and the user has appropriate permissions, a
* comment will be added/dropped using the CreateComments() routine.
* The type's name and the comments are the paramters to this routine.
*------------------------------------------------------------------
char *user;
/*** First, validate user ***/
-
- #ifndef NO_SECURITY
+
+ #ifndef NO_SECURITY
user = GetPgUserName();
- if (!pg_ownercheck(user, type, TYPENAME)) {
+ if (!pg_ownercheck(user, type, TYPENAME)) {
elog(ERROR, "you are not permitted to comment on type '%s'",
type);
}
#endif
/*** Next, find the type's oid ***/
-
+
typetuple = SearchSysCacheTuple(TYPENAME, PointerGetDatum(type),
0, 0, 0);
if (!HeapTupleIsValid(typetuple)) {
}
oid = typetuple->t_data->t_oid;
-
+
/*** Call CreateComments() to create/drop the comments ***/
CreateComments(oid, comment);
/*------------------------------------------------------------------
* CommentAggregate --
*
- * This routine is used to allow a user to provide comments on an
+ * This routine is used to allow a user to provide comments on an
* aggregate function. The aggregate function is determined by both
- * its name and its argument type, which, with the comments are
+ * its name and its argument type, which, with the comments are
* the three parameters handed to this routine.
*------------------------------------------------------------------
*/
void CommentAggregate(char *aggregate, char *argument, char *comment) {
-
+
HeapTuple aggtuple;
Oid baseoid, oid;
bool defined;
char *user;
-
+
/*** First, attempt to determine the base aggregate oid ***/
if (argument) {
} else {
baseoid = 0;
}
-
+
/*** Next, validate the user's attempt to comment ***/
#ifndef NO_SECURITY
elog(ERROR, "aggregate '%s' does not exist", aggregate);
}
}
-
+
oid = aggtuple->t_data->t_oid;
-
+
/*** Call CreateComments() to create/drop the comments ***/
CreateComments(oid, comment);
/*------------------------------------------------------------------
* CommentProc --
*
- * This routine is used to allow a user to provide comments on an
+ * This routine is used to allow a user to provide comments on an
* procedure (function). The procedure is determined by both
- * its name and its argument list. The argument list is expected to
+ * its name and its argument list. The argument list is expected to
* be a series of parsed nodes pointed to by a List object. If the
* comments string is empty, the associated comment is dropped.
*------------------------------------------------------------------
void CommentProc(char *function, List *arguments, char *comment) {
HeapTuple argtuple, functuple;
- Oid oid, argoids[8];
+ Oid oid, argoids[FUNC_MAX_ARGS];
char *user, *argument;
int i, argcount;
argcount = length(arguments);
if (argcount > 0) {
- MemSet(argoids, 0, 8 * sizeof(Oid));
+ MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = 0; i < argcount; i++) {
argument = strVal(lfirst(arguments));
arguments = lnext(arguments);
PointerGetDatum(argoids), 0);
/*** Deallocate our argument oids and check the function tuple ***/
-
+
if (!HeapTupleIsValid(functuple)) {
elog(ERROR, "function '%s' with the supplied %s does not exist",
function, "argument list");
}
-
+
oid = functuple->t_data->t_oid;
-
+
/*** Call CreateComments() to create/drop the comments ***/
CreateComments(oid, comment);
}
-
+
/*------------------------------------------------------------------
* CommentOperator --
*
- * This routine is used to allow a user to provide comments on an
+ * This routine is used to allow a user to provide comments on an
* operator. The operator for commenting is determined by both
* its name and its argument list which defines the left and right
- * hand types the operator will operate on. The argument list is
- * expected to be a couple of parse nodes pointed to be a List
- * object. If the comments string is empty, the associated comment
+ * hand types the operator will operate on. The argument list is
+ * expected to be a couple of parse nodes pointed to be a List
+ * object. If the comments string is empty, the associated comment
* is dropped.
*------------------------------------------------------------------
*/
if (lfirst(arguments) != NULL) {
lefttype = strVal(lfirst(arguments));
- }
+ }
if (lsecond(arguments) != NULL) {
righttype = strVal(lsecond(arguments));
}
elog(ERROR, "left type '%s' does not exist", lefttype);
}
}
-
+
/*** Attempt to fetch the right oid, if specified ***/
-
+
if (righttype != NULL) {
rightoid = TypeGet(righttype, &defined);
if (!OidIsValid(rightoid)) {
else if (OidIsValid(leftoid)) oprtype = 'l';
else if (OidIsValid(rightoid)) oprtype = 'r';
else elog(ERROR, "operator '%s' is of an illegal type'", opername);
-
+
/*** Attempt to fetch the operator oid ***/
optuple = SearchSysCacheTupleCopy(OPERNAME, PointerGetDatum(opername),
elog(ERROR, "operator '%s' does not exist", opername);
}
- oid = optuple->t_data->t_oid;
-
+ oid = optuple->t_data->t_oid;
+
/*** Valid user's ability to comment on this operator ***/
#ifndef NO_SECURITY
ScanKeyData entry;
Oid oid = InvalidOid;
char *user;
-
- /*** First, validate the user's action ***/
+
+ /*** First, validate the user's action ***/
#ifndef NO_SECURITY
user = GetPgUserName();
/*** Now, fetch the trigger oid from pg_trigger ***/
- relation = heap_openr(relname, AccessShareLock);
+ relation = heap_openr(relname, AccessShareLock);
pg_trigger = heap_openr(TriggerRelationName, AccessShareLock);
ScanKeyEntryInitialize(&entry, 0, Anum_pg_trigger_tgrelid,
- F_OIDEQ, RelationGetRelid(relation));
+ F_OIDEQ, RelationGetRelid(relation));
scan = heap_beginscan(pg_trigger, 0, SnapshotNow, 1, &entry);
triggertuple = heap_getnext(scan, 0);
while (HeapTupleIsValid(triggertuple)) {
}
/*** Create the comments with the pg_trigger oid ***/
-
+
CreateComments(oid, comment);
-
+
/*** Complete the scan and close any opened relations ***/
-
+
heap_endscan(scan);
heap_close(pg_trigger, AccessShareLock);
heap_close(relation, AccessShareLock);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.16 1999/12/16 22:19:41 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.17 2000/01/10 17:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
*opOidP = tuple->t_data->t_oid;
- MemSet(argTypes, 0, 8 * sizeof(Oid));
+ MemSet(argTypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
/*
* process the function arguments
HeapTuple langTup;
HeapTuple procTup;
- Oid typev[8];
+ Oid typev[FUNC_MAX_ARGS];
char nulls[Natts_pg_language];
Datum values[Natts_pg_language];
Relation rel;
CatalogIndexInsert(idescs, Num_pg_language_indices, rel, tup);
CatalogCloseIndices(Num_pg_language_indices, idescs);
}
-
+
heap_close(rel, RowExclusiveLock);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.42 1999/12/16 22:19:41 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.43 2000/01/10 17:14:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
DeleteComments(tup->t_data->t_oid);
heap_delete(rel, &tup->t_self, NULL);
-
+
}
heap_endscan(scan);
{
Relation relation;
HeapTuple tup;
- Oid argList[8];
+ Oid argList[FUNC_MAX_ARGS];
char *userName;
char *typename;
int i;
- MemSet(argList, 0, 8 * sizeof(Oid));
+ MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = 0; i < nargs; i++)
{
typename = strVal(lfirst(argNameList));
aggName);
}
}
-
+
/*** Remove any comments related to this aggregate ***/
DeleteComments(tup->t_data->t_oid);
CreateTrigger(CreateTrigStmt *stmt)
{
int16 tgtype;
- int16 tgattr[8] = {0};
+ int16 tgattr[FUNC_MAX_ARGS] = {0};
Datum values[Natts_pg_trigger];
char nulls[Natts_pg_trigger];
Relation rel;
Relation idescs[Num_pg_trigger_indices];
Relation ridescs[Num_pg_class_indices];
MemoryContext oldcxt;
- Oid fargtypes[8];
+ Oid fargtypes[FUNC_MAX_ARGS];
int found = 0;
int i;
char constrtrigname[NAMEDATALEN];
}
heap_endscan(tgscan);
- MemSet(fargtypes, 0, 8 * sizeof(Oid));
+ MemSet(fargtypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
tuple = SearchSysCacheTuple(PROCNAME,
PointerGetDatum(stmt->funcname),
Int32GetDatum(0),
heap_delete(tgrel, &tuple->t_self, NULL);
tgfound++;
-
+
}
else
found++;
/*** Delete any comments associated with this trigger ***/
DeleteComments(tup->t_data->t_oid);
-
+
heap_delete(tgrel, &tup->t_self, NULL);
}
build->tgdeferrable = pg_trigger->tgdeferrable;
build->tginitdeferred = pg_trigger->tginitdeferred;
build->tgnargs = pg_trigger->tgnargs;
- memcpy(build->tgattr, &(pg_trigger->tgattr), 8 * sizeof(int16));
+ memcpy(build->tgattr, &(pg_trigger->tgattr), FUNC_MAX_ARGS * sizeof(int16));
val = (struct varlena *) fastgetattr(&tuple,
Anum_pg_trigger_tgargs,
tgrel->rd_att, &isnull);
trigstate = (DeferredTriggerStatus)
palloc(sizeof(DeferredTriggerStatusData));
trigstate->dts_tgoid = tgoid;
- trigstate->dts_tgisdeferred =
+ trigstate->dts_tgisdeferred =
((itemstate & TRIGGER_DEFERRED_INITDEFERRED) != 0);
deftrig_trigstates = lappend(deftrig_trigstates, trigstate);
* Add a new trigger event to the queue.
* ----------
*/
-static void
+static void
deferredTriggerAddEvent(DeferredTriggerEvent event)
{
deftrig_events = lappend(deftrig_events, event);
if (previous->dte_event & TRIGGER_DEFERRED_CANCELED)
continue;
- if (ItemPointerGetBlockNumber(ctid) ==
+ if (ItemPointerGetBlockNumber(ctid) ==
ItemPointerGetBlockNumber(&(previous->dte_newctid)) &&
ItemPointerGetOffsetNumber(ctid) ==
ItemPointerGetOffsetNumber(&(previous->dte_newctid)))
return previous;
}
- elog(ERROR,
+ elog(ERROR,
"deferredTriggerGetPreviousEvent(): event for tuple %s not found",
tidout(ctid));
return NULL;
case TRIGGER_EVENT_INSERT:
SaveTriggerData.tg_trigtuple = &newtuple;
SaveTriggerData.tg_newtuple = NULL;
- SaveTriggerData.tg_trigger =
+ SaveTriggerData.tg_trigger =
rel->trigdesc->tg_after_row[TRIGGER_EVENT_INSERT][itemno];
break;
case TRIGGER_EVENT_UPDATE:
SaveTriggerData.tg_trigtuple = &oldtuple;
SaveTriggerData.tg_newtuple = &newtuple;
- SaveTriggerData.tg_trigger =
+ SaveTriggerData.tg_trigger =
rel->trigdesc->tg_after_row[TRIGGER_EVENT_UPDATE][itemno];
break;
case TRIGGER_EVENT_DELETE:
SaveTriggerData.tg_trigtuple = &oldtuple;
SaveTriggerData.tg_newtuple = NULL;
- SaveTriggerData.tg_trigger =
+ SaveTriggerData.tg_trigger =
rel->trigdesc->tg_after_row[TRIGGER_EVENT_DELETE][itemno];
break;
default:
- }
+ }
/* ----------
* Call the trigger and throw away an eventually returned
* ----------
*/
event = (DeferredTriggerEvent) lfirst(el);
- if (event->dte_event & (TRIGGER_DEFERRED_DONE |
+ if (event->dte_event & (TRIGGER_DEFERRED_DONE |
TRIGGER_DEFERRED_CANCELED))
continue;
-
+
/* ----------
* Check each trigger item in the event.
* ----------
* ----------
*/
if (immediate_only && deferredTriggerCheckState(
- event->dte_item[i].dti_tgoid,
+ event->dte_item[i].dti_tgoid,
event->dte_item[i].dti_state))
{
still_deferred_ones = true;
DeferredTriggerStatus stat;
if (deftrig_cxt != NULL)
- elog(FATAL,
+ elog(FATAL,
"DeferredTriggerBeginXact() called while inside transaction");
/* ----------
deftrig_all_isset = deftrig_dfl_all_isset;
deftrig_all_isdeferred = deftrig_dfl_all_isdeferred;
-
+
deftrig_trigstates = NIL;
foreach (l, deftrig_dfl_trigstates)
{
dflstat = (DeferredTriggerStatus) lfirst(l);
- stat = (DeferredTriggerStatus)
+ stat = (DeferredTriggerStatus)
palloc(sizeof(DeferredTriggerStatusData));
stat->dts_tgoid = dflstat->dts_tgoid;
*/
pg_trigger = (Form_pg_trigger) GETSTRUCT(&tuple);
if (stmt->deferred & !pg_trigger->tgdeferrable)
- elog(ERROR, "Constraint '%s' is not deferrable",
+ elog(ERROR, "Constraint '%s' is not deferrable",
(char *)lfirst(l));
constr_oid = tuple.t_data->t_oid;
state->dts_tgoid = (Oid) lfirst(l);
state->dts_tgisdeferred = stmt->deferred;
- deftrig_dfl_trigstates =
+ deftrig_dfl_trigstates =
lappend(deftrig_dfl_trigstates, state);
}
}
state->dts_tgoid = (Oid) lfirst(l);
state->dts_tgisdeferred = stmt->deferred;
- deftrig_trigstates =
+ deftrig_trigstates =
lappend(deftrig_trigstates, state);
}
}
TriggerData SaveTriggerData;
if (deftrig_cxt == NULL)
- elog(ERROR,
+ elog(ERROR,
"DeferredTriggerSaveEvent() called outside of transaction");
/* ----------
ItemPointerSetInvalid(&(newctid));
/* ----------
- * Create a new event
+ * Create a new event
* ----------
*/
oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
new_size = sizeof(DeferredTriggerEventData) +
ntriggers * sizeof(DeferredTriggerEventItem);
-
+
new_event = (DeferredTriggerEvent) palloc(new_size);
new_event->dte_event = event & TRIGGER_EVENT_OPMASK;
new_event->dte_relid = rel->rd_id;
for (i = 0; i < ntriggers; i++)
{
new_event->dte_item[i].dti_tgoid = triggers[i]->tgoid;
- new_event->dte_item[i].dti_state =
- ((triggers[i]->tgdeferrable) ?
+ new_event->dte_item[i].dti_state =
+ ((triggers[i]->tgdeferrable) ?
TRIGGER_DEFERRED_DEFERRABLE : 0) |
- ((triggers[i]->tginitdeferred) ?
+ ((triggers[i]->tginitdeferred) ?
TRIGGER_DEFERRED_INITDEFERRED : 0) |
((rel->trigdesc->n_before_row[event] > 0) ?
TRIGGER_DEFERRED_HAS_BEFORE : 0);
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
prev_event = NULL;
else
- prev_event =
+ prev_event =
deferredTriggerGetPreviousEvent(rel->rd_id, &oldctid);
/* ----------
case F_RI_FKEY_SETDEFAULT_UPD:
is_ri_trigger = true;
break;
-
+
default:
is_ri_trigger = false;
break;
CurrentTriggerData = &SaveTriggerData;
key_unchanged = RI_FKey_keyequal_upd();
CurrentTriggerData = NULL;
-
+
if (key_unchanged)
{
/* ----------
if (prev_event)
{
- if (prev_event->dte_event &
+ if (prev_event->dte_event &
TRIGGER_DEFERRED_ROW_INSERTED)
{
/* ----------
* So any key value is considered changed.
* ----------
*/
- new_event->dte_event |=
+ new_event->dte_event |=
TRIGGER_DEFERRED_ROW_INSERTED;
- new_event->dte_event |=
+ new_event->dte_event |=
TRIGGER_DEFERRED_KEY_CHANGED;
new_event->dte_item[i].dti_state |=
TRIGGER_DEFERRED_KEY_CHANGED;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.64 1999/11/12 06:39:34 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.65 2000/01/10 17:14:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool *isNull,
bool *isDone)
{
- Datum argV[MAXFMGRARGS];
+ Datum argV[FUNC_MAX_ARGS];
FunctionCachePtr fcache;
Func *funcNode = NULL;
Oper *operNode = NULL;
{
bool argDone;
- if (fcache->nargs > MAXFMGRARGS)
+ if (fcache->nargs > FUNC_MAX_ARGS)
elog(ERROR, "ExecMakeFunctionResult: too many arguments");
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.25 2000/01/05 18:23:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.26 2000/01/10 17:14:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int nargs)
{
char *retval; /* XXX - should be datum, maybe ? */
- char *arg[8];
+ char *arg[FUNC_MAX_ARGS];
int i;
/* ----------------
v,
f,
offsets;
- char *fields[8];
- PQArgBlock pqargs[7];
+ char *fields[FUNC_MAX_ARGS];
+ PQArgBlock pqargs[FUNC_MAX_ARGS];
int res;
char *pqres;
* parse q into fields
* ----------------
*/
- i = strparse(q, fields, &offsets, 8);
+ i = strparse(q, fields, &offsets, FUNC_MAX_ARGS);
printf("pqtest_PQfn: strparse returns %d fields\n", i); /* debug */
if (i == 0)
return -1;
* build a PQArgBlock
* ----------------
*/
- for (j = 1; j < i && j < 8; j++)
+ for (j = 1; j < i && j < FUNC_MAX_ARGS; j++)
{
k = j - 1;
v = atoi(fields[j]);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.26 1999/12/10 07:37:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.27 2000/01/10 17:14:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
HeapTuple ftup;
int i;
Type tp;
- Oid oid_array[MAXFARGS];
+ Oid oid_array[FUNC_MAX_ARGS];
/* run through argument list... */
for (i = 0; i < nargs; i++)
*/
else if (input_typeids[i] != UNKNOWNOID)
{
- MemSet(oid_array, 0, MAXFARGS * sizeof(Oid));
+ MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
oid_array[0] = input_typeids[i];
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.65 1999/12/16 22:19:48 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.66 2000/01/10 17:14:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Oid relid;
int nargs = length(fargs);
Func *funcnode;
- Oid oid_array[MAXFARGS];
+ Oid oid_array[FUNC_MAX_ARGS];
Oid *true_oid_array;
Node *retval;
bool retset;
* transform relation name arguments into varnodes of the appropriate
* form.
*/
- MemSet(oid_array, 0, MAXFARGS * sizeof(Oid));
+ MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
nargs = 0;
foreach(i, fargs)
refname);
#endif
}
-
+
relname = rte->relname;
vnum = refnameRangeTablePosn(pstate, rte->refname, NULL);
}
/* Most of the rest of the parser just assumes that functions do not
- * have more than MAXFARGS parameters. We have to test here to protect
+ * have more than FUNC_MAX_ARGS parameters. We have to test here to protect
* against array overruns, etc.
*/
- if (nargs >= MAXFARGS)
+ if (nargs >= FUNC_MAX_ARGS)
elog(ERROR, "Cannot pass more than %d arguments to a function",
- MAXFARGS);
+ FUNC_MAX_ARGS);
oid_array[nargs++] = toid;
}
current_candidate = (CandidateList)
palloc(sizeof(struct _CandidateList));
current_candidate->args = (Oid *)
- palloc(MAXFARGS * sizeof(Oid));
- MemSet(current_candidate->args, 0, MAXFARGS * sizeof(Oid));
+ palloc(FUNC_MAX_ARGS * sizeof(Oid));
+ MemSet(current_candidate->args, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = 0; i < nargs; i++)
current_candidate->args[i] = pgProcP->proargtypes[i];
{
Oid relid;
int i;
- InhPaths arginh[MAXFARGS];
+ InhPaths arginh[FUNC_MAX_ARGS];
- for (i = 0; i < MAXFARGS; i++)
+ for (i = 0; i < FUNC_MAX_ARGS; i++)
{
if (i < nargs)
{
Oid *oneres;
int i,
j;
- int cur[MAXFARGS];
+ int cur[FUNC_MAX_ARGS];
nanswers = 1;
for (i = 0; i < nargs; i++)
/* compute the cross product from right to left */
for (;;)
{
- oneres = (Oid *) palloc(MAXFARGS * sizeof(Oid));
- MemSet(oneres, 0, MAXFARGS * sizeof(Oid));
+ oneres = (Oid *) palloc(FUNC_MAX_ARGS * sizeof(Oid));
+ MemSet(oneres, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = nargs - 1; i >= 0 && cur[i] > arginh[i].nsupers; i--)
continue;
void
func_error(char *caller, char *funcname, int nargs, Oid *argtypes, char *msg)
{
- char p[(NAMEDATALEN + 2) * MAXFMGRARGS],
+ char p[(NAMEDATALEN + 2) * FUNC_MAX_ARGS],
*ptr;
int i;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.50 1999/12/10 07:37:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.51 2000/01/10 17:14:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
int32 attrtypmod)
{
char *funcname;
- Oid oid_array[MAXFARGS];
+ Oid oid_array[FUNC_MAX_ARGS];
HeapTuple ftup;
int i;
funcname = typeidTypeName(attrtype);
oid_array[0] = attrtype;
oid_array[1] = INT4OID;
- for (i = 2; i < MAXFARGS; i++)
+ for (i = 2; i < FUNC_MAX_ARGS; i++)
oid_array[i] = InvalidOid;
/* attempt to find with arguments exactly as specified... */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.32 2000/01/10 16:13:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.33 2000/01/10 17:14:37 momjian Exp $
*
* NOTES
* This cruft is the server side of PQfn.
/*
* This structure saves enough state so that one can avoid having to
* do catalog lookups over and over again. (Each RPC can require up
- * to MAXFMGRARGS+2 lookups, which is quite tedious.)
+ * to FUNC_MAX_ARGS+2 lookups, which is quite tedious.)
*
* The previous incarnation of this code just assumed that any argument
* of size <= 4 was by value; this is not correct. There is no cheap
{
Oid funcid;
int nargs;
- bool argbyval[MAXFMGRARGS];
- int32 arglen[MAXFMGRARGS]; /* signed (for varlena) */
+ bool argbyval[FUNC_MAX_ARGS];
+ int32 arglen[FUNC_MAX_ARGS]; /* signed (for varlena) */
bool retbyval;
int32 retlen; /* signed (for varlena) */
TransactionId xid;
int argsize;
int nargs;
int tmp;
- char *arg[8];
+ char *arg[FUNC_MAX_ARGS];
char *retval;
int i;
uint32 palloced;
* need to remember, so that we pfree() it after the call.
*/
palloced = 0x0;
- for (i = 0; i < 8; ++i)
+ for (i = 0; i < FUNC_MAX_ARGS; ++i)
{
if (i >= nargs)
arg[i] = (char *) NULL;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.48 2000/01/10 16:13:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.49 2000/01/10 17:14:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
HeapTuple typetup;
text *result;
int num;
- Oid *sp;
if (oidArray == NULL)
{
return result;
}
- result = (text *) palloc(NAMEDATALEN * 8 + 8 + VARHDRSZ);
+ result = (text *) palloc(NAMEDATALEN * FUNC_MAX_ARGS +
+ FUNC_MAX_ARGS + VARHDRSZ);
*VARDATA(result) = '\0';
- sp = oidArray;
- for (num = 8; num != 0; num--, sp++)
+ for (num = 0; num < FUNC_MAX_ARGS; num++)
{
- if (*sp != InvalidOid)
+ if (oidArray[num] != InvalidOid)
{
typetup = SearchSysCacheTuple(TYPEOID,
- ObjectIdGetDatum(*sp),
+ ObjectIdGetDatum(oidArray[num]),
0, 0, 0);
if (HeapTupleIsValid(typetup))
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.45 2000/01/09 00:26:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.46 2000/01/10 17:14:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
rtype = ((Form_pg_operator) GETSTRUCT(oprtuple))->oprright;
/* Convert the constant to a uniform comparison scale. */
- if (! convert_to_scale(value,
+ if (! convert_to_scale(value,
((flag & SEL_RIGHT) ? rtype : ltype),
&val))
{
* stats are out of date and return a default...
*/
*result = DEFAULT_INEQ_SEL;
- }
+ }
else if (val <= low || val >= high)
{
/* If given value is outside the statistical range, return a
/* See whether there is a registered type-conversion function,
* namely a procedure named "float8" with the right signature.
*/
- Oid oid_array[MAXFARGS];
+ Oid oid_array[FUNC_MAX_ARGS];
HeapTuple ftup;
- MemSet(oid_array, 0, MAXFARGS * sizeof(Oid));
+ MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid));
oid_array[0] = typid;
ftup = SearchSysCacheTuple(PROCNAME,
PointerGetDatum("float8"),
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.33 1999/11/22 17:56:33 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.34 2000/01/10 17:14:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
values.data[0] = arg0;
if (n_arguments > 1)
{
- if (n_arguments > MAXFMGRARGS)
+ if (n_arguments > FUNC_MAX_ARGS)
elog(ERROR, "fmgr_pl: function %u: too many arguments (%d > %d)",
- fmgr_pl_finfo->fn_oid, n_arguments, MAXFMGRARGS);
+ fmgr_pl_finfo->fn_oid, n_arguments, FUNC_MAX_ARGS);
va_start(pvar, arg0);
for (i = 1; i < n_arguments; i++)
values.data[i] = va_arg(pvar, char *);
values->data[6], values->data[7]);
break;
case 9:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8]);
+ break;
+ case 10:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9]);
+ break;
+ case 11:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10]);
+ break;
+ case 12:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10], values->data[11]);
+ break;
+ case 13:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10], values->data[11],
+ values->data[12]);
+ break;
+ case 14:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10], values->data[11],
+ values->data[12], values->data[13]);
+ break;
+ case 15:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10], values->data[11],
+ values->data[12], values->data[13],
+ values->data[14]);
+ break;
+ case 16:
+ returnValue = (*user_fn) (values->data[0], values->data[1],
+ values->data[2], values->data[3],
+ values->data[4], values->data[5],
+ values->data[6], values->data[7],
+ values->data[8], values->data[9],
+ values->data[10], values->data[11],
+ values->data[12], values->data[13],
+ values->data[14], values->data[15]);
+ break;
+ case 17:
/*
- * XXX Note that functions with >8 arguments can only be
+ * XXX Note that functions with >FUNC_MAX_ARGS arguments can only be
* called from inside the system, not from the user level,
- * since the catalogs only store 8 argument types for user
+ * since the catalogs only store FUNC_MAX_ARGS argument types for user
* type-checking!
*/
returnValue = (*user_fn) (values->data[0], values->data[1],
values->data[2], values->data[3],
values->data[4], values->data[5],
values->data[6], values->data[7],
- values->data[8]);
+ values->data[8], values->data[9],
+ values->data[10], values->data[11],
+ values->data[12], values->data[13],
+ values->data[14], values->data[15]);
break;
default:
elog(ERROR, "fmgr_c: function %u: too many arguments (%d > %d)",
- finfo->fn_oid, n_arguments, MAXFMGRARGS);
+ finfo->fn_oid, n_arguments, FUNC_MAX_ARGS);
break;
}
return returnValue;
fmgr_info(procedureId, &finfo);
pronargs = finfo.fn_nargs;
- if (pronargs > MAXFMGRARGS)
+ if (pronargs > FUNC_MAX_ARGS)
elog(ERROR, "fmgr: function %u: too many arguments (%d > %d)",
- procedureId, pronargs, MAXFMGRARGS);
+ procedureId, pronargs, FUNC_MAX_ARGS);
va_start(pvar, procedureId);
for (i = 0; i < pronargs; ++i)
va_start(pvar, finfo);
n_arguments = va_arg(pvar, int);
local_finfo->fn_nargs = n_arguments;
- if (n_arguments > MAXFMGRARGS)
+ if (n_arguments > FUNC_MAX_ARGS)
{
elog(ERROR, "fmgr_ptr: function %u: too many arguments (%d > %d)",
- func_id, n_arguments, MAXFMGRARGS);
+ func_id, n_arguments, FUNC_MAX_ARGS);
}
for (i = 0; i < n_arguments; ++i)
values.data[i] = va_arg(pvar, char *);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.130 2000/01/10 16:13:16 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.131 2000/01/10 17:14:40 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
#ifdef HAVE_GETOPT_LONG
fprintf(stderr,
-
+
" -a, --data-only dump out only the data, no schema\n"
" -c, --clean clean(drop) schema prior to create\n"
" -d, --insert-proper dump data as proper insert strings\n"
" -v, --verbose verbose\n"
" -x, --no-acl do not dump ACL's (grant/revoke)\n"
" -?, --help show this help message\n"
-
+
); /* fprintf */
#else
fprintf(stderr,
-
+
" -a dump out only the data, no schema\n"
" -c clean(drop) schema prior to create\n"
" -d dump data as proper insert strings\n"
" -v verbose\n"
" -x do not dump ACL's (grant/revoke)\n"
" -? show this help message\n"
-
+
); /* fprintf */
#endif
-
+
fprintf(stderr,
"\nIf dbname is not supplied, then the DATABASE environment variable value is used.\n\n");
{"verbose", no_argument, NULL, 'v'},
{"no-acl", no_argument, NULL, 'x'},
{"help", no_argument, NULL, '?'},
- };
+ };
int optindex;
#endif
"%s: The -z option(dump ACLs) is now the default, continuing.\n",
progname);
break;
- case '?':
+ case '?':
default:
usage(progname);
break;
progname);
exit(2);
}
-
+
/* open the output file */
if (filename == NULL)
g_fout = stdout;
free(fun[i].proname);
if (fun[i].usename)
free(fun[i].usename);
- for (a = 0; a < 8; ++a)
+ for (a = 0; a < FUNC_MAX_ARGS ; ++a)
if (fun[i].argtypes[a])
free(fun[i].argtypes[a]);
if (fun[i].prorettype)
free(tblinfo[i].typnames);
if (tblinfo[i].notnull)
free(tblinfo[i].notnull);
- if (tblinfo[i].primary_key)
- free(tblinfo[i].primary_key);
+ if (tblinfo[i].primary_key)
+ free(tblinfo[i].primary_key);
}
free(tblinfo);
}
else
tblinfo[i].check_expr = NULL;
- /* Get primary key */
- if (strcmp(PQgetvalue(res, i, i_relhasindex), "t")==0)
- {
- PGresult * res2;
- char str[INDEX_MAX_KEYS * NAMEDATALEN + 3] = "";
- int j;
+ /* Get primary key */
+ if (strcmp(PQgetvalue(res, i, i_relhasindex), "t")==0)
+ {
+ PGresult * res2;
+ char str[INDEX_MAX_KEYS * NAMEDATALEN + 3] = "";
+ int j;
resetPQExpBuffer(query);
appendPQExpBuffer(query,
- "SELECT a.attname "
- "FROM pg_index i, pg_class c, pg_attribute a "
- "WHERE i.indisprimary AND i.indrelid = %s "
- " AND i.indexrelid = c.oid AND a.attnum > 0 AND a.attrelid = c.oid "
- "ORDER BY a.attnum ",
- tblinfo[i].oid);
- res2 = PQexec(g_conn, query->data);
+ "SELECT a.attname "
+ "FROM pg_index i, pg_class c, pg_attribute a "
+ "WHERE i.indisprimary AND i.indrelid = %s "
+ " AND i.indexrelid = c.oid AND a.attnum > 0 AND a.attrelid = c.oid "
+ "ORDER BY a.attnum ",
+ tblinfo[i].oid);
+ res2 = PQexec(g_conn, query->data);
if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK)
{
fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY) failed. Explanation from backend: %s",
- PQerrorMessage(g_conn));
+ PQerrorMessage(g_conn));
exit_nicely(g_conn);
}
-
- for (j = 0; j < PQntuples(res2); j++)
- {
- if (strlen(str)>0)
- strcat(str, ", ");
- strcat(str, fmtId(PQgetvalue(res2, j, 0), force_quotes));
- }
-
- if (strlen(str)>0) {
- tblinfo[i].primary_key = strdup(str);
- if (tblinfo[i].primary_key == NULL) {
- perror("strdup");
- exit(1);
- }
- }
- else
- tblinfo[i].primary_key = NULL;
- }
- else
- tblinfo[i].primary_key = NULL;
+
+ for (j = 0; j < PQntuples(res2); j++)
+ {
+ if (strlen(str)>0)
+ strcat(str, ", ");
+ strcat(str, fmtId(PQgetvalue(res2, j, 0), force_quotes));
+ }
+
+ if (strlen(str)>0) {
+ tblinfo[i].primary_key = strdup(str);
+ if (tblinfo[i].primary_key == NULL) {
+ perror("strdup");
+ exit(1);
+ }
+ }
+ else
+ tblinfo[i].primary_key = NULL;
+ }
+ else
+ tblinfo[i].primary_key = NULL;
/* Get Triggers */
if (tblinfo[i].ntrig > 0)
*/
appendPQExpBuffer(query,
- "SELECT t1.relname as indexrelname, t2.relname as indrelname, "
+ "SELECT t1.relname as indexrelname, t2.relname as indrelname, "
"i.indproc, i.indkey, i.indclass, "
"a.amname as indamname, i.indisunique "
"from pg_index i, pg_class t1, pg_class t2, pg_am a "
tblinfo[i].check_expr[k]);
}
- /* PRIMARY KEY */
- if (tblinfo[i].primary_key) {
- if (actual_atts + tblinfo[i].ncheck > 0)
- appendPQExpBuffer(q, ",\n\t");
- appendPQExpBuffer(q, "PRIMARY KEY (%s)", tblinfo[i].primary_key);
- }
+ /* PRIMARY KEY */
+ if (tblinfo[i].primary_key) {
+ if (actual_atts + tblinfo[i].ncheck > 0)
+ appendPQExpBuffer(q, ",\n\t");
+ appendPQExpBuffer(q, "PRIMARY KEY (%s)", tblinfo[i].primary_key);
+ }
- appendPQExpBuffer(q, "\n)");
+ appendPQExpBuffer(q, "\n)");
if (numParents > 0)
{
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_dump.h,v 1.43 1999/12/27 15:42:44 momjian Exp $
+ * $Id: pg_dump.h,v 1.44 2000/01/10 17:14:40 momjian Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
char *proowner;
int lang;
int nargs;
- char *argtypes[8]; /* should be derived from obj/fmgr.h
+ char *argtypes[FUNC_MAX_ARGS]; /* should be derived from obj/fmgr.h
* instead of hardwired */
char *prorettype;
int retset; /* 1 if the function returns a set, 0
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: funcindex.h,v 1.7 1999/02/13 23:20:50 momjian Exp $
+ * $Id: funcindex.h,v 1.8 2000/01/10 17:14:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
typedef struct
{
int nargs;
- Oid arglist[8];
+ Oid arglist[FUNC_MAX_ARGS];
Oid procOid;
NameData funcName;
} FuncIndexInfo;
#define INDEXSCAN_PATCH
/*
- * Maximum number of columns in an index.
+ * Maximum number of columns in an index and maximum number of args
+ * to a function. They must be the same value.
*/
#define INDEX_MAX_KEYS 8
+#define FUNC_MAX_ARGS INDEX_MAX_KEYS
/*
* Enables debugging print statements in the date/time support routines.
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_func.h,v 1.20 1999/12/10 07:37:33 tgl Exp $
+ * $Id: parse_func.h,v 1.21 2000/01/10 17:14:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "parser/parse_node.h"
-
-#define MAXFARGS 8 /* max # args to a c or postquel function */
-
/*
* This structure is used to explore the inheritance hierarchy above
* nodes in the type tree in order to disambiguate among polymorphic
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.30 1999/11/16 04:14:03 momjian Exp $
+ * $Id: rel.h,v 1.31 2000/01/10 17:14:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool tgdeferrable;
bool tginitdeferred;
int16 tgnargs;
- int16 tgattr[8];
+ int16 tgattr[FUNC_MAX_ARGS];
char **tgargs;
} Trigger;
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.14 1999/12/20 01:41:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.15 2000/01/10 17:14:45 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
PLpgSQL_row *row;
PLpgSQL_rec *rec;
int i;
- int arg_varnos[MAXFMGRARGS];
+ int arg_varnos[FUNC_MAX_ARGS];
/* ----------
* Initialize the compiler
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.4 1999/07/17 20:18:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.5 2000/01/10 17:14:45 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
bool fn_retset;
int fn_nargs;
- int fn_argvarnos[MAXFMGRARGS];
+ int fn_argvarnos[FUNC_MAX_ARGS];
int found_varno;
int new_varno;
int old_varno;
* procedural language (PL)
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.16 2000/01/05 18:23:54 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.17 2000/01/10 17:14:46 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
Oid result_in_elem;
int result_in_len;
int nargs;
- FmgrInfo arg_out_func[MAXFMGRARGS];
- Oid arg_out_elem[MAXFMGRARGS];
- int arg_out_len[MAXFMGRARGS];
- int arg_is_rel[MAXFMGRARGS];
+ FmgrInfo arg_out_func[FUNC_MAX_ARGS];
+ Oid arg_out_elem[FUNC_MAX_ARGS];
+ int arg_out_len[FUNC_MAX_ARGS];
+ int arg_is_rel[FUNC_MAX_ARGS];
} pltcl_proc_desc;