Fix for pg_dump -T/-N - Mailing list pgsql-patches

From Bruce Momjian
Subject Fix for pg_dump -T/-N
Date
Msg-id 200608041833.k74IXVK16057@momjian.us
Whole thread Raw
List pgsql-patches
The attached, applied patch fixes a bug in new pg_dump -T/-N handling
that was dumping system schemas if these options were used before -n/-t.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/pg_dump/pg_dump.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v
retrieving revision 1.445
diff -c -c -r1.445 pg_dump.c
*** src/bin/pg_dump/pg_dump.c    2 Aug 2006 21:43:43 -0000    1.445
--- src/bin/pg_dump/pg_dump.c    4 Aug 2006 17:17:00 -0000
***************
*** 632,638 ****
          {
              /* Special case for when -N is the first argument */
              if (this_obj_name == schemaList && !this_obj_name->is_include)
!                 appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_namespace EXCEPT\n");

              appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_namespace WHERE");
          }
--- 632,641 ----
          {
              /* Special case for when -N is the first argument */
              if (this_obj_name == schemaList && !this_obj_name->is_include)
!                 appendPQExpBuffer(query,
!                     "SELECT oid FROM pg_catalog.pg_namespace "
!                     "WHERE nspname NOT LIKE 'pg_%%' AND "
!                     "      nspname != 'information_schema' EXCEPT\n");

              appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_namespace WHERE");
          }
***************
*** 694,700 ****
          {
              /* Special case for when -T is the first argument */
              if (this_obj_name == tableList && !this_obj_name->is_include && !strlen(query->data))
!                 appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_class WHERE relkind='r' EXCEPT\n");

              appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_class WHERE relkind='r' AND (");
          }
--- 697,708 ----
          {
              /* Special case for when -T is the first argument */
              if (this_obj_name == tableList && !this_obj_name->is_include && !strlen(query->data))
!                 appendPQExpBuffer(query,
!                     "SELECT pg_class.oid FROM pg_catalog.pg_class, pg_catalog.pg_namespace "
!                     "WHERE relkind='r' AND "
!                     "      relnamespace = pg_namespace.oid AND "
!                     "      nspname NOT LIKE 'pg_%%' AND "
!                     "      nspname != 'information_schema' EXCEPT\n");

              appendPQExpBuffer(query, "SELECT oid FROM pg_catalog.pg_class WHERE relkind='r' AND (");
          }
***************
*** 6169,6175 ****
       * Skip this cast if all objects are from pg_
       */
      if ((funcInfo == NULL ||
!          strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
          strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) == 0 &&
          strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) == 0)
          return;
--- 6177,6183 ----
       * Skip this cast if all objects are from pg_
       */
      if ((funcInfo == NULL ||
!         strncmp(funcInfo->dobj.namespace->dobj.name, "pg_", 3) == 0) &&
          strncmp(sourceInfo->dobj.namespace->dobj.name, "pg_", 3) == 0 &&
          strncmp(targetInfo->dobj.namespace->dobj.name, "pg_", 3) == 0)
          return;

pgsql-patches by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: Values list-of-targetlists patch for comments (was Re:
Next
From: "Hiroshi Saito"
Date:
Subject: patch of libpq-int.h is required of msvc.