@@ -8696,6 +8696,26 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
8696
8696
{
8697
8697
DumpOptions *dopt = fout->dopt;
8698
8698
PQExpBuffer q = createPQExpBuffer();
8699
+ int i_attnum;
8700
+ int i_attname;
8701
+ int i_atttypname;
8702
+ int i_atttypmod;
8703
+ int i_attstattarget;
8704
+ int i_attstorage;
8705
+ int i_typstorage;
8706
+ int i_attidentity;
8707
+ int i_attgenerated;
8708
+ int i_attisdropped;
8709
+ int i_attlen;
8710
+ int i_attalign;
8711
+ int i_attislocal;
8712
+ int i_attnotnull;
8713
+ int i_attoptions;
8714
+ int i_attcollation;
8715
+ int i_attcompression;
8716
+ int i_attfdwoptions;
8717
+ int i_attmissingval;
8718
+ int i_atthasdef;
8699
8719
8700
8720
for (int i = 0; i < numTables; i++)
8701
8721
{
@@ -8839,32 +8859,53 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
8839
8859
tbinfo->attrdefs = (AttrDefInfo **) pg_malloc(ntups * sizeof(AttrDefInfo *));
8840
8860
hasdefaults = false;
8841
8861
8862
+ i_attnum = PQfnumber(res, "attnum");
8863
+ i_attname = PQfnumber(res, "attname");
8864
+ i_atttypname = PQfnumber(res, "atttypname");
8865
+ i_atttypmod = PQfnumber(res, "atttypmod");
8866
+ i_attstattarget = PQfnumber(res, "attstattarget");
8867
+ i_attstorage = PQfnumber(res, "attstorage");
8868
+ i_typstorage = PQfnumber(res, "typstorage");
8869
+ i_attidentity = PQfnumber(res, "attidentity");
8870
+ i_attgenerated = PQfnumber(res, "attgenerated");
8871
+ i_attisdropped = PQfnumber(res, "attisdropped");
8872
+ i_attlen = PQfnumber(res, "attlen");
8873
+ i_attalign = PQfnumber(res, "attalign");
8874
+ i_attislocal = PQfnumber(res, "attislocal");
8875
+ i_attnotnull = PQfnumber(res, "attnotnull");
8876
+ i_attoptions = PQfnumber(res, "attoptions");
8877
+ i_attcollation = PQfnumber(res, "attcollation");
8878
+ i_attcompression = PQfnumber(res, "attcompression");
8879
+ i_attfdwoptions = PQfnumber(res, "attfdwoptions");
8880
+ i_attmissingval = PQfnumber(res, "attmissingval");
8881
+ i_atthasdef = PQfnumber(res, "atthasdef");
8882
+
8842
8883
for (int j = 0; j < ntups; j++)
8843
8884
{
8844
- if (j + 1 != atoi(PQgetvalue(res, j, PQfnumber(res, "attnum") )))
8885
+ if (j + 1 != atoi(PQgetvalue(res, j, i_attnum )))
8845
8886
fatal("invalid column numbering in table \"%s\"",
8846
8887
tbinfo->dobj.name);
8847
- tbinfo->attnames[j] = pg_strdup(PQgetvalue(res, j, PQfnumber(res, "attname") ));
8848
- tbinfo->atttypnames[j] = pg_strdup(PQgetvalue(res, j, PQfnumber(res, "atttypname") ));
8849
- tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, PQfnumber(res, "atttypmod") ));
8850
- tbinfo->attstattarget[j] = atoi(PQgetvalue(res, j, PQfnumber(res, "attstattarget") ));
8851
- tbinfo->attstorage[j] = *(PQgetvalue(res, j, PQfnumber(res, "attstorage") ));
8852
- tbinfo->typstorage[j] = *(PQgetvalue(res, j, PQfnumber(res, "typstorage") ));
8853
- tbinfo->attidentity[j] = *(PQgetvalue(res, j, PQfnumber(res, "attidentity") ));
8854
- tbinfo->attgenerated[j] = *(PQgetvalue(res, j, PQfnumber(res, "attgenerated") ));
8888
+ tbinfo->attnames[j] = pg_strdup(PQgetvalue(res, j, i_attname ));
8889
+ tbinfo->atttypnames[j] = pg_strdup(PQgetvalue(res, j, i_atttypname ));
8890
+ tbinfo->atttypmod[j] = atoi(PQgetvalue(res, j, i_atttypmod ));
8891
+ tbinfo->attstattarget[j] = atoi(PQgetvalue(res, j, i_attstattarget ));
8892
+ tbinfo->attstorage[j] = *(PQgetvalue(res, j, i_attstorage ));
8893
+ tbinfo->typstorage[j] = *(PQgetvalue(res, j, i_typstorage ));
8894
+ tbinfo->attidentity[j] = *(PQgetvalue(res, j, i_attidentity ));
8895
+ tbinfo->attgenerated[j] = *(PQgetvalue(res, j, i_attgenerated ));
8855
8896
tbinfo->needs_override = tbinfo->needs_override || (tbinfo->attidentity[j] == ATTRIBUTE_IDENTITY_ALWAYS);
8856
- tbinfo->attisdropped[j] = (PQgetvalue(res, j, PQfnumber(res, "attisdropped") )[0] == 't');
8857
- tbinfo->attlen[j] = atoi(PQgetvalue(res, j, PQfnumber(res, "attlen") ));
8858
- tbinfo->attalign[j] = *(PQgetvalue(res, j, PQfnumber(res, "attalign") ));
8859
- tbinfo->attislocal[j] = (PQgetvalue(res, j, PQfnumber(res, "attislocal") )[0] == 't');
8860
- tbinfo->notnull[j] = (PQgetvalue(res, j, PQfnumber(res, "attnotnull") )[0] == 't');
8861
- tbinfo->attoptions[j] = pg_strdup(PQgetvalue(res, j, PQfnumber(res, "attoptions") ));
8862
- tbinfo->attcollation[j] = atooid(PQgetvalue(res, j, PQfnumber(res, "attcollation") ));
8863
- tbinfo->attcompression[j] = *(PQgetvalue(res, j, PQfnumber(res, "attcompression") ));
8864
- tbinfo->attfdwoptions[j] = pg_strdup(PQgetvalue(res, j, PQfnumber(res, "attfdwoptions") ));
8865
- tbinfo->attmissingval[j] = pg_strdup(PQgetvalue(res, j, PQfnumber(res, "attmissingval") ));
8897
+ tbinfo->attisdropped[j] = (PQgetvalue(res, j, i_attisdropped )[0] == 't');
8898
+ tbinfo->attlen[j] = atoi(PQgetvalue(res, j, i_attlen ));
8899
+ tbinfo->attalign[j] = *(PQgetvalue(res, j, i_attalign ));
8900
+ tbinfo->attislocal[j] = (PQgetvalue(res, j, i_attislocal )[0] == 't');
8901
+ tbinfo->notnull[j] = (PQgetvalue(res, j, i_attnotnull )[0] == 't');
8902
+ tbinfo->attoptions[j] = pg_strdup(PQgetvalue(res, j, i_attoptions ));
8903
+ tbinfo->attcollation[j] = atooid(PQgetvalue(res, j, i_attcollation ));
8904
+ tbinfo->attcompression[j] = *(PQgetvalue(res, j, i_attcompression ));
8905
+ tbinfo->attfdwoptions[j] = pg_strdup(PQgetvalue(res, j, i_attfdwoptions ));
8906
+ tbinfo->attmissingval[j] = pg_strdup(PQgetvalue(res, j, i_attmissingval ));
8866
8907
tbinfo->attrdefs[j] = NULL; /* fix below */
8867
- if (PQgetvalue(res, j, PQfnumber(res, "atthasdef") )[0] == 't')
8908
+ if (PQgetvalue(res, j, i_atthasdef )[0] == 't')
8868
8909
hasdefaults = true;
8869
8910
/* these flags will be set in flagInhAttrs() */
8870
8911
tbinfo->inhNotNull[j] = false;
@@ -10712,6 +10753,8 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
10712
10753
char *qtypname;
10713
10754
char *qualtypname;
10714
10755
char *label;
10756
+ int i_enumlabel;
10757
+ int i_oid;
10715
10758
10716
10759
if (fout->remoteVersion >= 90100)
10717
10760
appendPQExpBuffer(query, "SELECT oid, enumlabel "
@@ -10749,10 +10792,12 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
10749
10792
10750
10793
if (!dopt->binary_upgrade)
10751
10794
{
10795
+ i_enumlabel = PQfnumber(res, "enumlabel");
10796
+
10752
10797
/* Labels with server-assigned oids */
10753
10798
for (i = 0; i < num; i++)
10754
10799
{
10755
- label = PQgetvalue(res, i, PQfnumber(res, "enumlabel") );
10800
+ label = PQgetvalue(res, i, i_enumlabel );
10756
10801
if (i > 0)
10757
10802
appendPQExpBufferChar(q, ',');
10758
10803
appendPQExpBufferStr(q, "\n ");
@@ -10764,11 +10809,14 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
10764
10809
10765
10810
if (dopt->binary_upgrade)
10766
10811
{
10812
+ i_oid = PQfnumber(res, "oid");
10813
+ i_enumlabel = PQfnumber(res, "enumlabel");
10814
+
10767
10815
/* Labels with dump-assigned (preserved) oids */
10768
10816
for (i = 0; i < num; i++)
10769
10817
{
10770
- enum_oid = atooid(PQgetvalue(res, i, PQfnumber(res, "oid") ));
10771
- label = PQgetvalue(res, i, PQfnumber(res, "enumlabel") );
10818
+ enum_oid = atooid(PQgetvalue(res, i, i_oid ));
10819
+ label = PQgetvalue(res, i, i_enumlabel );
10772
10820
10773
10821
if (i == 0)
10774
10822
appendPQExpBufferStr(q, "\n-- For binary upgrade, must preserve pg_enum oids\n");
0 commit comments