From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Cross <theophilusx@gmail.com>
Cc: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: psql UPDATE field [tab] expands to DEFAULT?
Date: Mon, 17 Jun 2019 20:39:21 -0400
Message-ID: <23408.1560818361@sss.pgh.pa.us> (raw)
In-Reply-To: <CAC=50j-YLBHrr+wyDv5FhvjOKSnRGg8N2ayk-yHmjzbaa85nkw@mail.gmail.com>
References: <CAD3a31XpXzrZA9TT3BqLSHghdTK+=cXjNCE+oL2Zn4+oWoc=qA@mail.gmail.com>
<b70db19f-d582-0d1a-5b4d-15ea385781a4@aklaver.com>
<CAD3a31Vh2DDAthHCOZ0H_-PpXYqtjUtLuHOzRnKYULONDn-eew@mail.gmail.com>
<CAC=50j-YLBHrr+wyDv5FhvjOKSnRGg8N2ayk-yHmjzbaa85nkw@mail.gmail.com>
Tim Cross <theophilusx@gmail.com> writes:
> On Tue, 18 Jun 2019 at 09:34, Ken Tanzer <ken.tanzer@gmail.com> wrote:
>> Thanks Adrian, though I wasn't really seeking tips for column names. I
>> was instead trying to understand whether this particular tab expansion was
>> intentional and considered useful, and if so what that usefulness was,
>> because it's rather escaping me!
> Have to say, I fid that behaviour unusual as well.
I don't think it's intentional. A look into tab-complete.c shows that it
makes no attempt to offer completions beyond the "=" part of the syntax;
so there's room for improvement there. But then what is producing the
"DEFAULT" completion? After looking around a bit, I think it's
accidentally matching the pattern for a GUC "set" command:
else if (TailMatches("SET", MatchAny, "TO|="))
{
/* special cased code for individual GUCs */
...
else
COMPLETE_WITH("DEFAULT");
}
So perhaps that needs to look more like this other place where somebody
already noticed the conflict against UPDATE:
else if (TailMatches("SET|RESET") && !TailMatches("UPDATE", MatchAny, "SET"))
COMPLETE_WITH_QUERY(Query_for_list_of_set_vars);
More generally, though, I'm inclined to think that offering DEFAULT
and nothing else, which is what this code does if it doesn't recognize
the "GUC name", is just ridiculous. If the word after SET is not a known
GUC name then we probably have misconstrued the context, as indeed is
happening in your example; and in any case DEFAULT is about the least
likely thing for somebody to be trying to enter here. (They'd probably
have selected RESET not SET if they were trying to do that.)
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, theophilusx@gmail.com, ken.tanzer@gmail.com, adrian.klaver@aklaver.com
Subject: Re: psql UPDATE field [tab] expands to DEFAULT?
In-Reply-To: <23408.1560818361@sss.pgh.pa.us>
References: <CAD3a31XpXzrZA9TT3BqLSHghdTK+=cXjNCE+oL2Zn4+oWoc=qA@mail.gmail.com> <b70db19f-d582-0d1a-5b4d-15ea385781a4@aklaver.com> <CAD3a31Vh2DDAthHCOZ0H_-PpXYqtjUtLuHOzRnKYULONDn-eew@mail.gmail.com> <CAC=50j-YLBHrr+wyDv5FhvjOKSnRGg8N2ayk-yHmjzbaa85nkw@mail.gmail.com> <23408.1560818361@sss.pgh.pa.us>
* 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