Skip to content

Commit 4b4a9fb

Browse files
markhannumclaude
andcommitted
test: verify page-in counters stay separate across lua inner statements
Extends fingerprints.test with a stored procedure containing two distinct inner SQL statements, run multiple times, checking each inner statement's total_pagein_read/total_pagein_read_io invariants independently -- a scenario t10 didn't cover since it only exercised plain top-level SQL, not the lua inner-statement path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Mark Hannum <mhannum@bloomberg.net>
1 parent 27deab7 commit 4b4a9fb

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

tests/fingerprints.test/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ are not deterministic across environments, the test checks structural
99
invariants instead of exact values: total_pagein_read is at least the
1010
execution count, and total_pagein_read_io never exceeds total_pagein_read.
1111

12+
"t11.req" checks the same page-in invariants for two distinct SQL statements
13+
executed inside a single stored procedure (Lua inner statements), verifying
14+
each gets its own independently-tracked page-in counters rather than one
15+
statement's counters leaking into the other's.
16+
1217
-------------------------------- SPECIAL NOTES --------------------------------
1318

1419
The "t03.req" test file purposely excludes the following fingerprints from its

tests/fingerprints.test/t11.req

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE TABLE fp_pagein_a(x INTEGER);$$
2+
CREATE TABLE fp_pagein_b(y INTEGER);$$
3+
INSERT INTO fp_pagein_a(x) VALUES(1);
4+
INSERT INTO fp_pagein_a(x) VALUES(2);
5+
INSERT INTO fp_pagein_b(y) VALUES(10);
6+
INSERT INTO fp_pagein_b(y) VALUES(20);
7+
CREATE PROCEDURE fp_pagein_sp VERSION 'test' {
8+
local function run_and_drain(sql)
9+
local q, rc = db:exec(sql)
10+
if rc == 0 then
11+
local row = q:fetch()
12+
while row do
13+
row = q:fetch()
14+
end
15+
end
16+
end
17+
local function main()
18+
run_and_drain("SELECT * FROM fp_pagein_a ORDER BY x")
19+
run_and_drain("SELECT * FROM fp_pagein_b ORDER BY y")
20+
end}$$
21+
PUT DEFAULT PROCEDURE fp_pagein_sp 'test'
22+
EXEC PROCEDURE fp_pagein_sp()
23+
EXEC PROCEDURE fp_pagein_sp()
24+
EXEC PROCEDURE fp_pagein_sp()
25+
SELECT (total_pagein_read >= count) AS reads_ge_count, (total_pagein_read_io <= total_pagein_read) AS io_le_total FROM comdb2_fingerprints WHERE normalized_sql LIKE 'SELECT%fp_pagein_a%';
26+
SELECT (total_pagein_read >= count) AS reads_ge_count, (total_pagein_read_io <= total_pagein_read) AS io_le_total FROM comdb2_fingerprints WHERE normalized_sql LIKE 'SELECT%fp_pagein_b%';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(rows inserted=1)
2+
(rows inserted=1)
3+
(rows inserted=1)
4+
(rows inserted=1)
5+
(version='test')
6+
(reads_ge_count=1, io_le_total=1)
7+
(reads_ge_count=1, io_le_total=1)

0 commit comments

Comments
 (0)