pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: tab completion of enum values is broken
Date: Thu, 13 Jan 2022 12:23:02 +0100
Message-ID: <8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com> (raw)

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.





view thread (4+ messages)  latest in thread

Message-ID: <8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com>
Permalink:  ../8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com/
Also on:    postgresql.org/message-id/8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@enterprisedb.com
  Subject: Re: tab completion of enum values is broken
  In-Reply-To: <8ca82d89-ec3d-8b28-8291-500efaf23b25@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox