Thread: parser error?
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?? -- Felipe Schnack Analista de Sistemas felipes@ritterdosreis.br Cel.: (51)91287530 Linux Counter #281893 Centro Universitário Ritter dos Reis http://www.ritterdosreis.br ritter@ritterdosreis.br Fone/Fax.: (51)32303341
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;
Hey, actually it did! There is a way I can tell pgsql to stop doing that? I have some problems here with that. On Mon, 2003-01-06 at 16:35, Stephan Szabo wrote: > 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; > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Felipe Schnack Analista de Sistemas felipes@ritterdosreis.br Cel.: (51)91287530 Linux Counter #281893 Centro Universitário Ritter dos Reis http://www.ritterdosreis.br ritter@ritterdosreis.br Fone/Fax.: (51)32303341
On 6 Jan 2003, Felipe Schnack wrote: > Hey, actually it did! > There is a way I can tell pgsql to stop doing that? I have some > problems here with that. I don't think so currently (but I haven't checked the docs). Probably it should be something settable like the transform_null_equals.