Skip to content

Commit 84a67fe

Browse files
feat: add failing tests analysis script for structural investigation
Co-Authored-By: Dan Lynch <[email protected]>
1 parent 1347d8e commit 84a67fe

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { parse } = require('@pgsql/parser');
2+
3+
const failingQueries = [
4+
"EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle)",
5+
"INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i)",
6+
"ALTER TABLE tmp7 ADD CONSTRAINT identity CHECK (b = boo(b))",
7+
"COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args'",
8+
"DROP FUNCTION echo_me(anyenum)",
9+
"SELECT repeat('[', 10000)::jsonb",
10+
"CREATE TABLE log_table (tstamp timestamp default timeofday()::timestamp)"
11+
];
12+
13+
console.log("Analyzing failing test AST structures between PG13 and PG14...\n");
14+
15+
failingQueries.forEach((sql, index) => {
16+
console.log(`=== Query ${index + 1}: ${sql} ===`);
17+
try {
18+
const result13 = parse(sql, { version: '13' });
19+
const result14 = parse(sql, { version: '14' });
20+
21+
if (result13 && result14) {
22+
const json13 = JSON.stringify(result13, null, 2);
23+
const json14 = JSON.stringify(result14, null, 2);
24+
25+
if (json13 !== json14) {
26+
console.log("STRUCTURAL DIFFERENCES DETECTED!");
27+
28+
const funcformat13 = (json13.match(/"funcformat"/g) || []).length;
29+
const funcformat14 = (json14.match(/"funcformat"/g) || []).length;
30+
const objfuncargs13 = (json13.match(/"objfuncargs"/g) || []).length;
31+
const objfuncargs14 = (json14.match(/"objfuncargs"/g) || []).length;
32+
33+
console.log(`PG13 funcformat count: ${funcformat13}, PG14: ${funcformat14}`);
34+
console.log(`PG13 objfuncargs count: ${objfuncargs13}, PG14: ${objfuncargs14}`);
35+
36+
const fields13 = new Set(json13.match(/"[a-zA-Z_][a-zA-Z0-9_]*":/g) || []);
37+
const fields14 = new Set(json14.match(/"[a-zA-Z_][a-zA-Z0-9_]*":/g) || []);
38+
39+
const onlyIn13 = [...fields13].filter(f => !fields14.has(f));
40+
const onlyIn14 = [...fields14].filter(f => !fields13.has(f));
41+
42+
if (onlyIn13.length > 0) console.log("Fields only in PG13:", onlyIn13);
43+
if (onlyIn14.length > 0) console.log("Fields only in PG14:", onlyIn14);
44+
45+
} else {
46+
console.log("No structural differences found");
47+
}
48+
}
49+
} catch (error) {
50+
console.log("Parse error:", error.message);
51+
}
52+
console.log("---\n");
53+
});

0 commit comments

Comments
 (0)