summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTom Lane2016-03-12 21:05:10 +0000
committerTom Lane2016-03-12 21:05:29 +0000
commit23a27b039d94ba359286694831eafe03cd970eef (patch)
tree4b1d6acb2fe4ae5c1275292adb3f027f2e052ea8 /contrib
parente01157500f26342bf4f067a4eb1e45ab9a3cd410 (diff)
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
Diffstat (limited to 'contrib')
-rw-r--r--contrib/auto_explain/auto_explain.c4
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c12
-rw-r--r--contrib/spi/refint.c2
-rw-r--r--contrib/tablefunc/tablefunc.c28
-rw-r--r--contrib/xml2/xpath.c6
5 files changed, 23 insertions, 29 deletions
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index 76d18315677..6708d817fba 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -61,7 +61,7 @@ void _PG_fini(void);
static void explain_ExecutorStart(QueryDesc *queryDesc, int eflags);
static void explain_ExecutorRun(QueryDesc *queryDesc,
ScanDirection direction,
- long count);
+ uint64 count);
static void explain_ExecutorFinish(QueryDesc *queryDesc);
static void explain_ExecutorEnd(QueryDesc *queryDesc);
@@ -257,7 +257,7 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
* ExecutorRun hook: all we need do is track nesting depth
*/
static void
-explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count)
+explain_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
{
nesting_level++;
PG_TRY();
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 9ce60e696c9..3d9b8e45d9f 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -289,7 +289,7 @@ static void pgss_post_parse_analyze(ParseState *pstate, Query *query);
static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags);
static void pgss_ExecutorRun(QueryDesc *queryDesc,
ScanDirection direction,
- long count);
+ uint64 count);
static void pgss_ExecutorFinish(QueryDesc *queryDesc);
static void pgss_ExecutorEnd(QueryDesc *queryDesc);
static void pgss_ProcessUtility(Node *parsetree, const char *queryString,
@@ -866,7 +866,7 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
* ExecutorRun hook: all we need do is track nesting depth
*/
static void
-pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, long count)
+pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
{
nested_level++;
PG_TRY();
@@ -1001,13 +1001,7 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
/* parse command tag to retrieve the number of affected rows. */
if (completionTag &&
strncmp(completionTag, "COPY ", 5) == 0)
- {
-#ifdef HAVE_STRTOULL
- rows = strtoull(completionTag + 5, NULL, 10);
-#else
- rows = strtoul(completionTag + 5, NULL, 10);
-#endif
- }
+ rows = pg_strtouint64(completionTag + 5, NULL, 10);
else
rows = 0;
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index 26022107410..01dd717522c 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -593,7 +593,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
else
{
#ifdef REFINT_VERBOSE
- elog(NOTICE, "%s: %d tuple(s) of %s are %s",
+ elog(NOTICE, "%s: " UINT64_FORMAT " tuple(s) of %s are %s",
trigger->tgname, SPI_processed, relname,
(action == 'c') ? "deleted" : "set to null");
#endif
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
index 1ea4a635cd5..787c02d08fc 100644
--- a/contrib/tablefunc/tablefunc.c
+++ b/contrib/tablefunc/tablefunc.c
@@ -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;
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
index 655c5322cdf..ac28996867b 100644
--- a/contrib/xml2/xpath.c
+++ b/contrib/xml2/xpath.c
@@ -553,8 +553,7 @@ xpath_table(PG_FUNCTION_ARGS)
int numpaths;
int ret;
- int proc;
- int i;
+ uint64 proc;
int j;
int rownr; /* For issuing multiple rows from one original
* document */
@@ -664,7 +663,6 @@ xpath_table(PG_FUNCTION_ARGS)
query_buf.data);
proc = SPI_processed;
- /* elog(DEBUG1,"xpath_table: SPI returned %d rows",proc); */
tuptable = SPI_tuptable;
spi_tupdesc = tuptable->tupdesc;
@@ -692,6 +690,8 @@ xpath_table(PG_FUNCTION_ARGS)
PG_TRY();
{
/* For each row i.e. document returned from SPI */
+ uint64 i;
+
for (i = 0; i < proc; i++)
{
char *pkey;