Expand description
§sql-fingerprint
A SQL fingerprinter.
sql-fingerprint reduces SQL queries to recognizable fingerprints for easier comparison. The goal is to provide readable traces from queries captured during tests, so that changes can be tracked over time.
For example, given a query like:
SELECT name, age /* computed */ FROM cheeses WHERE origin = 'France'
…it will output a fingerprint like:
SELECT ... FROM cheeses WHERE ...
The fingerprinting process applies these changes:
- Comments are dropped.
- Whitespace is normalized to a single space.
- Identifier and value lists are reduced to ‘…’.
- Identifiers consisting of letters, numbers, and underscores have any quoting removed.
- Savepoint IDs are replaced with ‘s1’, ‘s2’, etc.
- Unparsable SQL is returned unchanged.
Functions§
- fingerprint_
many - Fingerprint multiple SQL strings. Doing so for a batch of strings allows sharing some state, such as savepoint ID aliases.
- fingerprint_
one - Fingerprint a single SQL string.