--- shp2pgsql.c.old	Thu Aug  5 09:07:04 2004
+++ shp2pgsql.c	Thu Aug  5 09:13:20 2004
@@ -921,8 +921,16 @@
 
 		if (!dump_format)
 		{
-			printf("INSERT INTO \"%s\" %s VALUES ('%d',",
+			if ( schema )
+			{
+				printf("INSERT INTO \"%s\".\"%s\" %s VALUES ('%d',",
+                                        schema, table, col_names, j);
+			}
+			else
+			{
+		  		printf("INSERT INTO \"%s\" %s VALUES ('%d',",
 					table, col_names, j);
+			}
 		}
 		else
 		{
--- pgsql2shp.c.old	Thu Aug  5 09:13:54 2004
+++ pgsql2shp.c	Thu Aug  5 12:40:08 2004
@@ -2393,6 +2393,7 @@
 		sprintf(query, "SELECT a.attname, a.atttypid, a.attlen FROM "
 			"pg_attribute a, pg_class c, pg_namespace n WHERE "
 			"n.nspname = '%s' AND a.attrelid = c.oid AND "
+			"n.oid = c.relnamespace AND "
 			"a.atttypid != 0 AND "
 			"a.attnum > 0 AND c.relname = '%s'", schema, table);
 	}
