~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-updates

« back to all changes in this revision

Viewing changes to src/bin/pg_dump/pg_dump.c

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2012-08-16 17:06:20 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120816170620-jo0bdsnqqc4u5iqf
Tags: 9.1.5-0ubuntu11.10
* New upstream bug fix/security release:
 - Prevent access to external files/URLs via XML entity references
   (Noah Misch, Tom Lane)
   xml_parse() would attempt to fetch external files or URLs as needed
   to resolve DTD and entity references in an XML value, thus allowing
   unprivileged database users to attempt to fetch data with the
   privileges of the database server. While the external data wouldn't
   get returned directly to the user, portions of it could be exposed
   in error messages if the data didn't parse as valid XML; and in any
   case the mere ability to check existence of a file might be useful
   to an attacker. (CVE-2012-3489)
 - Prevent access to external files/URLs via "contrib/xml2"'s
   xslt_process() (Peter Eisentraut)
   libxslt offers the ability to read and write both files and URLs
   through stylesheet commands, thus allowing unprivileged database
   users to both read and write data with the privileges of the
   database server. Disable that through proper use of libxslt's
   security options. (CVE-2012-3488)
   Also, remove xslt_process()'s ability to fetch documents and
   stylesheets from external files/URLs. While this was a documented
   "feature", it was long regarded as a bad idea. The fix for
   CVE-2012-3489 broke that capability, and rather than expend effort
   on trying to fix it, we're just going to summarily remove it.
 - Prevent too-early recycling of btree index pages (Noah Misch)
   When we allowed read-only transactions to skip assigning XIDs, we
   introduced the possibility that a deleted btree page could be
   recycled while a read-only transaction was still in flight to it.
   This would result in incorrect index search results. The
   probability of such an error occurring in the field seems very low
   because of the timing requirements, but nonetheless it should be
   fixed.
 - Fix crash-safety bug with newly-created-or-reset sequences (Tom
   Lane)
   If "ALTER SEQUENCE" was executed on a freshly created or reset
   sequence, and then precisely one nextval() call was made on it, and
   then the server crashed, WAL replay would restore the sequence to a
   state in which it appeared that no nextval() had been done, thus
   allowing the first sequence value to be returned again by the next
   nextval() call. In particular this could manifest for serial
   columns, since creation of a serial column's sequence includes an
   "ALTER SEQUENCE OWNED BY" step.
 - Fix race condition in enum-type value comparisons (Robert Haas, Tom
   Lane)
   Comparisons could fail when encountering an enum value added since
   the current query started.
 - Fix txid_current() to report the correct epoch when not in hot
   standby (Heikki Linnakangas)
   This fixes a regression introduced in the previous minor release.
 - Prevent selection of unsuitable replication connections as the
   synchronous standby (Fujii Masao)
   The master might improperly choose pseudo-servers such as
   pg_receivexlog or pg_basebackup as the synchronous standby, and
   then wait indefinitely for them.
 - Fix bug in startup of Hot Standby when a master transaction has
   many subtransactions (Andres Freund)
   This mistake led to failures reported as "out-of-order XID
   insertion in KnownAssignedXids".
 - Ensure the "backup_label" file is fsync'd after pg_start_backup()
   (Dave Kerr)
 - Fix timeout handling in walsender processes (Tom Lane)
   WAL sender background processes neglected to establish a SIGALRM
   handler, meaning they would wait forever in some corner cases where
   a timeout ought to happen.
 - Wake walsenders after each background flush by walwriter (Andres
   Freund, Simon Riggs)
   This greatly reduces replication delay when the workload contains
   only asynchronously-committed transactions.
 - Fix LISTEN/NOTIFY to cope better with I/O problems, such as out of
   disk space (Tom Lane)
   After a write failure, all subsequent attempts to send more NOTIFY
   messages would fail with messages like "Could not read from file
   "pg_notify/nnnn" at offset nnnnn: Success".
 - Only allow autovacuum to be auto-canceled by a directly blocked
   process (Tom Lane)
   The original coding could allow inconsistent behavior in some
   cases; in particular, an autovacuum could get canceled after less
   than deadlock_timeout grace period.
 - Improve logging of autovacuum cancels (Robert Haas)
 - Fix log collector so that log_truncate_on_rotation works during the
   very first log rotation after server start (Tom Lane)
 - Fix WITH attached to a nested set operation
   (UNION/INTERSECT/EXCEPT) (Tom Lane)
 - Ensure that a whole-row reference to a subquery doesn't include any
   extra GROUP BY or ORDER BY columns (Tom Lane)
 - Fix dependencies generated during ALTER TABLE ... ADD CONSTRAINT
   USING INDEX (Tom Lane)
   This command left behind a redundant pg_depend entry for the index,
   which could confuse later operations, notably ALTER TABLE ... ALTER
   COLUMN TYPE on one of the indexed columns.
 - Fix "REASSIGN OWNED" to work on extensions (Alvaro Herrera)
 - Disallow copying whole-row references in CHECK constraints and
   index definitions during "CREATE TABLE" (Tom Lane)
   This situation can arise in "CREATE TABLE" with LIKE or INHERITS.
   The copied whole-row variable was incorrectly labeled with the row
   type of the original table not the new one. Rejecting the case
   seems reasonable for LIKE, since the row types might well diverge
   later. For INHERITS we should ideally allow it, with an implicit
   coercion to the parent table's row type; but that will require more
   work than seems safe to back-patch.
 - Fix memory leak in ARRAY(SELECT ...) subqueries (Heikki
   Linnakangas, Tom Lane)
 - Fix planner to pass correct collation to operator selectivity
   estimators (Tom Lane)
   This was not previously required by any core selectivity estimation
   function, but third-party code might need it.
 - Fix extraction of common prefixes from regular expressions (Tom
   Lane)
   The code could get confused by quantified parenthesized
   subexpressions, such as ^(foo)?bar. This would lead to incorrect
   index optimization of searches for such patterns.
 - Fix bugs with parsing signed "hh":"mm" and "hh":"mm":"ss" fields in
   interval constants (Amit Kapila, Tom Lane)
 - Fix pg_dump to better handle views containing partial GROUP BY
   lists (Tom Lane)
   A view that lists only a primary key column in GROUP BY, but uses
   other table columns as if they were grouped, gets marked as
   depending on the primary key. Improper handling of such primary key
   dependencies in pg_dump resulted in poorly-ordered dumps, which at
   best would be inefficient to restore and at worst could result in
   outright failure of a parallel pg_restore run.
 - In PL/Perl, avoid setting UTF8 flag when in SQL_ASCII encoding
   (Alex Hunsaker, Kyotaro Horiguchi, Alvaro Herrera)
 - Use Postgres' encoding conversion functions, not Python's, when
   converting a Python Unicode string to the server encoding in
   PL/Python (Jan Urbanski)
   This avoids some corner-case problems, notably that Python doesn't
   support all the encodings Postgres does. A notable functional
   change is that if the server encoding is SQL_ASCII, you will get
   the UTF-8 representation of the string; formerly, any non-ASCII
   characters in the string would result in an error.
 - Fix mapping of PostgreSQL encodings to Python encodings in
   PL/Python (Jan Urbanski)
 - Report errors properly in "contrib/xml2"'s xslt_process() (Tom
   Lane)
 - Update time zone data files to tzdata release 2012e for DST law
   changes in Morocco and Tokelau

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
                const char *acls);
