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.92) (envelope-from ) id 1j6i74-0003lK-VU for pgsql-general@arkaria.postgresql.org; Tue, 25 Feb 2020 21:51:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j6i73-00032a-At for pgsql-general@arkaria.postgresql.org; Tue, 25 Feb 2020 21:51: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 1j6i72-00032S-R7 for pgsql-general@lists.postgresql.org; Tue, 25 Feb 2020 21:51:33 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j6i6y-000752-NR for pgsql-general@postgresql.org; Tue, 25 Feb 2020 21:51:31 +0000 Received: by mail-pj1-x1032.google.com with SMTP id e9so322342pjr.4 for ; Tue, 25 Feb 2020 13:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=D9jY4tsnGFAl8jxeXED9w4pOY0H1eoHnqpt0I7Byxyk=; b=Q6X4QMr0mSPh9Td97XzaIxHv7wkmTJ2qiQks0ivO5+2VoWF/zB9gKlLdYDpPz3qevI NVmimabbHAi9w5vG/ky1XAZZrkJd6q6edYv+Y8nCcztGyF6mE5cTyxbjWHSsYfMhKlHC QwfA90GOJ6tqq0enevAROjG8H61+UJXQk8QvS8UlUb1KFCrOg8WRqJ/TvFqiL78t2ld6 828B/tw+j50hLmJcs9ePLmxExApr37aQHWsaEjZaMrFcl4hf98AYUiXV+5ysUtX4x5KQ YA+m8irj1DclEsUisCon7elsssHFaPte+j6+BuD8x5LFIbSs3rlF6Zo/lloMhSjdgSQU S67g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=D9jY4tsnGFAl8jxeXED9w4pOY0H1eoHnqpt0I7Byxyk=; b=Xoezuh1Thd6E5NluR3XrkDds+BfhuRJsHB6sGFo/QYTALwze6w3h0qbKHzgWMklhUC DCuJbC5jaB7hLb2f8ghIxpmHzBOS0V4DQ6sphiwGQnUJo1o/Pb1F7QJztN9Ot+ikGjyD yc9Q3src3bD8VCZZRypQsveVnABzTTLgvFe8Kf4N7fOOxPDGJCb1uzylCBJ3UKEncFJn e/A+m2MJK8wvum5fljNV5yy42z+i2MKUox+WchDgWWMpriEi+RlV2HNOiEzpL8SPAWUC mzJbnyg+t3EecDjhvWejWWUm6zeWy+PBfV4K+MWQzaF/Pg0qkedQg7bGKjAbTy/GqzCQ U42A== X-Gm-Message-State: APjAAAUCPi5H30zwkGYhjabLMwTfugEi9PuyLAUZjW3E5PXf6QadV8fI 2X5gWsxjK3ZVNCxWUvO9LfcQXsr+ X-Google-Smtp-Source: APXvYqyVQlHjC9+AkF9J6S4Pgqx2Z0y4NN29kMBDpSvzsmR486dvv1yzlF4vA0ojCmaLTncd94KO7w== X-Received: by 2002:a17:902:d705:: with SMTP id w5mr632029ply.68.1582667487075; Tue, 25 Feb 2020 13:51:27 -0800 (PST) Received: from [10.106.131.4] ([155.100.47.4]) by smtp.gmail.com with ESMTPSA id 64sm51247pfd.48.2020.02.25.13.51.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Feb 2020 13:51:26 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Rob Sargent Mime-Version: 1.0 (1.0) Subject: Re: a proposal for a new functionality: "SELECT * [EXCEPT col1 [,col2]] Date: Tue, 25 Feb 2020 14:51:25 -0700 Message-Id: <1157C290-FBB8-4041-BDA4-E5E18C37174C@gmail.com> References: <20110.1582665236@sss.pgh.pa.us> Cc: Paul Jungwirth , Stanislav Motycka , PG-General Mailing List In-Reply-To: <20110.1582665236@sss.pgh.pa.us> To: Tom Lane X-Mailer: iPhone Mail (17D50) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Feb 25, 2020, at 2:14 PM, Tom Lane wrote: >=20 > =EF=BB=BFPaul Jungwirth writes: >> Not that this is necessarily fatal, but you'd need to avoid parsing=20 >> trouble with the other EXCEPT, e.g. >> SELECT 1 EXCEPT SELECT 1; >=20 > Yeah, it doesn't sound like much consideration has been given to > that ambiguity, but it's a big problem if you want to use a syntax > like this. >=20 >> Google Big Query was mentioned upthread. I see they require parens, e.g.=20= >> SELECT ... EXCEPT (...). I don't think that actually fixes the ambiguity=20= >> though. >=20 > Indeed it doesn't, because you can parenthesize an EXCEPT's sub-queries: >=20 > regression=3D# select 1 except (select 2); > ?column?=20 > ---------- > 1 > (1 row) >=20 > In principle, once you got to the SELECT keyword you could tell things > apart, but I'm afraid that might be too late for a Bison-based parser. >=20 >> So it seems they require at least one `*` in the SELECT target list. In=20= >> fact the `*` must be the very last thing. Personally I think it should=20= >> be as general as possible and work even without a `*` (let alone caring=20= >> about its position). >=20 > I wonder if they aren't thinking of the EXCEPT as annotating the '*' > rather than the whole SELECT list. That seems potentially more flexible, > not less so. Consider >=20 > SELECT t1.* EXCEPT (foo, bar), t2.* EXCEPT (baz) ... FROM t1, t2, ... >=20 > This doesn't have any problem with ambiguity if t2 has a "foo" column, > or if t1 has a "baz" column; which indeed would be cases where this > sort of ability would be pretty useful, since otherwise you end up > with painful-to-rename duplicate output column names. And certainly > there is no particular need for this construct if you didn't write > a "*". >=20 > regards, tom lane >=20 OMIT rather than EXCEPT? >=20