Unix Technical Forum

Re: DELETE ... USING

This is a discussion on Re: DELETE ... USING within the Pgsql Patches forums, part of the PostgreSQL category; --> Hi Neil, > Looking at how to implement this, there is some rather dodgy code in > warnAutoRange() in ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 12:13 AM
Euler Taveira de Oliveira
 
Posts: n/a
Default Re: DELETE ... USING

Hi Neil,

> Looking at how to implement this, there is some rather dodgy code in
> warnAutoRange() in parse_relation.c that only emits the notice about
> adding a missing FROM clause entry if the query already has at least
> one
> range table entry in its FROM clause. The idea appears to be to not
> issue warnings about queries like "SELECT foo.*;", but it also means
> we
> don't end up warning about DELETE and UPDATE.
>
> I think the right fix is to remove the "inFromCl" check, and always
> issue a notice. With add_missing_from=true, all these queries are
> rejected anyway, so I think it makes sense to warn about all of them
> when add_missing_from is disabled. Objections?
>

No. That's why I'm thinking now while looking at the code Could you
provide a patch?


Euler Taveira de Oliveira
euler[at]yahoo_com_br





Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 12:13 AM
Neil Conway
 
Posts: n/a
Default Re: DELETE ... USING

Euler Taveira de Oliveira wrote:
> Could you provide a patch?


Sure, a revised patch is attached. Note that this change will also
require updating 25 (!) of the regression tests, since they use the
SELECT-without-FROM syntax. I will update the tests (by adding an
explicit FROM clause) before applying the patch -- which I'll do
tomorrow, barring any objections.

-Neil


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 12:13 AM
Bruce Momjian
 
Posts: n/a
Default Re: DELETE ... USING

Neil Conway wrote:
> Euler Taveira de Oliveira wrote:
> > Could you provide a patch?

>
> Sure, a revised patch is attached. Note that this change will also
> require updating 25 (!) of the regression tests, since they use the
> SELECT-without-FROM syntax. I will update the tests (by adding an
> explicit FROM clause) before applying the patch -- which I'll do
> tomorrow, barring any objections.


I just checked current CVS and see exactly what you describe:

test=> SELECT pg_class.* LIMIT 0;
ERROR: missing FROM-clause entry for table "pg_class"

test=> SET add_missing_from=true;
SET
test=> SELECT pg_class.* LIMIT 0;
NOTICE: adding missing FROM-clause entry for table "pg_class"

Is this what we want? I don't think so. I thought we wanted to
maintain the backward-compatible syntax of no FROM clause.

--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 12:13 AM
Neil Conway
 
Posts: n/a
Default Re: DELETE ... USING

Bruce Momjian wrote:
> Is this what we want? I don't think so. I thought we wanted to
> maintain the backward-compatible syntax of no FROM clause.


We do? Why?

It is just as noncompliant with the SQL spec as other variants of this
behavior. add_missing_from would *always* have rejected those queries,
so ISTM we have been discouraging this case for as long as
add_missing_from has existed. If we want to allow this syntax by
default, we will need to effectively redefine the meaning of
add_missing_from -- which is fine, I just didn't think anyone wanted that.

-Neil

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-18-2008, 12:13 AM
Tom Lane
 
Posts: n/a
Default Re: DELETE ... USING

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> test=> SELECT pg_class.* LIMIT 0;
> NOTICE: adding missing FROM-clause entry for table "pg_class"


> Is this what we want? I don't think so. I thought we wanted to
> maintain the backward-compatible syntax of no FROM clause.


Well, the discussion earlier in the week concluded that
add_missing_from=true should emit a notice in every case where
add_missing_from=false would fail. Do you want to argue against
that conclusion?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:21 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com