forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit442accc
committed
Allow memory contexts to have both fixed and variable ident strings.
Originally, we treated memory context names as potentially variable inall cases, and therefore always copied them into the context header.Commit9fa6f00 rethought this a little bit and invented a distinctionbetween fixed and variable names, skipping the copy step for the former.But we can make things both simpler and more useful by instead allowingthere to be two parts to a context's identification, a fixed "name" andan optional, variable "ident". The name supplied in the context createcall is now required to be a compile-time-constant string in all cases,as it is never copied but just pointed to. The "ident" string, ifwanted, is supplied later. This is needed because typically we wantthe ident to be stored inside the context so that it's cleaned upautomatically on context deletion; that means it has to be copied intothe context before we can set the pointer.The cost of this approach is basically just an additional pointer fieldin struct MemoryContextData, which isn't much overhead, and is boughtback entirely in the AllocSet case by not needing a headerSize fieldanymore, since we no longer have to cope with variable header length.In addition, we can simplify the internal interfaces for memory contextcreation still further, saving a few cycles there. And it's no longertrue that a custom identifier disqualifies a context from participatingin aset.c's freelist scheme, so possibly there's some win on that end.All the places that were using non-compile-time-constant context namesare adjusted to put the variable info into the "ident" instead. Thisallows more effective identification of those contexts in many cases;for example, subsidary contexts of relcache entries are now identifiedby both type (e.g. "index info") and relname, where before you got onlyone or the other. Contexts associated with PL function cache entriesare now identified more fully and uniformly, too.I also arranged for plancache contexts to use the query source stringas their identifier. This is basically free for CachedPlanSources, asthey contained a copy of that string already. We pay an extra pstrdupto do it for CachedPlans. That could perhaps be avoided, but it wouldmake things more fragile (since the CachedPlanSource is sometimesdestroyed first). I suspect future improvements in error reporting willrequire CachedPlans to have a copy of that string anyway, so it's notclear that it's worth moving mountains to avoid it now.This also changes the APIs for context statistics routines so that thecontext-specific routines no longer assume that output goes straightto stderr, nor do they know all details of the output format. Thisis useful immediately to reduce code duplication, and it also allowsfor external code to do something with stats output that's differentfrom printing to stderr.The reason for pushing this now rather than waiting for v12 is thatit rethinks some of the API changes made by commit9fa6f00. Seemsbetter for extension authors to endure just one round of API changesnot two.Discussion:https://postgr.es/m/CAB=Je-FdtmFZ9y9REHD7VsSrnCkiBhsA4mdsLKSPauwXtQBeNA@mail.gmail.com1 parentc203d6c commit442accc
File tree
20 files changed
+263
-210
lines changed- src
- backend
- access/transam
- catalog
- commands
- executor
- replication/logical
- statistics
- utils
- cache
- hash
- mmgr
- include
- nodes
- utils
- pl
- plperl
- plpgsql/src
- plpython
- tcl
20 files changed
+263
-210
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
999 | 999 |
| |
1000 | 1000 |
| |
1001 | 1001 |
| |
1002 |
| - | |
1003 | 1002 |
| |
1004 | 1003 |
| |
1005 | 1004 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
525 | 525 |
| |
526 | 526 |
| |
527 | 527 |
| |
528 |
| - | |
529 |
| - | |
530 |
| - | |
531 |
| - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
532 | 533 |
| |
533 | 534 |
| |
534 | 535 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
214 | 214 |
| |
215 | 215 |
| |
216 | 216 |
| |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 |
| |
218 | 221 |
| |
219 | 222 |
| |
|
Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
612 | 612 |
| |
613 | 613 |
| |
614 | 614 |
| |
615 |
| - | |
| 615 | + | |
616 | 616 |
| |
617 | 617 |
| |
618 | 618 |
| |
| |||
635 | 635 |
| |
636 | 636 |
| |
637 | 637 |
| |
638 |
| - | |
| 638 | + | |
| 639 | + | |
639 | 640 |
| |
640 | 641 |
| |
| 642 | + | |
641 | 643 |
| |
642 | 644 |
| |
643 | 645 |
| |
|
Lines changed: 0 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
246 |
| - | |
247 | 246 |
| |
248 | 247 |
| |
249 | 248 |
| |
250 | 249 |
| |
251 | 250 |
| |
252 |
| - | |
253 | 251 |
| |
254 | 252 |
| |
255 | 253 |
| |
256 | 254 |
| |
257 | 255 |
| |
258 |
| - | |
259 | 256 |
| |
260 | 257 |
| |
261 | 258 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
77 |
| - | |
| 77 | + | |
| 78 | + | |
78 | 79 |
| |
79 | 80 |
| |
80 | 81 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
180 | 180 |
| |
181 | 181 |
| |
182 | 182 |
| |
| 183 | + | |
183 | 184 |
| |
184 | 185 |
| |
185 | 186 |
| |
| |||
951 | 952 |
| |
952 | 953 |
| |
953 | 954 |
| |
| 955 | + | |
954 | 956 |
| |
955 | 957 |
| |
956 | 958 |
| |
| |||
1346 | 1348 |
| |
1347 | 1349 |
| |
1348 | 1350 |
| |
| 1351 | + | |
1349 | 1352 |
| |
1350 | 1353 |
| |
1351 | 1354 |
| |
|
Lines changed: 20 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
675 | 675 |
| |
676 | 676 |
| |
677 | 677 |
| |
678 |
| - | |
679 |
| - | |
680 |
| - | |
681 |
| - | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
682 | 681 |
| |
| 682 | + | |
| 683 | + | |
683 | 684 |
| |
684 | 685 |
| |
685 | 686 |
| |
| |||
852 | 853 |
| |
853 | 854 |
| |
854 | 855 |
| |
855 |
| - | |
856 |
| - | |
857 |
| - | |
858 |
| - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
859 | 861 |
| |
860 | 862 |
| |
861 | 863 |
| |
| |||
1533 | 1535 |
| |
1534 | 1536 |
| |
1535 | 1537 |
| |
1536 |
| - | |
1537 |
| - | |
1538 |
| - | |
1539 |
| - | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
1540 | 1541 |
| |
| 1542 | + | |
| 1543 | + | |
1541 | 1544 |
| |
1542 | 1545 |
| |
1543 | 1546 |
| |
| |||
5603 | 5606 |
| |
5604 | 5607 |
| |
5605 | 5608 |
| |
5606 |
| - | |
5607 |
| - | |
5608 |
| - | |
5609 |
| - | |
5610 |
| - | |
| 5609 | + | |
| 5610 | + | |
| 5611 | + | |
5611 | 5612 |
| |
| 5613 | + | |
| 5614 | + | |
5612 | 5615 |
| |
5613 | 5616 |
| |
5614 | 5617 |
| |
|
Lines changed: 8 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
301 | 301 |
| |
302 | 302 |
| |
303 | 303 |
| |
304 | 304 |
| |
305 | 305 |
| |
306 |
| - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
307 | 310 |
| |
308 | 311 |
| |
309 | 312 |
| |
|
Lines changed: 7 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
340 | 340 |
| |
341 | 341 |
| |
342 | 342 |
| |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
348 | 346 |
| |
349 | 347 |
| |
350 | 348 |
| |
| |||
354 | 352 |
| |
355 | 353 |
| |
356 | 354 |
| |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
357 | 359 |
| |
358 | 360 |
| |
359 | 361 |
| |
|
0 commit comments
Comments
(0)