On 07/22/2013 06:20 PM, Jeff Janes wrote: > On Fri, Jul 19, 2013 at 3:20 PM, Natalie Wenz <nataliew...@ebureau.com> wrote: >> Hi all, >> >> I am moving some data from one table to another in 9.2.4, and keep seeing >> this strange scenario: >> >> insert into newtable select data from oldtable where proc_date >= x and >> proc_date < y; >> >> INSERT 0 78551642 >> >> select count(*) from newtable where proc_date >= x and proc_date < y; >> count >> ----------- >> 4373518938 > It looks to me like the status report is 32 bits and overflowed. > > 4,373,518,938 - 2^32 = 78,551,642
Attached is a small patch that should fix the problem. Vik
*** a/src/backend/commands/createas.c --- b/src/backend/commands/createas.c *************** *** 172,178 **** ExecCreateTableAs(CreateTableAsStmt *stmt, const char *queryString, /* save the rowcount if we're given a completionTag to fill */ if (completionTag) snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "SELECT %u", queryDesc->estate->es_processed); /* and clean up */ ExecutorFinish(queryDesc); --- 172,178 ---- /* save the rowcount if we're given a completionTag to fill */ if (completionTag) snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "SELECT " UINT64_FORMAT, queryDesc->estate->es_processed); /* and clean up */ ExecutorFinish(queryDesc); *** a/src/backend/tcop/pquery.c --- b/src/backend/tcop/pquery.c *************** *** 195,201 **** ProcessQuery(PlannedStmt *plan, { case CMD_SELECT: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "SELECT %u", queryDesc->estate->es_processed); break; case CMD_INSERT: if (queryDesc->estate->es_processed == 1) --- 195,201 ---- { case CMD_SELECT: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "SELECT " UINT64_FORMAT, queryDesc->estate->es_processed); break; case CMD_INSERT: if (queryDesc->estate->es_processed == 1) *************** *** 203,217 **** ProcessQuery(PlannedStmt *plan, else lastOid = InvalidOid; snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "INSERT %u %u", lastOid, queryDesc->estate->es_processed); break; case CMD_UPDATE: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "UPDATE %u", queryDesc->estate->es_processed); break; case CMD_DELETE: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "DELETE %u", queryDesc->estate->es_processed); break; default: strcpy(completionTag, "???"); --- 203,217 ---- else lastOid = InvalidOid; snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "INSERT %u " UINT64_FORMAT, lastOid, queryDesc->estate->es_processed); break; case CMD_UPDATE: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "UPDATE " UINT64_FORMAT, queryDesc->estate->es_processed); break; case CMD_DELETE: snprintf(completionTag, COMPLETION_TAG_BUFSIZE, ! "DELETE " UINT64_FORMAT, queryDesc->estate->es_processed); break; default: strcpy(completionTag, "???"); *** a/src/include/nodes/execnodes.h --- b/src/include/nodes/execnodes.h *************** *** 375,381 **** typedef struct EState List *es_rowMarks; /* List of ExecRowMarks */ ! uint32 es_processed; /* # of tuples processed */ Oid es_lastoid; /* last oid processed (by INSERT) */ int es_top_eflags; /* eflags passed to ExecutorStart */ --- 375,381 ---- List *es_rowMarks; /* List of ExecRowMarks */ ! uint64 es_processed; /* # of tuples processed */ Oid es_lastoid; /* last oid processed (by INSERT) */ int es_top_eflags; /* eflags passed to ExecutorStart */
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers