-- -- first, define the datatype. Turn off echoing so that expected file -- does not depend on `CREATE EXTENSION wildspeed` output. -- SET client_min_messages = warning; \set ECHO none RESET client_min_messages; SELECT permute(''); permute --------- {$} (1 row) SELECT permute('0'); permute --------- {0$} (1 row) SELECT permute('01'); permute ----------- {01$,1$0} (1 row) SELECT permute('hello'); permute -------------------------------------- {hello$,ello$h,llo$he,lo$hel,o$hell} (1 row) CREATE TABLE testlike ( t text ); \copy testlike from 'data/testlike.data' INSERT INTO testlike VALUES (''); SELECT * FROM testlike WHERE t LIKE '' ORDER BY t; t --- (1 row) SELECT * FROM testlike WHERE t LIKE '%' ORDER BY t; t ------- hekko helko hella hello hillo jeeeh jelko jella jello (10 rows) SELECT * FROM testlike WHERE t LIKE 'hello' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE 'hello%' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE 'hel%' ORDER BY t; t ------- helko hella hello (3 rows) SELECT * FROM testlike WHERE t LIKE '%hello' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE '%lo' ORDER BY t; t ------- hello hillo jello (3 rows) SELECT * FROM testlike WHERE t LIKE '%hello%' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE '%ll%' ORDER BY t; t ------- hella hello hillo jella jello (5 rows) SELECT * FROM testlike WHERE t LIKE 'h%o' ORDER BY t; t ------- hekko helko hello hillo (4 rows) SELECT * FROM testlike WHERE t LIKE 'h%l%o' ORDER BY t; t ------- helko hello hillo (3 rows) SELECT * FROM testlike WHERE t LIKE 'h%l%o' ORDER BY t; t ------- helko hello hillo (3 rows) SELECT * FROM testlike WHERE t LIKE 'h%e%l%o' ORDER BY t; t ------- helko hello (2 rows) SELECT * FROM testlike WHERE t LIKE '%e%l%' ORDER BY t; t ------- helko hella hello jelko jella jello (6 rows) SELECT * FROM testlike WHERE t LIKE '%e%o' ORDER BY t; t ------- hekko helko hello jelko jello (5 rows) SELECT * FROM testlike WHERE t LIKE 'h%o%' ORDER BY t; t ------- hekko helko hello hillo (4 rows) SELECT * FROM testlike WHERE t LIKE 'j%e%' ORDER BY t; t ------- jeeeh jelko jella jello (4 rows) SELECT * FROM testlike WHERE t LIKE 'j%k%' ORDER BY t; t ------- jelko (1 row) SELECT * FROM testlike WHERE t LIKE 'h%k%' ORDER BY t; t ------- hekko helko (2 rows) CREATE INDEX like_idx ON testlike USING gin ( t wildcard_ops ); SET enable_seqscan=off; SELECT * FROM testlike WHERE t LIKE '' ORDER BY t; t --- (1 row) SELECT * FROM testlike WHERE t LIKE '%' ORDER BY t; t ------- hekko helko hella hello hillo jeeeh jelko jella jello (10 rows) SELECT * FROM testlike WHERE t LIKE 'hello' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE 'hello%' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE 'hel%' ORDER BY t; t ------- helko hella hello (3 rows) SELECT * FROM testlike WHERE t LIKE '%hello' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE '%lo' ORDER BY t; t ------- hello hillo jello (3 rows) SELECT * FROM testlike WHERE t LIKE '%hello%' ORDER BY t; t ------- hello (1 row) SELECT * FROM testlike WHERE t LIKE '%ll%' ORDER BY t; t ------- hella hello hillo jella jello (5 rows) SELECT * FROM testlike WHERE t LIKE 'h%o' ORDER BY t; t ------- hekko helko hello hillo (4 rows) SELECT * FROM testlike WHERE t LIKE 'h%l%o' ORDER BY t; t ------- helko hello hillo (3 rows) SELECT * FROM testlike WHERE t LIKE 'h%l%o' ORDER BY t; t ------- helko hello hillo (3 rows) SELECT * FROM testlike WHERE t LIKE 'h%e%l%o' ORDER BY t; t ------- helko hello (2 rows) SELECT * FROM testlike WHERE t LIKE '%e%l%' ORDER BY t; t ------- helko hella hello jelko jella jello (6 rows) SELECT * FROM testlike WHERE t LIKE '%e%o' ORDER BY t; t ------- hekko helko hello jelko jello (5 rows) SELECT * FROM testlike WHERE t LIKE 'h%o%' ORDER BY t; t ------- hekko helko hello hillo (4 rows) SELECT * FROM testlike WHERE t LIKE 'j%e%' ORDER BY t; t ------- jeeeh jelko jella jello (4 rows) SELECT * FROM testlike WHERE t LIKE 'j%k%' ORDER BY t; t ------- jelko (1 row) SELECT * FROM testlike WHERE t LIKE 'h%k%' ORDER BY t; t ------- hekko helko (2 rows)