diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index 6e13b74..3c0d41f
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** static SimpleOidList table_exclude_oids
*** 118,123 ****
--- 118,132 ----
  static SimpleStringList tabledata_exclude_patterns = {NULL, NULL};
  static SimpleOidList tabledata_exclude_oids = {NULL, NULL};
  
+ static int 
+ nsoid_compare(const void *node1, const void *node2)
+ {
+ 	if (((NamespaceInfo*)node1)->dobj.catId.oid < ((NamespaceInfo*)node2)->dobj.catId.oid ) return -1;
+ 	if (((NamespaceInfo*)node1)->dobj.catId.oid > ((NamespaceInfo*)node2)->dobj.catId.oid ) return +1;
+ 	return 0;
+ };
+ 
+ 
  /* default, if no "inclusion" switches appear, is to dump everything */
  static bool include_everything = true;
  
*************** getNamespaces(Archive *fout, int *numNam
*** 2612,2618 ****
  	 */
  	appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
  					  "(%s nspowner) AS rolname, "
! 					  "nspacl FROM pg_namespace",
  					  username_subquery);
  
  	res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
--- 2621,2627 ----
  	 */
  	appendPQExpBuffer(query, "SELECT tableoid, oid, nspname, "
  					  "(%s nspowner) AS rolname, "
! 					  "nspacl FROM pg_namespace order by oid",
  					  username_subquery);
  
  	res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
*************** static NamespaceInfo *
*** 2666,2674 ****
--- 2675,2695 ----
  findNamespace(Archive *fout, Oid nsoid, Oid objoid)
  {
  	int			i;
+ 	NamespaceInfo * res;
+ 	DumpableObject foo;
+ 	NamespaceInfo query;
+ 
  
  	if (fout->remoteVersion >= 70300)
  	{
+ 		query.dobj=foo;
+ 		query.dobj.catId.oid=nsoid;
+ 		res = bsearch(&query, g_namespaces, g_numNamespaces, sizeof(NamespaceInfo), nsoid_compare);
+ 		if (res == NULL) 
+ 			exit_horribly(NULL, "schema with OID %u does not exist\n", nsoid);
+ 		return res;
+ 
+ 		/*
  		for (i = 0; i < g_numNamespaces; i++)
  		{
  			NamespaceInfo *nsinfo = &g_namespaces[i];
*************** findNamespace(Archive *fout, Oid nsoid,
*** 2677,2682 ****
--- 2698,2704 ----
  				return nsinfo;
  		}
  		exit_horribly(NULL, "schema with OID %u does not exist\n", nsoid);
+ 		*/
  	}
  	else
  	{
