mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -79,7 +79,7 @@ static void ExecutePlan(EState *estate, PlanState *planstate,
|
||||
bool use_parallel_mode,
|
||||
CmdType operation,
|
||||
bool sendTuples,
|
||||
long numberTuples,
|
||||
uint64 numberTuples,
|
||||
ScanDirection direction,
|
||||
DestReceiver *dest);
|
||||
static bool ExecCheckRTEPerms(RangeTblEntry *rte);
|
||||
@ -278,7 +278,7 @@ standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
|
||||
*/
|
||||
void
|
||||
ExecutorRun(QueryDesc *queryDesc,
|
||||
ScanDirection direction, long count)
|
||||
ScanDirection direction, uint64 count)
|
||||
{
|
||||
if (ExecutorRun_hook)
|
||||
(*ExecutorRun_hook) (queryDesc, direction, count);
|
||||
@ -288,7 +288,7 @@ ExecutorRun(QueryDesc *queryDesc,
|
||||
|
||||
void
|
||||
standard_ExecutorRun(QueryDesc *queryDesc,
|
||||
ScanDirection direction, long count)
|
||||
ScanDirection direction, uint64 count)
|
||||
{
|
||||
EState *estate;
|
||||
CmdType operation;
|
||||
@ -1521,12 +1521,12 @@ ExecutePlan(EState *estate,
|
||||
bool use_parallel_mode,
|
||||
CmdType operation,
|
||||
bool sendTuples,
|
||||
long numberTuples,
|
||||
uint64 numberTuples,
|
||||
ScanDirection direction,
|
||||
DestReceiver *dest)
|
||||
{
|
||||
TupleTableSlot *slot;
|
||||
long current_tuple_count;
|
||||
uint64 current_tuple_count;
|
||||
|
||||
/*
|
||||
* initialize local variables
|
||||
@ -1542,7 +1542,7 @@ ExecutePlan(EState *estate,
|
||||
* If a tuple count was supplied, we must force the plan to run without
|
||||
* parallelism, because we might exit early.
|
||||
*/
|
||||
if (numberTuples != 0)
|
||||
if (numberTuples)
|
||||
use_parallel_mode = false;
|
||||
|
||||
/*
|
||||
|
@ -853,7 +853,7 @@ postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache)
|
||||
else
|
||||
{
|
||||
/* Run regular commands to completion unless lazyEval */
|
||||
long count = (es->lazyEval) ? 1L : 0L;
|
||||
uint64 count = (es->lazyEval) ? 1 : 0;
|
||||
|
||||
ExecutorRun(es->qd, ForwardScanDirection, count);
|
||||
|
||||
@ -861,7 +861,7 @@ postquel_getnext(execution_state *es, SQLFunctionCachePtr fcache)
|
||||
* If we requested run to completion OR there was no tuple returned,
|
||||
* command must be complete.
|
||||
*/
|
||||
result = (count == 0L || es->qd->estate->es_processed == 0);
|
||||
result = (count == 0 || es->qd->estate->es_processed == 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "utils/typcache.h"
|
||||
|
||||
|
||||
uint32 SPI_processed = 0;
|
||||
uint64 SPI_processed = 0;
|
||||
Oid SPI_lastoid = InvalidOid;
|
||||
SPITupleTable *SPI_tuptable = NULL;
|
||||
int SPI_result;
|
||||
@ -56,12 +56,12 @@ static void _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan);
|
||||
|
||||
static int _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
|
||||
Snapshot snapshot, Snapshot crosscheck_snapshot,
|
||||
bool read_only, bool fire_triggers, long tcount);
|
||||
bool read_only, bool fire_triggers, uint64 tcount);
|
||||
|
||||
static ParamListInfo _SPI_convert_params(int nargs, Oid *argtypes,
|
||||
Datum *Values, const char *Nulls);
|
||||
|
||||
static int _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, long tcount);
|
||||
static int _SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount);
|
||||
|
||||
static void _SPI_error_callback(void *arg);
|
||||
|
||||
@ -1991,10 +1991,10 @@ _SPI_prepare_oneshot_plan(const char *src, SPIPlanPtr plan)
|
||||
static int
|
||||
_SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
|
||||
Snapshot snapshot, Snapshot crosscheck_snapshot,
|
||||
bool read_only, bool fire_triggers, long tcount)
|
||||
bool read_only, bool fire_triggers, uint64 tcount)
|
||||
{
|
||||
int my_res = 0;
|
||||
uint32 my_processed = 0;
|
||||
uint64 my_processed = 0;
|
||||
Oid my_lastoid = InvalidOid;
|
||||
SPITupleTable *my_tuptable = NULL;
|
||||
int res = 0;
|
||||
@ -2218,8 +2218,8 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
|
||||
if (IsA(stmt, CreateTableAsStmt))
|
||||
{
|
||||
Assert(strncmp(completionTag, "SELECT ", 7) == 0);
|
||||
_SPI_current->processed = strtoul(completionTag + 7,
|
||||
NULL, 10);
|
||||
_SPI_current->processed = pg_strtouint64(completionTag + 7,
|
||||
NULL, 10);
|
||||
|
||||
/*
|
||||
* For historical reasons, if CREATE TABLE AS was spelled
|
||||
@ -2231,8 +2231,8 @@ _SPI_execute_plan(SPIPlanPtr plan, ParamListInfo paramLI,
|
||||
else if (IsA(stmt, CopyStmt))
|
||||
{
|
||||
Assert(strncmp(completionTag, "COPY ", 5) == 0);
|
||||
_SPI_current->processed = strtoul(completionTag + 5,
|
||||
NULL, 10);
|
||||
_SPI_current->processed = pg_strtouint64(completionTag + 5,
|
||||
NULL, 10);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2348,7 +2348,7 @@ _SPI_convert_params(int nargs, Oid *argtypes,
|
||||
}
|
||||
|
||||
static int
|
||||
_SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, long tcount)
|
||||
_SPI_pquery(QueryDesc *queryDesc, bool fire_triggers, uint64 tcount)
|
||||
{
|
||||
int operation = queryDesc->operation;
|
||||
int eflags;
|
||||
@ -2460,7 +2460,7 @@ static void
|
||||
_SPI_cursor_operation(Portal portal, FetchDirection direction, long count,
|
||||
DestReceiver *dest)
|
||||
{
|
||||
long nfetched;
|
||||
uint64 nfetched;
|
||||
|
||||
/* Check that the portal is valid */
|
||||
if (!PortalIsValid(portal))
|
||||
@ -2563,7 +2563,7 @@ _SPI_end_call(bool procmem)
|
||||
static bool
|
||||
_SPI_checktuples(void)
|
||||
{
|
||||
uint32 processed = _SPI_current->processed;
|
||||
uint64 processed = _SPI_current->processed;
|
||||
SPITupleTable *tuptable = _SPI_current->tuptable;
|
||||
bool failed = false;
|
||||
|
||||
|
Reference in New Issue
Block a user