Hi ,
Here is a patch corrected as your feedback except missed tests case because corresponding by clause is implemented on the top of set operation and you can’t do that to set operation without corresponding by clause too
Eg
postgres=# SELECT 1 a, 2 b, 3 c UNION SELECT 4 a, 5 b, 6 c, 8 d;
ERROR: each UNION query must have the same number of columns
LINE 1: SELECT 1 a, 2 b, 3 c UNION SELECT 4 a, 5 b, 6 c, 8 d;
^
postgres=# create table t1(a int, b int, c int);
CREATE TABLE
postgres=# create table t2(a int, b int);
CREATE TABLE
postgres=# select * from t1 union select * from t2;
ERROR: each UNION query must have the same number of columns
LINE 1: select * from t1 union select * from t2;
Thanks
Surafel