Re: Column name validation in embedded query.

From: "Jean-Pierre Pelletier" <pelletier_32(at)sympatico(dot)ca>
To: "Lori Pate" <lpate(at)opushealthcare(dot)com>, <pgadmin-support(at)postgresql(dot)org>
Subject: Re: Column name validation in embedded query.
Date: 2005-11-07 20:24:37
Message-ID: BAYC1-PASMTP043D6E1F04CF9EE0F10D9995650@CEZ.ICE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Column name validation in embedded query.The columns of testorder are
visible within the subquery
so the dbms interpret (correcly) patientorder_key as coming
from table testorder and gives no error.

I suggest you prefix column names within the subquery to avoid
such mistake.

Jean-Pierre Pelletier
e-djuster

----- Original Message -----
From: Lori Pate
To: pgadmin-support(at)postgresql(dot)org
Sent: Monday, November 07, 2005 9:55 AM
Subject: [pgadmin-support] Column name validation in embedded query.

I am using pgAdmin III, PostgreSQL tools, Version 1.2.0 Beta on Windows XP
Pro.
The following query, when executed as a stand alone query returns an error,
correctly, that the column name is not valid:
Query A) Select patientorder_key from patientorder where visit_key = 250314
and provider_key = 301;
The correct syntax should be:
Query B) Select patientorder.key from patientorder where visit_key = 250314
and provider_key = 301;
However, when the query with the incorrect column name (Query A) is embedded
in a where clause, column validation does not happen, no error is displayed,
and PGAdmin apparently ignores the where clause all together, resulting in
complete data deletion, as if there were no where clause:
Begin;
Delete from testorder where patientorder_key in
(Select patientorder_key from patientorder where visit_key = 250314 and
provider_key = 301);
End;
This resulted in massive amounts of data being deleted erroneously.
I believe this is a bug.
Lori E. Pate

Quality Assurance Engineer
Opus Healthcare Solutions, Inc.
12301 Research Blvd.
Bldg. IV, Suite 200
Austin, Texas 78759

Phone: 512.336.4562
E-Mail: lpate(at)opushealthcare(dot)com
AIM: loripate0508
http://www.opushealthcare.com/

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message MASAO TAKAHASHI 2005-11-08 02:51:55 Problem report on pgadmin3-1.4.0
Previous Message Dave Page 2005-11-07 19:35:37 Re: Column name validation in embedded query.