Use FLEXIBLE_ARRAY_MEMBER in a bunch more places.
Replace some bogus "x[1]" declarations with "x[FLEXIBLE_ARRAY_MEMBER]". Aside from being more self-documenting, this should help prevent bogus warnings from static code analyzers and perhaps compiler misoptimizations. This patch is just a down payment on eliminating the whole problem, but it gets rid of a lot of easy-to-fix cases. Note that the main problem with doing this is that one must no longer rely on computing sizeof(the containing struct), since the result would be compiler-dependent. Instead use offsetof(struct, lastfield). Autoconf also warns against spelling that offsetof(struct, lastfield[0]). Michael Paquier, review and additional fixes by me.
This commit is contained in:
parent
2fb7a75f37
commit
09d8d110a6
contrib
src
backend
catalog
commands
executor
nodes
postmaster
tcop
utils
bin/pg_dump
include
@ -23,11 +23,10 @@ typedef struct NDBOX
|
|||||||
unsigned int header;
|
unsigned int header;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variable length array. The lower left coordinates for each dimension
|
* The lower left coordinates for each dimension come first, followed by
|
||||||
* come first, followed by upper right coordinates unless the point flag
|
* upper right coordinates unless the point flag is set.
|
||||||
* is set.
|
|
||||||
*/
|
*/
|
||||||
double x[1];
|
double x[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} NDBOX;
|
} NDBOX;
|
||||||
|
|
||||||
#define POINT_BIT 0x80000000
|
#define POINT_BIT 0x80000000
|
||||||
@ -41,9 +40,9 @@ typedef struct NDBOX
|
|||||||
#define LL_COORD(cube, i) ( (cube)->x[i] )
|
#define LL_COORD(cube, i) ( (cube)->x[i] )
|
||||||
#define UR_COORD(cube, i) ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )
|
#define UR_COORD(cube, i) ( IS_POINT(cube) ? (cube)->x[i] : (cube)->x[(i) + DIM(cube)] )
|
||||||
|
|
||||||
#define POINT_SIZE(_dim) (offsetof(NDBOX, x[0]) + sizeof(double)*(_dim))
|
#define POINT_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim))
|
||||||
#define CUBE_SIZE(_dim) (offsetof(NDBOX, x[0]) + sizeof(double)*(_dim)*2)
|
#define CUBE_SIZE(_dim) (offsetof(NDBOX, x) + sizeof(double)*(_dim)*2)
|
||||||
|
|
||||||
#define DatumGetNDBOX(x) ((NDBOX*)DatumGetPointer(x))
|
#define DatumGetNDBOX(x) ((NDBOX *) PG_DETOAST_DATUM(x))
|
||||||
#define PG_GETARG_NDBOX(x) DatumGetNDBOX( PG_DETOAST_DATUM(PG_GETARG_DATUM(x)) )
|
#define PG_GETARG_NDBOX(x) DatumGetNDBOX(PG_GETARG_DATUM(x))
|
||||||
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
|
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
|
||||||
|
@ -73,7 +73,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 flag;
|
int32 flag;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} GISTTYPE;
|
} GISTTYPE;
|
||||||
|
|
||||||
#define ALLISTRUE 0x04
|
#define ALLISTRUE 0x04
|
||||||
@ -133,7 +133,7 @@ typedef struct QUERYTYPE
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 size; /* number of ITEMs */
|
int32 size; /* number of ITEMs */
|
||||||
ITEM items[1]; /* variable length array */
|
ITEM items[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} QUERYTYPE;
|
} QUERYTYPE;
|
||||||
|
|
||||||
#define HDRSIZEQT offsetof(QUERYTYPE, items)
|
#define HDRSIZEQT offsetof(QUERYTYPE, items)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16 len;
|
uint16 len;
|
||||||
char name[1];
|
char name[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} ltree_level;
|
} ltree_level;
|
||||||
|
|
||||||
#define LEVEL_HDRSIZE (offsetof(ltree_level,name))
|
#define LEVEL_HDRSIZE (offsetof(ltree_level,name))
|
||||||
@ -20,7 +20,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
uint16 numlevel;
|
uint16 numlevel;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} ltree;
|
} ltree;
|
||||||
|
|
||||||
#define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) )
|
#define LTREE_HDRSIZE MAXALIGN( offsetof(ltree, data) )
|
||||||
@ -34,7 +34,7 @@ typedef struct
|
|||||||
int32 val;
|
int32 val;
|
||||||
uint16 len;
|
uint16 len;
|
||||||
uint8 flag;
|
uint8 flag;
|
||||||
char name[1];
|
char name[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} lquery_variant;
|
} lquery_variant;
|
||||||
|
|
||||||
#define LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name))
|
#define LVAR_HDRSIZE MAXALIGN(offsetof(lquery_variant, name))
|
||||||
@ -51,7 +51,7 @@ typedef struct
|
|||||||
uint16 numvar;
|
uint16 numvar;
|
||||||
uint16 low;
|
uint16 low;
|
||||||
uint16 high;
|
uint16 high;
|
||||||
char variants[1];
|
char variants[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} lquery_level;
|
} lquery_level;
|
||||||
|
|
||||||
#define LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) )
|
#define LQL_HDRSIZE MAXALIGN( offsetof(lquery_level,variants) )
|
||||||
@ -72,7 +72,7 @@ typedef struct
|
|||||||
uint16 numlevel;
|
uint16 numlevel;
|
||||||
uint16 firstgood;
|
uint16 firstgood;
|
||||||
uint16 flag;
|
uint16 flag;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} lquery;
|
} lquery;
|
||||||
|
|
||||||
#define LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) )
|
#define LQUERY_HDRSIZE MAXALIGN( offsetof(lquery, data) )
|
||||||
@ -107,7 +107,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 size;
|
int32 size;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} ltxtquery;
|
} ltxtquery;
|
||||||
|
|
||||||
#define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int32))
|
#define HDRSIZEQT MAXALIGN(VARHDRSZ + sizeof(int32))
|
||||||
@ -208,7 +208,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
uint32 flag;
|
uint32 flag;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} ltree_gist;
|
} ltree_gist;
|
||||||
|
|
||||||
#define LTG_ONENODE 0x01
|
#define LTG_ONENODE 0x01
|
||||||
|
@ -192,7 +192,7 @@ page_header(PG_FUNCTION_ARGS)
|
|||||||
* Check that enough data was supplied, so that we don't try to access
|
* Check that enough data was supplied, so that we don't try to access
|
||||||
* fields outside the supplied buffer.
|
* fields outside the supplied buffer.
|
||||||
*/
|
*/
|
||||||
if (raw_page_size < sizeof(PageHeaderData))
|
if (raw_page_size < SizeOfPageHeaderData)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
errmsg("input page too small (%d bytes)", raw_page_size)));
|
errmsg("input page too small (%d bytes)", raw_page_size)));
|
||||||
|
@ -63,7 +63,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
uint8 flag;
|
uint8 flag;
|
||||||
char data[1];
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} TRGM;
|
} TRGM;
|
||||||
|
|
||||||
#define TRGMHDRSIZE (VARHDRSZ + sizeof(uint8))
|
#define TRGMHDRSIZE (VARHDRSZ + sizeof(uint8))
|
||||||
|
@ -261,9 +261,9 @@ RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode,
|
|||||||
* with the answer changing under them, or that they already hold some
|
* with the answer changing under them, or that they already hold some
|
||||||
* appropriate lock, and therefore return the first answer we get without
|
* appropriate lock, and therefore return the first answer we get without
|
||||||
* checking for invalidation messages. Also, if the requested lock is
|
* checking for invalidation messages. Also, if the requested lock is
|
||||||
* already held, LockRelationOid will not AcceptInvalidationMessages,
|
* already held, LockRelationOid will not AcceptInvalidationMessages, so
|
||||||
* so we may fail to notice a change. We could protect against that case
|
* we may fail to notice a change. We could protect against that case by
|
||||||
* by calling AcceptInvalidationMessages() before beginning this loop, but
|
* calling AcceptInvalidationMessages() before beginning this loop, but
|
||||||
* that would add a significant amount overhead, so for now we don't.
|
* that would add a significant amount overhead, so for now we don't.
|
||||||
*/
|
*/
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -1075,8 +1075,8 @@ FuncnameGetCandidates(List *names, int nargs, List *argnames,
|
|||||||
*/
|
*/
|
||||||
effective_nargs = Max(pronargs, nargs);
|
effective_nargs = Max(pronargs, nargs);
|
||||||
newResult = (FuncCandidateList)
|
newResult = (FuncCandidateList)
|
||||||
palloc(sizeof(struct _FuncCandidateList) - sizeof(Oid)
|
palloc(offsetof(struct _FuncCandidateList, args) +
|
||||||
+ effective_nargs * sizeof(Oid));
|
effective_nargs * sizeof(Oid));
|
||||||
newResult->pathpos = pathpos;
|
newResult->pathpos = pathpos;
|
||||||
newResult->oid = HeapTupleGetOid(proctup);
|
newResult->oid = HeapTupleGetOid(proctup);
|
||||||
newResult->nargs = effective_nargs;
|
newResult->nargs = effective_nargs;
|
||||||
@ -1597,7 +1597,8 @@ OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
|
|||||||
* separate palloc for each operator, but profiling revealed that the
|
* separate palloc for each operator, but profiling revealed that the
|
||||||
* pallocs used an unreasonably large fraction of parsing time.
|
* pallocs used an unreasonably large fraction of parsing time.
|
||||||
*/
|
*/
|
||||||
#define SPACE_PER_OP MAXALIGN(sizeof(struct _FuncCandidateList) + sizeof(Oid))
|
#define SPACE_PER_OP MAXALIGN(offsetof(struct _FuncCandidateList, args) + \
|
||||||
|
2 * sizeof(Oid))
|
||||||
|
|
||||||
if (catlist->n_members > 0)
|
if (catlist->n_members > 0)
|
||||||
resultSpace = palloc(catlist->n_members * SPACE_PER_OP);
|
resultSpace = palloc(catlist->n_members * SPACE_PER_OP);
|
||||||
|
@ -383,10 +383,9 @@ EvaluateParams(PreparedStatement *pstmt, List *params,
|
|||||||
/* Prepare the expressions for execution */
|
/* Prepare the expressions for execution */
|
||||||
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
|
exprstates = (List *) ExecPrepareExpr((Expr *) params, estate);
|
||||||
|
|
||||||
/* sizeof(ParamListInfoData) includes the first array element */
|
|
||||||
paramLI = (ParamListInfo)
|
paramLI = (ParamListInfo)
|
||||||
palloc(sizeof(ParamListInfoData) +
|
palloc(offsetof(ParamListInfoData, params) +
|
||||||
(num_params - 1) * sizeof(ParamExternData));
|
num_params * sizeof(ParamExternData));
|
||||||
/* we have static list of params, so no hooks needed */
|
/* we have static list of params, so no hooks needed */
|
||||||
paramLI->paramFetch = NULL;
|
paramLI->paramFetch = NULL;
|
||||||
paramLI->paramFetchArg = NULL;
|
paramLI->paramFetchArg = NULL;
|
||||||
|
@ -896,9 +896,9 @@ postquel_sub_params(SQLFunctionCachePtr fcache,
|
|||||||
|
|
||||||
if (fcache->paramLI == NULL)
|
if (fcache->paramLI == NULL)
|
||||||
{
|
{
|
||||||
/* sizeof(ParamListInfoData) includes the first array element */
|
paramLI = (ParamListInfo)
|
||||||
paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
|
palloc(offsetof(ParamListInfoData, params) +
|
||||||
(nargs - 1) * sizeof(ParamExternData));
|
nargs * sizeof(ParamExternData));
|
||||||
/* we have static list of params, so no hooks needed */
|
/* we have static list of params, so no hooks needed */
|
||||||
paramLI->paramFetch = NULL;
|
paramLI->paramFetch = NULL;
|
||||||
paramLI->paramFetchArg = NULL;
|
paramLI->paramFetchArg = NULL;
|
||||||
|
@ -2290,9 +2290,8 @@ _SPI_convert_params(int nargs, Oid *argtypes,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* sizeof(ParamListInfoData) includes the first array element */
|
paramLI = (ParamListInfo) palloc(offsetof(ParamListInfoData, params) +
|
||||||
paramLI = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
|
nargs * sizeof(ParamExternData));
|
||||||
(nargs - 1) * sizeof(ParamExternData));
|
|
||||||
/* we have static list of params, so no hooks needed */
|
/* we have static list of params, so no hooks needed */
|
||||||
paramLI->paramFetch = NULL;
|
paramLI->paramFetch = NULL;
|
||||||
paramLI->paramFetchArg = NULL;
|
paramLI->paramFetchArg = NULL;
|
||||||
|
@ -40,9 +40,8 @@ copyParamList(ParamListInfo from)
|
|||||||
if (from == NULL || from->numParams <= 0)
|
if (from == NULL || from->numParams <= 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* sizeof(ParamListInfoData) includes the first array element */
|
size = offsetof(ParamListInfoData, params) +
|
||||||
size = sizeof(ParamListInfoData) +
|
from->numParams * sizeof(ParamExternData);
|
||||||
(from->numParams - 1) * sizeof(ParamExternData);
|
|
||||||
|
|
||||||
retval = (ParamListInfo) palloc(size);
|
retval = (ParamListInfo) palloc(size);
|
||||||
retval->paramFetch = NULL;
|
retval->paramFetch = NULL;
|
||||||
|
@ -785,13 +785,13 @@ process_pipe_input(char *logbuffer, int *bytes_in_logbuffer)
|
|||||||
int dest = LOG_DESTINATION_STDERR;
|
int dest = LOG_DESTINATION_STDERR;
|
||||||
|
|
||||||
/* While we have enough for a header, process data... */
|
/* While we have enough for a header, process data... */
|
||||||
while (count >= (int) sizeof(PipeProtoHeader))
|
while (count >= (int) (offsetof(PipeProtoHeader, data) +1))
|
||||||
{
|
{
|
||||||
PipeProtoHeader p;
|
PipeProtoHeader p;
|
||||||
int chunklen;
|
int chunklen;
|
||||||
|
|
||||||
/* Do we have a valid header? */
|
/* Do we have a valid header? */
|
||||||
memcpy(&p, cursor, sizeof(PipeProtoHeader));
|
memcpy(&p, cursor, offsetof(PipeProtoHeader, data));
|
||||||
if (p.nuls[0] == '\0' && p.nuls[1] == '\0' &&
|
if (p.nuls[0] == '\0' && p.nuls[1] == '\0' &&
|
||||||
p.len > 0 && p.len <= PIPE_MAX_PAYLOAD &&
|
p.len > 0 && p.len <= PIPE_MAX_PAYLOAD &&
|
||||||
p.pid != 0 &&
|
p.pid != 0 &&
|
||||||
|
@ -1619,9 +1619,8 @@ exec_bind_message(StringInfo input_message)
|
|||||||
{
|
{
|
||||||
int paramno;
|
int paramno;
|
||||||
|
|
||||||
/* sizeof(ParamListInfoData) includes the first array element */
|
params = (ParamListInfo) palloc(offsetof(ParamListInfoData, params) +
|
||||||
params = (ParamListInfo) palloc(sizeof(ParamListInfoData) +
|
numParams * sizeof(ParamExternData));
|
||||||
(numParams - 1) * sizeof(ParamExternData));
|
|
||||||
/* we have static list of params, so no hooks needed */
|
/* we have static list of params, so no hooks needed */
|
||||||
params->paramFetch = NULL;
|
params->paramFetch = NULL;
|
||||||
params->paramFetchArg = NULL;
|
params->paramFetchArg = NULL;
|
||||||
|
@ -1390,7 +1390,7 @@ path_in(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
base_size = sizeof(path->p[0]) * npts;
|
base_size = sizeof(path->p[0]) * npts;
|
||||||
size = offsetof(PATH, p[0]) +base_size;
|
size = offsetof(PATH, p) +base_size;
|
||||||
|
|
||||||
/* Check for integer overflow */
|
/* Check for integer overflow */
|
||||||
if (base_size / npts != sizeof(path->p[0]) || size <= base_size)
|
if (base_size / npts != sizeof(path->p[0]) || size <= base_size)
|
||||||
@ -1443,12 +1443,12 @@ path_recv(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
closed = pq_getmsgbyte(buf);
|
closed = pq_getmsgbyte(buf);
|
||||||
npts = pq_getmsgint(buf, sizeof(int32));
|
npts = pq_getmsgint(buf, sizeof(int32));
|
||||||
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point)))
|
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p)) / sizeof(Point)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("invalid number of points in external \"path\" value")));
|
errmsg("invalid number of points in external \"path\" value")));
|
||||||
|
|
||||||
size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts;
|
size = offsetof(PATH, p) +sizeof(path->p[0]) * npts;
|
||||||
path = (PATH *) palloc(size);
|
path = (PATH *) palloc(size);
|
||||||
|
|
||||||
SET_VARSIZE(path, size);
|
SET_VARSIZE(path, size);
|
||||||
@ -3476,7 +3476,7 @@ poly_in(PG_FUNCTION_ARGS)
|
|||||||
errmsg("invalid input syntax for type polygon: \"%s\"", str)));
|
errmsg("invalid input syntax for type polygon: \"%s\"", str)));
|
||||||
|
|
||||||
base_size = sizeof(poly->p[0]) * npts;
|
base_size = sizeof(poly->p[0]) * npts;
|
||||||
size = offsetof(POLYGON, p[0]) +base_size;
|
size = offsetof(POLYGON, p) +base_size;
|
||||||
|
|
||||||
/* Check for integer overflow */
|
/* Check for integer overflow */
|
||||||
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
||||||
@ -3530,12 +3530,12 @@ poly_recv(PG_FUNCTION_ARGS)
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
npts = pq_getmsgint(buf, sizeof(int32));
|
npts = pq_getmsgint(buf, sizeof(int32));
|
||||||
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point)))
|
if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p)) / sizeof(Point)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
|
||||||
errmsg("invalid number of points in external \"polygon\" value")));
|
errmsg("invalid number of points in external \"polygon\" value")));
|
||||||
|
|
||||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts;
|
size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * npts;
|
||||||
poly = (POLYGON *) palloc0(size); /* zero any holes */
|
poly = (POLYGON *) palloc0(size); /* zero any holes */
|
||||||
|
|
||||||
SET_VARSIZE(poly, size);
|
SET_VARSIZE(poly, size);
|
||||||
@ -4251,7 +4251,7 @@ path_add(PG_FUNCTION_ARGS)
|
|||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
|
|
||||||
base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts);
|
base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts);
|
||||||
size = offsetof(PATH, p[0]) +base_size;
|
size = offsetof(PATH, p) +base_size;
|
||||||
|
|
||||||
/* Check for integer overflow */
|
/* Check for integer overflow */
|
||||||
if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
|
if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) ||
|
||||||
@ -4393,7 +4393,7 @@ path_poly(PG_FUNCTION_ARGS)
|
|||||||
* Never overflows: the old size fit in MaxAllocSize, and the new size is
|
* Never overflows: the old size fit in MaxAllocSize, and the new size is
|
||||||
* just a small constant larger.
|
* just a small constant larger.
|
||||||
*/
|
*/
|
||||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts;
|
size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * path->npts;
|
||||||
poly = (POLYGON *) palloc(size);
|
poly = (POLYGON *) palloc(size);
|
||||||
|
|
||||||
SET_VARSIZE(poly, size);
|
SET_VARSIZE(poly, size);
|
||||||
@ -4468,7 +4468,7 @@ box_poly(PG_FUNCTION_ARGS)
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
/* map four corners of the box to a polygon */
|
/* map four corners of the box to a polygon */
|
||||||
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * 4;
|
size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * 4;
|
||||||
poly = (POLYGON *) palloc(size);
|
poly = (POLYGON *) palloc(size);
|
||||||
|
|
||||||
SET_VARSIZE(poly, size);
|
SET_VARSIZE(poly, size);
|
||||||
@ -4502,7 +4502,7 @@ poly_path(PG_FUNCTION_ARGS)
|
|||||||
* Never overflows: the old size fit in MaxAllocSize, and the new size is
|
* Never overflows: the old size fit in MaxAllocSize, and the new size is
|
||||||
* smaller by a small constant.
|
* smaller by a small constant.
|
||||||
*/
|
*/
|
||||||
size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * poly->npts;
|
size = offsetof(PATH, p) +sizeof(path->p[0]) * poly->npts;
|
||||||
path = (PATH *) palloc(size);
|
path = (PATH *) palloc(size);
|
||||||
|
|
||||||
SET_VARSIZE(path, size);
|
SET_VARSIZE(path, size);
|
||||||
@ -5181,7 +5181,7 @@ circle_poly(PG_FUNCTION_ARGS)
|
|||||||
errmsg("must request at least 2 points")));
|
errmsg("must request at least 2 points")));
|
||||||
|
|
||||||
base_size = sizeof(poly->p[0]) * npts;
|
base_size = sizeof(poly->p[0]) * npts;
|
||||||
size = offsetof(POLYGON, p[0]) +base_size;
|
size = offsetof(POLYGON, p) +base_size;
|
||||||
|
|
||||||
/* Check for integer overflow */
|
/* Check for integer overflow */
|
||||||
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
|
||||||
|
2
src/backend/utils/cache/catcache.c
vendored
2
src/backend/utils/cache/catcache.c
vendored
@ -1590,7 +1590,7 @@ SearchCatCacheList(CatCache *cache,
|
|||||||
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
|
||||||
nmembers = list_length(ctlist);
|
nmembers = list_length(ctlist);
|
||||||
cl = (CatCList *)
|
cl = (CatCList *)
|
||||||
palloc(sizeof(CatCList) + nmembers * sizeof(CatCTup *));
|
palloc(offsetof(CatCList, members) +nmembers * sizeof(CatCTup *));
|
||||||
heap_copytuple_with_tuple(ntp, &cl->tuple);
|
heap_copytuple_with_tuple(ntp, &cl->tuple);
|
||||||
MemoryContextSwitchTo(oldcxt);
|
MemoryContextSwitchTo(oldcxt);
|
||||||
heap_freetuple(ntp);
|
heap_freetuple(ntp);
|
||||||
|
@ -1216,9 +1216,8 @@ simple_string_list_append(SimpleStringList *list, const char *val)
|
|||||||
{
|
{
|
||||||
SimpleStringListCell *cell;
|
SimpleStringListCell *cell;
|
||||||
|
|
||||||
/* this calculation correctly accounts for the null trailing byte */
|
|
||||||
cell = (SimpleStringListCell *)
|
cell = (SimpleStringListCell *)
|
||||||
pg_malloc(sizeof(SimpleStringListCell) + strlen(val));
|
pg_malloc(offsetof(SimpleStringListCell, val) +strlen(val) + 1);
|
||||||
|
|
||||||
cell->next = NULL;
|
cell->next = NULL;
|
||||||
strcpy(cell->val, val);
|
strcpy(cell->val, val);
|
||||||
|
@ -38,7 +38,7 @@ typedef struct SimpleOidList
|
|||||||
typedef struct SimpleStringListCell
|
typedef struct SimpleStringListCell
|
||||||
{
|
{
|
||||||
struct SimpleStringListCell *next;
|
struct SimpleStringListCell *next;
|
||||||
char val[1]; /* VARIABLE LENGTH FIELD */
|
char val[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string here */
|
||||||
} SimpleStringListCell;
|
} SimpleStringListCell;
|
||||||
|
|
||||||
typedef struct SimpleStringList
|
typedef struct SimpleStringList
|
||||||
|
@ -322,7 +322,7 @@ typedef struct GinOptions
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
bool useFastUpdate; /* use fast updates? */
|
bool useFastUpdate; /* use fast updates? */
|
||||||
int pendingListCleanupSize; /* maximum size of pending list */
|
int pendingListCleanupSize; /* maximum size of pending list */
|
||||||
} GinOptions;
|
} GinOptions;
|
||||||
|
|
||||||
#define GIN_DEFAULT_USE_FASTUPDATE true
|
#define GIN_DEFAULT_USE_FASTUPDATE true
|
||||||
@ -389,7 +389,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
ItemPointerData first; /* first item in this posting list (unpacked) */
|
ItemPointerData first; /* first item in this posting list (unpacked) */
|
||||||
uint16 nbytes; /* number of bytes that follow */
|
uint16 nbytes; /* number of bytes that follow */
|
||||||
unsigned char bytes[1]; /* varbyte encoded items (variable length) */
|
unsigned char bytes[FLEXIBLE_ARRAY_MEMBER]; /* varbyte encoded items */
|
||||||
} GinPostingList;
|
} GinPostingList;
|
||||||
|
|
||||||
#define SizeOfGinPostingList(plist) (offsetof(GinPostingList, bytes) + SHORTALIGN((plist)->nbytes) )
|
#define SizeOfGinPostingList(plist) (offsetof(GinPostingList, bytes) + SHORTALIGN((plist)->nbytes) )
|
||||||
|
@ -47,7 +47,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
BlockNumber prev;
|
BlockNumber prev;
|
||||||
uint32 freespace;
|
uint32 freespace;
|
||||||
char tupledata[1];
|
char tupledata[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} GISTNodeBufferPage;
|
} GISTNodeBufferPage;
|
||||||
|
|
||||||
#define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
|
#define BUFFER_PAGE_DATA_OFFSET MAXALIGN(offsetof(GISTNodeBufferPage, tupledata))
|
||||||
@ -131,7 +131,8 @@ typedef struct GISTSearchItem
|
|||||||
/* we must store parentlsn to detect whether a split occurred */
|
/* we must store parentlsn to detect whether a split occurred */
|
||||||
GISTSearchHeapItem heap; /* heap info, if heap tuple */
|
GISTSearchHeapItem heap; /* heap info, if heap tuple */
|
||||||
} data;
|
} data;
|
||||||
double distances[1]; /* array with numberOfOrderBys entries */
|
double distances[FLEXIBLE_ARRAY_MEMBER]; /* numberOfOrderBys
|
||||||
|
* entries */
|
||||||
} GISTSearchItem;
|
} GISTSearchItem;
|
||||||
|
|
||||||
#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
|
#define GISTSearchItemIsHeap(item) ((item).blkno == InvalidBlockNumber)
|
||||||
@ -144,7 +145,7 @@ typedef struct GISTSearchItem
|
|||||||
typedef struct GISTScanOpaqueData
|
typedef struct GISTScanOpaqueData
|
||||||
{
|
{
|
||||||
GISTSTATE *giststate; /* index information, see above */
|
GISTSTATE *giststate; /* index information, see above */
|
||||||
pairingheap *queue; /* queue of unvisited items */
|
pairingheap *queue; /* queue of unvisited items */
|
||||||
MemoryContext queueCxt; /* context holding the queue */
|
MemoryContext queueCxt; /* context holding the queue */
|
||||||
bool qual_ok; /* false if qual can never be satisfied */
|
bool qual_ok; /* false if qual can never be satisfied */
|
||||||
bool firstCall; /* true until first gistgettuple call */
|
bool firstCall; /* true until first gistgettuple call */
|
||||||
|
@ -132,7 +132,7 @@ typedef struct xl_heap_multi_insert
|
|||||||
{
|
{
|
||||||
uint8 flags;
|
uint8 flags;
|
||||||
uint16 ntuples;
|
uint16 ntuples;
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} xl_heap_multi_insert;
|
} xl_heap_multi_insert;
|
||||||
|
|
||||||
#define SizeOfHeapMultiInsert offsetof(xl_heap_multi_insert, offsets)
|
#define SizeOfHeapMultiInsert offsetof(xl_heap_multi_insert, offsets)
|
||||||
|
@ -426,7 +426,7 @@ typedef struct spgxlogMoveLeafs
|
|||||||
* the dead tuple from the source
|
* the dead tuple from the source
|
||||||
*----------
|
*----------
|
||||||
*/
|
*/
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} spgxlogMoveLeafs;
|
} spgxlogMoveLeafs;
|
||||||
|
|
||||||
#define SizeOfSpgxlogMoveLeafs offsetof(spgxlogMoveLeafs, offsets)
|
#define SizeOfSpgxlogMoveLeafs offsetof(spgxlogMoveLeafs, offsets)
|
||||||
@ -534,7 +534,7 @@ typedef struct spgxlogPickSplit
|
|||||||
* list of leaf tuples, length nInsert (unaligned!)
|
* list of leaf tuples, length nInsert (unaligned!)
|
||||||
*----------
|
*----------
|
||||||
*/
|
*/
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} spgxlogPickSplit;
|
} spgxlogPickSplit;
|
||||||
|
|
||||||
#define SizeOfSpgxlogPickSplit offsetof(spgxlogPickSplit, offsets)
|
#define SizeOfSpgxlogPickSplit offsetof(spgxlogPickSplit, offsets)
|
||||||
@ -558,7 +558,7 @@ typedef struct spgxlogVacuumLeaf
|
|||||||
* tuple numbers to insert in nextOffset links
|
* tuple numbers to insert in nextOffset links
|
||||||
*----------
|
*----------
|
||||||
*/
|
*/
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} spgxlogVacuumLeaf;
|
} spgxlogVacuumLeaf;
|
||||||
|
|
||||||
#define SizeOfSpgxlogVacuumLeaf offsetof(spgxlogVacuumLeaf, offsets)
|
#define SizeOfSpgxlogVacuumLeaf offsetof(spgxlogVacuumLeaf, offsets)
|
||||||
@ -571,7 +571,7 @@ typedef struct spgxlogVacuumRoot
|
|||||||
spgxlogState stateSrc;
|
spgxlogState stateSrc;
|
||||||
|
|
||||||
/* offsets of tuples to delete follow */
|
/* offsets of tuples to delete follow */
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} spgxlogVacuumRoot;
|
} spgxlogVacuumRoot;
|
||||||
|
|
||||||
#define SizeOfSpgxlogVacuumRoot offsetof(spgxlogVacuumRoot, offsets)
|
#define SizeOfSpgxlogVacuumRoot offsetof(spgxlogVacuumRoot, offsets)
|
||||||
@ -583,7 +583,7 @@ typedef struct spgxlogVacuumRedirect
|
|||||||
TransactionId newestRedirectXid; /* newest XID of removed redirects */
|
TransactionId newestRedirectXid; /* newest XID of removed redirects */
|
||||||
|
|
||||||
/* offsets of redirect tuples to make placeholders follow */
|
/* offsets of redirect tuples to make placeholders follow */
|
||||||
OffsetNumber offsets[1];
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} spgxlogVacuumRedirect;
|
} spgxlogVacuumRedirect;
|
||||||
|
|
||||||
#define SizeOfSpgxlogVacuumRedirect offsetof(spgxlogVacuumRedirect, offsets)
|
#define SizeOfSpgxlogVacuumRedirect offsetof(spgxlogVacuumRedirect, offsets)
|
||||||
|
@ -118,7 +118,7 @@ typedef struct xl_xact_assignment
|
|||||||
{
|
{
|
||||||
TransactionId xtop; /* assigned XID's top-level XID */
|
TransactionId xtop; /* assigned XID's top-level XID */
|
||||||
int nsubxacts; /* number of subtransaction XIDs */
|
int nsubxacts; /* number of subtransaction XIDs */
|
||||||
TransactionId xsub[1]; /* assigned subxids */
|
TransactionId xsub[FLEXIBLE_ARRAY_MEMBER]; /* assigned subxids */
|
||||||
} xl_xact_assignment;
|
} xl_xact_assignment;
|
||||||
|
|
||||||
#define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub)
|
#define MinSizeOfXactAssignment offsetof(xl_xact_assignment, xsub)
|
||||||
@ -128,7 +128,7 @@ typedef struct xl_xact_commit_compact
|
|||||||
TimestampTz xact_time; /* time of commit */
|
TimestampTz xact_time; /* time of commit */
|
||||||
int nsubxacts; /* number of subtransaction XIDs */
|
int nsubxacts; /* number of subtransaction XIDs */
|
||||||
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
|
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
|
||||||
TransactionId subxacts[1]; /* VARIABLE LENGTH ARRAY */
|
TransactionId subxacts[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} xl_xact_commit_compact;
|
} xl_xact_commit_compact;
|
||||||
|
|
||||||
#define MinSizeOfXactCommitCompact offsetof(xl_xact_commit_compact, subxacts)
|
#define MinSizeOfXactCommitCompact offsetof(xl_xact_commit_compact, subxacts)
|
||||||
@ -143,7 +143,7 @@ typedef struct xl_xact_commit
|
|||||||
Oid dbId; /* MyDatabaseId */
|
Oid dbId; /* MyDatabaseId */
|
||||||
Oid tsId; /* MyDatabaseTableSpace */
|
Oid tsId; /* MyDatabaseTableSpace */
|
||||||
/* Array of RelFileNode(s) to drop at commit */
|
/* Array of RelFileNode(s) to drop at commit */
|
||||||
RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
|
RelFileNode xnodes[FLEXIBLE_ARRAY_MEMBER];
|
||||||
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
|
/* ARRAY OF COMMITTED SUBTRANSACTION XIDs FOLLOWS */
|
||||||
/* ARRAY OF SHARED INVALIDATION MESSAGES FOLLOWS */
|
/* ARRAY OF SHARED INVALIDATION MESSAGES FOLLOWS */
|
||||||
} xl_xact_commit;
|
} xl_xact_commit;
|
||||||
@ -171,7 +171,7 @@ typedef struct xl_xact_abort
|
|||||||
int nrels; /* number of RelFileNodes */
|
int nrels; /* number of RelFileNodes */
|
||||||
int nsubxacts; /* number of subtransaction XIDs */
|
int nsubxacts; /* number of subtransaction XIDs */
|
||||||
/* Array of RelFileNode(s) to drop at abort */
|
/* Array of RelFileNode(s) to drop at abort */
|
||||||
RelFileNode xnodes[1]; /* VARIABLE LENGTH ARRAY */
|
RelFileNode xnodes[FLEXIBLE_ARRAY_MEMBER];
|
||||||
/* ARRAY OF ABORTED SUBTRANSACTION XIDs FOLLOWS */
|
/* ARRAY OF ABORTED SUBTRANSACTION XIDs FOLLOWS */
|
||||||
} xl_xact_abort;
|
} xl_xact_abort;
|
||||||
|
|
||||||
|
@ -424,8 +424,8 @@ typedef struct
|
|||||||
Oid elemtype;
|
Oid elemtype;
|
||||||
int dim1;
|
int dim1;
|
||||||
int lbound1;
|
int lbound1;
|
||||||
int16 values[1]; /* VARIABLE LENGTH ARRAY */
|
int16 values[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} int2vector; /* VARIABLE LENGTH STRUCT */
|
} int2vector;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -435,8 +435,8 @@ typedef struct
|
|||||||
Oid elemtype;
|
Oid elemtype;
|
||||||
int dim1;
|
int dim1;
|
||||||
int lbound1;
|
int lbound1;
|
||||||
Oid values[1]; /* VARIABLE LENGTH ARRAY */
|
Oid values[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} oidvector; /* VARIABLE LENGTH STRUCT */
|
} oidvector;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Representation of a Name: effectively just a C string, but null-padded to
|
* Representation of a Name: effectively just a C string, but null-padded to
|
||||||
|
@ -34,8 +34,8 @@ typedef struct _FuncCandidateList
|
|||||||
int nvargs; /* number of args to become variadic array */
|
int nvargs; /* number of args to become variadic array */
|
||||||
int ndargs; /* number of defaulted args */
|
int ndargs; /* number of defaulted args */
|
||||||
int *argnumbers; /* args' positional indexes, if named call */
|
int *argnumbers; /* args' positional indexes, if named call */
|
||||||
Oid args[1]; /* arg types --- VARIABLE LENGTH ARRAY */
|
Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */
|
||||||
} *FuncCandidateList; /* VARIABLE LENGTH STRUCT */
|
} *FuncCandidateList;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure for xxxOverrideSearchPath functions
|
* Structure for xxxOverrideSearchPath functions
|
||||||
|
@ -22,21 +22,6 @@
|
|||||||
#define XLOG_DBASE_CREATE 0x00
|
#define XLOG_DBASE_CREATE 0x00
|
||||||
#define XLOG_DBASE_DROP 0x10
|
#define XLOG_DBASE_DROP 0x10
|
||||||
|
|
||||||
typedef struct xl_dbase_create_rec_old
|
|
||||||
{
|
|
||||||
/* Records copying of a single subdirectory incl. contents */
|
|
||||||
Oid db_id;
|
|
||||||
char src_path[1]; /* VARIABLE LENGTH STRING */
|
|
||||||
/* dst_path follows src_path */
|
|
||||||
} xl_dbase_create_rec_old;
|
|
||||||
|
|
||||||
typedef struct xl_dbase_drop_rec_old
|
|
||||||
{
|
|
||||||
/* Records dropping of a single subdirectory incl. contents */
|
|
||||||
Oid db_id;
|
|
||||||
char dir_path[1]; /* VARIABLE LENGTH STRING */
|
|
||||||
} xl_dbase_drop_rec_old;
|
|
||||||
|
|
||||||
typedef struct xl_dbase_create_rec
|
typedef struct xl_dbase_create_rec
|
||||||
{
|
{
|
||||||
/* Records copying of a single subdirectory incl. contents */
|
/* Records copying of a single subdirectory incl. contents */
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
typedef struct xl_tblspc_create_rec
|
typedef struct xl_tblspc_create_rec
|
||||||
{
|
{
|
||||||
Oid ts_id;
|
Oid ts_id;
|
||||||
char ts_path[1]; /* VARIABLE LENGTH STRING */
|
char ts_path[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string */
|
||||||
} xl_tblspc_create_rec;
|
} xl_tblspc_create_rec;
|
||||||
|
|
||||||
typedef struct xl_tblspc_drop_rec
|
typedef struct xl_tblspc_drop_rec
|
||||||
|
@ -114,7 +114,7 @@ typedef struct HashMemoryChunkData
|
|||||||
|
|
||||||
struct HashMemoryChunkData *next; /* pointer to the next chunk (linked list) */
|
struct HashMemoryChunkData *next; /* pointer to the next chunk (linked list) */
|
||||||
|
|
||||||
char data[1]; /* buffer allocated at the end */
|
char data[FLEXIBLE_ARRAY_MEMBER]; /* buffer allocated at the end */
|
||||||
} HashMemoryChunkData;
|
} HashMemoryChunkData;
|
||||||
|
|
||||||
typedef struct HashMemoryChunkData *HashMemoryChunk;
|
typedef struct HashMemoryChunkData *HashMemoryChunk;
|
||||||
|
@ -32,8 +32,8 @@ typedef int32 signedbitmapword; /* must be the matching signed type */
|
|||||||
typedef struct Bitmapset
|
typedef struct Bitmapset
|
||||||
{
|
{
|
||||||
int nwords; /* number of words in array */
|
int nwords; /* number of words in array */
|
||||||
bitmapword words[1]; /* really [nwords] */
|
bitmapword words[FLEXIBLE_ARRAY_MEMBER]; /* really [nwords] */
|
||||||
} Bitmapset; /* VARIABLE LENGTH STRUCT */
|
} Bitmapset;
|
||||||
|
|
||||||
|
|
||||||
/* result of bms_subset_compare */
|
/* result of bms_subset_compare */
|
||||||
|
@ -71,7 +71,7 @@ typedef struct ParamListInfoData
|
|||||||
ParserSetupHook parserSetup; /* parser setup hook */
|
ParserSetupHook parserSetup; /* parser setup hook */
|
||||||
void *parserSetupArg;
|
void *parserSetupArg;
|
||||||
int numParams; /* number of ParamExternDatas following */
|
int numParams; /* number of ParamExternDatas following */
|
||||||
ParamExternData params[1]; /* VARIABLE LENGTH ARRAY */
|
ParamExternData params[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} ParamListInfoData;
|
} ParamListInfoData;
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ typedef struct
|
|||||||
int ntuples; /* -1 indicates lossy result */
|
int ntuples; /* -1 indicates lossy result */
|
||||||
bool recheck; /* should the tuples be rechecked? */
|
bool recheck; /* should the tuples be rechecked? */
|
||||||
/* Note: recheck is always true if ntuples < 0 */
|
/* Note: recheck is always true if ntuples < 0 */
|
||||||
OffsetNumber offsets[1]; /* VARIABLE LENGTH ARRAY */
|
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} TBMIterateResult; /* VARIABLE LENGTH STRUCT */
|
} TBMIterateResult;
|
||||||
|
|
||||||
/* function prototypes in nodes/tidbitmap.c */
|
/* function prototypes in nodes/tidbitmap.c */
|
||||||
|
|
||||||
|
@ -117,20 +117,20 @@ typedef union
|
|||||||
struct /* Normal varlena (4-byte length) */
|
struct /* Normal varlena (4-byte length) */
|
||||||
{
|
{
|
||||||
uint32 va_header;
|
uint32 va_header;
|
||||||
char va_data[1];
|
char va_data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} va_4byte;
|
} va_4byte;
|
||||||
struct /* Compressed-in-line format */
|
struct /* Compressed-in-line format */
|
||||||
{
|
{
|
||||||
uint32 va_header;
|
uint32 va_header;
|
||||||
uint32 va_rawsize; /* Original data size (excludes header) */
|
uint32 va_rawsize; /* Original data size (excludes header) */
|
||||||
char va_data[1]; /* Compressed data */
|
char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Compressed data */
|
||||||
} va_compressed;
|
} va_compressed;
|
||||||
} varattrib_4b;
|
} varattrib_4b;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint8 va_header;
|
uint8 va_header;
|
||||||
char va_data[1]; /* Data begins here */
|
char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Data begins here */
|
||||||
} varattrib_1b;
|
} varattrib_1b;
|
||||||
|
|
||||||
/* TOAST pointers are a subset of varattrib_1b with an identifying tag byte */
|
/* TOAST pointers are a subset of varattrib_1b with an identifying tag byte */
|
||||||
@ -138,7 +138,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint8 va_header; /* Always 0x80 or 0x01 */
|
uint8 va_header; /* Always 0x80 or 0x01 */
|
||||||
uint8 va_tag; /* Type of datum */
|
uint8 va_tag; /* Type of datum */
|
||||||
char va_data[1]; /* Data (of the type indicated by va_tag) */
|
char va_data[FLEXIBLE_ARRAY_MEMBER]; /* Type-specific data */
|
||||||
} varattrib_1b_e;
|
} varattrib_1b_e;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,7 +48,7 @@ typedef struct
|
|||||||
int32 pid; /* writer's pid */
|
int32 pid; /* writer's pid */
|
||||||
char is_last; /* last chunk of message? 't' or 'f' ('T' or
|
char is_last; /* last chunk of message? 't' or 'f' ('T' or
|
||||||
* 'F' for CSV case) */
|
* 'F' for CSV case) */
|
||||||
char data[1]; /* data payload starts here */
|
char data[FLEXIBLE_ARRAY_MEMBER]; /* data payload starts here */
|
||||||
} PipeProtoHeader;
|
} PipeProtoHeader;
|
||||||
|
|
||||||
typedef union
|
typedef union
|
||||||
|
@ -54,7 +54,7 @@ typedef struct WalSnd
|
|||||||
* Pointer to the walsender's latch. Used by backends to wake up this
|
* Pointer to the walsender's latch. Used by backends to wake up this
|
||||||
* walsender when it has work to do. NULL if the walsender isn't active.
|
* walsender when it has work to do. NULL if the walsender isn't active.
|
||||||
*/
|
*/
|
||||||
Latch *latch;
|
Latch *latch;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The priority order of the standby managed by this WALSender, as listed
|
* The priority order of the standby managed by this WALSender, as listed
|
||||||
@ -88,7 +88,7 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
bool sync_standbys_defined;
|
bool sync_standbys_defined;
|
||||||
|
|
||||||
WalSnd walsnds[1]; /* VARIABLE LENGTH ARRAY */
|
WalSnd walsnds[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} WalSndCtlData;
|
} WalSndCtlData;
|
||||||
|
|
||||||
extern WalSndCtlData *WalSndCtl;
|
extern WalSndCtlData *WalSndCtl;
|
||||||
|
@ -156,7 +156,7 @@ typedef struct PageHeaderData
|
|||||||
LocationIndex pd_special; /* offset to start of special space */
|
LocationIndex pd_special; /* offset to start of special space */
|
||||||
uint16 pd_pagesize_version;
|
uint16 pd_pagesize_version;
|
||||||
TransactionId pd_prune_xid; /* oldest prunable XID, or zero if none */
|
TransactionId pd_prune_xid; /* oldest prunable XID, or zero if none */
|
||||||
ItemIdData pd_linp[1]; /* beginning of line pointer array */
|
ItemIdData pd_linp[FLEXIBLE_ARRAY_MEMBER]; /* line pointer array */
|
||||||
} PageHeaderData;
|
} PageHeaderData;
|
||||||
|
|
||||||
typedef PageHeaderData *PageHeader;
|
typedef PageHeaderData *PageHeader;
|
||||||
|
@ -39,7 +39,7 @@ typedef struct
|
|||||||
* NonLeafNodesPerPage elements are upper nodes, and the following
|
* NonLeafNodesPerPage elements are upper nodes, and the following
|
||||||
* LeafNodesPerPage elements are leaf nodes. Unused nodes are zero.
|
* LeafNodesPerPage elements are leaf nodes. Unused nodes are zero.
|
||||||
*/
|
*/
|
||||||
uint8 fp_nodes[1];
|
uint8 fp_nodes[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} FSMPageData;
|
} FSMPageData;
|
||||||
|
|
||||||
typedef FSMPageData *FSMPage;
|
typedef FSMPageData *FSMPage;
|
||||||
|
@ -60,7 +60,7 @@ extern void StandbyReleaseOldLocks(int nxids, TransactionId *xids);
|
|||||||
typedef struct xl_standby_locks
|
typedef struct xl_standby_locks
|
||||||
{
|
{
|
||||||
int nlocks; /* number of entries in locks array */
|
int nlocks; /* number of entries in locks array */
|
||||||
xl_standby_lock locks[1]; /* VARIABLE LENGTH ARRAY */
|
xl_standby_lock locks[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} xl_standby_locks;
|
} xl_standby_locks;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -75,7 +75,7 @@ typedef struct xl_running_xacts
|
|||||||
TransactionId oldestRunningXid; /* *not* oldestXmin */
|
TransactionId oldestRunningXid; /* *not* oldestXmin */
|
||||||
TransactionId latestCompletedXid; /* so we can set xmax */
|
TransactionId latestCompletedXid; /* so we can set xmax */
|
||||||
|
|
||||||
TransactionId xids[1]; /* VARIABLE LENGTH ARRAY */
|
TransactionId xids[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} xl_running_xacts;
|
} xl_running_xacts;
|
||||||
|
|
||||||
#define MinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)
|
#define MinSizeOfXactRunningXacts offsetof(xl_running_xacts, xids)
|
||||||
|
@ -21,7 +21,7 @@ typedef struct RegisNode
|
|||||||
len:16,
|
len:16,
|
||||||
unused:14;
|
unused:14;
|
||||||
struct RegisNode *next;
|
struct RegisNode *next;
|
||||||
unsigned char data[1];
|
unsigned char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} RegisNode;
|
} RegisNode;
|
||||||
|
|
||||||
#define RNHDRSZ (offsetof(RegisNode,data))
|
#define RNHDRSZ (offsetof(RegisNode,data))
|
||||||
|
@ -49,7 +49,7 @@ typedef struct
|
|||||||
typedef struct SPNode
|
typedef struct SPNode
|
||||||
{
|
{
|
||||||
uint32 length;
|
uint32 length;
|
||||||
SPNodeData data[1];
|
SPNodeData data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} SPNode;
|
} SPNode;
|
||||||
|
|
||||||
#define SPNHDRSZ (offsetof(SPNode,data))
|
#define SPNHDRSZ (offsetof(SPNode,data))
|
||||||
@ -70,7 +70,7 @@ typedef struct spell_struct
|
|||||||
int len;
|
int len;
|
||||||
} d;
|
} d;
|
||||||
} p;
|
} p;
|
||||||
char word[1]; /* variable length, null-terminated */
|
char word[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} SPELL;
|
} SPELL;
|
||||||
|
|
||||||
#define SPELLHDRSZ (offsetof(SPELL, word))
|
#define SPELLHDRSZ (offsetof(SPELL, word))
|
||||||
@ -120,7 +120,7 @@ typedef struct AffixNode
|
|||||||
{
|
{
|
||||||
uint32 isvoid:1,
|
uint32 isvoid:1,
|
||||||
length:31;
|
length:31;
|
||||||
AffixNodeData data[1];
|
AffixNodeData data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} AffixNode;
|
} AffixNode;
|
||||||
|
|
||||||
#define ANHRDSZ (offsetof(AffixNode, data))
|
#define ANHRDSZ (offsetof(AffixNode, data))
|
||||||
|
@ -63,7 +63,7 @@ typedef uint16 WordEntryPos;
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint16 npos;
|
uint16 npos;
|
||||||
WordEntryPos pos[1]; /* variable length */
|
WordEntryPos pos[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} WordEntryPosVector;
|
} WordEntryPosVector;
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 size;
|
int32 size;
|
||||||
WordEntry entries[1]; /* variable length */
|
WordEntry entries[FLEXIBLE_ARRAY_MEMBER];
|
||||||
/* lexemes follow the entries[] array */
|
/* lexemes follow the entries[] array */
|
||||||
} TSVectorData;
|
} TSVectorData;
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 size; /* number of QueryItems */
|
int32 size; /* number of QueryItems */
|
||||||
char data[1]; /* data starts here */
|
char data[FLEXIBLE_ARRAY_MEMBER]; /* data starts here */
|
||||||
} TSQueryData;
|
} TSQueryData;
|
||||||
|
|
||||||
typedef TSQueryData *TSQuery;
|
typedef TSQueryData *TSQuery;
|
||||||
|
@ -147,8 +147,8 @@ typedef struct catclist
|
|||||||
uint32 hash_value; /* hash value for lookup keys */
|
uint32 hash_value; /* hash value for lookup keys */
|
||||||
HeapTupleData tuple; /* header for tuple holding keys */
|
HeapTupleData tuple; /* header for tuple holding keys */
|
||||||
int n_members; /* number of member tuples */
|
int n_members; /* number of member tuples */
|
||||||
CatCTup *members[1]; /* members --- VARIABLE LENGTH ARRAY */
|
CatCTup *members[FLEXIBLE_ARRAY_MEMBER]; /* members */
|
||||||
} CatCList; /* VARIABLE LENGTH STRUCT */
|
} CatCList;
|
||||||
|
|
||||||
|
|
||||||
typedef struct catcacheheader
|
typedef struct catcacheheader
|
||||||
|
@ -219,7 +219,7 @@ typedef struct TimeZoneAbbrevTable
|
|||||||
{
|
{
|
||||||
Size tblsize; /* size in bytes of TimeZoneAbbrevTable */
|
Size tblsize; /* size in bytes of TimeZoneAbbrevTable */
|
||||||
int numabbrevs; /* number of entries in abbrevs[] array */
|
int numabbrevs; /* number of entries in abbrevs[] array */
|
||||||
datetkn abbrevs[1]; /* VARIABLE LENGTH ARRAY */
|
datetkn abbrevs[FLEXIBLE_ARRAY_MEMBER];
|
||||||
/* DynamicZoneAbbrev(s) may follow the abbrevs[] array */
|
/* DynamicZoneAbbrev(s) may follow the abbrevs[] array */
|
||||||
} TimeZoneAbbrevTable;
|
} TimeZoneAbbrevTable;
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ typedef struct TimeZoneAbbrevTable
|
|||||||
typedef struct DynamicZoneAbbrev
|
typedef struct DynamicZoneAbbrev
|
||||||
{
|
{
|
||||||
pg_tz *tz; /* NULL if not yet looked up */
|
pg_tz *tz; /* NULL if not yet looked up */
|
||||||
char zone[1]; /* zone name (var length, NUL-terminated) */
|
char zone[FLEXIBLE_ARRAY_MEMBER]; /* NUL-terminated zone name */
|
||||||
} DynamicZoneAbbrev;
|
} DynamicZoneAbbrev;
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ typedef struct
|
|||||||
int32 npts;
|
int32 npts;
|
||||||
int32 closed; /* is this a closed polygon? */
|
int32 closed; /* is this a closed polygon? */
|
||||||
int32 dummy; /* padding to make it double align */
|
int32 dummy; /* padding to make it double align */
|
||||||
Point p[1]; /* variable length array of POINTs */
|
Point p[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} PATH;
|
} PATH;
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ typedef struct
|
|||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 npts;
|
int32 npts;
|
||||||
BOX boundbox;
|
BOX boundbox;
|
||||||
Point p[1]; /* variable length array of POINTs */
|
Point p[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} POLYGON;
|
} POLYGON;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------
|
/*---------------------------------------------------------------------
|
||||||
|
@ -194,7 +194,7 @@ typedef struct JsonbContainer
|
|||||||
{
|
{
|
||||||
uint32 header; /* number of elements or key/value pairs, and
|
uint32 header; /* number of elements or key/value pairs, and
|
||||||
* flags */
|
* flags */
|
||||||
JEntry children[1]; /* variable length */
|
JEntry children[FLEXIBLE_ARRAY_MEMBER];
|
||||||
|
|
||||||
/* the data for each child node follows. */
|
/* the data for each child node follows. */
|
||||||
} JsonbContainer;
|
} JsonbContainer;
|
||||||
|
@ -29,7 +29,7 @@ typedef struct xl_relmap_update
|
|||||||
Oid dbid; /* database ID, or 0 for shared map */
|
Oid dbid; /* database ID, or 0 for shared map */
|
||||||
Oid tsid; /* database's tablespace, or pg_global */
|
Oid tsid; /* database's tablespace, or pg_global */
|
||||||
int32 nbytes; /* size of relmap data */
|
int32 nbytes; /* size of relmap data */
|
||||||
char data[1]; /* VARIABLE LENGTH ARRAY */
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
||||||
} xl_relmap_update;
|
} xl_relmap_update;
|
||||||
|
|
||||||
#define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data)
|
#define MinSizeOfRelmapUpdate offsetof(xl_relmap_update, data)
|
||||||
|
@ -26,7 +26,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||||
int32 bit_len; /* number of valid bits */
|
int32 bit_len; /* number of valid bits */
|
||||||
bits8 bit_dat[1]; /* bit string, most sig. byte first */
|
bits8 bit_dat[FLEXIBLE_ARRAY_MEMBER]; /* bit string, most sig. byte
|
||||||
|
* first */
|
||||||
} VarBit;
|
} VarBit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user