Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit308da17

Browse files
committed
Add COPY_ARRAY_FIELD and COMPARE_ARRAY_FIELD
These handle node fields that are inline arrays (as opposed todynamically allocated arrays handled by COPY_POINTER_FIELD andCOMPARE_POINTER_FIELD). These cases were hand-coded until now.Reviewed-by: Jacob Champion <pchampion@vmware.com>Discussion:https://www.postgresql.org/message-id/c091e5cd-45f8-69ee-6a9b-de86912cc7e7@enterprisedb.com
1 parent8539929 commit308da17

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

‎src/backend/nodes/copyfuncs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
#defineCOPY_STRING_FIELD(fldname) \
5454
(newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
5555

56+
/* Copy a field that is an inline array */
57+
#defineCOPY_ARRAY_FIELD(fldname) \
58+
memcpy(newnode->fldname, from->fldname, sizeof(newnode->fldname))
59+
5660
/* Copy a field that is a pointer to a simple palloc'd object of size sz */
5761
#defineCOPY_POINTER_FIELD(fldname,sz) \
5862
do { \
@@ -4947,10 +4951,9 @@ _copyForeignKeyCacheInfo(const ForeignKeyCacheInfo *from)
49474951
COPY_SCALAR_FIELD(conrelid);
49484952
COPY_SCALAR_FIELD(confrelid);
49494953
COPY_SCALAR_FIELD(nkeys);
4950-
/* COPY_SCALAR_FIELD might work for these, but let's not assume that */
4951-
memcpy(newnode->conkey,from->conkey,sizeof(newnode->conkey));
4952-
memcpy(newnode->confkey,from->confkey,sizeof(newnode->confkey));
4953-
memcpy(newnode->conpfeqop,from->conpfeqop,sizeof(newnode->conpfeqop));
4954+
COPY_ARRAY_FIELD(conkey);
4955+
COPY_ARRAY_FIELD(confkey);
4956+
COPY_ARRAY_FIELD(conpfeqop);
49544957

49554958
returnnewnode;
49564959
}

‎src/backend/nodes/equalfuncs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
#defineequalstr(a,b)\
7575
(((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
7676

77+
/* Compare a field that is an inline array */
78+
#defineCOMPARE_ARRAY_FIELD(fldname) \
79+
do { \
80+
if (memcmp(a->fldname, b->fldname, sizeof(a->fldname)) != 0) \
81+
return false; \
82+
} while (0)
83+
7784
/* Compare a field that is a pointer to a simple palloc'd object of size sz */
7885
#defineCOMPARE_POINTER_FIELD(fldname,sz) \
7986
do { \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp