tab completion of enum values is broken

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: tab completion of enum values is broken
Date: 2022-01-13 11:23:02
Message-ID: 8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This doesn't work anymore:

create type e2 as enum ('foo', 'bar');
alter type e2 rename value 'b<TAB>

This now results in

alter type e2 rename value 'b'

Bisecting blames

commit cd69ec66c88633c09bc9a984a7f0930e09c7c96e
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Date: Thu Jan 23 11:07:12 2020 -0500

Improve psql's tab completion for filenames.

which did deal with quoting of things to be completed, so it seems very
plausible to be some collateral damage.

The queries issued by the completion engine are

bad

LOG: statement: SELECT pg_catalog.quote_literal(enumlabel) FROM
pg_catalog.pg_enum e, pg_catalog.pg_type t WHERE t.oid = e.enumtypid
AND substring(pg_catalog.quote_literal(enumlabel),1,1)='b' AND
(pg_catalog.quote_ident(typname)='e2' OR '"' || typname ||
'"'='e2') AND pg_catalog.pg_type_is_visible(t.oid) LIMIT 1000

good

LOG: statement: SELECT pg_catalog.quote_literal(enumlabel) FROM
pg_catalog.pg_enum e, pg_catalog.pg_type t WHERE t.oid = e.enumtypid
AND substring(pg_catalog.quote_literal(enumlabel),1,2)='''b' AND
(pg_catalog.quote_ident(typname)='e2' OR '"' || typname ||
'"'='e2') AND pg_catalog.pg_type_is_visible(t.oid) LIMIT 1000

I tried quickly fiddling with the substring() call to correct for the
changed offset somehow, but didn't succeed. Needs more analysis.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-01-13 11:29:54 Re: Support tab completion for upper character inputs in psql
Previous Message RKN Sai Krishna 2022-01-13 11:16:57 Isolation levels on primary and standby