Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 34A821337B97 for ; Mon, 9 May 2011 11:00:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 68739-08 for ; Mon, 9 May 2011 14:00:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B51001337990 for ; Mon, 9 May 2011 11:00:34 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p49E0Tnr028884; Mon, 9 May 2011 10:00:29 -0400 (EDT) To: Rodriguez Fernando cc: pgsql-bugs@postgresql.org Subject: Re: column check mistake or not? In-reply-to: <4DC7D1D5.5070306@ort.edu.uy> References: <4DC7D1D5.5070306@ort.edu.uy> Comments: In-reply-to Rodriguez Fernando message dated "Mon, 09 May 2011 08:36:53 -0300" Date: Mon, 09 May 2011 10:00:29 -0400 Message-ID: <28883.1304949629@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/51 X-Sequence-Number: 30190 Rodriguez Fernando writes: > Yesterday i did a mistake executing one query, i use a column daes not > exists in the table the result was all rows of the table. > Platform Fedora 14 32 bits > Version Postgresql 9.0.2 > The column id_documento not exists in t_log_modificar_deuda, this > behavior is correct or not? > query > select * from t_documento where (importe_deudor_documento > > importe_documento) or id_documento in (select id_documento from > t_log_modificar_deuda); > result all column of t_documento. Yes, it is. That's an outer reference to the id_documento from t_documento, so of course the IN will succeed (assuming id_documento isn't null and there's at least one row in t_log_modificar_deuda). Outer references are a SQL feature that bites novices fairly often :-( but on the other hand sub-selects would be far less useful without them. regards, tom lane