@@ -8696,6 +8696,26 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
86968696{
86978697DumpOptions *dopt = fout->dopt;
86988698PQExpBuffer q = createPQExpBuffer();
8699+ inti_attnum;
8700+ inti_attname;
8701+ inti_atttypname;
8702+ inti_atttypmod;
8703+ inti_attstattarget;
8704+ inti_attstorage;
8705+ inti_typstorage;
8706+ inti_attidentity;
8707+ inti_attgenerated;
8708+ inti_attisdropped;
8709+ inti_attlen;
8710+ inti_attalign;
8711+ inti_attislocal;
8712+ inti_attnotnull;
8713+ inti_attoptions;
8714+ inti_attcollation;
8715+ inti_attcompression;
8716+ inti_attfdwoptions;
8717+ inti_attmissingval;
8718+ inti_atthasdef;
86998719
87008720for (int i = 0; i < numTables; i++)
87018721{
@@ -8839,32 +8859,53 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
88398859tbinfo->attrdefs = (AttrDefInfo **) pg_malloc(ntups * sizeof(AttrDefInfo *));
88408860hasdefaults = false;
88418861
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+
88428883for (int j = 0; j < ntups; j++)
88438884{
8844- if (j + 1 != atoi(PQgetvalue(res, j,PQfnumber(res, "attnum") )))
8885+ if (j + 1 != atoi(PQgetvalue(res, j,i_attnum )))
88458886fatal("invalid column numbering in table \"%s\"",
88468887 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 ));
88558896tbinfo->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 ));
88668907tbinfo->attrdefs[j] = NULL; /* fix below */
8867- if (PQgetvalue(res, j,PQfnumber(res, "atthasdef") )[0] == 't')
8908+ if (PQgetvalue(res, j,i_atthasdef )[0] == 't')
88688909hasdefaults = true;
88698910/* these flags will be set in flagInhAttrs() */
88708911tbinfo->inhNotNull[j] = false;
@@ -10712,6 +10753,8 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
1071210753char *qtypname;
1071310754char *qualtypname;
1071410755char *label;
10756+ inti_enumlabel;
10757+ inti_oid;
1071510758
1071610759if (fout->remoteVersion >= 90100)
1071710760appendPQExpBuffer(query, "SELECT oid, enumlabel "
@@ -10749,10 +10792,12 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
1074910792
1075010793if (!dopt->binary_upgrade)
1075110794{
10795+ i_enumlabel = PQfnumber(res, "enumlabel");
10796+
1075210797/* Labels with server-assigned oids */
1075310798for (i = 0; i < num; i++)
1075410799{
10755- label = PQgetvalue(res, i,PQfnumber(res, "enumlabel") );
10800+ label = PQgetvalue(res, i,i_enumlabel );
1075610801if (i > 0)
1075710802appendPQExpBufferChar(q, ',');
1075810803appendPQExpBufferStr(q, "\n ");
@@ -10764,11 +10809,14 @@ dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
1076410809
1076510810if (dopt->binary_upgrade)
1076610811{
10812+ i_oid = PQfnumber(res, "oid");
10813+ i_enumlabel = PQfnumber(res, "enumlabel");
10814+
1076710815/* Labels with dump-assigned (preserved) oids */
1076810816for (i = 0; i < num; i++)
1076910817{
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 );
1077210820
1077310821if (i == 0)
1077410822appendPQExpBufferStr(q, "\n-- For binary upgrade, must preserve pg_enum oids\n");