203
203
 
204
204
static void getDependencies(void);
 
205
 
 
206
static DumpableObject *createBoundaryObjects(void);
 
207
static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs,
 
208
                                                DumpableObject *boundaryObjs);
 
209
 
205
210
static void getDomainConstraints(TypeInfo *tyinfo);
206
211
static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
207
212
static void makeTableDataInfo(TableInfo *tbinfo, bool oids);
260
265
        int                     numTables;
261
266
        DumpableObject **dobjs;
262
267
        int                     numObjs;
 
268
        DumpableObject *boundaryObjs;
263
269
        int                     i;
264
270
        enum trivalue prompt_password = TRI_DEFAULT;
265
271
        int                     compressLevel = -1;
742
748
         */
743
749
        getDependencies();
744
750
 
 
751
        /* Lastly, create dummy objects to represent the section boundaries */
 
752
        boundaryObjs = createBoundaryObjects();
 
753
 
 
754
        /* Get pointers to all the known DumpableObjects */
 
755
        getDumpableObjects(&dobjs, &numObjs);
 
756
 
 
757
        /*
 
758
         * Add dummy dependencies to enforce the dump section ordering.
 
759
         */
 
760
        addBoundaryDependencies(dobjs, numObjs, boundaryObjs);
 
761
 
745
762
        /*
746
763
         * Sort the objects into a safe dump order (no forward references).
747
764
         *
751
768
         * will dump identically.  Before 7.3 we don't have dependencies and we
752
769
         * use OID ordering as an (unreliable) guide to creation order.
753
770
         */
