@@ -3409,6 +3409,8 @@ getTables(int *numTables)
3409
3409
int i_relhasrules ;
3410
3410
int i_relhasoids ;
3411
3411
int i_relfrozenxid ;
3412
+ int i_toastoid ;
3413
+ int i_toastfrozenxid ;
3412
3414
int i_owning_tab ;
3413
3415
int i_owning_col ;
3414
3416
int i_reltablespace ;
@@ -3451,7 +3453,8 @@ getTables(int *numTables)
3451
3453
"(%s c.relowner) AS rolname, "
3452
3454
"c.relchecks, c.relhastriggers, "
3453
3455
"c.relhasindex, c.relhasrules, c.relhasoids, "
3454
- "c.relfrozenxid, "
3456
+ "c.relfrozenxid, tc.oid AS toid, "
3457
+ "tc.relfrozenxid AS tfrozenxid, "
3455
3458
"CASE WHEN c.reloftype <> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END AS reloftype, "
3456
3459
"d.refobjid AS owning_tab, "
3457
3460
"d.refobjsubid AS owning_col, "
@@ -3484,7 +3487,8 @@ getTables(int *numTables)
3484
3487
"(%s c.relowner) AS rolname, "
3485
3488
"c.relchecks, c.relhastriggers, "
3486
3489
"c.relhasindex, c.relhasrules, c.relhasoids, "
3487
- "c.relfrozenxid, "
3490
+ "c.relfrozenxid, tc.oid AS toid, "
3491
+ "tc.relfrozenxid AS tfrozenxid, "
3488
3492
"NULL AS reloftype, "
3489
3493
"d.refobjid AS owning_tab, "
3490
3494
"d.refobjsubid AS owning_col, "
@@ -3518,6 +3522,8 @@ getTables(int *numTables)
3518
3522
"relchecks, (reltriggers <> 0) AS relhastriggers, "
3519
3523
"relhasindex, relhasrules, relhasoids, "
3520
3524
"relfrozenxid, "
3525
+ "0 AS toid, "
3526
+ "0 AS tfrozenxid, "
3521
3527
"NULL AS reloftype, "
3522
3528
"d.refobjid AS owning_tab, "
3523
3529
"d.refobjsubid AS owning_col, "
@@ -3550,6 +3556,8 @@ getTables(int *numTables)
3550
3556
"relchecks, (reltriggers <> 0) AS relhastriggers, "
3551
3557
"relhasindex, relhasrules, relhasoids, "
3552
3558
"0 AS relfrozenxid, "
3559
+ "0 AS toid, "
3560
+ "0 AS tfrozenxid, "
3553
3561
"NULL AS reloftype, "
3554
3562
"d.refobjid AS owning_tab, "
3555
3563
"d.refobjsubid AS owning_col, "
@@ -3582,6 +3590,8 @@ getTables(int *numTables)
3582
3590
"relchecks, (reltriggers <> 0) AS relhastriggers, "
3583
3591
"relhasindex, relhasrules, relhasoids, "
3584
3592
"0 AS relfrozenxid, "
3593
+ "0 AS toid, "
3594
+ "0 AS tfrozenxid, "
3585
3595
"NULL AS reloftype, "
3586
3596
"d.refobjid AS owning_tab, "
3587
3597
"d.refobjsubid AS owning_col, "
@@ -3610,6 +3620,8 @@ getTables(int *numTables)
3610
3620
"relchecks, (reltriggers <> 0) AS relhastriggers, "
3611
3621
"relhasindex, relhasrules, relhasoids, "
3612
3622
"0 AS relfrozenxid, "
3623
+ "0 AS toid, "
3624
+ "0 AS tfrozenxid, "
3613
3625
"NULL AS reloftype, "
3614
3626
"NULL::oid AS owning_tab, "
3615
3627
"NULL::int4 AS owning_col, "
@@ -3633,6 +3645,8 @@ getTables(int *numTables)
3633
3645
"relhasindex, relhasrules, "
3634
3646
"'t'::bool AS relhasoids, "
3635
3647
"0 AS relfrozenxid, "
3648
+ "0 AS toid, "
3649
+ "0 AS tfrozenxid, "
3636
3650
"NULL AS reloftype, "
3637
3651
"NULL::oid AS owning_tab, "
3638
3652
"NULL::int4 AS owning_col, "
@@ -3666,6 +3680,8 @@ getTables(int *numTables)
3666
3680
"relhasindex, relhasrules, "
3667
3681
"'t'::bool AS relhasoids, "
3668
3682
"0 as relfrozenxid, "
3683
+ "0 AS toid, "
3684
+ "0 AS tfrozenxid, "
3669
3685
"NULL AS reloftype, "
3670
3686
"NULL::oid AS owning_tab, "
3671
3687
"NULL::int4 AS owning_col, "
@@ -3711,6 +3727,8 @@ getTables(int *numTables)
3711
3727
i_relhasrules = PQfnumber (res , "relhasrules" );
3712
3728
i_relhasoids = PQfnumber (res , "relhasoids" );
3713
3729
i_relfrozenxid = PQfnumber (res , "relfrozenxid" );
3730
+ i_toastoid = PQfnumber (res , "toid" );
3731
+ i_toastfrozenxid = PQfnumber (res , "tfrozenxid" );
3714
3732
i_owning_tab = PQfnumber (res , "owning_tab" );
3715
3733
i_owning_col = PQfnumber (res , "owning_col" );
3716
3734
i_reltablespace = PQfnumber (res , "reltablespace" );
@@ -3750,6 +3768,8 @@ getTables(int *numTables)
3750
3768
tblinfo [i ].hastriggers = (strcmp (PQgetvalue (res , i , i_relhastriggers ), "t" ) == 0 );
3751
3769
tblinfo [i ].hasoids = (strcmp (PQgetvalue (res , i , i_relhasoids ), "t" ) == 0 );
3752
3770
tblinfo [i ].frozenxid = atooid (PQgetvalue (res , i , i_relfrozenxid ));
3771
+ tblinfo [i ].toast_oid = atooid (PQgetvalue (res , i , i_toastoid ));
3772
+ tblinfo [i ].toast_frozenxid = atooid (PQgetvalue (res , i , i_toastfrozenxid ));
3753
3773
if (PQgetisnull (res , i , i_reloftype ))
3754
3774
tblinfo [i ].reloftype = NULL ;
3755
3775
else
@@ -10852,13 +10872,23 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
10852
10872
}
10853
10873
}
10854
10874
10855
- appendPQExpBuffer (q , "\n-- For binary upgrade, set relfrozenxid. \n" );
10875
+ appendPQExpBuffer (q , "\n-- For binary upgrade, set heap's relfrozenxid\n" );
10856
10876
appendPQExpBuffer (q , "UPDATE pg_catalog.pg_class\n"
10857
10877
"SET relfrozenxid = '%u'\n"
10858
10878
"WHERE oid = " ,
10859
10879
tbinfo -> frozenxid );
10860
10880
appendStringLiteralAH (q , fmtId (tbinfo -> dobj .name ), fout );
10861
10881
appendPQExpBuffer (q , "::pg_catalog.regclass;\n" );
10882
+
10883
+ if (tbinfo -> toast_oid )
10884
+ {
10885
+ /* We preserve the toast oids, so we can use it during restore */
10886
+ appendPQExpBuffer (q , "\n-- For binary upgrade, set toast's relfrozenxid\n" );
10887
+ appendPQExpBuffer (q , "UPDATE pg_catalog.pg_class\n"
10888
+ "SET relfrozenxid = '%u'\n"
10889
+ "WHERE oid = '%u';\n" ,
10890
+ tbinfo -> toast_frozenxid , tbinfo -> toast_oid );
10891
+ }
10862
10892
}
10863
10893
10864
10894
/* Loop dumping statistics and storage statements */
0 commit comments