tab completion of enum values is broken - Mailing list pgsql-hackers

From Peter Eisentraut
Subject tab completion of enum values is broken
Date
Msg-id 8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com
Whole thread Raw
Responses Re: tab completion of enum values is broken
Re: tab completion of enum values is broken
List 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@sss.pgh.pa.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.



pgsql-hackers by date:

Previous
From: RKN Sai Krishna
Date:
Subject: Isolation levels on primary and standby
Next
From: Peter Eisentraut
Date:
Subject: Re: Support tab completion for upper character inputs in psql