SQL, regex and small parsing helpers written by AI
A recipe for having an assistant write a database query, a text pattern or a small script, then proving it on a hand-checked sample, row counts and a long input before you use it.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a calculator that never says it is unsure. It always gives a number. If you press the wrong key, you still get a number. You test it on two plus two before you trust it with a bill.
Daily List is a to-do list app. Lily asks an assistant for a (Structured Query Language) query that counts reminders for each user. The query runs. Leo, who has no reminders, shows a count of 1. Nothing warns her. (SYNTHETIC / TRAINING ONLY: Daily List and the people here are invented.).
What it is: The helper may be a , a , or a short script. SQL is the language of the query. A table is a grid. A row is one user or one reminder. A column is one fact, such as user_id. A fan-out join repeats rows and can make a total too big, or, with COUNT(*), can turn a missing match into 1. The neighbour is a query you wrote yourself and already checked. The assistant's query still needs that same check.
Why it matters: A helper that runs is not a helper that is right. Tom's is a : Lily 2, Sam 3, Leo 0. If the query disagrees, he does not ship it.
The same checks cover more than one kind of helper. A regular expression that stalls is ReDoS, so he tries a long input. A (comma-separated values) file and a file are counted in and out. A command line script is read before it runs. A date that depends on a time zone is checked by hand.
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Getting a query, pattern or small script from an assistant, and proving it on known answers before use.
- Give names and a sample
- Ask for helper and explanation
- Run on known answers
- Count rows and try long input
- Keep the checks
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Sums you already know, like two plus two | A hand-checked sample with a known answer |
| A calculator that never says error | A query that runs and gives a wrong total |
| Pressing the key twice by accident | A join that repeats each row |
| Typing a huge number to see if it hangs | A long input that tests a pattern for ReDoS |
WHERE THIS PICTURE STOPS
- A calculator is wrong the same way each time. An assistant may write a different helper on each ask.
- A calculator does only arithmetic. A query, a pattern and a script each fail in their own way.
- Small sums miss large-number faults. A small sample can miss faults that only show in big data.
HOOK
Test the calculator on sums you know.
REMEMBER IT THIS WAY
A rule of thumb: if you see this, think that.
If a query total comes back exactly double, usually suspect a join that repeats each row. Compare it with a sample you counted by hand.
| In the trick | What it stands for |
|---|---|
| Double total | A join that repeats each row |
| Hand count | A hand-checked sample with a known answer |
| Long input | A long input that tests a pattern for ReDoS |
It misleads when the true total really is near double, so count by hand before you blame the join.
TELL A FRIEND
Test every helper on a small case whose answer you already know before you trust it with real work.
OFTEN MIXED UP WITH Synthetic data, masking and test files with AI. The earlier lesson made the data to test with. This lesson checks the small helpers that read and change that data.
Sources & standards — 4 sources
- Market practice
Fan-out resolution (Holistics documentation) ↗ — Holistics · When a one-to-many join runs before a sum or count, the single side is repeated and the total counts the copies, which gives a wrong number with no error (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Understanding Regular Expression Denial of Service (ReDoS): Insights from Regexes Written by Language Models and Developer Forums (International Conference on Program Comprehension, 2024) ↗ — Institute of Electrical and Electronics Engineers (IEEE) and Association for Computing Machinery (ACM), International Conference on Program Comprehension · Regular expressions written by language models were tested for being correct and for being open to denial of service; the generated ones mainly showed a slow, polynomial kind of weakness (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Re(gEx|DoS)Eval: Evaluating Generated Regular Expressions and their Proneness to DoS (ICSE 2024) ↗ — International Conference on Software Engineering (ICSE) · A benchmark of real user regular-expression requests scores generated patterns on whether they work and on whether they are open to denial of service (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Test::Regexp (Perl module documentation) ↗ — MetaCPAN · It is important to test which strings do not match a regular expression as well as which do (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Fan-out resolution (Holistics documentation) ↗ — Holistics · When a one-to-many join runs before a sum or count, the single side is repeated and the total counts the copies, which gives a wrong number with no error (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Understanding Regular Expression Denial of Service (ReDoS): Insights from Regexes Written by Language Models and Developer Forums (International Conference on Program Comprehension, 2024) ↗ — Institute of Electrical and Electronics Engineers (IEEE) and Association for Computing Machinery (ACM), International Conference on Program Comprehension · Regular expressions written by language models were tested for being correct and for being open to denial of service; the generated ones mainly showed a slow, polynomial kind of weakness (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Re(gEx|DoS)Eval: Evaluating Generated Regular Expressions and their Proneness to DoS (ICSE 2024) ↗ — International Conference on Software Engineering (ICSE) · A benchmark of real user regular-expression requests scores generated patterns on whether they work and on whether they are open to denial of service (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Test::Regexp (Perl module documentation) ↗ — MetaCPAN · It is important to test which strings do not match a regular expression as well as which do (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.