Re: Minor buglet in update...from (I think)
От | Bruce Momjian |
---|---|
Тема | Re: Minor buglet in update...from (I think) |
Дата | |
Msg-id | 200111270039.fAR0d6d13929@candle.pha.pa.us обсуждение исходный текст |
Ответ на | Re: Minor buglet in update...from (I think) (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Minor buglet in update...from (I think)
|
Список | pgsql-hackers |
> Bruce Momjian <pgman@candle.pha.pa.us> writes: > > Oh, so it is the aggregate. What threw me off is that both parts of the > > WHERE clause are required to cause the failure, > > Not necessarily; I think it's got more to do with a null aggregate > result: > > regression=# create table t1 (f1 datetime); > CREATE > regression=# create table t2 (f2 datetime); > CREATE > regression=# update t2 set f2 = min(f1) from t1; > ERROR: ExecutePlan: (junk) `ctid' is NULL! > regression=# insert into t1 values ('now'); > INSERT 400577 1 > regression=# update t2 set f2 = min(f1) from t1; > ERROR: ExecutePlan: (junk) `ctid' is NULL! > regression=# insert into t2 values ('now'); > INSERT 400578 1 > regression=# update t2 set f2 = min(f1) from t1; > UPDATE 1 > regression=# > > However the ERROR is only one symptom. The real problem is that the > calculation that's being done is useless/nonsensical. > > > I don't see a problem with aggregates in UPDATE, > > Think harder ... what is the aggregate being taken over, and how do you > associate the aggregate's single result row with any particular row in > the UPDATE's target table? I thought the aggregate would be generated on all rows in the table in the pre-transaction version of the table, so in this example: regression=# update t2 set f2 = min(f1) from t1; It places the minimum value of t1.f1 in all t2.f2 rows. Is there another way to look at it? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
В списке pgsql-hackers по дате отправления: