-- test/sql/regex_class_index.sql -- -- POSIX bracket classes, class escapes and embedded options through the -- INDEX must give the same rows as a sequential scan. -- -- Before 4.3.0 pg_tre's own pattern tokenizer (src/query/tokens.c) had no -- [:class:] support: '[[:alpha:]]' was read as the set {[, :, a, l, p, h} -- followed by a literal ']', so the index demanded a trigram the row did -- not have and silently DROPPED matching rows. \d \w \s raised "not yet -- implemented", and "(?i)" raised an empty "invalid regex pattern" -- both -- only on the index path, so the plan decided between a right answer and -- an error. Now: a collation-dependent bracket member or class escape is -- one opaque character for trigram extraction (like '.'), and embedded -- options make the pattern unindexable (lossy bitmap + recheck, as ILIKE). -- ASCII only on purpose: which non-ASCII letters a class holds depends on -- the collation (that is tested per strategy in tre_ctype_strategies.sql). CREATE EXTENSION IF NOT EXISTS pg_tre; SET client_min_messages = warning; DROP TABLE IF EXISTS rci; CREATE TABLE rci (id int, s text); INSERT INTO rci VALUES (1, 'xayz'), (2, 'x yz'), (3, 'x5yz'), (4, 'XAYZ'), (5, 'x_yz'), (6, 'x-yz'), (7, 'x:yz'), (8, 'x]yz'), (9, 'x.yz'), (10, 'x yz'), (11, 'abc123def'), (12, 'abc def'), (13, 'ABC DEF'), (14, 'a café b'), (15, 'ababcab'), (16, 'x as anchors). ('caf\xe9'), ('caf\u00e9'), ('x\x5fyz'), ('caf[\xe9]'), ('\mabc'), ('def\M'), ('\yabc\y'), ('\Aabc'), ('def\Z'), ('(ab)c\1'), ('x\