Teodor Sigaev wrote:
Ah, I think this is the missing, essential component:
CREATE INDEX ON t(right(i::text,1)) WHERE i::text LIKE '%1';
Finally, I reproduce it with attached script.
In attachment simplified version of script. psql uses ordinary sql query to get info about index with usual transaction isolation/MVCC. To create a description of index it calls pg_get_indexdef() which doesn't use transaction snapshot, it uses catalog snapshot because it accesses to catalog through system catalog cache. So the difference is used snapshot between ordinary SQL query and pg_get_indexdef(). I'm not sure that easy to fix and should it be fixed at all.

Simplified query:
SELECT c2.relname, i.indexrelid,
        pg_catalog.pg_get_indexdef(i.indexrelid, 0, true)
FROM pg_catalog.pg_class c, pg_catalog.pg_class c2,
        pg_catalog.pg_index i
WHERE c.relname = 't' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
--
Teodor Sigaev                      E-mail: teo...@sigaev.ru
                                      WWW: http://www.sigaev.ru/

Attachment: 1.sh
Description: application/shellscript

Reply via email to