Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd29u-0001IE-Bq for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:39:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hd29t-0002ih-2t for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 00:39:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd29s-0002iA-Hp for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 00:39:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hd29p-0003QB-TK for pgsql-general@postgresql.org; Tue, 18 Jun 2019 00:39:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5I0dL0v023409; Mon, 17 Jun 2019 20:39:21 -0400 From: Tom Lane To: Tim Cross cc: Ken Tanzer , Adrian Klaver , PG-General Mailing List Subject: Re: psql UPDATE field [tab] expands to DEFAULT? In-reply-to: References: Comments: In-reply-to Tim Cross message dated "Tue, 18 Jun 2019 10:09:11 +1000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23407.1560818361.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 17 Jun 2019 20:39:21 -0400 Message-ID: <23408.1560818361@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tim Cross writes: > On Tue, 18 Jun 2019 at 09:34, Ken Tanzer 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 "=3D" 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|=3D")) { /* 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