1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* execdebug.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* #defines governing debugging behaviour in the executor
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2006-05-23 17:21:52 +02:00
|
|
|
* XXX this is all pretty old and crufty. Newer code tends to use elog()
|
|
|
|
* for debug printouts, because that's more flexible than printf().
|
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2017-01-03 19:48:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/executor/execdebug.h
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef EXECDEBUG_H
|
|
|
|
#define EXECDEBUG_H
|
|
|
|
|
2000-06-15 02:52:26 +02:00
|
|
|
#include "executor/executor.h"
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "nodes/print.h"
|
1999-07-15 17:21:54 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* debugging defines.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* If you want certain debugging behaviour, then #define
|
1999-02-23 08:39:40 +01:00
|
|
|
* the variable to 1. No need to explicitly #undef by default,
|
|
|
|
* since we can use -D compiler options to enable features.
|
|
|
|
* - thomas 1999-02-20
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
|
2006-05-23 17:21:52 +02:00
|
|
|
* nest loop node by NL_printf() and ENL_printf() in nodeNestloop.c
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
#undef EXEC_NESTLOOPDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
*/
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* EXEC_SORTDEBUG is a flag which turns on debugging of
|
2006-05-23 17:21:52 +02:00
|
|
|
* the ExecSort() stuff by SO_printf() in nodeSort.c
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
#undef EXEC_SORTDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
*/
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
|
2006-05-23 17:21:52 +02:00
|
|
|
* the ExecMergeJoin() stuff by MJ_printf() in nodeMergejoin.c
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
#undef EXEC_MERGEJOINDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
*/
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* #defines controlled by above definitions
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Note: most of these are "incomplete" because I didn't
|
|
|
|
* need the ones not defined. More should be added
|
|
|
|
* only as necessary -cim 10/26/89
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------------------------------------------------------
|
|
|
|
*/
|
2000-09-12 23:07:18 +02:00
|
|
|
#define T_OR_F(b) ((b) ? "true" : "false")
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* nest loop debugging defines
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
#ifdef EXEC_NESTLOOPDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
#define NL_nodeDisplay(l) nodeDisplay(l)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NL_printf(s) printf(s)
|
|
|
|
#define NL1_printf(s, a) printf(s, a)
|
|
|
|
#define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
|
1996-07-09 08:22:35 +02:00
|
|
|
#else
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NL_nodeDisplay(l)
|
|
|
|
#define NL_printf(s)
|
|
|
|
#define NL1_printf(s, a)
|
1996-07-09 08:22:35 +02:00
|
|
|
#define ENL1_printf(message)
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* EXEC_NESTLOOPDEBUG */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* sort node debugging defines
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
#ifdef EXEC_SORTDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
#define SO_nodeDisplay(l) nodeDisplay(l)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define SO_printf(s) printf(s)
|
|
|
|
#define SO1_printf(s, p) printf(s, p)
|
1996-07-09 08:22:35 +02:00
|
|
|
#else
|
1997-09-07 07:04:48 +02:00
|
|
|
#define SO_nodeDisplay(l)
|
|
|
|
#define SO_printf(s)
|
|
|
|
#define SO1_printf(s, p)
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* EXEC_SORTDEBUG */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* merge join debugging defines
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
#ifdef EXEC_MERGEJOINDEBUG
|
1999-02-23 08:39:40 +01:00
|
|
|
|
|
|
|
#define MJ_nodeDisplay(l) nodeDisplay(l)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define MJ_printf(s) printf(s)
|
|
|
|
#define MJ1_printf(s, p) printf(s, p)
|
|
|
|
#define MJ2_printf(s, p1, p2) printf(s, p1, p2)
|
2005-03-16 22:38:10 +01:00
|
|
|
#define MJ_debugtup(slot) debugtup(slot, NULL)
|
2000-09-12 23:07:18 +02:00
|
|
|
#define MJ_dump(state) ExecMergeTupleDump(state)
|
2005-05-13 23:20:16 +02:00
|
|
|
#define MJ_DEBUG_COMPARE(res) \
|
|
|
|
MJ1_printf(" MJCompare() returns %d\n", (res))
|
1996-07-09 08:22:35 +02:00
|
|
|
#define MJ_DEBUG_QUAL(clause, res) \
|
|
|
|
MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
|
2005-05-13 23:20:16 +02:00
|
|
|
CppAsString(clause), T_OR_F(res))
|
1996-07-09 08:22:35 +02:00
|
|
|
#define MJ_DEBUG_PROC_NODE(slot) \
|
2000-09-12 23:07:18 +02:00
|
|
|
MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
|
2005-05-13 23:20:16 +02:00
|
|
|
CppAsString(slot), NULL_OR_TUPLE(slot))
|
1996-07-09 08:22:35 +02:00
|
|
|
#else
|
2000-09-12 23:07:18 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#define MJ_nodeDisplay(l)
|
1997-09-07 07:04:48 +02:00
|
|
|
#define MJ_printf(s)
|
|
|
|
#define MJ1_printf(s, p)
|
1996-07-09 08:22:35 +02:00
|
|
|
#define MJ2_printf(s, p1, p2)
|
2005-03-16 22:38:10 +01:00
|
|
|
#define MJ_debugtup(slot)
|
2000-09-12 23:07:18 +02:00
|
|
|
#define MJ_dump(state)
|
2005-05-13 23:20:16 +02:00
|
|
|
#define MJ_DEBUG_COMPARE(res)
|
1996-07-09 08:22:35 +02:00
|
|
|
#define MJ_DEBUG_QUAL(clause, res)
|
|
|
|
#define MJ_DEBUG_PROC_NODE(slot)
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* EXEC_MERGEJOINDEBUG */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
Faster expression evaluation and targetlist projection.
This replaces the old, recursive tree-walk based evaluation, with
non-recursive, opcode dispatch based, expression evaluation.
Projection is now implemented as part of expression evaluation.
This both leads to significant performance improvements, and makes
future just-in-time compilation of expressions easier.
The speed gains primarily come from:
- non-recursive implementation reduces stack usage / overhead
- simple sub-expressions are implemented with a single jump, without
function calls
- sharing some state between different sub-expressions
- reduced amount of indirect/hard to predict memory accesses by laying
out operation metadata sequentially; including the avoidance of
nearly all of the previously used linked lists
- more code has been moved to expression initialization, avoiding
constant re-checks at evaluation time
Future just-in-time compilation (JIT) has become easier, as
demonstrated by released patches intended to be merged in a later
release, for primarily two reasons: Firstly, due to a stricter split
between expression initialization and evaluation, less code has to be
handled by the JIT. Secondly, due to the non-recursive nature of the
generated "instructions", less performance-critical code-paths can
easily be shared between interpreted and compiled evaluation.
The new framework allows for significant future optimizations. E.g.:
- basic infrastructure for to later reduce the per executor-startup
overhead of expression evaluation, by caching state in prepared
statements. That'd be helpful in OLTPish scenarios where
initialization overhead is measurable.
- optimizing the generated "code". A number of proposals for potential
work has already been made.
- optimizing the interpreter. Similarly a number of proposals have
been made here too.
The move of logic into the expression initialization step leads to some
backward-incompatible changes:
- Function permission checks are now done during expression
initialization, whereas previously they were done during
execution. In edge cases this can lead to errors being raised that
previously wouldn't have been, e.g. a NULL array being coerced to a
different array type previously didn't perform checks.
- The set of domain constraints to be checked, is now evaluated once
during expression initialization, previously it was re-built
every time a domain check was evaluated. For normal queries this
doesn't change much, but e.g. for plpgsql functions, which caches
ExprStates, the old set could stick around longer. The behavior
around might still change.
Author: Andres Freund, with significant changes by Tom Lane,
changes by Heikki Linnakangas
Reviewed-By: Tom Lane, Heikki Linnakangas
Discussion: https://postgr.es/m/20161206034955.bh33paeralxbtluv@alap3.anarazel.de
2017-03-14 23:45:36 +01:00
|
|
|
#endif /* EXECDEBUG_H */
|