Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 8 files changed
  • 0 comments
  • 1 contributor
2  Makefile
... ... @@ -1,5 +1,5 @@
1 1 MODULE_big = pg_check
2   -OBJS = src/pg_check.o src/common.o src/heap.o src/index.o
  2 +OBJS = src/pg_check.o src/common.o src/heap.o src/index.o src/item-bitmap.o
3 3
4 4 EXTENSION = pg_check
5 5 DATA = sql/pg_check--0.1.0.sql
4 sql/pg_check--0.1.0.sql
@@ -5,12 +5,12 @@ SET search_path = public;
5 5 -- pg_check_table()
6 6 --
7 7
8   -CREATE OR REPLACE FUNCTION pg_check_table(table_relation regclass, check_indexes bool)
  8 +CREATE OR REPLACE FUNCTION pg_check_table(table_relation regclass, check_indexes bool, cross_check bool)
9 9 RETURNS int4
10 10 AS '$libdir/pg_check', 'pg_check_table'
11 11 LANGUAGE C STRICT;
12 12
13   -COMMENT ON FUNCTION pg_check_table(regclass, bool) IS 'checks consistency of the whole table (and optionally all indexes on it)';
  13 +COMMENT ON FUNCTION pg_check_table(regclass, bool, bool) IS 'checks consistency of the whole table (and optionally all indexes on it)';
