Thread: UNION and VIEW

UNION and VIEW

From
Roland Schulz
Date:
Your name               : Roland Schulz
Your email address      : rschulz9@web.de


System Configuration
---------------------
  Architecture (example: Intel Pentium)         : Intel Pentium MMX

  Operating System (example: Linux 2.0.26 ELF)  : Linux 2.4.1 ELF

  PostgreSQL version (example: PostgreSQL-7.1):   PostgreSQL-7.1beta4

  Compiler used (example:  gcc 2.8.0)           : 2.95.2


Please enter a FULL description of your problem:
------------------------------------------------
When using UNION in a VIEW, the view displays always all records
disregarding any WHERE's. This problem didn't happen with beta1. The
SELECT in the example should only display the records where the field
'typ' is 1 not all records.create database test;

\connect test

CREATE TABLE "t2" (
    "nr2" integer,
    "t1" integer
);

CREATE TABLE "t1" (
    "nr1" integer,
    "typ" integer,
    "art" integer
);

CREATE VIEW "feld" as SELECT * FROM t1, t2 WHERE t1.nr1 = t2.t1 UNION
 SELECT *, null, null FROM t1 WHERE t1.art = 1;

insert into t2 values(4,    4);
insert into t2 values(3,    3);

insert into t1 values(1,    1,    1);
insert into t1 values(2,    2,    1);
insert into t1 values(3,    1,    2);
insert into t1 values(4,    2,    2);

select * from feld where typ=1;

\c

drop database test;

Re: UNION and VIEW

From
Tom Lane
Date:
Roland Schulz <rschulz9@web.de> writes:
> When using UNION in a VIEW, the view displays always all records
> disregarding any WHERE's. This problem didn't happen with beta1.

Yeah, this was a silly error added in beta4.  It's fixed in the current
snapshot.

            regards, tom lane