Bug 41181 - Problem in Postgres query
Summary: Problem in Postgres query
Status: NEW
Alias: None
Product: Slide
Classification: Unclassified
Component: Stores (show other bugs)
Version: Nightly
Hardware: Other All
: P2 major (vote)
Target Milestone: ---
Assignee: Slide Developer List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-15 06:52 UTC by Olivier ETIENNE
Modified: 2007-02-25 23:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier ETIENNE 2006-12-15 06:52:02 UTC
I think the 2d request of the method :
void removeObject(Connection connection, Uri uri, ObjectNode object)

In the class : org.apache.slide.store.impl.rdbms.PostgresRDBMSAdapter
will not work : 
delete from VERSION_HISTORY  
where VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?"

Because the element *URI.URI_ID* is unknown.
Comment 1 Antoine Levy-Lambert 2007-02-25 12:52:34 UTC
Hello Olivier,

I do not have a slide installation with a Postgres backend to test that.
I am relatively new in slide development. All the SQL statements in this class look weird, because they 
are all referencing columns of this URI table.

instead of :

delete from VERSION_HISTORY  
where VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?"


I would expect

delete from VERSION_HISTORY  
where VERSION_HISTORY.URI_ID IN (SELECT URI_ID FROM URI where URI_STRING = ?)"

Could you try it ?

If this change works, then probably most or all the SQL statements in this class need a similar change.

Regards,

Antoine
Comment 2 Carlos Villegas 2007-02-25 19:15:43 UTC
The current syntax is correct. This is a non-standard syntax in PostgreSQL 
SQL. As explained in the PostgreSQL documentation:

Notes

PostgreSQL lets you reference columns of other tables in the WHERE condition. 
For example, to delete all films produced by a given producer, one might do

DELETE FROM films
  WHERE producer_id = producers.id AND producers.name = 'foo';

What is essentially happening here is a join between films and producers, with 
all successfully joined films rows being marked for deletion. This syntax is 
not standard. A more standard way to do it is

DELETE FROM films
  WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');
Comment 3 Nicolas Aguil 2007-02-25 23:49:50 UTC
Hi,

I've had the same problem and i've solved it like this :
 - add a USING foo1, foo2,... clause in the query

ex :
delete from VERSION_HISTORY
using URI
where VERSION_HISTORY.URI_ID = URI.URI_ID and URI.URI_STRING = ?

It works for me (PostgreSQL 8.2.3)


Nicolas Aguilé