PQExpBuffer delqry = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
- /* Make sure we are in proper schema */
- selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
-
snprintf(bufm, sizeof(bufm), INT64_FORMAT, PG_INT64_MIN);
snprintf(bufx, sizeof(bufx), INT64_FORMAT, PG_INT64_MAX);
if (fout->remoteVersion >= 100000)
{
+ /* Make sure we are in proper schema */
+ selectSourceSchema(fout, "pg_catalog");
+
appendPQExpBuffer(query,
"SELECT seqstart, seqincrement, "
"CASE WHEN seqincrement > 0 AND seqmax = %s THEN NULL "
"seqcache, seqcycle "
"FROM pg_class c "
"JOIN pg_sequence s ON (s.seqrelid = c.oid) "
- "WHERE relname = ",
- bufx, bufm);
- appendStringLiteralAH(query, tbinfo->dobj.name, fout);
+ "WHERE c.oid = '%u'::oid",
+ bufx, bufm,
+ tbinfo->dobj.catId.oid);
}
else if (fout->remoteVersion >= 80400)
{
+ /*
+ * Before PostgreSQL 10, sequence metadata is in the sequence itself,
+ * so switch to the sequence's schema instead of pg_catalog.
+ */
+
+ /* Make sure we are in proper schema */
+ selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
+
appendPQExpBuffer(query,
"SELECT start_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "
}
else
{
+ /* Make sure we are in proper schema */
+ selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
+
appendPQExpBuffer(query,
"SELECT 0 AS start_value, increment_by, "
"CASE WHEN increment_by > 0 AND max_value = %s THEN NULL "