@@ -15430,8 +15430,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1543015430if (fout->remoteVersion >= 100000)
1543115431{
1543215432appendPQExpBuffer(query,
15433- "SELECT relname, "
15434- "seqstart, seqincrement, "
15433+ "SELECT seqstart, seqincrement, "
1543515434 "CASE WHEN seqincrement > 0 AND seqmax = %s THEN NULL "
1543615435 " WHEN seqincrement < 0 AND seqmax = -1 THEN NULL "
1543715436 " ELSE seqmax "
@@ -15450,8 +15449,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1545015449else if (fout->remoteVersion >= 80400)
1545115450{
1545215451appendPQExpBuffer(query,
15453- "SELECT sequence_name, "
15454- "start_value, increment_by, "
15452+ "SELECT start_value, increment_by, "
1545515453 "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
1545615454 " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
1545715455 " ELSE max_value "
@@ -15467,8 +15465,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1546715465else
1546815466{
1546915467appendPQExpBuffer(query,
15470- "SELECT sequence_name, "
15471- "0 AS start_value, increment_by, "
15468+ "SELECT 0 AS start_value, increment_by, "
1547215469 "CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
1547315470 " WHEN increment_by < 0 AND max_value = -1 THEN NULL "
1547415471 " ELSE max_value "
@@ -15493,24 +15490,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1549315490exit_nicely(1);
1549415491}
1549515492
15496- /* Disable this check: it fails if sequence has been renamed */
15497- #ifdef NOT_USED
15498- if (strcmp(PQgetvalue(res, 0, 0), tbinfo->dobj.name) != 0)
15499- {
15500- write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n",
15501- tbinfo->dobj.name, PQgetvalue(res, 0, 0));
15502- exit_nicely(1);
15503- }
15504- #endif
15505-
15506- startv = PQgetvalue(res, 0, 1);
15507- incby = PQgetvalue(res, 0, 2);
15493+ startv = PQgetvalue(res, 0, 0);
15494+ incby = PQgetvalue(res, 0, 1);
15495+ if (!PQgetisnull(res, 0, 2))
15496+ maxv = PQgetvalue(res, 0, 2);
1550815497if (!PQgetisnull(res, 0, 3))
15509- maxv = PQgetvalue(res, 0, 3);
15510- if (!PQgetisnull(res, 0, 4))
15511- minv = PQgetvalue(res, 0, 4);
15512- cache = PQgetvalue(res, 0, 5);
15513- cycled = (strcmp(PQgetvalue(res, 0, 6), "t") == 0);
15498+ minv = PQgetvalue(res, 0, 3);
15499+ cache = PQgetvalue(res, 0, 4);
15500+ cycled = (strcmp(PQgetvalue(res, 0, 5), "t") == 0);
1551415501
1551515502/*
1551615503 * DROP must be fully qualified in case same name appears in pg_catalog