Problem:
--------
SELECT * FROM <view> returns following error message:
ERROR:  replace_vars_with_subplan_refs: variable not in subplan target list

Environment:
------------
Version: PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.95.2
System: Linux jtam.brno.czechin.cz 2.2.17-RAID #8 SMP Mon Oct 16 10:48:13
CEST 2000 i686 unknown

Exact steps to reproduce this bug:
----------------------------
CREATE TABLE "fs_ucastnici" (
        "id" integer DEFAULT nextval('"fs_ucastnici_id_seq"'::text) NOT
NULL,
        "jmeno" character varying(50),
        "email" character varying(40),
        Constraint "fs_ucastnici_pkey" Primary Key ("id")
);
CREATE SEQUENCE "fs_ucastnici_id_seq" start 1 increment 1 maxvalue
2147483647 minvalue 1 cache 1;

CREATE TABLE "userdb" (
        "username" character varying(16) NOT NULL,
        "email" text,
        "name" character varying(80)
);
CREATE UNIQUE INDEX userdb_pkey ON userdb USING btree (username);

CREATE TABLE "emaily" (
        "email" text NOT NULL,
        "jmeno" text,
        "akce" character varying(40) NOT NULL,
        Constraint "emaily_pkey" Primary Key ("email")
);

CREATE VIEW "infomail" as 
        SELECT DISTINCT ON (lower(vsichni.email)) vsichni.email,
vsichni.jmeno, vsichni.id, vsichni.odkud FROM (
                SELECT fs_ucastnici.email, fs_ucastnici.jmeno,
fs_ucastnici.id::text AS id, 'soutez' AS odkud FROM ONLY fs_ucastnici 
                UNION 
                SELECT userdb.email, userdb.name, (userdb.username)::text AS
username, 'userdb' FROM ONLY userdb 
                UNION 
                SELECT emaily.email, emaily.jmeno, ''::text, 'emaily' 
                FROM ONLY emaily WHERE (emaily.akce = 'add')
        ) vsichni 
        WHERE (vsichni.email ~ '@'::text) 
        ORDER BY lower(vsichni.email);

When this schema exists, try:

SELECT * FROM infomail;

On my system, it fails with "ERROR:  replace_vars_with_subplan_refs:
variable not in subplan target list".



bye,
Michal Schwarz

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to