- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit42a1de3
committed
Add helper functions for dshash tables with string keys.
Presently, string keys are not well-supported for dshash tables.The dshash code always copies key_size bytes into new entries'keys, and dshash.h only provides compare and hash functions thatforward to memcmp() and tag_hash(), both of which do not stop atthe first NUL. This means that callers must pad string keys sothat the data beyond the first NUL does not adversely affect theresults of copying, comparing, and hashing the keys.To better support string keys in dshash tables, this commit doesa couple things:* A new copy_function field is added to the dshash_parameters struct. This function pointer specifies how the key should be copied into new table entries. For example, we only want to copy up to the first NUL byte for string keys. A dshash_memcpy() helper function is provided and used for all existing in-tree dshash tables without string keys.* A set of helper functions for string keys are provided. These helper functions forward to strcmp(), strcpy(), and string_hash(), all of which ignore data beyond the first NUL.This commit also adjusts the DSM registry's dshash table to use thenew helper functions for string keys.Reviewed-by: Andy FanDiscussion:https://postgr.es/m/20240119215941.GA1322079%40nathanxps131 parent5fe08c0 commit42a1de3
File tree
6 files changed
+83
-7
lines changed- src
- backend
- lib
- replication/logical
- storage/ipc
- utils
- activity
- cache
- include/lib
6 files changed
+83
-7
lines changedLines changed: 57 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
188 | 188 |
| |
189 | 189 |
| |
190 | 190 |
| |
| 191 | + | |
| 192 | + | |
191 | 193 |
| |
192 | 194 |
| |
193 | 195 |
| |
| |||
583 | 585 |
| |
584 | 586 |
| |
585 | 587 |
| |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
586 | 631 |
| |
587 | 632 |
| |
588 | 633 |
| |
| |||
949 | 994 |
| |
950 | 995 |
| |
951 | 996 |
| |
952 |
| - | |
| 997 | + | |
953 | 998 |
| |
954 | 999 |
| |
955 | 1000 |
| |
| |||
1032 | 1077 |
| |
1033 | 1078 |
| |
1034 | 1079 |
| |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| 91 | + | |
91 | 92 |
| |
92 | 93 |
| |
93 | 94 |
| |
|
Lines changed: 4 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 |
| - | |
54 |
| - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
55 | 56 |
| |
56 | 57 |
| |
57 | 58 |
| |
| |||
132 | 133 |
| |
133 | 134 |
| |
134 | 135 |
| |
135 |
| - | |
136 | 136 |
| |
137 | 137 |
| |
138 | 138 |
| |
| |||
155 | 155 |
| |
156 | 156 |
| |
157 | 157 |
| |
158 |
| - | |
159 |
| - | |
| 158 | + | |
160 | 159 |
| |
161 | 160 |
| |
162 | 161 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
| 67 | + | |
67 | 68 |
| |
68 | 69 |
| |
69 | 70 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
259 | 259 |
| |
260 | 260 |
| |
261 | 261 |
| |
| 262 | + | |
262 | 263 |
| |
263 | 264 |
| |
264 | 265 |
| |
| |||
268 | 269 |
| |
269 | 270 |
| |
270 | 271 |
| |
| 272 | + | |
271 | 273 |
| |
272 | 274 |
| |
273 | 275 |
| |
|
Lines changed: 18 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
37 | 37 |
| |
38 | 38 |
| |
39 | 39 |
| |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 |
| |
41 | 45 |
| |
42 | 46 |
| |
| |||
55 | 59 |
| |
56 | 60 |
| |
57 | 61 |
| |
| 62 | + | |
58 | 63 |
| |
59 | 64 |
| |
60 | 65 |
| |
| |||
105 | 110 |
| |
106 | 111 |
| |
107 | 112 |
| |
108 |
| - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
109 | 117 |
| |
110 | 118 |
| |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
111 | 128 |
| |
112 | 129 |
| |
113 | 130 |
| |
|
0 commit comments
Comments
(0)