diff --git a/src/backend/distributed/cdc/cdc_decoder_utils.c b/src/backend/distributed/cdc/cdc_decoder_utils.c index 9053d1b680b..73e454e6806 100644 --- a/src/backend/distributed/cdc/cdc_decoder_utils.c +++ b/src/backend/distributed/cdc/cdc_decoder_utils.c @@ -153,7 +153,7 @@ CdcExtractShardIdFromTableName(const char *tableName, bool missingOk) char *shardIdStringEnd = NULL; /* find the last underscore and increment for shardId string */ - char *shardIdString = strrchr(tableName, SHARD_NAME_SEPARATOR); + const char *shardIdString = strrchr(tableName, SHARD_NAME_SEPARATOR); if (shardIdString == NULL && !missingOk) { ereport(ERROR, (errmsg("could not extract shardId from table name \"%s\"", diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index b4130c54552..6b0986c0828 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -114,7 +114,7 @@ /* constant used in binary protocol */ -static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0"; +static const char BinarySignature[11] pg_attribute_nonstring = "PGCOPY\n\377\r\n\0"; /* if true, skip validation of JSONB columns during COPY */ bool SkipJsonbValidationInCopy = true; diff --git a/src/backend/distributed/utils/citus_safe_lib.c b/src/backend/distributed/utils/citus_safe_lib.c index 2d504a644f1..4099a949368 100644 --- a/src/backend/distributed/utils/citus_safe_lib.c +++ b/src/backend/distributed/utils/citus_safe_lib.c @@ -288,7 +288,7 @@ SafeBsearch(const void *key, const void *ptr, rsize_t count, rsize_t size, * does. We cannot use bsearch_s as a replacement, since it's not available * in safestringlib. */ - return bsearch(key, ptr, count, size, comp); /* IGNORE-BANNED */ + return (void *) bsearch(key, ptr, count, size, comp); /* IGNORE-BANNED */ } diff --git a/src/backend/distributed/worker/worker_data_fetch_protocol.c b/src/backend/distributed/worker/worker_data_fetch_protocol.c index dade1857cff..5889bf81074 100644 --- a/src/backend/distributed/worker/worker_data_fetch_protocol.c +++ b/src/backend/distributed/worker/worker_data_fetch_protocol.c @@ -558,7 +558,7 @@ ExtractShardIdFromTableName(const char *tableName, bool missingOk) char *shardIdStringEnd = NULL; /* find the last underscore and increment for shardId string */ - char *shardIdString = strrchr(tableName, SHARD_NAME_SEPARATOR); + const char *shardIdString = strrchr(tableName, SHARD_NAME_SEPARATOR); if (shardIdString == NULL && !missingOk) { ereport(ERROR, (errmsg("could not extract shardId from table name \"%s\"", diff --git a/src/include/pg_version_compat.h b/src/include/pg_version_compat.h index 49963b3747e..a50824077ca 100644 --- a/src/include/pg_version_compat.h +++ b/src/include/pg_version_compat.h @@ -477,4 +477,17 @@ getStxstattarget_compat(HeapTuple tup) " MINVALUE " INT64_FORMAT " MAXVALUE " INT64_FORMAT \ " START WITH " INT64_FORMAT " CACHE " INT64_FORMAT " %sCYCLE" +/* + * pg_attribute_nonstring marks a character array that is not meant to be + * NUL-terminated, silencing -Wunterminated-string-initialization (GCC 15+). + * It was introduced in PostgreSQL 18, so provide a fallback for older versions. + */ +#ifndef pg_attribute_nonstring +#if defined(__has_attribute) && __has_attribute(nonstring) +#define pg_attribute_nonstring __attribute__((nonstring)) +#else +#define pg_attribute_nonstring +#endif +#endif + #endif /* PG_VERSION_COMPAT_H */