754
 
        getDumpableObjects(&dobjs, &numObjs);
755
 
 
756
771
        if (g_fout->remoteVersion >= 70300)
757
772
                sortDumpableObjectsByTypeName(dobjs, numObjs);
758
773
        else
759
774
                sortDumpableObjectsByTypeOid(dobjs, numObjs);
760
775
 
761
 
        sortDumpableObjects(dobjs, numObjs);
 
776
        sortDumpableObjects(dobjs, numObjs,
 
777
                                                boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
762
778
 
763
779
        /*
764
780
         * Create archive TOC entries for all the objects to be dumped, in a safe
7113
7129
                                                 dobj->dependencies, dobj->nDeps,
7114
7130
                                                 dumpBlobs, NULL);
7115
7131
                        break;
 
7132
                case DO_PRE_DATA_BOUNDARY:
 
7133
                case DO_POST_DATA_BOUNDARY:
 
7134
                        /* never dumped, nothing to do */
 
7135
                        break;
7116
7136
        }
7117
7137
}
7118
7138
 
11578
11598
           daclinfo->dobj.namespace ? daclinfo->dobj.namespace->dobj.name : NULL,
11579
11599
                                 NULL,
11580
11600
                                 daclinfo->defaclrole,
11581
 
                                 false, "DEFAULT ACL", SECTION_NONE,
 
11601
                                 false, "DEFAULT ACL", SECTION_POST_DATA,
11582
11602
                                 q->data, "", NULL,
11583
11603
                                 daclinfo->dobj.dependencies, daclinfo->dobj.nDeps,
11584
11604
                                 NULL, NULL);
13961
13981
 
13962
13982
 
13963
13983
/*
 
13984
 * createBoundaryObjects - create dummy DumpableObjects to represent
 
13985
 * dump section boundaries.
 
13986
 */
 
13987
static DumpableObject *
 
13988
createBoundaryObjects(void)
 
13989
{
 
13990
        DumpableObject *dobjs;
 
13991
 
 
13992
        dobjs = (DumpableObject *) pg_malloc(2 * sizeof(DumpableObject));
 
13993
 
 
13994
        dobjs[0].objType = DO_PRE_DATA_BOUNDARY;
 
13995
        dobjs[0].catId = nilCatalogId;
 
13996
        AssignDumpId(dobjs + 0);
 
13997
        dobjs[0].name = pg_strdup("PRE-DATA BOUNDARY");
 
13998
 
 
13999
        dobjs[1].objType = DO_POST_DATA_BOUNDARY;
 
14000
        dobjs[1].catId = nilCatalogId;
 
14001
        AssignDumpId(dobjs + 1);
 
14002
        dobjs[1].name = pg_strdup("POST-DATA BOUNDARY");
 
14003
 
 
14004
        return dobjs;
 
14005
}
 
14006
 
 
14007
/*
 
14008
 * addBoundaryDependencies - add dependencies as needed to enforce the dump
 
14009
 * section boundaries.
 
14010
 */
 
