~ubuntu-branches/ubuntu/precise/postgresql-8.4/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-04-20 16:10:45 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110420161045-nrk3s2t0szvn2o80
Tags: 8.4.8-0ubuntu0.11.04
* New upstream bug fix release: (LP: #767165)
  - If your installation was upgraded from a previous major release by
    running pg_upgrade, you should take action to prevent possible data loss
    due to a now-fixed bug in pg_upgrade. The recommended solution is to run
    "VACUUM FREEZE" on all TOAST tables.  More information is available at
    http://wiki.postgresql.org/wiki/20110408pg_upgrade_fix.
  - Fix pg_upgrade's handling of TOAST tables.
    This error poses a significant risk of data loss for installations
    that have been upgraded with pg_upgrade. This patch corrects the
    problem for future uses of pg_upgrade, but does not in itself cure
    the issue in installations that have been processed with a buggy
    version of pg_upgrade.
  - Suppress incorrect "PD_ALL_VISIBLE flag was incorrectly set"
    warning.
  - Disallow including a composite type in itself.
  - Avoid potential deadlock during catalog cache initialization.
  - Fix dangling-pointer problem in BEFORE ROW UPDATE trigger handling
    when there was a concurrent update to the target tuple.
  - Disallow "DROP TABLE" when there are pending deferred trigger
    events for the table.
    Formerly the "DROP" would go through, leading to "could not open
    relation with OID nnn" errors when the triggers were eventually
    fired.
  - Prevent crash triggered by constant-false WHERE conditions during
    GEQO optimization.
  - Improve planner's handling of semi-join and anti-join cases.
  - Fix selectivity estimation for text search to account for NULLs.
  - Improve PL/pgSQL's ability to handle row types with dropped columns.
  - Fix PL/Python memory leak involving array slices.
  - Fix pg_restore to cope with long lines (over 1KB) in TOC files.
  - Put in more safeguards against crashing due to division-by-zero
    with overly enthusiastic compiler optimization. (Closes: #616180)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3185
3185
        int                     i_relhasrules;
3186
3186
        int                     i_relhasoids;
3187
3187
        int                     i_relfrozenxid;
 
3188
        int                     i_toastoid;
 
3189
        int                     i_toastfrozenxid;
3188
3190
        int                     i_owning_tab;
3189
3191
        int                     i_owning_col;
3190
3192
        int                     i_reltablespace;
3226
3228
                                                  "(%s c.relowner) AS rolname, "
3227
3229
                                                  "c.relchecks, c.relhastriggers, "
3228
3230
                                                  "c.relhasindex, c.relhasrules, c.relhasoids, "
3229
 
                                                  "c.relfrozenxid, "
 
3231
                                                  "c.relfrozenxid, tc.oid AS toid, "
 
3232
                                                  "tc.relfrozenxid AS tfrozenxid, "
3230
3233
                                                  "d.refobjid AS owning_tab, "
3231
3234
                                                  "d.refobjsubid AS owning_col, "
3232
3235
                                                  "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
3259
3262
                                                  "relchecks, (reltriggers <> 0) AS relhastriggers, "
3260
3263
                                                  "relhasindex, relhasrules, relhasoids, "
3261
3264
                                                  "relfrozenxid, "
 
3265
                                                  "0 AS toid, "
 
3266
                                                  "0 AS tfrozenxid, "
3262
3267
                                                  "d.refobjid AS owning_tab, "
3263
3268
                                                  "d.refobjsubid AS owning_col, "
3264
3269
                                                  "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
3290
3295
                                                  "relchecks, (reltriggers <> 0) AS relhastriggers, "
3291
3296
                                                  "relhasindex, relhasrules, relhasoids, "
3292
3297
                                                  "0 AS relfrozenxid, "
 
3298
                                                  "0 AS toid, "
 
3299
                                                  "0 AS tfrozenxid, "
3293
3300
                                                  "d.refobjid AS owning_tab, "
3294
3301
                                                  "d.refobjsubid AS owning_col, "
3295
3302
                                                  "(SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS reltablespace, "
3321
3328
                                                  "relchecks, (reltriggers <> 0) AS relhastriggers, "
3322
3329
                                                  "relhasindex, relhasrules, relhasoids, "
3323
3330
                                                  "0 AS relfrozenxid, "
 
3331
                                                  "0 AS toid, "
 
3332
                                                  "0 AS tfrozenxid, "
3324
3333
                                                  "d.refobjid AS owning_tab, "
3325
3334
                                                  "d.refobjsubid AS owning_col, "
3326
3335
                                                  "NULL AS reltablespace, "
3348
3357
                                                  "relchecks, (reltriggers <> 0) AS relhastriggers, "
3349
3358
                                                  "relhasindex, relhasrules, relhasoids, "
3350
3359
                                                  "0 AS relfrozenxid, "
 
3360
                                                  "0 AS toid, "
 
3361
                                                  "0 AS tfrozenxid, "
3351
3362
                                                  "NULL::oid AS owning_tab, "
3352
3363
                                                  "NULL::int4 AS owning_col, "
3353
3364
                                                  "NULL AS reltablespace, "
3370
3381
                                                  "relhasindex, relhasrules, "
3371
3382
                                                  "'t'::bool AS relhasoids, "
3372
3383
                                                  "0 AS relfrozenxid, "
 
3384
                                                  "0 AS toid, "
 
3385
                                                  "0 AS tfrozenxid, "
3373
3386
                                                  "NULL::oid AS owning_tab, "
3374
3387
                                                  "NULL::int4 AS owning_col, "
3375
3388
                                                  "NULL AS reltablespace, "
3402
3415
                                                  "relhasindex, relhasrules, "
3403
3416
                                                  "'t'::bool AS relhasoids, "
3404
3417
                                                  "0 as relfrozenxid, "
 
3418
                                                  "0 AS toid, "
 
3419
                                                  "0 AS tfrozenxid, "
3405
3420
                                                  "NULL::oid AS owning_tab, "
3406
3421
                                                  "NULL::int4 AS owning_col, "
3407
3422
                                                  "NULL AS reltablespace, "
3446
3461
        i_relhasrules = PQfnumber(res, "relhasrules");
3447
3462
        i_relhasoids = PQfnumber(res, "relhasoids");
3448
3463
        i_relfrozenxid = PQfnumber(res, "relfrozenxid");
 
3464
        i_toastoid = PQfnumber(res, "toid");
 
3465
        i_toastfrozenxid = PQfnumber(res, "tfrozenxid");
3449
3466
        i_owning_tab = PQfnumber(res, "owning_tab");
3450
3467
        i_owning_col = PQfnumber(res, "owning_col");
3451
3468
        i_reltablespace = PQfnumber(res, "reltablespace");
3484
3501
                tblinfo[i].hastriggers = (strcmp(PQgetvalue(res, i, i_relhastriggers), "t") == 0);
3485
3502
                tblinfo[i].hasoids = (strcmp(PQgetvalue(res, i, i_relhasoids), "t") == 0);
3486
3503
                tblinfo[i].frozenxid = atooid(PQgetvalue(res, i, i_relfrozenxid));
 
3504
                tblinfo[i].toast_oid = atooid(PQgetvalue(res, i, i_toastoid));
 
3505
                tblinfo[i].toast_frozenxid = atooid(PQgetvalue(res, i, i_toastfrozenxid));
3487
3506
                tblinfo[i].ncheck = atoi(PQgetvalue(res, i, i_relchecks));
3488
3507
                if (PQgetisnull(res, i, i_owning_tab))
3489
3508
                {
10044
10063
                                }
10045
10064
                        }
10046
10065
 
10047
 
                        appendPQExpBuffer(q, "\n-- For binary upgrade, set relfrozenxid.\n");
 
10066
                        appendPQExpBuffer(q, "\n-- For binary upgrade, set heap's relfrozenxid\n");
10048
10067
                        appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
10049
10068
                                                          "SET relfrozenxid = '%u'\n"
10050
10069
                                                          "WHERE oid = ",
10051
10070
                                                          tbinfo->frozenxid);
10052
10071
                        appendStringLiteralAH(q, fmtId(tbinfo->dobj.name), fout);
10053
10072
                        appendPQExpBuffer(q, "::pg_catalog.regclass;\n");
 
10073
 
 
10074
                        if (tbinfo->toast_oid)
 
10075
                        {
 
10076
                                /* We preserve the toast oids, so we can use it during restore */
 
10077
                                appendPQExpBuffer(q, "\n-- For binary upgrade, set toast's relfrozenxid\n");
 
10078
                                appendPQExpBuffer(q, "UPDATE pg_catalog.pg_class\n"
 
10079
                                                                  "SET relfrozenxid = '%u'\n"
 
10080
                                                                  "WHERE oid = '%u';\n",
 
10081
                                                                  tbinfo->toast_frozenxid, tbinfo->toast_oid);
 
10082
                        }
10054
10083
                }
10055
10084
 
10056
10085
                /* Loop dumping statistics and storage statements */