mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
amcheck: Normalize index tuples containing uncompressed varlena
It might happen that the varlena value wasn't compressed by index_form_tuple() due to current storage parameters. If compression is currently enabled, we need to compress such values to match index tuple coming from the heap. Backpatch to all supported versions. Discussion: https://postgr.es/m/flat/7bdbe559-d61a-4ae4-a6e1-48abdf3024cc%40postgrespro.ru Author: Andrey Borodin Reviewed-by: Alexander Lakhin, Michael Zhilin, Jian He, Alexander Korotkov Backpatch-through: 12
This commit is contained in:
parent
50f8611d07
commit
d603e67446
@ -202,6 +202,16 @@ SELECT bt_index_check('varlena_bug_idx', true);
|
||||
|
||||
(1 row)
|
||||
|
||||
-- Also check that we compress varlena values, which were previously stored
|
||||
-- uncompressed in index.
|
||||
INSERT INTO varlena_bug VALUES (repeat('Test', 250));
|
||||
ALTER TABLE varlena_bug ALTER COLUMN v SET STORAGE extended;
|
||||
SELECT bt_index_check('varlena_bug_idx', true);
|
||||
bt_index_check
|
||||
----------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- cleanup
|
||||
DROP TABLE bttest_a;
|
||||
DROP TABLE bttest_b;
|
||||
|
@ -140,6 +140,12 @@ x
|
||||
CREATE INDEX varlena_bug_idx on varlena_bug(v);
|
||||
SELECT bt_index_check('varlena_bug_idx', true);
|
||||
|
||||
-- Also check that we compress varlena values, which were previously stored
|
||||
-- uncompressed in index.
|
||||
INSERT INTO varlena_bug VALUES (repeat('Test', 250));
|
||||
ALTER TABLE varlena_bug ALTER COLUMN v SET STORAGE extended;
|
||||
SELECT bt_index_check('varlena_bug_idx', true);
|
||||
|
||||
-- cleanup
|
||||
DROP TABLE bttest_a;
|
||||
DROP TABLE bttest_b;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "access/table.h"
|
||||
#include "access/tableam.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/tuptoaster.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/index.h"
|
||||
#include "catalog/pg_am.h"
|
||||
@ -2093,6 +2094,18 @@ bt_normalize_tuple(BtreeCheckState *state, IndexTuple itup)
|
||||
ItemPointerGetBlockNumber(&(itup->t_tid)),
|
||||
ItemPointerGetOffsetNumber(&(itup->t_tid)),
|
||||
RelationGetRelationName(state->rel))));
|
||||
else if (!VARATT_IS_COMPRESSED(DatumGetPointer(normalized[i])) &&
|
||||
VARSIZE(DatumGetPointer(normalized[i])) > TOAST_INDEX_TARGET &&
|
||||
(att->attstorage == 'x' ||
|
||||
att->attstorage == 'm'))
|
||||
{
|
||||
/*
|
||||
* This value will be compressed by index_form_tuple() with the
|
||||
* current storage settings. We may be here because this tuple
|
||||
* was formed with different storage settings. So, force forming.
|
||||
*/
|
||||
formnewtup = true;
|
||||
}
|
||||
else if (VARATT_IS_COMPRESSED(DatumGetPointer(normalized[i])))
|
||||
{
|
||||
formnewtup = true;
|
||||
|
Loading…
Reference in New Issue
Block a user