14 14
15 15 CREATE OR REPLACE FUNCTION pg_check_table(table_relation regclass, block_start bigint, block_end bigint)
16 16 RETURNS int4
4 src/index.c
@@ -104,7 +104,11 @@ uint32 check_index_tuples(Relation rel, PageHeader header, char *buffer, int blo
104 104
105 105 ereport(DEBUG1, (errmsg("[%d] max number of tuples = %d", block, ntuples)));
106 106
  107 + /* FIXME check btpo_flags (BTP_LEAF, BTP_ROOT, BTP_DELETED, BTP_META, BTP_HALF_DEAD,
  108 + * BTP_SPLIT_END and BTP_HAS_GARBAGE) and act accordingly */
  109 +
107 110 for (i = 0; i < ntuples; i++) {
  111 + /* FIXME this should check lp_flags, just as the heap check */
108 112 nerrs += check_index_tuple(rel, header, block, i, buffer);
109 113 }
110 114
261 src/item-bitmap.c
... ... @@ -0,0 +1,261 @@
  1 +#include "item-bitmap.h"
  2 +
  3 +#include <unistd.h>
  4 +
  5 +#include "access/itup.h"
  6 +
  7 +/* allocate the memory in 1kB chunks */
  8 +#define PALLOC_CHUNK 1024
  9 +
  10 +/* allocate the bitmap (~4.5MB for each 1GB of heap) */
  11 +item_bitmap * bitmap_alloc(int npages) {
  12 +
  13 + item_bitmap * bitmap = (item_bitmap*)palloc(sizeof(item_bitmap));
  14 +
  15 + bitmap->npages = npages;
  16 + bitmap->pages = (int*)palloc(sizeof(int)*npages);
  17 +
  18 + bitmap->nbytes = 0;
  19 + bitmap->maxBytes = PALLOC_CHUNK;
  20 + bitmap->data = (char*)palloc(PALLOC_CHUNK);
  21 +
  22 + return bitmap;
  23 +
  24 +}
  25 +
  26 +/* allocate the bitmap (~4.5MB for each 1GB of heap) */
  27 +item_bitmap * bitmap_prealloc(item_bitmap * src) {
  28 +
  29 + item_bitmap * bitmap = (item_bitmap*)palloc(sizeof(item_bitmap));
  30 +
  31 + bitmap->npages = src->npages;
  32 +
  33 + bitmap->nbytes = src->nbytes;
  34 + bitmap->maxBytes = src->maxBytes;
  35 +
  36 + bitmap->pages = (int*)palloc(sizeof(int)*src->npages);
  37 + memcpy(bitmap->pages, src->pages, sizeof(int)*src->npages);
  38 +
  39 + bitmap->data = (char*)palloc(src->maxBytes);
  40 + memset(bitmap->data, 0, src->maxBytes);
  41 +
  42 + return bitmap;
  43 +
  44 +}
  45 +
  46 +void bitmap_reset(item_bitmap* bitmap) {
  47 + memset(bitmap->data, 0, bitmap->maxBytes);
  48 +}
  49 +
  50 +void bitmap_free(item_bitmap* bitmap) {
  51 + pfree(bitmap->pages);
  52 + pfree(bitmap->data);
  53 + pfree(bitmap);
  54 +}
  55 +
  56 +/* needs to be called for paged 0,1,2,3,...npages (not randomly) */
  57 +/* extends the bitmap to handle another page */
  58 +void bitmap_add_page(item_bitmap * bitmap, int page, int items) {
  59 +
  60 + bitmap->pages[page] = (page == 0) ? items : (items + bitmap->pages[page-1]);
  61 +
  62 + /* if needed more bytes than */
  63 + bitmap->nbytes = ((bitmap->pages[page] + 7) / 8);
  64 + if (bitmap->nbytes > bitmap->maxBytes) {
  65 + bitmap->maxBytes += PALLOC_CHUNK;
  66 + bitmap->data = (char*)repalloc(bitmap->data, bitmap->maxBytes);
  67 + }
  68 +
  69 +}
  70 +
  71 +/* update the bitmap bith all items from a page (tracks number of items) */
  72 +int bitmap_add_heap_items(item_bitmap * bitmap, PageHeader header, char *raw_page, int page) {
  73 +
  74 + /* tuple checks */
  75 + int nerrs = 0;
  76 + int ntuples = PageGetMaxOffsetNumber(raw_page);
  77 + int item;
  78 +
  79 + bitmap_add_page(bitmap, page, ntuples);
  80 +
  81 + /* by default set all LP_REDIRECT / LP_NORMAL items to '1' (we'll remove the HOT chains in the second pass) */
  82 + /* FIXME what if there is a HOT chain and then an index is created? */
  83 + for (item = 0; item < ntuples; item++) {
  84 + if ((header->pd_linp[item].lp_flags == LP_NORMAL) || (header->pd_linp[item].lp_flags == LP_REDIRECT)) {
  85 + if (! bitmap_set_item(bitmap, page, item, true)) {
  86 + nerrs++;
  87 + }
  88 + }
  89 + }
  90 +
  91 + /* second pass - remove the HOT chains */
  92 + for (item = 0; item < ntuples; item++) {
  93 +
  94 + if (header->pd_linp[item].lp_flags == LP_REDIRECT) {
  95 + /* walk only if not walked this HOT chain yet (skip the first item in the chain) */
  96 + if (bitmap_get_item(bitmap, page, item)) {
  97 + int next = item;
  98 + do {
  99 + next = header->pd_linp[next].lp_off;
  100 + if (! bitmap_set_item(bitmap, page, next, false)) {
  101 + nerrs++;
  102 + }
  103 + } while (header->pd_linp[next].lp_flags != LP_REDIRECT);
  104 + }
  105 + }
  106 +
  107 + }
  108 +
  109 + return nerrs;
  110 +
  111 +}
  112 +
  113 +/* checks index tuples on the page, one by one */
  114 +int bitmap_add_index_items(item_bitmap * bitmap, PageHeader header, char *raw_page, int page) {
  115 +
  116 + /* tuple checks */
  117 + int nerrs = 0;
  118 + int ntuples = PageGetMaxOffsetNumber(raw_page);
  119 + int item;
  120 +
  121 + for (item = 0; item < ntuples; item++) {
  122 +
  123 + IndexTuple itup = (IndexTuple)(raw_page + header->pd_linp[item].lp_off);
  124 + if (! bitmap_set_item(bitmap, BlockIdGetBlockNumber(&(itup->t_tid.ip_blkid)), (itup->t_tid.ip_posid-1), true)) {
  125 + nerrs++;
  126 + }
  127 +
  128 + }
  129 +
  130 + return nerrs;
  131 +
  132 +}
  133 +
  134 +/* mark the (page,item) as occupied */
  135 +bool bitmap_set_item(item_bitmap * bitmap, int page, int item, bool state) {
  136 +
  137 + int byteIdx = (GetBitmapIndex(bitmap, page, item)) / 8;
  138 + int bitIdx = (GetBitmapIndex(bitmap, page, item)) % 8;
  139 +
  140 + if (page >= bitmap->npages) {
  141 + elog(WARNING, "invalid page %d (max page %d)", page, bitmap->npages-1);
  142 + return false;
  143 + }
  144 +
  145 + if (byteIdx > bitmap->nbytes) {
  146 + elog(WARNING, "invalid byte %d (max byte %d)", byteIdx, bitmap->nbytes);
  147 + return false;
  148 + }
  149 +
  150 + if (item >= bitmap->pages[page]) {
  151 + elog(WARNING, "item %d out of range, page has only %d items", item, bitmap->pages[page]);
  152 + return false;
  153 + }
  154 +
  155 + if (state) {
  156 + /* set the bit (OR) */
  157 + bitmap->data[byteIdx] |= (1 << bitIdx);
  158 + } else {
  159 + /* remove the bit (XOR) */
  160 + bitmap->data[byteIdx] &= ~(1 << bitIdx);
  161 + }
  162 +
  163 + return true;
  164 +
  165 +}
  166 +
  167 +/* check if the (page,item) is occupied */
  168 +bool bitmap_get_item(item_bitmap * bitmap, int page, int item) {
  169 +
  170 + int byteIdx = (GetBitmapIndex(bitmap, page, item)) / 8;
  171 + int bitIdx = (GetBitmapIndex(bitmap, page, item)) % 8;
  172 +
  173 + if (page >= bitmap->npages) {
  174 + elog(WARNING, "invalid page %d (max page %d)", page, bitmap->npages-1);
  175 + return false;
  176 + }
  177 +
  178 + if (byteIdx > bitmap->nbytes) {
  179 + elog(WARNING, "invalid byte %d (max byte %d)", byteIdx, bitmap->nbytes);
  180 + return false;
  181 + }
  182 +
  183 + if (item >= bitmap->pages[page]) {
  184 + elog(WARNING, "item %d out of range, page has only %d items", item, bitmap->pages[page]);
  185 + return false;
  186 + }
  187 +
  188 + return (bitmap->data[byteIdx] && (1 << bitIdx));
  189 +
  190 +}
  191 +
  192 +/* counts bits set to 1 in the bitmap */
  193 +long bitmap_count(item_bitmap * bitmap) {
  194 +
  195 + long i, j, items = 0;
  196 +
  197 + for (i = 0; i < bitmap->nbytes; i++) {
  198 + for (j = 0; j < 8; j++) {
  199 + if (bitmap->data[i] & (1 << j)) {
  200 + items++;
  201 + }
  202 + }
  203 + }
  204 +
  205 + return items;
  206 +
  207 +}
  208 +
  209 +/* compare bitmaps, returns number of differences */
  210 +long bitmap_compare(item_bitmap * bitmap_a, item_bitmap * bitmap_b) {
  211 +
  212 + long i, j, ndiff = 0;
  213 + char diff = 0;
  214 +
  215 + /* compare number of pages and total items */
  216 + /* FIXME this rather a sanity check, because these values are copied by bitmap_prealloc */
  217 + if (bitmap_a->npages != bitmap_b->npages) {
  218 + elog(WARNING, "bitmaps do not track the same number of pages (%d != %d)",
  219 + bitmap_a->npages, bitmap_b->npages);
  220 + return MAX(bitmap_a->pages[bitmap_a->npages-1],
  221 + bitmap_b->pages[bitmap_b->npages-1]);
  222 + } else if (bitmap_a->pages[bitmap_a->npages-1] != bitmap_b->pages[bitmap_b->npages-1]) {
  223 + elog(WARNING, "bitmaps do not track the same number of pages (%d != %d)",
  224 + bitmap_a->pages[bitmap_a->npages-1], bitmap_b->pages[bitmap_b->npages-1]);
  225 + }
  226 +
  227 + /* the actual check, compares the bits one by one */
  228 + for (i = 0; i < bitmap_a->nbytes; i++) {
  229 + diff = (bitmap_a->data[i] ^ bitmap_b->data[i]);
  230 + if (diff != 0) {
  231 + for (j = 0; j < 8; j++) {
  232 + if (diff & (1 << j)) {
  233 + ndiff++;
  234 + }
  235 + }
  236 + }
  237 + }
  238 +
  239 + return ndiff;
  240 +
  241 +}
  242 +
  243 +/* print the bitmap (for debugging purposes) */
  244 +/* TODO print details about differences (items missing in heap, items missing in index) */
  245 +void bitmap_print(item_bitmap * bitmap) {
  246 +
  247 + int i, j, k = 0;
  248 + char str[bitmap->nbytes*8+1];
  249 +
  250 + for (i = 0; i < bitmap->nbytes; i++) {
  251 + for (j = 0; j < 8; j++) {
  252 + if (bitmap->data[i] & (1 << j)) {
  253 + str[k++] = '1';
  254 + } else {
  255 + str[k++] = '0';
  256 + }
  257 + }
  258 + }
  259 + str[k++] = 0;
  260 + elog(WARNING, "bitmap [%s]", str);
  261 +}
59 src/item-bitmap.h
... ... @@ -0,0 +1,59 @@
  1 +#ifndef HBITMAP_CHECK_H
  2 +#define HBITMAP_CHECK_H
  3 +
  4 +#include "postgres.h"
  5 +#include "access/heapam.h"
  6 +
  7 +#define GetBitmapIndex(bmap, page, item) \
  8 + ((page == 0) ? (item) : (bmap->pages[page-1] + item))
  9 +
  10 +#define MAX(a,b) ((a > b) ? a : b)
  11 +
  12 +/* bitmap, used to cross-check heap and indexes */
  13 +typedef struct item_bitmap {
  14 +
  15 + /* current number of tracked pages */
  16 + int npages;
  17 +
  18 + int nbytes; /* used bytes */
  19 + int maxBytes; /* allocated bytes */
  20 +
  21 + /* running sum of items on a page, e.g. [10, 20, 30] if
  22 + there are three pages and there are 10 items on each */
  23 + int * pages;
  24 +
  25 + /* data of the bitmap (0/1 for each item) */
  26 + char * data;
  27 +
  28 +} item_bitmap;
  29 +
  30 +
  31 +/* allocate the bitmap (~4.5MB for each 1GB of heap) */
  32 +item_bitmap * bitmap_alloc(int npages);
  33 +item_bitmap * bitmap_prealloc(item_bitmap* src); /* preallocate empty bitmap */
  34 +void bitmap_free(item_bitmap* bitmap);
  35 +
  36 +void bitmap_reset(item_bitmap* bitmap);
  37 +
  38 +/* extends the bitmap to handle another page */
  39 +void bitmap_add_page(item_bitmap * bitmap, int page, int items);
  40 +
  41 +/* update the bitmap with all items from the table */
  42 +int bitmap_add_heap_items(item_bitmap * bitmap, PageHeader header, char *raw_page, int page);
  43 +int bitmap_add_index_items(item_bitmap * bitmap, PageHeader header, char *raw_page, int page);
  44 +
  45 +/* mark the (page,item) as occupied */
  46 +bool bitmap_set_item(item_bitmap * bitmap, int page, int item, bool state);
  47 +
  48 +/* check if the (page,item) is occupied */
  49 +bool bitmap_get_item(item_bitmap * bitmap, int page, int item);
  50 +
  51 +/* count bits set in the bitmap */
  52 +long bitmap_count(item_bitmap * bitmap);
  53 +
  54 +/* compare bitmaps, returns number of differences */
  55 +long bitmap_compare(item_bitmap * bitmap_a, item_bitmap * bitmap_b);
  56 +
  57 +void bitmap_print(item_bitmap * bitmap);
  58 +
  59 +#endif /* HEAP_CHECK_H */
76 src/pg_check.c
@@ -12,6 +12,7 @@
12 12 #include "postgres.h"
13 13
14 14 #include "access/itup.h"
  15 +#include "access/nbtree.h"
15 16 #include "catalog/namespace.h"
16 17 #include "catalog/pg_class.h"
17 18 #include "funcapi.h"
@@ -24,6 +25,9 @@
24 25 #include "common.h"
25 26 #include "index.h"
26 27 #include "heap.h"
  28 +#include "item-bitmap.h"
  29 +
  30 +#define BTPageGetOpaque(page) ((BTPageOpaque) PageGetSpecialPointer(page))
27 31
28 32 PG_MODULE_MAGIC;
29 33
@@ -33,11 +37,11 @@ Datum pg_check_table_pages(PG_FUNCTION_ARGS);
33 37 Datum pg_check_index(PG_FUNCTION_ARGS);
34 38 Datum pg_check_index_pages(PG_FUNCTION_ARGS);
35 39
36   -static uint32 check_table(Oid relid, bool checkIndexes, BlockNumber blockFrom, BlockNumber blockTo, bool blockRangeGiven);
  40 +static uint32 check_table(Oid relid, bool checkIndexes, bool crossCheckIndexes, BlockNumber blockFrom, BlockNumber blockTo, bool blockRangeGiven);
37 41
38 42 static uint32 check_index(Oid indexOid, BlockNumber blockFrom, BlockNumber blockTo, bool blockRangeGiven);
39 43
40   -static uint32 check_index_oid(Oid indexOid);
  44 +static uint32 check_index_oid(Oid indexOid, item_bitmap * bitmap);
41 45
42 46 /*
43 47 * pg_check_table
@@ -51,9 +55,10 @@ pg_check_table(PG_FUNCTION_ARGS)
51 55 {
52 56 Oid relid = PG_GETARG_OID(0);
53 57 bool checkIndexes = PG_GETARG_BOOL(1);
  58 + bool crossCheckIndexes = PG_GETARG_BOOL(2);
54 59 uint32 nerrs;
55 60
56   - nerrs = check_table(relid, checkIndexes, 0, 0, false);
  61 + nerrs = check_table(relid, checkIndexes, crossCheckIndexes, 0, 0, false);
57 62
58 63 PG_RETURN_INT32(nerrs);
59 64 }
@@ -81,7 +86,7 @@ pg_check_table_pages(PG_FUNCTION_ARGS)
81 86 ereport(ERROR,
82 87 (errmsg("invalid ending block number")));
83 88
84   - nerrs = check_table(relid, false,
  89 + nerrs = check_table(relid, false, false,
85 90 (BlockNumber) blkfrom, (BlockNumber) blkto,
86 91 true);
87 92
@@ -138,17 +143,21 @@ pg_check_index_pages(PG_FUNCTION_ARGS)
138 143 * check the table, acquires AccessShareLock
139 144 */
140 145 static uint32
141   -check_table(Oid relid, bool checkIndexes,
  146 +check_table(Oid relid, bool checkIndexes, bool crossCheckIndexes,
142 147 BlockNumber blockFrom, BlockNumber blockTo, bool blockRangeGiven)
143 148 {
144 149 Relation rel; /* relation for the 'relname' */
145 150 char *raw_page; /* raw data of the page */
146 151 Buffer buf; /* buffer the page is read into */
147   - uint32 nerrs = 0; /* number of errors found */
  152 + uint32 nerrs = 0; /* number of errors found */
148 153 BlockNumber blkno; /* current block */
149 154 PageHeader header; /* page header */
150 155 BufferAccessStrategy strategy; /* bulk strategy to avoid polluting cache */
151 156
  157 + /* used to cross-check heap and indexes */
  158 + bool bitmap_build = false; /* true only when block range not given */
  159 + item_bitmap *bitmap_heap = NULL; /* bitmap data */
  160 +
152 161 if (!superuser())
153 162 ereport(ERROR,
154 163 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
@@ -175,6 +184,13 @@ check_table(Oid relid, bool checkIndexes,
175 184 {
176 185 blockFrom = 0;
177 186 blockTo = RelationGetNumberOfBlocks(rel);
  187 +
  188 + /* build the bitmap only when we need to cross-check */
  189 + if (crossCheckIndexes) {
  190 + /* FIXME this needs exclusive lock on the relation (and indexes) */
  191 + bitmap_build = true;
  192 + bitmap_heap = bitmap_alloc(blockTo);
  193 + }
178 194 }
179 195
180 196 strategy = GetAccessStrategy(BAS_BULKREAD);
@@ -198,22 +214,60 @@ check_table(Oid relid, bool checkIndexes,
198 214
199 215 /* FIXME Does that make sense to check the tuples if the page header is corrupted? */
200 216 nerrs += check_heap_tuples(rel, header, raw_page, blkno);
  217 +
  218 + /* update the bitmap with items from this page (but only when needed) */
  219 + if (bitmap_build) {
  220 + bitmap_add_heap_items(bitmap_heap, header, raw_page, blkno);
  221 + }
  222 +
201 223 }
202 224
203 225 /* check indexes */
204 226 if (checkIndexes) {
205 227 List *list_of_indexes;
206 228 ListCell *index;
  229 +
  230 + item_bitmap * bitmap_idx = NULL;
  231 +
  232 + if (bitmap_build) {
  233 + bitmap_idx = bitmap_prealloc(bitmap_heap);
  234 + }
207 235
208 236 list_of_indexes = RelationGetIndexList(rel);
209 237
210 238 foreach(index, list_of_indexes) {
211   - nerrs += check_index_oid(lfirst_oid(index));
  239 +
  240 + /* reset the bitmap (if needed) */
  241 + if (bitmap_build) {
  242 + bitmap_reset(bitmap_idx);
  243 + }
  244 +
  245 + nerrs += check_index_oid(lfirst_oid(index), bitmap_idx);
  246 +
  247 + /* evaluate the bitmap difference (if needed) */
  248 + if (bitmap_build) {
  249 + /* compare the bitmaps */
  250 + int n = bitmap_compare(bitmap_heap, bitmap_idx);
  251 + if (n != 0) {
  252 + elog(WARNING, "there are %d differences between the table and the index", n);
  253 + }
  254 + nerrs += n;
  255 + }
  256 +
  257 + }
  258 +
  259 + if (bitmap_build) {
  260 + bitmap_free(bitmap_idx);
212 261 }
213 262
214 263 list_free(list_of_indexes);
215 264 }
216 265
  266 + /* release the the heap bitmap */
  267 + if (bitmap_build) {
  268 + bitmap_free(bitmap_heap);
  269 + }
  270 +
217 271 FreeAccessStrategy(strategy);
218 272
219 273 relation_close(rel, AccessShareLock);
@@ -230,7 +284,7 @@ check_table(Oid relid, bool checkIndexes,
230 284 * only a part of the index.
231 285 */
232 286 static uint32
233   -check_index_oid(Oid indexOid)
  287 +check_index_oid(Oid indexOid, item_bitmap * bitmap)
234 288 {
235 289 Relation rel; /* relation for the 'relname' */
236 290 char *raw_page; /* raw data of the page */
@@ -293,6 +347,12 @@ check_index_oid(Oid indexOid)
293 347 /* FIXME Does that make sense to check the tuples if the page header is corrupted? */
294 348 nerrs += check_index_tuples(rel, header, raw_page, blkno);
295 349
  350 + /* if this is a leaf page (containing actual pointers to the heap),
  351 + then update the bitmap */
  352 + if ((bitmap != NULL) && P_ISLEAF(BTPageGetOpaque(raw_page))) {
  353 + nerrs += bitmap_add_index_items(bitmap, header, raw_page, blkno);
  354 + }
  355 +
296 356 }
297 357
298 358 }
20 test/expected/pg_check.out
@@ -6,13 +6,13 @@ CREATE TABLE test_table (
6 6 );
7 7 INSERT INTO test_table SELECT NULL FROM generate_series(1,10000) s(i);
8 8 CREATE INDEX test_table_index ON test_table (id);
9   -SELECT pg_check_table('test_table', false);
  9 +SELECT pg_check_table('test_table', false, false);
10 10 pg_check_table
11 11 ----------------
12 12 0
13 13 (1 row)
14 14
15   -SELECT pg_check_table('test_table', true);
  15 +SELECT pg_check_table('test_table', true, true);
16 16 NOTICE: checking index: test_table_index
17 17 pg_check_table
18 18 ----------------
@@ -26,13 +26,13 @@ CREATE TABLE test_table (
26 26 );
27 27 NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_table_pkey" for table "test_table"
28 28 INSERT INTO test_table SELECT i FROM generate_series(1,10000) s(i);
29   -SELECT pg_check_table('test_table', false);
  29 +SELECT pg_check_table('test_table', false, false);
30 30 pg_check_table
31 31 ----------------
32 32 0
33 33 (1 row)
34 34
35   -SELECT pg_check_table('test_table', true);
  35 +SELECT pg_check_table('test_table', true, true);
36 36 NOTICE: checking index: test_table_pkey
37 37 pg_check_table
38 38 ----------------
@@ -51,13 +51,13 @@ INSERT INTO test_table SELECT i, NULL, NULL FROM generate_series(1,10000) s(i);
51 51 CREATE INDEX test_table_a_index ON test_table (val_a);
52 52 CREATE INDEX test_table_b_index ON test_table (val_b);
53 53 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
54   -SELECT pg_check_table('test_table', false);
  54 +SELECT pg_check_table('test_table', false, false);
55 55 pg_check_table
56 56 ----------------
57 57 0
58 58 (1 row)
59 59
60   -SELECT pg_check_table('test_table', true);
  60 +SELECT pg_check_table('test_table', true, true);
61 61 NOTICE: checking index: test_table_pkey
62 62 NOTICE: checking index: test_table_a_index
63 63 NOTICE: checking index: test_table_b_index
@@ -79,13 +79,13 @@ INSERT INTO test_table SELECT i, substr(md5(i::text), 0, floor(random()*10)::int
79 79 CREATE INDEX test_table_a_index ON test_table (val_a);
80 80 CREATE INDEX test_table_b_index ON test_table (val_b);
81 81 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
82   -SELECT pg_check_table('test_table', false);
  82 +SELECT pg_check_table('test_table', false, false);
83 83 pg_check_table
84 84 ----------------
85 85 0
86 86 (1 row)
87 87
88   -SELECT pg_check_table('test_table', true);
  88 +SELECT pg_check_table('test_table', true, true);
89 89 NOTICE: checking index: test_table_pkey
90 90 NOTICE: checking index: test_table_a_index
91 91 NOTICE: checking index: test_table_b_index
@@ -107,13 +107,13 @@ INSERT INTO test_table SELECT i, NULL, substr(md5(i::text), 0, floor(random()*10
107 107 CREATE INDEX test_table_a_index ON test_table (val_a);
108 108 CREATE INDEX test_table_b_index ON test_table (val_b);
109 109 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
110   -SELECT pg_check_table('test_table', false);
  110 +SELECT pg_check_table('test_table', false, false);
111 111 pg_check_table
112 112 ----------------
113 113 0
114 114 (1 row)
115 115
116   -SELECT pg_check_table('test_table', true);
  116 +SELECT pg_check_table('test_table', true, true);
117 117 NOTICE: checking index: test_table_pkey
118 118 NOTICE: checking index: test_table_a_index
119 119 NOTICE: checking index: test_table_b_index
20 test/sql/pg_check.sql
@@ -11,8 +11,8 @@ INSERT INTO test_table SELECT NULL FROM generate_series(1,10000) s(i);
11 11
12 12 CREATE INDEX test_table_index ON test_table (id);
13 13
14   -SELECT pg_check_table('test_table', false);
15   -SELECT pg_check_table('test_table', true);
  14 +SELECT pg_check_table('test_table', false, false);
  15 +SELECT pg_check_table('test_table', true, true);
16 16
17 17 DROP TABLE test_table;
18 18
@@ -23,8 +23,8 @@ CREATE TABLE test_table (
23 23
24 24 INSERT INTO test_table SELECT i FROM generate_series(1,10000) s(i);
25 25
26   -SELECT pg_check_table('test_table', false);
27   -SELECT pg_check_table('test_table', true);
  26 +SELECT pg_check_table('test_table', false, false);
  27 +SELECT pg_check_table('test_table', true, true);
28 28
29 29 DROP TABLE test_table;
30 30
@@ -41,8 +41,8 @@ CREATE INDEX test_table_a_index ON test_table (val_a);
41 41 CREATE INDEX test_table_b_index ON test_table (val_b);
42 42 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
43 43
44   -SELECT pg_check_table('test_table', false);
45   -SELECT pg_check_table('test_table', true);
  44 +SELECT pg_check_table('test_table', false, false);
  45 +SELECT pg_check_table('test_table', true, true);
46 46
47 47 DROP TABLE test_table;
48 48
@@ -59,8 +59,8 @@ CREATE INDEX test_table_a_index ON test_table (val_a);
59 59 CREATE INDEX test_table_b_index ON test_table (val_b);
60 60 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
61 61
62   -SELECT pg_check_table('test_table', false);
63   -SELECT pg_check_table('test_table', true);
  62 +SELECT pg_check_table('test_table', false, false);
  63 +SELECT pg_check_table('test_table', true, true);
64 64
65 65 DROP TABLE test_table;
66 66
@@ -77,8 +77,8 @@ CREATE INDEX test_table_a_index ON test_table (val_a);
77 77 CREATE INDEX test_table_b_index ON test_table (val_b);
78 78 CREATE INDEX test_table_ab_index ON test_table (val_a, val_b);
79 79
80   -SELECT pg_check_table('test_table', false);
81   -SELECT pg_check_table('test_table', true);
  80 +SELECT pg_check_table('test_table', false, false);
  81 +SELECT pg_check_table('test_table', true, true);
82 82
83 83 DROP TABLE test_table;
84 84

No commit comments for this range

Something went wrong with that request. Please try again.