[PATCH v6 1/2] Add static assertions about size of GinTernaryValue vs bool
Peter Eisentraut <peter_e@gmx.net>
From: Peter Eisentraut <peter_e@gmx.net>
To:
Date: 2017-12-19T18:54:05Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Move strtoint() to common
- 17bb62501787 11.0 cited
We need these to be the same because some code casts between pointers to them. --- src/backend/utils/adt/tsginidx.c | 4 +++- src/include/access/gin.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c index de59e6417e..00e32b2570 100644 --- a/src/backend/utils/adt/tsginidx.c +++ b/src/backend/utils/adt/tsginidx.c @@ -309,7 +309,9 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS) * query. */ gcv.first_item = GETQUERY(query); - gcv.check = check; + StaticAssertStmt(sizeof(GinTernaryValue) == sizeof(bool), + "sizes of GinTernaryValue and bool are not equal"); + gcv.check = (GinTernaryValue *) check; gcv.map_item_operand = (int *) (extra_data[0]); gcv.need_recheck = recheck; diff --git a/src/include/access/gin.h b/src/include/access/gin.h index 0acdb88241..3d8a130b69 100644 --- a/src/include/access/gin.h +++ b/src/include/access/gin.h @@ -51,8 +51,8 @@ typedef struct GinStatsData /* * A ternary value used by tri-consistent functions. * - * For convenience, this is compatible with booleans. A boolean can be - * safely cast to a GinTernaryValue. + * This must be of the same size as a bool because some code will cast a + * pointer to a bool to a pointer to a GinTernaryValue. */ typedef char GinTernaryValue; base-commit: 17bb62501787c56e0518e61db13a523d47afd724 -- 2.16.2 --------------B00F3D5C7F79BB1E3887F7C5 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="v6-0002-Use-stdbool.h-if-suitable.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="v6-0002-Use-stdbool.h-if-suitable.patch"