aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2021-11-05 09:17:40 -0400
committerRobert Haas <rhaas@postgresql.org>2021-11-05 09:24:25 -0400
commitbd807be6935929bdefe74d1258ca08048f0aafa3 (patch)
tree15d7a9c58256d76f35a9c5d0d8a25966a7191aea /src
parentdb7d1a7b0530e8cbd045744e1c75b0e63fb6916f (diff)
downloadpostgresql-bd807be6935929bdefe74d1258ca08048f0aafa3.tar.gz
postgresql-bd807be6935929bdefe74d1258ca08048f0aafa3.zip
amcheck: Add additional TOAST pointer checks.
Expand the checks of toasted attributes to complain if the rawsize is overlarge. For compressed attributes, also complain if compression appears to have expanded the attribute or if the compression method is invalid. Mark Dilger, reviewed by Justin Pryzby, Alexander Alekseev, Heikki Linnakangas, Greg Stark, and me. Discussion: http://postgr.es/m/8E42250D-586A-4A27-B317-8B062C3816A8@enterprisedb.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_amcheck/t/004_verify_heapam.pl24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl
index 4ca7ed297c0..ae729336d26 100644
--- a/src/bin/pg_amcheck/t/004_verify_heapam.pl
+++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl
@@ -218,7 +218,7 @@ my $rel = $node->safe_psql('postgres',
my $relpath = "$pgdata/$rel";
# Insert data and freeze public.test
-use constant ROWCOUNT => 16;
+use constant ROWCOUNT => 18;
$node->safe_psql(
'postgres', qq(
INSERT INTO public.test (a, b, c)
@@ -297,7 +297,7 @@ close($file)
$node->start;
# Ok, Xids and page layout look ok. We can run corruption tests.
-plan tests => 19;
+plan tests => 21;
# Check that pg_amcheck runs against the uncorrupted table without error.
$node->command_ok(
@@ -504,7 +504,7 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
push @expected,
qr/${header}multitransaction ID 4 equals or exceeds next valid multitransaction ID 1/;
}
- elsif ($offnum == 15) # Last offnum must equal ROWCOUNT
+ elsif ($offnum == 15)
{
# Set both HEAP_XMAX_COMMITTED and HEAP_XMAX_IS_MULTI
$tup->{t_infomask} |= HEAP_XMAX_COMMITTED;
@@ -514,6 +514,24 @@ for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx++)
push @expected,
qr/${header}multitransaction ID 4000000000 precedes relation minimum multitransaction ID threshold 1/;
}
+ elsif ($offnum == 16)
+ {
+ # Set raw size too large
+ $tup->{c_va_rawsize} = 1073741824;
+
+ $header = header(0, $offnum, 2);
+ push @expected,
+ qr/${header}toast value \d+ rawsize 1073741824 exceeds limit 1073741823/;
+ }
+ elsif ($offnum == 17) # Last offnum should equal ROWCOUNT-1
+ {
+ # Set raw size too small.
+ $tup->{c_va_rawsize} = 9998;
+
+ $header = header(0, $offnum, 2);
+ push @expected,
+ qr/${header}toast value \d+ external size 10000 exceeds maximum expected for rawsize 9998/;
+ }
write_tuple($file, $offset, $tup);
}
close($file)