14011
static void
 
14012
addBoundaryDependencies(DumpableObject **dobjs, int numObjs,
 
14013
                                                DumpableObject *boundaryObjs)
 
14014
{
 
14015
        DumpableObject *preDataBound = boundaryObjs + 0;
 
14016
        DumpableObject *postDataBound = boundaryObjs + 1;
 
14017
        int                     i;
 
14018
 
 
14019
        for (i = 0; i < numObjs; i++)
 
14020
        {
 
14021
                DumpableObject *dobj = dobjs[i];
 
14022
 
 
14023
                /*
 
14024
                 * The classification of object types here must match the SECTION_xxx
 
14025
                 * values assigned during subsequent ArchiveEntry calls!
 
14026
                 */
 
14027
                switch (dobj->objType)
 
14028
                {
 
14029
                        case DO_NAMESPACE:
 
14030
                        case DO_EXTENSION:
 
14031
                        case DO_TYPE:
 
14032
                        case DO_SHELL_TYPE:
 
14033
                        case DO_FUNC:
 
14034
                        case DO_AGG:
 
14035
                        case DO_OPERATOR:
 
14036
                        case DO_OPCLASS:
 
14037
                        case DO_OPFAMILY:
 
14038
                        case DO_COLLATION:
 
14039
                        case DO_CONVERSION:
 
14040
                        case DO_TABLE:
 
14041
                        case DO_ATTRDEF:
 
14042
                        case DO_PROCLANG:
 
14043
                        case DO_CAST:
 
14044
                        case DO_DUMMY_TYPE:
 
14045
                        case DO_TSPARSER:
 
14046
                        case DO_TSDICT:
 
14047
                        case DO_TSTEMPLATE:
 
14048
                        case DO_TSCONFIG:
 
14049
                        case DO_FDW:
 
14050
                        case DO_FOREIGN_SERVER:
 
14051
                        case DO_BLOB:
 
14052
                                /* Pre-data objects: must come before the pre-data boundary */
 
14053
                                addObjectDependency(preDataBound, dobj->dumpId);
 
14054
                                break;
 
14055
                        case DO_TABLE_DATA:
 
14056
                        case DO_BLOB_DATA:
 
14057
                                /* Data objects: must come between the boundaries */
 
14058
                                addObjectDependency(dobj, preDataBound->dumpId);
 
14059
                                addObjectDependency(postDataBound, dobj->dumpId);
 
14060
                                break;
 
14061
                        case DO_INDEX:
 
14062
                        case DO_TRIGGER:
 
14063
                        case DO_DEFAULT_ACL:
 
14064
                                /* Post-data objects: must come after the post-data boundary */
 
14065
                                addObjectDependency(dobj, postDataBound->dumpId);
 
14066
                                break;
 
14067
                        case DO_RULE:
 
14068
                                /* Rules are post-data, but only if dumped separately */
 
14069
                                if (((RuleInfo *) dobj)->separate)
 
14070
                                        addObjectDependency(dobj, postDataBound->dumpId);
 
14071
                                break;
 
14072
                        case DO_CONSTRAINT:
 
14073
                        case DO_FK_CONSTRAINT:
 
14074
                                /* Constraints are post-data, but only if dumped separately */
 
14075
                                if (((ConstraintInfo *) dobj)->separate)
 
14076
                                        addObjectDependency(dobj, postDataBound->dumpId);
 
14077
                                break;
 
14078
                        case DO_PRE_DATA_BOUNDARY:
 
14079
                                /* nothing to do */
 
14080
                                break;
 
14081
                        case DO_POST_DATA_BOUNDARY:
 
14082
                                /* must come after the pre-data boundary */
 
14083
                                addObjectDependency(dobj, preDataBound->dumpId);
 
14084
                                break;
 
14085
                }
 
14086
        }
 
14087
}
 
14088
 
 
14089
 
 
14090
/*
13964
14091
 * selectSourceSchema - make the specified schema the active search path
13965
14092
 * in the source database.
13966
14093
 *