aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/remove.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-10-07 00:58:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-10-07 00:58:23 +0000
commitfbd26d69846fcbfb69deee45bdddcc692dd59b07 (patch)
tree2aee8f89268d64645b1c4c96958a0e575a12e259 /src/backend/commands/remove.c
parent4837270be9cbba925a7003de5980918c3de8fb37 (diff)
downloadpostgresql-fbd26d69846fcbfb69deee45bdddcc692dd59b07.tar.gz
postgresql-fbd26d69846fcbfb69deee45bdddcc692dd59b07.zip
Arrange that no database accesses are attempted during parser() --- this
took some rejiggering of typename and ACL parsing, as well as moving parse_analyze call out of parser(). Restructure postgres.c processing so that parse analysis and rewrite are skipped when in abort-transaction state. Only COMMIT and ABORT statements will be processed beyond the raw parser() phase. This addresses problem of parser failing with database access errors while in aborted state (see pghackers discussions around 7/28/00). Also fix some bugs with COMMIT/ABORT statements appearing in the middle of a single query input string. Function, operator, and aggregate arguments/results can now use full TypeName production, in particular foo[] for array types. DROP OPERATOR and COMMENT ON OPERATOR were broken for unary operators. Allow CREATE AGGREGATE to accept unquoted numeric constants for initcond.
Diffstat (limited to 'src/backend/commands/remove.c')
-rw-r--r--src/backend/commands/remove.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c
index c5b7968e5fd..6da32297f61 100644
--- a/src/backend/commands/remove.c
+++ b/src/backend/commands/remove.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.52 2000/09/12 16:48:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.53 2000/10/07 00:58:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@
#include "commands/comment.h"
#include "commands/defrem.h"
#include "miscadmin.h"
+#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "utils/acl.h"
#include "utils/syscache.h"
@@ -39,8 +40,8 @@
*/
void
RemoveOperator(char *operatorName, /* operator name */
- char *typeName1, /* first type name */
- char *typeName2) /* optional second type name */
+ char *typeName1, /* left argument type name */
+ char *typeName2) /* right argument type name */
{
Relation relation;
HeapTuple tup;
@@ -53,28 +54,22 @@ RemoveOperator(char *operatorName, /* operator name */
{
typeId1 = TypeGet(typeName1, &defined);
if (!OidIsValid(typeId1))
- {
elog(ERROR, "RemoveOperator: type '%s' does not exist", typeName1);
- return;
- }
}
if (typeName2)
{
typeId2 = TypeGet(typeName2, &defined);
if (!OidIsValid(typeId2))
- {
elog(ERROR, "RemoveOperator: type '%s' does not exist", typeName2);
- return;
- }
}
if (OidIsValid(typeId1) && OidIsValid(typeId2))
oprtype = 'b';
else if (OidIsValid(typeId1))
- oprtype = 'l';
- else
oprtype = 'r';
+ else
+ oprtype = 'l';
relation = heap_openr(OperatorRelationName, RowExclusiveLock);
@@ -94,7 +89,6 @@ RemoveOperator(char *operatorName, /* operator name */
operatorName);
#endif
-
/*** Delete any comments associated with this operator ***/
DeleteComments(tup->t_data->t_oid);
@@ -308,13 +302,12 @@ RemoveType(char *typeName) /* type name to be removed */
*/
void
RemoveFunction(char *functionName, /* function name to be removed */
- int nargs,
- List *argNameList /* list of TypeNames */ )
+ List *argTypes) /* list of TypeName nodes */
{
+ int nargs = length(argTypes);
Relation relation;
HeapTuple tup;
Oid argList[FUNC_MAX_ARGS];
- char *typename;
int i;
if (nargs > FUNC_MAX_ARGS)
@@ -323,19 +316,20 @@ RemoveFunction(char *functionName, /* function name to be removed */
MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = 0; i < nargs; i++)
{
- typename = strVal(lfirst(argNameList));
- argNameList = lnext(argNameList);
+ TypeName *t = (TypeName *) lfirst(argTypes);
+ char *typnam = TypeNameToInternalName(t);
- if (strcmp(typename, "opaque") == 0)
- argList[i] = 0;
+ argTypes = lnext(argTypes);
+
+ if (strcmp(typnam, "opaque") == 0)
+ argList[i] = InvalidOid;
else
{
tup = SearchSysCacheTuple(TYPENAME,
- PointerGetDatum(typename),
+ PointerGetDatum(typnam),
0, 0, 0);
-
if (!HeapTupleIsValid(tup))
- elog(ERROR, "RemoveFunction: type '%s' not found", typename);
+ elog(ERROR, "RemoveFunction: type '%s' not found", typnam);
argList[i] = tup->t_data->t_oid;
}
}