Re: Intersection or zero-column queries

2017-12-22 Thread Tom Lane
I wrote: > "David G. Johnston" writes: >> How about just erroring out? > Hm, yeah, inserting a FEATURE_NOT_SUPPORTED error might be an > appropriate amount of effort. When I looked into this more closely, it turns out that in v10/HEAD it takes less code to fix it than to throw an error ;-). So

Re: Intersection or zero-column queries

2017-12-22 Thread Tom Lane
Ken Tanzer writes: > I noticed I get this behavior in 9.6, but in 9.2 an empty select results in > a syntax error. Which just got me curious what caused the change, if it > was deliberate, and if one or the other is more proper behavior. Yes, it was an intentional change, see https://git.postgre

Re: Intersection or zero-column queries

2017-12-21 Thread Ken Tanzer
I noticed I get this behavior in 9.6, but in 9.2 an empty select results in a syntax error. Which just got me curious what caused the change, if it was deliberate, and if one or the other is more proper behavior. Cheers, Ken -- AGENCY Software A Free Software data system By and for non-profits

Re: Intersection or zero-column queries

2017-12-21 Thread Tom Lane
"David G. Johnston" writes: > On Thursday, December 21, 2017, Tom Lane wrote: >> So yeah, it's wrong ... but personally I'm not terribly excited >> about fixing it. Maybe somebody else wants to; but what's the >> practical use? > How about just erroring out? Hm, yeah, inserting a FEATURE_NOT_S

Re: Intersection or zero-column queries

2017-12-21 Thread David G. Johnston
On Thursday, December 21, 2017, Tom Lane wrote: > which would only be the right plan for UNION ALL. > > So yeah, it's wrong ... but personally I'm not terribly excited > about fixing it. Maybe somebody else wants to; but what's the > practical use? > How about just erroring out? David J.

Re: Intersection or zero-column queries

2017-12-21 Thread Tom Lane
Victor Yegorov writes: > However, if I'll do `EXCPET` or `INTERSECT` of such queries, I'll get 2 > rows: > postgres=# select except select; > -- > (2 rows) > postgres=# select intersect all select; > -- > (2 rows) > Why is it so? The UNION case seems wrong as well: regr

Re: Intersection or zero-column queries

2017-12-21 Thread David G. Johnston
On Thu, Dec 21, 2017 at 5:08 PM, Victor Yegorov wrote: > > Also, intersection should not return more rows, than there're in the > sub-relations. > > Doh!, I think I got UNION into my mind somewhere in that... David J.

Re: Intersection or zero-column queries

2017-12-21 Thread Victor Yegorov
2017-12-22 2:03 GMT+02:00 David G. Johnston : > On Thu, Dec 21, 2017 at 4:53 PM, Victor Yegorov > wrote: > >> postgres=# select except select; >> -- >> (2 rows) >> postgres=# select intersect all select; >> -- >> (2 rows) >> >> Why is it so? >> Should this be reported as a

Re: Intersection or zero-column queries

2017-12-21 Thread David G. Johnston
On Thu, Dec 21, 2017 at 4:53 PM, Victor Yegorov wrote: > postgres=# select except select; > -- > (2 rows) > postgres=# select intersect all select; > -- > (2 rows) > > Why is it so? > Should this be reported as a bug?.. ;) > ​The intersection case seems correct - one row

Intersection or zero-column queries

2017-12-21 Thread Victor Yegorov
Greetings. One can issue an empty `SELECT` statement and 1 row without columns will be returned: postgres=# select; -- (1 row) However, if I'll do `EXCPET` or `INTERSECT` of such queries, I'll get 2 rows: postgres=# select except select; -- (2 rows) postgres=# select