mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +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:
@ -120,7 +120,7 @@ typedef struct
|
||||
typedef struct crosstab_cat_desc
|
||||
{
|
||||
char *catname; /* full category name */
|
||||
int attidx; /* zero based */
|
||||
uint64 attidx; /* zero based */
|
||||
} crosstab_cat_desc;
|
||||
|
||||
#define MAX_CATNAME_LEN NAMEDATALEN
|
||||
@ -174,8 +174,8 @@ Datum
|
||||
normal_rand(PG_FUNCTION_ARGS)
|
||||
{
|
||||
FuncCallContext *funcctx;
|
||||
int call_cntr;
|
||||
int max_calls;
|
||||
uint64 call_cntr;
|
||||
uint64 max_calls;
|
||||
normal_rand_fctx *fctx;
|
||||
float8 mean;
|
||||
float8 stddev;
|
||||
@ -352,8 +352,8 @@ crosstab(PG_FUNCTION_ARGS)
|
||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||
Tuplestorestate *tupstore;
|
||||
TupleDesc tupdesc;
|
||||
int call_cntr;
|
||||
int max_calls;
|
||||
uint64 call_cntr;
|
||||
uint64 max_calls;
|
||||
AttInMetadata *attinmeta;
|
||||
SPITupleTable *spi_tuptable;
|
||||
TupleDesc spi_tupdesc;
|
||||
@ -364,7 +364,7 @@ crosstab(PG_FUNCTION_ARGS)
|
||||
MemoryContext per_query_ctx;
|
||||
MemoryContext oldcontext;
|
||||
int ret;
|
||||
int proc;
|
||||
uint64 proc;
|
||||
|
||||
/* check to see if caller supports us returning a tuplestore */
|
||||
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
|
||||
@ -389,7 +389,7 @@ crosstab(PG_FUNCTION_ARGS)
|
||||
proc = SPI_processed;
|
||||
|
||||
/* If no qualifying tuples, fall out early */
|
||||
if (ret != SPI_OK_SELECT || proc <= 0)
|
||||
if (ret != SPI_OK_SELECT || proc == 0)
|
||||
{
|
||||
SPI_finish();
|
||||
rsinfo->isDone = ExprEndResult;
|
||||
@ -708,7 +708,7 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
|
||||
HTAB *crosstab_hash;
|
||||
HASHCTL ctl;
|
||||
int ret;
|
||||
int proc;
|
||||
uint64 proc;
|
||||
MemoryContext SPIcontext;
|
||||
|
||||
/* initialize the category hash table */
|
||||
@ -740,7 +740,7 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
|
||||
{
|
||||
SPITupleTable *spi_tuptable = SPI_tuptable;
|
||||
TupleDesc spi_tupdesc = spi_tuptable->tupdesc;
|
||||
int i;
|
||||
uint64 i;
|
||||
|
||||
/*
|
||||
* The provided categories SQL query must always return one column:
|
||||
@ -800,7 +800,7 @@ get_crosstab_tuplestore(char *sql,
|
||||
char **values;
|
||||
HeapTuple tuple;
|
||||
int ret;
|
||||
int proc;
|
||||
uint64 proc;
|
||||
|
||||
/* initialize our tuplestore (while still in query context!) */
|
||||
tupstore = tuplestore_begin_heap(randomAccess, false, work_mem);
|
||||
@ -823,8 +823,8 @@ get_crosstab_tuplestore(char *sql,
|
||||
char *rowid;
|
||||
char *lastrowid = NULL;
|
||||
bool firstpass = true;
|
||||
int i,
|
||||
j;
|
||||
uint64 i;
|
||||
int j;
|
||||
int result_ncols;
|
||||
|
||||
if (num_categories == 0)
|
||||
@ -1220,7 +1220,7 @@ build_tuplestore_recursively(char *key_fld,
|
||||
{
|
||||
TupleDesc tupdesc = attinmeta->tupdesc;
|
||||
int ret;
|
||||
int proc;
|
||||
uint64 proc;
|
||||
int serial_column;
|
||||
StringInfoData sql;
|
||||
char **values;
|
||||
@ -1313,7 +1313,7 @@ build_tuplestore_recursively(char *key_fld,
|
||||
HeapTuple spi_tuple;
|
||||
SPITupleTable *tuptable = SPI_tuptable;
|
||||
TupleDesc spi_tupdesc = tuptable->tupdesc;
|
||||
int i;
|
||||
uint64 i;
|
||||
StringInfoData branchstr;
|
||||
StringInfoData chk_branchstr;
|
||||
StringInfoData chk_current_key;
|
||||
|
Reference in New Issue
Block a user