mirror of
https://github.com/postgres/postgres.git
synced 2025-12-22 17:42:17 +03:00
Make number of args to a function configurable.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -695,14 +695,14 @@ getParamTypes(TgElement * elem, Oid *typev)
|
||||
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)
|
||||
@@ -810,7 +810,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||
{
|
||||
TgElement *elem;
|
||||
char *funcName;
|
||||
Oid typev[8], /* eight arguments maximum */
|
||||
Oid typev[FUNC_MAX_ARGS], /* eight arguments maximum */
|
||||
relid;
|
||||
int i,
|
||||
parameterCount;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* comment.c
|
||||
*
|
||||
*
|
||||
* PostgreSQL object comments utility code.
|
||||
*
|
||||
* Copyright (c) 1999, PostgreSQL Global Development Group
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
* 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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
@@ -55,10 +55,10 @@ static void CommentTrigger(char *trigger, char *relation, char *comments);
|
||||
/*------------------------------------------------------------------
|
||||
* 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
|
||||
@@ -66,9 +66,9 @@ static void CommentTrigger(char *trigger, char *relation, char *comments);
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
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):
|
||||
@@ -102,18 +102,18 @@ void CommentObject(int objtype, char *objname, char *objproperty,
|
||||
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.
|
||||
*
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
@@ -147,7 +147,7 @@ void CreateComments(Oid oid, char *comment) {
|
||||
}
|
||||
|
||||
/*** 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);
|
||||
@@ -156,21 +156,21 @@ void CreateComments(Oid oid, char *comment) {
|
||||
/*** 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;
|
||||
@@ -179,14 +179,14 @@ void CreateComments(Oid oid, char *comment) {
|
||||
/*** 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);
|
||||
}
|
||||
@@ -198,10 +198,10 @@ void CreateComments(Oid oid, char *comment) {
|
||||
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
/*------------------------------------------------------------------
|
||||
* 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.
|
||||
@@ -220,7 +220,7 @@ void DeleteComments(Oid oid) {
|
||||
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);
|
||||
@@ -228,24 +228,24 @@ void DeleteComments(Oid oid) {
|
||||
|
||||
/*** 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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
@@ -300,10 +300,10 @@ void CommentRelation(int reltype, char *relname, char *comment) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*** Create the comments using the tuple's oid ***/
|
||||
|
||||
CreateComments(oid, comment);
|
||||
CreateComments(oid, comment);
|
||||
|
||||
}
|
||||
|
||||
@@ -311,11 +311,11 @@ void CommentRelation(int reltype, char *relname, char *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
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -332,10 +332,10 @@ void CommentAttribute(char *relname, char *attrname, char *comment) {
|
||||
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)) {
|
||||
@@ -343,14 +343,14 @@ void CommentAttribute(char *relname, char *attrname, char *comment) {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -358,10 +358,10 @@ void CommentAttribute(char *relname, char *attrname, char *comment) {
|
||||
* 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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -374,7 +374,7 @@ void CommentDatabase(char *database, char *comment) {
|
||||
Oid oid;
|
||||
bool superuser;
|
||||
int4 dba, userid;
|
||||
char *username;
|
||||
char *username;
|
||||
|
||||
/*** First find the tuple in pg_database for the database ***/
|
||||
|
||||
@@ -383,7 +383,7 @@ void CommentDatabase(char *database, char *comment) {
|
||||
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)) {
|
||||
@@ -391,9 +391,9 @@ void CommentDatabase(char *database, char *comment) {
|
||||
}
|
||||
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);
|
||||
@@ -402,9 +402,9 @@ void CommentDatabase(char *database, char *comment) {
|
||||
}
|
||||
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'",
|
||||
@@ -413,11 +413,11 @@ void CommentDatabase(char *database, char *comment) {
|
||||
#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);
|
||||
|
||||
@@ -428,7 +428,7 @@ void CommentDatabase(char *database, char *comment) {
|
||||
*
|
||||
* 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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
@@ -441,8 +441,8 @@ void CommentRewrite(char *rule, char *comment) {
|
||||
int aclcheck;
|
||||
|
||||
/*** First, validate user ***/
|
||||
|
||||
#ifndef NO_SECURITY
|
||||
|
||||
#ifndef NO_SECURITY
|
||||
user = GetPgUserName();
|
||||
relation = RewriteGetRuleEventRel(rule);
|
||||
aclcheck = pg_aclcheck(relation, user, ACL_RU);
|
||||
@@ -453,7 +453,7 @@ void CommentRewrite(char *rule, char *comment) {
|
||||
#endif
|
||||
|
||||
/*** Next, find the rule's oid ***/
|
||||
|
||||
|
||||
rewritetuple = SearchSysCacheTuple(RULENAME, PointerGetDatum(rule),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(rewritetuple)) {
|
||||
@@ -461,7 +461,7 @@ void CommentRewrite(char *rule, char *comment) {
|
||||
}
|
||||
|
||||
oid = rewritetuple->t_data->t_oid;
|
||||
|
||||
|
||||
/*** Call CreateComments() to create/drop the comments ***/
|
||||
|
||||
CreateComments(oid, comment);
|
||||
@@ -473,7 +473,7 @@ void CommentRewrite(char *rule, char *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.
|
||||
*------------------------------------------------------------------
|
||||
@@ -486,17 +486,17 @@ void CommentType(char *type, char *comment) {
|
||||
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)) {
|
||||
@@ -504,7 +504,7 @@ void CommentType(char *type, char *comment) {
|
||||
}
|
||||
|
||||
oid = typetuple->t_data->t_oid;
|
||||
|
||||
|
||||
/*** Call CreateComments() to create/drop the comments ***/
|
||||
|
||||
CreateComments(oid, comment);
|
||||
@@ -514,20 +514,20 @@ void CommentType(char *type, char *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) {
|
||||
@@ -538,7 +538,7 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
|
||||
} else {
|
||||
baseoid = 0;
|
||||
}
|
||||
|
||||
|
||||
/*** Next, validate the user's attempt to comment ***/
|
||||
|
||||
#ifndef NO_SECURITY
|
||||
@@ -566,9 +566,9 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
|
||||
elog(ERROR, "aggregate '%s' does not exist", aggregate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
oid = aggtuple->t_data->t_oid;
|
||||
|
||||
|
||||
/*** Call CreateComments() to create/drop the comments ***/
|
||||
|
||||
CreateComments(oid, comment);
|
||||
@@ -578,9 +578,9 @@ void CommentAggregate(char *aggregate, char *argument, char *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.
|
||||
*------------------------------------------------------------------
|
||||
@@ -589,7 +589,7 @@ void CommentAggregate(char *aggregate, char *argument, char *comment) {
|
||||
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;
|
||||
|
||||
@@ -597,7 +597,7 @@ void CommentProc(char *function, List *arguments, char *comment) {
|
||||
|
||||
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);
|
||||
@@ -632,29 +632,29 @@ void CommentProc(char *function, List *arguments, char *comment) {
|
||||
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.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
@@ -670,7 +670,7 @@ void CommentOperator(char *opername, List *arguments, char *comment) {
|
||||
|
||||
if (lfirst(arguments) != NULL) {
|
||||
lefttype = strVal(lfirst(arguments));
|
||||
}
|
||||
}
|
||||
if (lsecond(arguments) != NULL) {
|
||||
righttype = strVal(lsecond(arguments));
|
||||
}
|
||||
@@ -683,9 +683,9 @@ void CommentOperator(char *opername, List *arguments, char *comment) {
|
||||
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)) {
|
||||
@@ -699,7 +699,7 @@ void CommentOperator(char *opername, List *arguments, char *comment) {
|
||||
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),
|
||||
@@ -710,8 +710,8 @@ void CommentOperator(char *opername, List *arguments, char *comment) {
|
||||
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
|
||||
@@ -748,8 +748,8 @@ void CommentTrigger(char *trigger, char *relname, char *comment) {
|
||||
ScanKeyData entry;
|
||||
Oid oid = InvalidOid;
|
||||
char *user;
|
||||
|
||||
/*** First, validate the user's action ***/
|
||||
|
||||
/*** First, validate the user's action ***/
|
||||
|
||||
#ifndef NO_SECURITY
|
||||
user = GetPgUserName();
|
||||
@@ -761,10 +761,10 @@ void CommentTrigger(char *trigger, char *relname, char *comment) {
|
||||
|
||||
/*** 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)) {
|
||||
@@ -784,11 +784,11 @@ void CommentTrigger(char *trigger, char *relname, char *comment) {
|
||||
}
|
||||
|
||||
/*** 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);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -414,7 +414,7 @@ FuncIndexArgs(IndexElem *funcIndex,
|
||||
}
|
||||
*opOidP = tuple->t_data->t_oid;
|
||||
|
||||
MemSet(argTypes, 0, 8 * sizeof(Oid));
|
||||
MemSet(argTypes, 0, FUNC_MAX_ARGS * sizeof(Oid));
|
||||
|
||||
/*
|
||||
* process the function arguments
|
||||
|
||||
@@ -50,7 +50,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
HeapTuple langTup;
|
||||
HeapTuple procTup;
|
||||
|
||||
Oid typev[8];
|
||||
Oid typev[FUNC_MAX_ARGS];
|
||||
char nulls[Natts_pg_language];
|
||||
Datum values[Natts_pg_language];
|
||||
Relation rel;
|
||||
@@ -136,7 +136,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
CatalogIndexInsert(idescs, Num_pg_language_indices, rel, tup);
|
||||
CatalogCloseIndices(Num_pg_language_indices, idescs);
|
||||
}
|
||||
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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 $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -163,7 +163,7 @@ SingleOpOperatorRemove(Oid typeOid)
|
||||
DeleteComments(tup->t_data->t_oid);
|
||||
|
||||
heap_delete(rel, &tup->t_self, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
heap_endscan(scan);
|
||||
@@ -315,13 +315,13 @@ RemoveFunction(char *functionName, /* function name to be removed */
|
||||
{
|
||||
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));
|
||||
@@ -444,7 +444,7 @@ RemoveAggregate(char *aggName, char *aggType)
|
||||
aggName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Remove any comments related to this aggregate ***/
|
||||
|
||||
DeleteComments(tup->t_data->t_oid);
|
||||
|
||||
@@ -41,7 +41,7 @@ void
|
||||
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;
|
||||
@@ -53,7 +53,7 @@ CreateTrigger(CreateTrigStmt *stmt)
|
||||
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];
|
||||
@@ -144,7 +144,7 @@ CreateTrigger(CreateTrigStmt *stmt)
|
||||
}
|
||||
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),
|
||||
@@ -306,7 +306,7 @@ DropTrigger(DropTrigStmt *stmt)
|
||||
|
||||
heap_delete(tgrel, &tuple->t_self, NULL);
|
||||
tgfound++;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
found++;
|
||||
@@ -368,7 +368,7 @@ RelationRemoveTriggers(Relation rel)
|
||||
/*** Delete any comments associated with this trigger ***/
|
||||
|
||||
DeleteComments(tup->t_data->t_oid);
|
||||
|
||||
|
||||
heap_delete(tgrel, &tup->t_self, NULL);
|
||||
|
||||
}
|
||||
@@ -473,7 +473,7 @@ RelationBuildTriggers(Relation relation)
|
||||
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);
|
||||
@@ -992,7 +992,7 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
|
||||
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);
|
||||
|
||||
@@ -1008,7 +1008,7 @@ deferredTriggerCheckState(Oid tgoid, int32 itemstate)
|
||||
* Add a new trigger event to the queue.
|
||||
* ----------
|
||||
*/
|
||||
static void
|
||||
static void
|
||||
deferredTriggerAddEvent(DeferredTriggerEvent event)
|
||||
{
|
||||
deftrig_events = lappend(deftrig_events, event);
|
||||
@@ -1040,14 +1040,14 @@ deferredTriggerGetPreviousEvent(Oid relid, ItemPointer ctid)
|
||||
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;
|
||||
@@ -1107,26 +1107,26 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
|
||||
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
|
||||
@@ -1195,10 +1195,10 @@ deferredTriggerInvokeEvents(bool immediate_only)
|
||||
* ----------
|
||||
*/
|
||||
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.
|
||||
* ----------
|
||||
@@ -1215,7 +1215,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
|
||||
* ----------
|
||||
*/
|
||||
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;
|
||||
@@ -1273,7 +1273,7 @@ DeferredTriggerBeginXact(void)
|
||||
DeferredTriggerStatus stat;
|
||||
|
||||
if (deftrig_cxt != NULL)
|
||||
elog(FATAL,
|
||||
elog(FATAL,
|
||||
"DeferredTriggerBeginXact() called while inside transaction");
|
||||
|
||||
/* ----------
|
||||
@@ -1286,12 +1286,12 @@ DeferredTriggerBeginXact(void)
|
||||
|
||||
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;
|
||||
@@ -1530,7 +1530,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
|
||||
*/
|
||||
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;
|
||||
@@ -1582,7 +1582,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
|
||||
state->dts_tgoid = (Oid) lfirst(l);
|
||||
state->dts_tgisdeferred = stmt->deferred;
|
||||
|
||||
deftrig_dfl_trigstates =
|
||||
deftrig_dfl_trigstates =
|
||||
lappend(deftrig_dfl_trigstates, state);
|
||||
}
|
||||
}
|
||||
@@ -1618,7 +1618,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
|
||||
state->dts_tgoid = (Oid) lfirst(l);
|
||||
state->dts_tgisdeferred = stmt->deferred;
|
||||
|
||||
deftrig_trigstates =
|
||||
deftrig_trigstates =
|
||||
lappend(deftrig_trigstates, state);
|
||||
}
|
||||
}
|
||||
@@ -1652,7 +1652,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
TriggerData SaveTriggerData;
|
||||
|
||||
if (deftrig_cxt == NULL)
|
||||
elog(ERROR,
|
||||
elog(ERROR,
|
||||
"DeferredTriggerSaveEvent() called outside of transaction");
|
||||
|
||||
/* ----------
|
||||
@@ -1681,7 +1681,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
ItemPointerSetInvalid(&(newctid));
|
||||
|
||||
/* ----------
|
||||
* Create a new event
|
||||
* Create a new event
|
||||
* ----------
|
||||
*/
|
||||
oldcxt = MemoryContextSwitchTo((MemoryContext) deftrig_cxt);
|
||||
@@ -1691,7 +1691,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
|
||||
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;
|
||||
@@ -1702,10 +1702,10 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
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);
|
||||
@@ -1729,7 +1729,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
if (oldtup->t_data->t_xmin != GetCurrentTransactionId())
|
||||
prev_event = NULL;
|
||||
else
|
||||
prev_event =
|
||||
prev_event =
|
||||
deferredTriggerGetPreviousEvent(rel->rd_id, &oldctid);
|
||||
|
||||
/* ----------
|
||||
@@ -1759,7 +1759,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
case F_RI_FKEY_SETDEFAULT_UPD:
|
||||
is_ri_trigger = true;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
is_ri_trigger = false;
|
||||
break;
|
||||
@@ -1776,7 +1776,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
CurrentTriggerData = &SaveTriggerData;
|
||||
key_unchanged = RI_FKey_keyequal_upd();
|
||||
CurrentTriggerData = NULL;
|
||||
|
||||
|
||||
if (key_unchanged)
|
||||
{
|
||||
/* ----------
|
||||
@@ -1789,7 +1789,7 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
|
||||
if (prev_event)
|
||||
{
|
||||
if (prev_event->dte_event &
|
||||
if (prev_event->dte_event &
|
||||
TRIGGER_DEFERRED_ROW_INSERTED)
|
||||
{
|
||||
/* ----------
|
||||
@@ -1797,9 +1797,9 @@ DeferredTriggerSaveEvent(Relation rel, int event,
|
||||
* 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;
|
||||
|
||||
Reference in New Issue
Block a user