Review for pg_sequence catalog
I like this change since it moves all the parts which should be
transactional to the system catalogs while keeping the only
non-transactional stuff in the sequence relations.
There was some discussion upthread about more compact representations
for the sequences, but I feel that is a separate issue mostly unrelated
to this patch.
I might play around more with it but it seems to work well so far.
As pointed out by Peter this patch also requires the changes to
pg_upgrade. I have not looked at those patches.
= Functional review
- The patch applies and compiles and seems to work fine after some quick
manual testing.
- The pg_dump tests fails due to the pg_dump code not being updated. I
have attached a patch which fixes this.
= Benchmarks
I was a bit worried that the extra syscache lookups might slow down
nextval(), but I got a measurable speed up on a very simple workload
which consisted of only calls to nextval() to one sequence. The speedup
was about 10% on my machine.
= Code
The changes to the code looks generally good.
> @@ -1155,6 +1156,8 @@ doDeletion(const ObjectAddress *object, int flags)
> else
> heap_drop_with_catalog(object->objectId);
> }
> + if (relKind == RELKIND_SEQUENCE)
> + DeleteSequenceTuple(object->objectId);
> break;
> }
I think it might be cleaner here to put this as a "else if" just like
"relKind == RELKIND_INDEX".
= Documentation
The patch does not update catalogs.sgml which it should do.
Andreas
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index ee1f673..a272ad3 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -15115,7 +15115,27 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE);
snprintf(bufx, sizeof(bufx), INT64_FORMAT, SEQ_MAXVALUE);
- if (fout->remoteVersion >= 80400)
+ if (fout->remoteVersion >= 100000)
+ {
+ appendPQExpBuffer(query,
+ "SELECT relname, "
+ "seqstart, seqincrement, "
+ "CASE WHEN seqincrement > 0 AND seqmax = %s THEN NULL "
+ " WHEN seqincrement < 0 AND seqmax = -1 THEN NULL "
+ " ELSE seqmax "
+ "END AS seqmax, "
+ "CASE WHEN seqincrement > 0 AND seqmin = 1 THEN NULL "
+ " WHEN seqincrement < 0 AND seqmin = %s THEN NULL "
+ " ELSE seqmin "
+ "END AS seqmin, "
+ "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);
+ }
+ else if (fout->remoteVersion >= 80400)
{
appendPQExpBuffer(query,
"SELECT sequence_name, "
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers