*** a/src/bin/pg_dump/pg_backup_archiver.c
--- b/src/bin/pg_dump/pg_backup_archiver.c
***************
*** 123,128 **** CloseArchive(Archive *AHX)
--- 123,144 ----
  					 strerror(errno));
  }
  
+ /*
+  * List all objects that can be DROPped that are made up of more
+  * than a single word.
+  */
+ static const char *multiword_drops[] = {
+ 	"FOREIGN DATA WRAPPER",
+ 	"OPERATOR CLASS",
+ 	"OPERATOR FAMILY",
+ 	"TEXT SEARCH CONFIGURATION",
+ 	"TEXT SEARCH DICTIONARY",
+ 	"TEXT SEARCH PARSER",
+ 	"TEXT SEARCH TEMPLATE",
+ 	"USER MAPPING",
+ 	NULL
+ };
+ 
  /* Public */
  void
  RestoreArchive(Archive *AHX, RestoreOptions *ropt)
***************
*** 249,256 **** RestoreArchive(Archive *AHX, RestoreOptions *ropt)
  				/* Select owner and schema as necessary */
  				_becomeOwner(AH, te);
  				_selectOutputSchema(AH, te->namespace);
! 				/* Drop it */
! 				ahprintf(AH, "%s", te->dropStmt);
  			}
  		}
  
--- 265,308 ----
  				/* Select owner and schema as necessary */
  				_becomeOwner(AH, te);
  				_selectOutputSchema(AH, te->namespace);
! 				/*
! 				 * Figure out if it's something we can do DROP IF EXISTS on.
! 				 * Check for "DROP " just to be sure.
! 				 */
! 				if (strncmp(te->dropStmt, "DROP ", 5) == 0)
! 				{
! 					char   *cp = te->dropStmt + 5;
! 					char   *insertpoint = NULL;
! 					char   *newstr = NULL;
! 					int		i;
! 
! 					/*
! 					 * Assume that all objects can be DROP IF EXISTS:ed. However,
! 					 * some have more than one word in them, so we need to figure
! 					 * out exactly where to insert the IF EXISTS.
! 					 */
! 					for (i = 0; multiword_drops[i] != NULL; i++)
! 					{
! 						if (strncmp(cp, multiword_drops[i], strlen(multiword_drops[i])) == 0)
! 						{
! 							insertpoint = cp + strlen(multiword_drops[i]);
! 							break;
! 						}
! 					}
! 					if (insertpoint == NULL)
! 						insertpoint = strchr(cp, ' ');
! 					if (insertpoint == NULL)
! 						die_horribly(AH,modulename,"malformatted DROP statement: %s", te->dropStmt);
! 
! 					newstr = calloc(strlen(te->dropStmt) + 11, 1); /* "IF EXISTS " + terminator */
! 					strncpy(newstr, te->dropStmt, insertpoint - te->dropStmt);
! 					strcat(newstr, " IF EXISTS");
! 					strcat(newstr, insertpoint);
! 					ahprintf(AH, "%s", newstr);
! 					free(newstr);
! 				}
! 				else
! 					ahprintf(AH, "%s", te->dropStmt);
  			}
  		}
  
