pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedcolumn check mistake or not?
2+ messages / 2 participants
[nested] [flat]
* column check mistake or not?
@ 2011-05-09 11:36 Rodriguez Fernando <rodriguez@ort.edu.uy>
0 siblings, 1 reply; 2+ messages in thread
From: Rodriguez Fernando @ 2011-05-09 11:36 UTC (permalink / raw)
To: pgsql-bugs
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.
schema
CREATE TABLE t_documento (
id_documento d_codigo NOT NULL,
nro_documento d_codigo NOT NULL,
importe_documento d_importe,
id_cliente d_codigo,
id_razon_social d_codigo,
fecha_documento d_fecha NOT NULL,
usuario_ingreso d_usuario_ingreso,
fecha_ingreso d_fecha_ingreso,
hora_ingreso d_hora_ingreso,
id_tipo_documento d_codigo,
fecha_vencimiento_documento d_fecha,
id_moneda d_codigo,
id_sucursal d_codigo,
motivo_anulacion_documento d_descripcion,
fecha_anulacion_documento d_fecha,
hora_anulacion_documento d_hora,
usuario_anulacion_documento d_nombre,
sistema_viejo_documento d_boolean DEFAULT 'N'::bpchar NOT NULL,
redondeo_documento d_importe DEFAULT 0 NOT NULL,
importe_deudor_documento d_importe DEFAULT 0 NOT NULL,
id_categoria_documento d_codigo NOT NULL,
fecha_exportado_memory_documento d_fechahora,
aniomes_exportado_gestoria_documento integer,
importe_deudor_documento_ant d_importe,
modificado integer DEFAULT 0,
anulacion_exportado_memory_documento d_fechahora
);
ALTER TABLE ONLY t_documento
ADD CONSTRAINT documento_primary PRIMARY KEY (id_documento);
ALTER TABLE ONLY t_documento
ADD CONSTRAINT nro_documento_unico UNIQUE (nro_documento);
CREATE TABLE t_log_modificar_deuda (
nro_documento d_codigo NOT NULL,
importe_actual d_importe NOT NULL,
importe_sugerido d_importe NOT NULL,
usuario_ingreso d_usuario_ingreso,
fecha_ingreso d_fecha_ingreso,
hora_ingreso d_hora_ingreso
);
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: column check mistake or not?
@ 2011-05-09 14:00 Tom Lane <tgl@sss.pgh.pa.us>
parent: Rodriguez Fernando <rodriguez@ort.edu.uy>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2011-05-09 14:00 UTC (permalink / raw)
To: Rodriguez Fernando <rodriguez@ort.edu.uy>; +Cc: pgsql-bugs
Rodriguez Fernando <rodriguez@ort.edu.uy> 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-05-09 14:00 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-09 11:36 column check mistake or not? Rodriguez Fernando <rodriguez@ort.edu.uy>
2011-05-09 14:00 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox