diff options
author | Tom Lane | 2016-03-12 21:05:10 +0000 |
---|---|---|
committer | Tom Lane | 2016-03-12 21:05:29 +0000 |
commit | 23a27b039d94ba359286694831eafe03cd970eef (patch) | |
tree | 4b1d6acb2fe4ae5c1275292adb3f027f2e052ea8 /src/include | |
parent | e01157500f26342bf4f067a4eb1e45ab9a3cd410 (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 'src/include')
-rw-r--r-- | src/include/executor/executor.h | 6 | ||||
-rw-r--r-- | src/include/executor/spi.h | 6 | ||||
-rw-r--r-- | src/include/executor/spi_priv.h | 2 | ||||
-rw-r--r-- | src/include/funcapi.h | 4 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 2 | ||||
-rw-r--r-- | src/include/postgres.h | 27 | ||||
-rw-r--r-- | src/include/tcop/pquery.h | 2 | ||||
-rw-r--r-- | src/include/utils/builtins.h | 1 | ||||
-rw-r--r-- | src/include/utils/portal.h | 11 |
9 files changed, 44 insertions, 17 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 1a44085a2ce..44fac278a49 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -80,7 +80,7 @@ extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook; /* Hook for plugins to get control in ExecutorRun() */ typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc, ScanDirection direction, - long count); + uint64 count); extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook; /* Hook for plugins to get control in ExecutorFinish() */ @@ -175,9 +175,9 @@ extern TupleTableSlot *ExecFilterJunk(JunkFilter *junkfilter, extern void ExecutorStart(QueryDesc *queryDesc, int eflags); extern void standard_ExecutorStart(QueryDesc *queryDesc, int eflags); extern void ExecutorRun(QueryDesc *queryDesc, - ScanDirection direction, long count); + ScanDirection direction, uint64 count); extern void standard_ExecutorRun(QueryDesc *queryDesc, - ScanDirection direction, long count); + ScanDirection direction, uint64 count); extern void ExecutorFinish(QueryDesc *queryDesc); extern void standard_ExecutorFinish(QueryDesc *queryDesc); extern void ExecutorEnd(QueryDesc *queryDesc); diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index 8c3ca261237..1792fb12172 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -21,8 +21,8 @@ typedef struct SPITupleTable { MemoryContext tuptabcxt; /* memory context of result table */ - uint32 alloced; /* # of alloced vals */ - uint32 free; /* # of free vals */ + uint64 alloced; /* # of alloced vals */ + uint64 free; /* # of free vals */ TupleDesc tupdesc; /* tuple descriptor */ HeapTuple *vals; /* tuples */ slist_node next; /* link for internal bookkeeping */ @@ -59,7 +59,7 @@ typedef struct _SPI_plan *SPIPlanPtr; #define SPI_OK_UPDATE_RETURNING 13 #define SPI_OK_REWRITTEN 14 -extern PGDLLIMPORT uint32 SPI_processed; +extern PGDLLIMPORT uint64 SPI_processed; extern PGDLLIMPORT Oid SPI_lastoid; extern PGDLLIMPORT SPITupleTable *SPI_tuptable; extern PGDLLIMPORT int SPI_result; diff --git a/src/include/executor/spi_priv.h b/src/include/executor/spi_priv.h index 3187230c020..e8084dff091 100644 --- a/src/include/executor/spi_priv.h +++ b/src/include/executor/spi_priv.h @@ -21,7 +21,7 @@ typedef struct { /* current results */ - uint32 processed; /* by Executor */ + uint64 processed; /* by Executor */ Oid lastoid; SPITupleTable *tuptable; /* tuptable currently being built */ diff --git a/src/include/funcapi.h b/src/include/funcapi.h index b6ae93fe0d0..e73a82427ca 100644 --- a/src/include/funcapi.h +++ b/src/include/funcapi.h @@ -62,7 +62,7 @@ typedef struct FuncCallContext * call_cntr is initialized to 0 for you by SRF_FIRSTCALL_INIT(), and * incremented for you every time SRF_RETURN_NEXT() is called. */ - uint32 call_cntr; + uint64 call_cntr; /* * OPTIONAL maximum number of calls @@ -71,7 +71,7 @@ typedef struct FuncCallContext * not set, you must provide alternative means to know when the function * is done. */ - uint32 max_calls; + uint64 max_calls; /* * OPTIONAL pointer to result slot diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 064a0509c4d..d35ec810450 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -387,7 +387,7 @@ typedef struct EState List *es_rowMarks; /* List of ExecRowMarks */ - uint32 es_processed; /* # of tuples processed */ + uint64 es_processed; /* # of tuples processed */ Oid es_lastoid; /* last oid processed (by INSERT) */ int es_top_eflags; /* eflags passed to ExecutorStart */ diff --git a/src/include/postgres.h b/src/include/postgres.h index 453147e1f0b..cde939b7cab 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -630,6 +630,33 @@ extern Datum Int64GetDatum(int64 X); #endif /* + * DatumGetUInt64 + * Returns 64-bit unsigned integer value of a datum. + * + * Note: this macro hides whether int64 is pass by value or by reference. + */ + +#ifdef USE_FLOAT8_BYVAL +#define DatumGetUInt64(X) ((uint64) GET_8_BYTES(X)) +#else +#define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X))) +#endif + +/* + * UInt64GetDatum + * Returns datum representation for a 64-bit unsigned integer. + * + * Note: if int64 is pass by reference, this function returns a reference + * to palloc'd space. + */ + +#ifdef USE_FLOAT8_BYVAL +#define UInt64GetDatum(X) ((Datum) SET_8_BYTES(X)) +#else +#define UInt64GetDatum(X) Int64GetDatum((int64) (X)) +#endif + +/* * DatumGetFloat4 * Returns 4-byte floating point value of a datum. * diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index 4f1fd139a36..e04fc4330d9 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -37,7 +37,7 @@ extern bool PortalRun(Portal portal, long count, bool isTopLevel, DestReceiver *dest, DestReceiver *altdest, char *completionTag); -extern long PortalRunFetch(Portal portal, +extern uint64 PortalRunFetch(Portal portal, FetchDirection fdirection, long count, DestReceiver *dest); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 115f8afb45b..59a00bbcbcf 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -292,6 +292,7 @@ extern void pg_ltoa(int32 l, char *a); extern void pg_lltoa(int64 ll, char *a); extern char *pg_ltostr_zeropad(char *str, int32 value, int32 minwidth); extern char *pg_ltostr(char *str, int32 value); +extern uint64 pg_strtouint64(const char *str, char **endptr, int base); /* * Per-opclass comparison functions for new btrees. These are diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 4236215b796..7250c9c1bb3 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -166,15 +166,14 @@ typedef struct PortalData * atStart, atEnd and portalPos indicate the current cursor position. * portalPos is zero before the first row, N after fetching N'th row of * query. After we run off the end, portalPos = # of rows in query, and - * atEnd is true. If portalPos overflows, set posOverflow (this causes us - * to stop relying on its value for navigation). Note that atStart - * implies portalPos == 0, but not the reverse (portalPos could have - * overflowed). + * atEnd is true. Note that atStart implies portalPos == 0, but not the + * reverse: we might have backed up only as far as the first row, not to + * the start. Also note that various code inspects atStart and atEnd, but + * only the portal movement routines should touch portalPos. */ bool atStart; bool atEnd; - bool posOverflow; - long portalPos; + uint64 portalPos; /* Presentation data, primarily used by the pg_cursors system view */ TimestampTz creation_time; /* time at which this portal was defined */ |