Commit fa41cf8f authored by Peter Geoghegan's avatar Peter Geoghegan

Avoid misinterpreting GiST pages in pageinspect.

GistPageSetDeleted() sets pd_lower when deleting a page, and sets the
page contents to a GISTDeletedPageContents.  Avoid treating deleted GiST
pages as regular slotted pages within pageinspect.

Oversight in commit 756ab291.

Author: Andrey Borodin <x4mmm@yandex-team.ru>
parent 7cde6b13
...@@ -103,6 +103,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS) ...@@ -103,6 +103,7 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
MemoryContext oldcontext; MemoryContext oldcontext;
Page page; Page page;
OffsetNumber offset; OffsetNumber offset;
OffsetNumber maxoff = InvalidOffsetNumber;
if (!superuser()) if (!superuser())
ereport(ERROR, ereport(ERROR,
...@@ -135,11 +136,14 @@ gist_page_items_bytea(PG_FUNCTION_ARGS) ...@@ -135,11 +136,14 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
page = get_page_from_raw(raw_page); page = get_page_from_raw(raw_page);
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
if (GistPageIsDeleted(page)) if (GistPageIsDeleted(page))
elog(NOTICE, "page is deleted"); elog(NOTICE, "page is deleted");
else
maxoff = PageGetMaxOffsetNumber(page);
for (offset = FirstOffsetNumber; for (offset = FirstOffsetNumber;
offset <= PageGetMaxOffsetNumber(page); offset <= maxoff;
offset++) offset++)
{ {
Datum values[4]; Datum values[4];
...@@ -187,6 +191,7 @@ gist_page_items(PG_FUNCTION_ARGS) ...@@ -187,6 +191,7 @@ gist_page_items(PG_FUNCTION_ARGS)
MemoryContext oldcontext; MemoryContext oldcontext;
Page page; Page page;
OffsetNumber offset; OffsetNumber offset;
OffsetNumber maxoff = InvalidOffsetNumber;
if (!superuser()) if (!superuser())
ereport(ERROR, ereport(ERROR,
...@@ -222,11 +227,14 @@ gist_page_items(PG_FUNCTION_ARGS) ...@@ -222,11 +227,14 @@ gist_page_items(PG_FUNCTION_ARGS)
page = get_page_from_raw(raw_page); page = get_page_from_raw(raw_page);
/* Avoid bogus PageGetMaxOffsetNumber() call with deleted pages */
if (GistPageIsDeleted(page)) if (GistPageIsDeleted(page))
elog(NOTICE, "page is deleted"); elog(NOTICE, "page is deleted");
else
maxoff = PageGetMaxOffsetNumber(page);
for (offset = FirstOffsetNumber; for (offset = FirstOffsetNumber;
offset <= PageGetMaxOffsetNumber(page); offset <= maxoff;
offset++) offset++)
{ {
Datum values[4]; Datum values[4];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment