postgresql/src/include/utils
Tom Lane 442accc3fe Allow memory contexts to have both fixed and variable ident strings.
Originally, we treated memory context names as potentially variable in
all cases, and therefore always copied them into the context header.
Commit 9fa6f00b1 rethought this a little bit and invented a distinction
between fixed and variable names, skipping the copy step for the former.
But we can make things both simpler and more useful by instead allowing
there to be two parts to a context's identification, a fixed "name" and
an optional, variable "ident".  The name supplied in the context create
call 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, if
wanted, is supplied later.  This is needed because typically we want
the ident to be stored inside the context so that it's cleaned up
automatically on context deletion; that means it has to be copied into
the context before we can set the pointer.

The cost of this approach is basically just an additional pointer field
in struct MemoryContextData, which isn't much overhead, and is bought
back entirely in the AllocSet case by not needing a headerSize field
anymore, since we no longer have to cope with variable header length.
In addition, we can simplify the internal interfaces for memory context
creation still further, saving a few cycles there.  And it's no longer
true that a custom identifier disqualifies a context from participating
in 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 names
are adjusted to put the variable info into the "ident" instead.  This
allows more effective identification of those contexts in many cases;
for example, subsidary contexts of relcache entries are now identified
by both type (e.g. "index info") and relname, where before you got only
one or the other.  Contexts associated with PL function cache entries
are now identified more fully and uniformly, too.

I also arranged for plancache contexts to use the query source string
as their identifier.  This is basically free for CachedPlanSources, as
they contained a copy of that string already.  We pay an extra pstrdup
to do it for CachedPlans.  That could perhaps be avoided, but it would
make things more fragile (since the CachedPlanSource is sometimes
destroyed first).  I suspect future improvements in error reporting will
require CachedPlans to have a copy of that string anyway, so it's not
clear that it's worth moving mountains to avoid it now.

This also changes the APIs for context statistics routines so that the
context-specific routines no longer assume that output goes straight
to stderr, nor do they know all details of the output format.  This
is useful immediately to reduce code duplication, and it also allows
for external code to do something with stats output that's different
from printing to stderr.

The reason for pushing this now rather than waiting for v12 is that
it rethinks some of the API changes made by commit 9fa6f00b1.  Seems
better for extension authors to endure just one round of API changes
not two.

Discussion: https://postgr.es/m/CAB=Je-FdtmFZ9y9REHD7VsSrnCkiBhsA4mdsLKSPauwXtQBeNA@mail.gmail.com
2018-03-27 16:46:51 -04:00
..
.gitignore Generate fmgr prototypes automatically 2017-01-17 14:06:07 -05:00
acl.h Replace AclObjectKind with ObjectType 2018-01-19 14:01:15 -05:00
aclchk_internal.h Replace GrantObjectType with ObjectType 2018-01-19 14:01:14 -05:00
array.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
arrayaccess.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ascii.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
attoptcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
backend_random.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
builtins.h Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY. 2018-03-19 18:50:05 -04:00
bytea.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
combocid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
date.h Fix compiler warnings due to commit cc4feded 2018-01-17 03:33:02 -05:00
datetime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
datum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dsa.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dynahash.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
dynamic_loader.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
elog.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
evtcache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandeddatum.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
expandedrecord.h Make plpgsql use its DTYPE_REC code paths for composite-type variables. 2018-02-13 18:52:21 -05:00
fmgrtab.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
formatting.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
freepage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
geo_decls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
guc.h Fix mishandling of quoted-list GUC values in pg_dump and ruleutils.c. 2018-03-21 20:03:28 -04:00
guc_tables.h Split out documentation of SSL parameters into their own section 2018-01-23 07:11:38 -05:00
hashutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
help_config.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
hsearch.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
index_selfuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inet.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
int8.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
inval.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
json.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
jsonapi.h Centralize json and jsonb handling of datetime types 2018-01-16 19:07:13 -05:00
jsonb.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
logtape.h Support parallel btree index builds. 2018-02-02 13:32:44 -05:00
lsyscache.h Add prokind column, replacing proisagg and proiswindow 2018-03-02 13:48:33 -05:00
memdebug.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
memutils.h Allow memory contexts to have both fixed and variable ident strings. 2018-03-27 16:46:51 -04:00
nabstime.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
numeric.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
palloc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_crc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_locale.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_lsn.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pg_rusage.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
pidfile.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
plancache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
portal.h Transaction control in PL procedures 2018-01-22 08:43:06 -05:00
ps_status.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
queryenvironment.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rangetypes.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
regproc.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
rel.h Allow HOT updates for some expression indexes 2018-03-27 19:57:02 +01:00
relcache.h Allow HOT updates for some expression indexes 2018-03-27 19:57:02 +01:00
relfilenodemap.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relmapper.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
relptr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
reltrigger.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
resowner_private.h Basic JIT provider and error handling infrastructure. 2018-03-21 19:28:28 -07:00
rls.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
ruleutils.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sampling.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
selfuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sharedtuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapmgr.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
snapshot.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
sortsupport.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
spccache.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
syscache.h Save a few bytes by removing useless last argument to SearchCatCacheList. 2018-01-29 15:13:17 -05:00
timeout.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
timestamp.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tqual.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
tuplesort.h Support parallel btree index builds. 2018-02-02 13:32:44 -05:00
tuplestore.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
typcache.h Make plpgsql use its DTYPE_REC code paths for composite-type variables. 2018-02-13 18:52:21 -05:00
tzparser.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
uuid.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varbit.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
varlena.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
xml.h Update copyright for 2018 2018-01-02 23:30:12 -05:00