v23-0004-Fix-a-bug-related-to-atomic-function.patch
application/octet-stream
Filename: v23-0004-Fix-a-bug-related-to-atomic-function.patch
Type: application/octet-stream
Part: 4
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v23-0004
Subject: Fix a bug related to atomic function
| File | + | − |
|---|---|---|
| src/backend/nodes/read.c | 20 | 0 |
| src/backend/nodes/readfuncs.c | 22 | 2 |
| src/include/nodes/readfuncs.h | 2 | 0 |
From 914045526469d8010becaa4e3ebebff23167681a Mon Sep 17 00:00:00 2001
From: Yuya Watari <watari.yuya@gmail.com>
Date: Mon, 11 Dec 2023 12:20:20 +0900
Subject: [PATCH v23 4/6] Fix a bug related to atomic function
Author: Alena Rybakina <lena.ribackina@yandex.ru>
https://www.postgresql.org/message-id/72d292a1-06ff-432a-a803-af5053786444%40yandex.ru
---
src/backend/nodes/read.c | 20 ++++++++++++++++++++
src/backend/nodes/readfuncs.c | 24 ++++++++++++++++++++++--
src/include/nodes/readfuncs.h | 2 ++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c
index 969d0ec199..39c5a39fa7 100644
--- a/src/backend/nodes/read.c
+++ b/src/backend/nodes/read.c
@@ -514,3 +514,23 @@ nodeRead(const char *token, int tok_len)
return (void *) result;
}
+
+/*
+ * pg_strtok_save_context -
+ * Save context initialized by stringToNode.
+ */
+void
+pg_strtok_save_context(const char **pcontext)
+{
+ *pcontext = pg_strtok_ptr;
+}
+
+/*
+ * pg_strtok_restore_context -
+ * Resore saved context.
+ */
+void
+pg_strtok_restore_context(const char *context)
+{
+ pg_strtok_ptr = context;
+}
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index deebfaf994..0b713838dd 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -191,6 +191,26 @@ nullable_string(const char *token, int length)
return debackslash(token, length);
}
+/* Read an equivalence field (anything written as ":fldname %u") and check it */
+#define READ_EQ_BITMAPSET_FIELD_CHECK(fldname) \
+{ \
+ int save_length = length; \
+ const char *context; \
+ pg_strtok_save_context(&context); \
+ token = pg_strtok(&length); \
+ if (length > 0 && strncmp(token, ":"#fldname, strlen(":"#fldname))) \
+ { \
+ /* "fldname" field was not found - fill it and restore context. */ \
+ local_node->fldname = NULL; \
+ pg_strtok_restore_context(context); \
+ length = save_length; \
+ } \
+ else \
+ { \
+ local_node->fldname = _readBitmapset(); \
+ } \
+}
+
/*
* _readBitmapset
@@ -574,8 +594,8 @@ _readRangeTblEntry(void)
READ_BOOL_FIELD(inh);
READ_BOOL_FIELD(inFromCl);
READ_NODE_FIELD(securityQuals);
- READ_BITMAPSET_FIELD(eclass_source_indexes);
- READ_BITMAPSET_FIELD(eclass_derive_indexes);
+ READ_EQ_BITMAPSET_FIELD_CHECK(eclass_source_indexes);
+ READ_EQ_BITMAPSET_FIELD_CHECK(eclass_derive_indexes);
READ_DONE();
}
diff --git a/src/include/nodes/readfuncs.h b/src/include/nodes/readfuncs.h
index 8466038ed0..0dc2ed5112 100644
--- a/src/include/nodes/readfuncs.h
+++ b/src/include/nodes/readfuncs.h
@@ -29,6 +29,8 @@ extern PGDLLIMPORT bool restore_location_fields;
extern const char *pg_strtok(int *length);
extern char *debackslash(const char *token, int length);
extern void *nodeRead(const char *token, int tok_len);
+extern void pg_strtok_save_context(const char **pcontext);
+extern void pg_strtok_restore_context(const char *context);
/*
* prototypes for functions in readfuncs.c
--
2.42.0.windows.2