v20250403-0002-add-new-list-type-simple_oid_string_list-t.patch
text/x-patch
Filename: v20250403-0002-add-new-list-type-simple_oid_string_list-t.patch
Type: text/x-patch
Part: 1
Message:
Re: Non-text mode for pg_dumpall
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 v20250403-0002
Subject: add new list type simple_oid_string_list to fe-utils/simple_list
| File | + | − |
|---|---|---|
| src/fe_utils/simple_list.c | 41 | 0 |
| src/include/fe_utils/simple_list.h | 16 | 0 |
| src/tools/pgindent/typedefs.list | 2 | 0 |
From 367ecd4f6870f9402a2254152bbf7e97ff1f2a23 Mon Sep 17 00:00:00 2001
From: Andrew Dunstan <andrew@dunslane.net>
Date: Fri, 28 Mar 2025 18:10:24 -0400
Subject: [PATCH v20250403 2/4] add new list type simple_oid_string_list to
fe-utils/simple_list
This type contains both an oid and a string.
This will be used in forthcoming changes to pg_restore.
Author: Andrew Dunstan <andrew@dunslane.net>
---
src/fe_utils/simple_list.c | 41 ++++++++++++++++++++++++++++++
src/include/fe_utils/simple_list.h | 16 ++++++++++++
src/tools/pgindent/typedefs.list | 2 ++
3 files changed, 59 insertions(+)
diff --git a/src/fe_utils/simple_list.c b/src/fe_utils/simple_list.c
index 483d5455594..b0686e57c4a 100644
--- a/src/fe_utils/simple_list.c
+++ b/src/fe_utils/simple_list.c
@@ -192,3 +192,44 @@ simple_ptr_list_destroy(SimplePtrList *list)
cell = next;
}
}
+
+/*
+ * Add to an oid_string list
+ */
+void
+simple_oid_string_list_append(SimpleOidStringList *list, Oid oid, const char *str)
+{
+ SimpleOidStringListCell *cell;
+
+ cell = (SimpleOidStringListCell *)
+ pg_malloc(offsetof(SimpleOidStringListCell, str) + strlen(str) + 1);
+
+ cell->next = NULL;
+ cell->oid = oid;
+ strcpy(cell->str, str);
+
+ if (list->tail)
+ list->tail->next = cell;
+ else
+ list->head = cell;
+ list->tail = cell;
+}
+
+/*
+ * Destroy an oid_string list
+ */
+void
+simple_oid_string_list_destroy(SimpleOidStringList *list)
+{
+ SimpleOidStringListCell *cell;
+
+ cell = list->head;
+ while (cell != NULL)
+ {
+ SimpleOidStringListCell *next;
+
+ next = cell->next;
+ pg_free(cell);
+ cell = next;
+ }
+}
diff --git a/src/include/fe_utils/simple_list.h b/src/include/fe_utils/simple_list.h
index 3b8e38414ec..a5373932555 100644
--- a/src/include/fe_utils/simple_list.h
+++ b/src/include/fe_utils/simple_list.h
@@ -55,6 +55,19 @@ typedef struct SimplePtrList
SimplePtrListCell *tail;
} SimplePtrList;
+typedef struct SimpleOidStringListCell
+{
+ struct SimpleOidStringListCell *next;
+ Oid oid;
+ char str[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string here */
+} SimpleOidStringListCell;
+
+typedef struct SimpleOidStringList
+{
+ SimpleOidStringListCell *head;
+ SimpleOidStringListCell *tail;
+} SimpleOidStringList;
+
extern void simple_oid_list_append(SimpleOidList *list, Oid val);
extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
extern void simple_oid_list_destroy(SimpleOidList *list);
@@ -68,4 +81,7 @@ extern const char *simple_string_list_not_touched(SimpleStringList *list);
extern void simple_ptr_list_append(SimplePtrList *list, void *ptr);
extern void simple_ptr_list_destroy(SimplePtrList *list);
+extern void simple_oid_string_list_append(SimpleOidStringList *list, Oid oid, const char *str);
+extern void simple_oid_string_list_destroy(SimpleOidStringList *list);
+
#endif /* SIMPLE_LIST_H */
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 8f28d8ff28e..8be62c9216a 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2744,6 +2744,8 @@ SimpleActionListCell
SimpleEcontextStackEntry
SimpleOidList
SimpleOidListCell
+SimpleOidStringList
+SimpleOidListStringCell
SimplePtrList
SimplePtrListCell
SimpleStats
--
2.34.1