On Wed, Mar 9, 2016 at 1:23 AM, Jeff Janes <jeff.ja...@gmail.com> wrote: > On Tue, Mar 8, 2016 at 5:30 AM, Robert Haas <robertmh...@gmail.com> wrote:
> I left out the relkind check from the final commit because, for one > thing, the check you added isn't actually right: toast relations can > also have a visibility map. And also, I'm sort of wondering what the > point of that check is. What does it protect us from? It doesn't > seem very future-proof ... what if we add a new relkind in the future? > Do we really want to have to update this? > > How about instead changing things so that we specifically reject > indexes? And maybe some kind of a check that will reject anything > that lacks a relfilnode? That seems like it would be more on point. > I agree, I don't have strong opinion about this. It would be good to add condition for rejecting only indexes. Attached patches are, - Change heap2 rmgr description - Add condition to pg_visibility - Fix typo in pgvisibility.sgml (Sorry for the late notice..) Regards, -- Masahiko Sawada
diff --git a/doc/src/sgml/pgvisibility.sgml b/doc/src/sgml/pgvisibility.sgml index 6a98b55..cdd6a6f 100644 --- a/doc/src/sgml/pgvisibility.sgml +++ b/doc/src/sgml/pgvisibility.sgml @@ -21,7 +21,7 @@ until such time as a tuple is inserted, updated, deleted, or locked on that page. The page-level <literal>PD_ALL_VISIBLE</literal> bit has the same meaning as the all-visible bit in the visibility map, but is stored - within the data page itself rather than a separate data tructure. These + within the data page itself rather than a separate data structure. These will normally agree, but the page-level bit can sometimes be set while the visibility map bit is clear after a crash recovery; or they can disagree because of a change which occurs after <literal>pg_visibility</> examines
diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c index 5e5c7cc..c916d0d 100644 --- a/contrib/pg_visibility/pg_visibility.c +++ b/contrib/pg_visibility/pg_visibility.c @@ -56,6 +56,13 @@ pg_visibility_map(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid block number"))); + /* Check for relation type */ + if (rel->rd_rel->relkind == RELKIND_INDEX) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot use for index \"%s\"", + RelationGetRelationName(rel)))); + tupdesc = pg_visibility_tupdesc(false, false); MemSet(nulls, 0, sizeof(nulls)); @@ -95,6 +102,13 @@ pg_visibility(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid block number"))); + /* Check for relation type */ + if (rel->rd_rel->relkind == RELKIND_INDEX) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot use for index \"%s\"", + RelationGetRelationName(rel)))); + tupdesc = pg_visibility_tupdesc(false, true); MemSet(nulls, 0, sizeof(nulls)); @@ -226,6 +240,13 @@ pg_visibility_map_summary(PG_FUNCTION_ARGS) rel = relation_open(relid, AccessShareLock); nblocks = RelationGetNumberOfBlocks(rel); + /* Check for relation type */ + if (rel->rd_rel->relkind == RELKIND_INDEX) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot use for index \"%s\"", + RelationGetRelationName(rel)))); + for (blkno = 0; blkno < nblocks; ++blkno) { int32 mapbits; @@ -300,6 +321,13 @@ collect_visibility_data(Oid relid, bool include_pd) rel = relation_open(relid, AccessShareLock); + /* Check for relation type */ + if (rel->rd_rel->relkind == RELKIND_INDEX) + ereport(ERROR, + (errcode(ERRCODE_WRONG_OBJECT_TYPE), + errmsg("cannot use for index \"%s\"", + RelationGetRelationName(rel)))); + nblocks = RelationGetNumberOfBlocks(rel); info = palloc0(offsetof(vbits, bits) + nblocks); info->next = 0;
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c index a63162c..2b31ea4 100644 --- a/src/backend/access/rmgrdesc/heapdesc.c +++ b/src/backend/access/rmgrdesc/heapdesc.c @@ -125,7 +125,8 @@ heap2_desc(StringInfo buf, XLogReaderState *record) { xl_heap_visible *xlrec = (xl_heap_visible *) rec; - appendStringInfo(buf, "cutoff xid %u", xlrec->cutoff_xid); + appendStringInfo(buf, "cutoff xid %u flags %d", + xlrec->cutoff_xid, xlrec->flags); } else if (info == XLOG_HEAP2_MULTI_INSERT) {
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers