Commit 06476bf
fix: trim the generated normalized_match to match Java's normalizeForMatching
Found in hands-on QA of the previous commit, not by reading it.
SlowQueryAnalyticsService.normalizeForMatching ends with .trim(); the SQL
expression behind the generated column did not. A lineage row stored with
leading whitespace therefore normalized to " select ..." in the column and
"select ..." on the Java side, so the prefix LIKE never matched and
recoverFullText silently returned the truncated sample instead of the full
SQL. Verified against the local install: inserting ' SELECT x FROM t
WHERE y = 1 ' produced "[ select x from t where y = 1 ]" where Java
produces "[select x from t where y = 1]"; 4 of 1,174 real rows carried such
whitespace.
The flaw was equally present in the inline expression this column replaced,
so it is pre-existing rather than a regression — but it is silent either
way, which is why it survived.
Two parts to the fix:
* btrim(...) added to the expression in both the initializer and V118.
* The initializer now detects a stale column and rebuilds it. A generated
column's expression cannot be altered in place and ADD COLUMN IF NOT
EXISTS silently keeps whatever is already there, so an install that ran
the earlier build would have kept the untrimmed expression forever. It
compares pg_get_expr against the expected shape and only drops/re-adds
when they differ, so a normal restart does not rewrite the table.
Verified on the running stack: restart logged "Rebuilding
query_lineage.normalized_match: stored expression is out of date", the
stored expression now carries btrim, the index survived the rebuild, and
rows-with-untrimmed-normalization went from 4 to 0.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 4cf9014 commit 06476bf
2 files changed
Lines changed: 61 additions & 6 deletions
File tree
- backend/src/main
- java/com/dbaagent/config
- resources/db/migration
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | | - | |
| 74 | + | |
68 | 75 | | |
69 | 76 | | |
70 | | - | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
81 | 102 | | |
82 | 103 | | |
83 | 104 | | |
| |||
101 | 122 | | |
102 | 123 | | |
103 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
104 | 154 | | |
105 | 155 | | |
106 | 156 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | | - | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | | - | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
| |||
0 commit comments