pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Avoid caching expression state trees for domain constraints acro
2+ messages / 1 participants
[nested] [flat]

* pgsql: Avoid caching expression state trees for domain constraints acro
@ 2015-11-29 23:18  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-11-29 23:18 UTC (permalink / raw)
  To: pgsql-committers

Avoid caching expression state trees for domain constraints across queries.

In commit 8abb3cda0ddc00a0ab98977a1633a95b97068d4e I attempted to cache
the expression state trees constructed for domain CHECK constraints for
the life of the backend (assuming the domain's constraints don't get
redefined).  However, this turns out not to work very well, because
execQual.c will run those state trees with ecxt_per_query_memory pointing
to a query-lifespan context, and in some situations we'll end up with
pointers into that context getting stored into the state trees.  This
happens in particular with SQL-language functions, as reported by
Emre Hasegeli, but there are many other cases.

To fix, keep only the expression plan trees for domain CHECK constraints
in the typcache's data structure, and revert to performing ExecInitExpr
(at least) once per query to set up expression state trees in the query's
context.

Eventually it'd be nice to undo this, but that will require some careful
thought about memory management for expression state trees, and it seems
far too late for any such redesign in 9.5.  This way is still much more
efficient than what happened before 8abb3cda0.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ec7eef6b1103f92aea94aa79aabd8e0e87973010

Modified Files
--------------
src/backend/utils/cache/typcache.c   |   62 +++++++++++++++++++++++++++++++---
src/include/utils/typcache.h         |    1 +
src/test/regress/expected/domain.out |   25 ++++++++++++++
src/test/regress/sql/domain.sql      |   24 +++++++++++++
4 files changed, 108 insertions(+), 4 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Avoid caching expression state trees for domain constraints acro
@ 2015-11-29 23:18  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2015-11-29 23:18 UTC (permalink / raw)
  To: pgsql-committers

Avoid caching expression state trees for domain constraints across queries.

In commit 8abb3cda0ddc00a0ab98977a1633a95b97068d4e I attempted to cache
the expression state trees constructed for domain CHECK constraints for
the life of the backend (assuming the domain's constraints don't get
redefined).  However, this turns out not to work very well, because
execQual.c will run those state trees with ecxt_per_query_memory pointing
to a query-lifespan context, and in some situations we'll end up with
pointers into that context getting stored into the state trees.  This
happens in particular with SQL-language functions, as reported by
Emre Hasegeli, but there are many other cases.

To fix, keep only the expression plan trees for domain CHECK constraints
in the typcache's data structure, and revert to performing ExecInitExpr
(at least) once per query to set up expression state trees in the query's
context.

Eventually it'd be nice to undo this, but that will require some careful
thought about memory management for expression state trees, and it seems
far too late for any such redesign in 9.5.  This way is still much more
efficient than what happened before 8abb3cda0.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/e69d3a82e46461da4c3878487fb99c1294fb1d8f

Modified Files
--------------
src/backend/utils/cache/typcache.c   |   62 +++++++++++++++++++++++++++++++---
src/include/utils/typcache.h         |    1 +
src/test/regress/expected/domain.out |   25 ++++++++++++++
src/test/regress/sql/domain.sql      |   24 +++++++++++++
4 files changed, 108 insertions(+), 4 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-11-29 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-11-29 23:18 pgsql: Avoid caching expression state trees for domain constraints acro Tom Lane <tgl@sss.pgh.pa.us>
2015-11-29 23:18 pgsql: Avoid caching expression state trees for domain constraints acro Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox