Skip site navigation (1) Skip section navigation (2)

Re: bogus varno EXPLAIN bug (was Re: Explain analyze gives

From: Joe Conway <mail(at)joeconway(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kris Jurka <books(at)ejurka(dot)com>, Kris Jurka <jurka(at)ejurka(dot)com>,pgsql-bugs(at)postgresql(dot)org
Subject: Re: bogus varno EXPLAIN bug (was Re: Explain analyze gives
Date: 2002-12-06 17:54:58
Message-ID: 3DF0E472.6080109@joeconway.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Tom Lane wrote:
> Ah, thanks for the simplified test case.  This is undoubtedly my fault
> ... will look into it.  It is probably somewhat related to the join
> alias problem found yesterday (ie, somebody somewhere is trying to use
> the wrong rangetable list to interpret a Var node).

I spent a bit more time on it last night. Here's an even simpler example:

CREATE TABLE table1 (a int);
CREATE TABLE table2 (a int, b int);
INSERT INTO table1 (a) VALUES (1);
INSERT INTO table2 (a,b) VALUES (1,1);
INSERT INTO table2 (a,b) VALUES (1,2);

CREATE OR REPLACE FUNCTION func1(int) RETURNS setof int AS '
select a from table2 where a = $1
' LANGUAGE 'sql' WITH (isstrict);

CREATE OR REPLACE FUNCTION func2(int,int) RETURNS int AS '
select $1 * $2
' LANGUAGE 'sql' WITH (isstrict);

regression=# SELECT t2.a1 FROM (SELECT func2(t1.f1,3) as a1 FROM (SELECT 
func1(1) as f1) AS t1) AS t2 WHERE t2.a1 = 3;
  a1
----
   3
   3
(2 rows)

regression=# EXPLAIN SELECT t2.a1 FROM (SELECT func2(t1.f1,3) as a1 FROM 
(SELECT func1(1) as f1) AS t1) AS t2 WHERE t2.a1 = 3;
ERROR:  get_names_for_var: bogus varno 2

regression=# EXPLAIN SELECT t2.a1 FROM (SELECT func2(t1.f1,3) as a1 FROM 
(SELECT func1(1) as f1) AS t1) AS t2;                                    QUERY 
PLAN
----------------------------------------------------
  Subquery Scan t1  (cost=0.00..0.01 rows=1 width=0)
    ->  Result  (cost=0.00..0.01 rows=1 width=0)
(2 rows)

The problem is triggered by the WHERE clause. I was struggling as to where to 
be looking. BTW, it was still there after I sync'd up with cvs last night.

Joe



In response to

Responses

pgsql-bugs by date

Next:From: Bailey, ScottDate: 2002-12-06 19:33:27
Subject: test
Previous:From: Tom LaneDate: 2002-12-06 15:56:11
Subject: Re: bogus varno EXPLAIN bug (was Re: Explain analyze gives bogus varno for dblink views)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group