Re: parser error?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Felipe Schnack <felipes(at)ritterdosreis(dot)br>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: parser error?
Date: 2003-01-06 18:35:53
Message-ID: 20030106103405.V47795-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6 Jan 2003, Felipe Schnack wrote:

> I have a table called "questionarios" (sorry, it's portuguese), and
> its primary key is a field called "codquestionario". Why pgsql doesn't
> "throw" an error when this query is executed?
> select * from questionarios q where questionarios.codquestionario = 1
> In my opinion, "questionarios" should not be valid in this query, only
> "q", but for some reason the condition "questionarios.codquestionario"
> just get ignored and all records are returned.
> Why??

You probably should be getting a notice with that query.
NOTICE: Adding missing FROM-clause entry for table "questionarios"

It realizes the query is invalid as is and attempts to add questionarios
to the from list to make it valid, thus the query you're really running
is:

select * from questionarios q, questionarios where
questionarios.codquestionario = 1;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ren Salomo 2003-01-06 19:00:18 Re: refcursor
Previous Message Felipe Schnack 2003-01-06 18:35:08 Re: parser error?