1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Widen query numbers-of-tuples-processed counters to uint64.

This patch widens SPI_processed, EState's es_processed field, PortalData's
portalPos field, FuncCallContext's call_cntr and max_calls fields,
ExecutorRun's count argument, PortalRunFetch's result, and the max number
of rows in a SPITupleTable to uint64, and deals with (I hope) all the
ensuing fallout.  Some of these values were declared uint32 before, and
others "long".

I also removed PortalData's posOverflow field, since that logic seems
pretty useless given that portalPos is now always 64 bits.

The user-visible results are that command tags for SELECT etc will
correctly report tuple counts larger than 4G, as will plpgsql's GET
GET DIAGNOSTICS ... ROW_COUNT command.  Queries processing more tuples
than that are still not exactly the norm, but they're becoming more
common.

Most values associated with FETCH/MOVE distances, such as PortalRun's count
argument and the count argument of most SPI functions that have one, remain
declared as "long".  It's not clear whether it would be worth promoting
those to int64; but it would definitely be a large dollop of additional
API churn on top of this, and it would only help 32-bit platforms which
seem relatively less likely to see any benefit.

Andreas Scherbaum, reviewed by Christian Ullrich, additional hacking by me
This commit is contained in:
Tom Lane
2016-03-12 16:05:10 -05:00
parent e01157500f
commit 23a27b039d
32 changed files with 273 additions and 181 deletions

View File

@ -400,8 +400,8 @@ SPI_execute("INSERT INTO foo SELECT * FROM bar RETURNING *", false, 5);
typedef struct
{
MemoryContext tuptabcxt; /* memory context of result table */
uint32 alloced; /* number of alloced vals */
uint32 free; /* number of free vals */
uint64 alloced; /* number of alloced vals */
uint64 free; /* number of free vals */
TupleDesc tupdesc; /* row descriptor */
HeapTuple *vals; /* rows */
} SPITupleTable;
@ -4116,14 +4116,14 @@ INSERT INTO a SELECT * FROM a;
PG_MODULE_MAGIC;
#endif
int execq(text *sql, int cnt);
int64 execq(text *sql, int cnt);
int
int64
execq(text *sql, int cnt)
{
char *command;
int ret;
int proc;
uint64 proc;
/* Convert given text object to a C string */
command = text_to_cstring(sql);
@ -4141,11 +4141,12 @@ execq(text *sql, int cnt)
TupleDesc tupdesc = SPI_tuptable->tupdesc;
SPITupleTable *tuptable = SPI_tuptable;
char buf[8192];
int i, j;
uint64 j;
for (j = 0; j < proc; j++)
{
HeapTuple tuple = tuptable->vals[j];
int i;
for (i = 1, buf[0] = 0; i <= tupdesc->natts; i++)
snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf), " %s%s",
@ -4173,9 +4174,9 @@ execq(text *sql, int cnt)
a shared library (details are in <xref linkend="dfunc">.):
<programlisting>
CREATE FUNCTION execq(text, integer) RETURNS integer
CREATE FUNCTION execq(text, integer) RETURNS int8
AS '<replaceable>filename</replaceable>'
LANGUAGE C;
LANGUAGE C STRICT;
</programlisting>
</para>