Index: src/backend/tcop/utility.c
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.214
diff -c -r1.214 utility.c
*** src/backend/tcop/utility.c	5 May 2004 04:48:46 -0000	1.214
--- src/backend/tcop/utility.c	6 May 2004 20:33:38 -0000
***************
*** 99,106 ****
  };
  
  
  static void
! DropErrorMsg(char *relname, char wrongkind, char rightkind)
  {
  	const struct msgstrings *rentry;
  	const struct msgstrings *wentry;
--- 99,110 ----
  };
  
  
+ /*
+  * Emit the right error message for a "DROP" command issued on a
+  * relation of the wrong type
+  */
  static void
! DropErrorMsgWrongType(char *relname, char wrongkind, char rightkind)
  {
  	const struct msgstrings *rentry;
  	const struct msgstrings *wentry;
***************
*** 121,144 ****
  			 (wentry->kind != '\0') ? errhint(wentry->drophint_msg) : 0));
  }
  
  static void
! CheckDropPermissions(RangeVar *rel, char rightkind)
  {
  	const struct msgstrings *rentry;
- 	Oid			relOid;
- 	HeapTuple	tuple;
- 	Form_pg_class classform;
  
  	for (rentry = msgstringarray; rentry->kind != '\0'; rentry++)
  		if (rentry->kind == rightkind)
! 			break;
! 	Assert(rentry->kind != '\0');
  
  	relOid = RangeVarGetRelid(rel, true);
  	if (!OidIsValid(relOid))
! 		ereport(ERROR,
! 				(errcode(rentry->nonexistent_code),
! 				 errmsg(rentry->nonexistent_msg, rel->relname)));
  	tuple = SearchSysCache(RELOID,
  						   ObjectIdGetDatum(relOid),
  						   0, 0, 0);
--- 125,161 ----
  			 (wentry->kind != '\0') ? errhint(wentry->drophint_msg) : 0));
  }
  
+ /*
+  * Emit the right error message for a "DROP" command issued on a
+  * non-existent relation
+  */
  static void
! DropErrorMsgNonExistent(RangeVar *rel, char rightkind)
  {
  	const struct msgstrings *rentry;
  
  	for (rentry = msgstringarray; rentry->kind != '\0'; rentry++)
+ 	{
  		if (rentry->kind == rightkind)
! 			ereport(ERROR,
! 					(errcode(rentry->nonexistent_code),
! 					 errmsg(rentry->nonexistent_msg, rel->relname)));
! 	}
! 
! 	Assert(false); /* Should be impossible */
! }
! 
! static void
! CheckDropPermissions(RangeVar *rel, char rightkind)
! {
! 	Oid			relOid;
! 	HeapTuple	tuple;
! 	Form_pg_class classform;
  
  	relOid = RangeVarGetRelid(rel, true);
  	if (!OidIsValid(relOid))
! 		DropErrorMsgNonExistent(rel, rightkind);
! 
  	tuple = SearchSysCache(RELOID,
  						   ObjectIdGetDatum(relOid),
  						   0, 0, 0);
***************
*** 148,154 ****
  	classform = (Form_pg_class) GETSTRUCT(tuple);
  
  	if (classform->relkind != rightkind)
! 		DropErrorMsg(rel->relname, classform->relkind, rightkind);
  
  	/* Allow DROP to either table owner or schema owner */
  	if (!pg_class_ownercheck(relOid, GetUserId()) &&
--- 165,172 ----
  	classform = (Form_pg_class) GETSTRUCT(tuple);
  
  	if (classform->relkind != rightkind)
! 		DropErrorMsgWrongType(rel->relname, classform->relkind,
! 							  rightkind);
  
  	/* Allow DROP to either table owner or schema owner */
  	if (!pg_class_ownercheck(relOid, GetUserId()) &&
