http://dev.mysql.com/doc/refman/4.1/en/insert-select.html

Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.

We require MySQL 4.1.

Comments

catch’s picture

#189832 was duplicate, yay!

FiReaNGeL’s picture

Make perfect sense to me; I wasn't even aware of that limitation in pre 4.1 MySQL.

catch’s picture

Status: Needs review » Reviewed & tested by the community

disabled comment module.
Posted a node - no record made in node_comment_statistics
applied the patch
enabled comment module
node_comment_statistics was updated, and the values were all fine.

Bye bye then.

chx’s picture

To continue the quote from MySQL manual

In this case, MySQL creates a temporary table to hold the rows from the SELECT and then inserts those rows into the target table.

I just tested that INSERT...SELECT works into the same table with just INSERT and SELECT grants. So while the manual says there is a temporary table being made that's behind the scenes, somewhat similar to the well known fact that some ordinary SELECTs result in a temporary table (and when those get on disk, your performance plumets).

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs review

Who tested this on PostgreSQL?

chx’s picture

Status: Needs review » Reviewed & tested by the community

Me.

test=# create table boo (foo int);
CREATE TABLE
test=# insert into boo values (1);
INSERT 0 1
test=# insert into boo values (2);
INSERT 0 1
test=# insert into boo select * from boo;
INSERT 0 2
test=# select * from boo;
 foo
-----
   1
   2
   1
   2
(4 rows)
gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

OK, committed, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.