From ad26b2da1a5f784f867b471dc647fc6b593711a0 Mon Sep 17 00:00:00 2001 From: Peter Mattis Date: Thu, 28 Dec 2017 16:34:29 -0500 Subject: [PATCH] sql: document differing subquery behavior from Postgres Release note: None --- .../logictest/testdata/logic_test/subquery | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/sql/logictest/testdata/logic_test/subquery b/pkg/sql/logictest/testdata/logic_test/subquery index d1b2411821a5..a3bfbae6b5a8 100644 --- a/pkg/sql/logictest/testdata/logic_test/subquery +++ b/pkg/sql/logictest/testdata/logic_test/subquery @@ -60,24 +60,49 @@ SELECT (SELECT 1) IN (1) ---- true +# NB: Cockroach has different behavior from Postgres on a few esoteric +# subqueries. The Cockroach behavior seems more sensical and +# supporting the specific Postgres behavior appears onerous. Fingers +# crossed this doesn't bite us down the road. + +# Postgres cannot handle this query (but MySQL can), even though it +# seems sensical: +# ERROR: subquery must return only one column +# LINE 1: select (select 1, 2) IN (select 1, 2); +# ^ query B SELECT (SELECT 1, 2) IN (SELECT 1, 2) ---- true +# Postgres cannot handle this query, even though it seems sensical: +# ERROR: subquery must return only one column +# LINE 1: select (select 1, 2) IN ((1, 2)); +# ^ query B SELECT (SELECT 1, 2) IN ((1, 2)) ---- true +# Postgres cannot handle this query, even though it seems sensical: +# ERROR: subquery has too many columns +# LINE 1: select (select (1, 2)) IN (select 1, 2); +# ^ query B SELECT (SELECT (1, 2)) IN (SELECT 1, 2) ---- true +query B +SELECT (SELECT (1, 2)) IN ((1, 2)) +---- +true + query error unsupported comparison operator: IN SELECT (SELECT 1, 2) IN (SELECT (1, 2)) +# Postgres successfully handles this query (returning true), even +# though doing so seems at odds with other rules. query error unsupported comparison operator: IN SELECT (SELECT (1, 2)) IN (SELECT (1, 2))