Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

explain.c

Blame
    • Tom Lane's avatar
      7bddca34
      Fix up foreign-key mechanism so that there is a sound semantic basis for the · 7bddca34
      Tom Lane authored
      equality checks it applies, instead of a random dependence on whatever
      operators might be named "=".  The equality operators will now be selected
      from the opfamily of the unique index that the FK constraint depends on to
      enforce uniqueness of the referenced columns; therefore they are certain to be
      consistent with that index's notion of equality.  Among other things this
      should fix the problem noted awhile back that pg_dump may fail for foreign-key
      constraints on user-defined types when the required operators aren't in the
      search path.  This also means that the former warning condition about "foreign
      key constraint will require costly sequential scans" is gone: if the
      comparison condition isn't indexable then we'll reject the constraint
      entirely. All per past discussions.
      
      Along the way, make the RI triggers look into pg_constraint for their
      information, instead of using pg_trigger.tgargs; and get rid of the always
      error-prone fixed-size string buffers in ri_triggers.c in favor of building up
      the RI queries in StringInfo buffers.
      
      initdb forced due to columns added to pg_constraint and pg_trigger.
      7bddca34
      History
      Fix up foreign-key mechanism so that there is a sound semantic basis for the
      Tom Lane authored
      equality checks it applies, instead of a random dependence on whatever
      operators might be named "=".  The equality operators will now be selected
      from the opfamily of the unique index that the FK constraint depends on to
      enforce uniqueness of the referenced columns; therefore they are certain to be
      consistent with that index's notion of equality.  Among other things this
      should fix the problem noted awhile back that pg_dump may fail for foreign-key
      constraints on user-defined types when the required operators aren't in the
      search path.  This also means that the former warning condition about "foreign
      key constraint will require costly sequential scans" is gone: if the
      comparison condition isn't indexable then we'll reject the constraint
      entirely. All per past discussions.
      
      Along the way, make the RI triggers look into pg_constraint for their
      information, instead of using pg_trigger.tgargs; and get rid of the always
      error-prone fixed-size string buffers in ri_triggers.c in favor of building up
      the RI queries in StringInfo buffers.
      
      initdb forced due to columns added to pg_constraint and pg_trigger.
    explain.c 30.11 KiB
    /*-------------------------------------------------------------------------
     *
     * explain.c
     *	  Explain query execution plans
     *
     * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
     * Portions Copyright (c) 1994-5, Regents of the University of California
     *
     * IDENTIFICATION
     *	  $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.154 2007/02/14 01:58:56 tgl Exp $
     *
     *-------------------------------------------------------------------------
     */
    #include "postgres.h"
    
    #include "access/xact.h"
    #include "catalog/pg_constraint.h"
    #include "catalog/pg_type.h"
    #include "commands/explain.h"
    #include "commands/prepare.h"
    #include "commands/trigger.h"
    #include "executor/instrument.h"
    #include "nodes/print.h"
    #include "optimizer/clauses.h"
    #include "optimizer/planner.h"
    #include "optimizer/var.h"
    #include "parser/parsetree.h"
    #include "rewrite/rewriteHandler.h"
    #include "utils/builtins.h"
    #include "utils/guc.h"
    #include "utils/lsyscache.h"
    
    
    typedef struct ExplainState
    {
    	/* options */
    	bool		printNodes;		/* do nodeToString() too */
    	bool		printAnalyze;	/* print actual times */
    	/* other states */
    	List	   *rtable;			/* range table */
    } ExplainState;
    
    static void ExplainOneQuery(Query *query, ExplainStmt *stmt,
    				ParamListInfo params, TupOutputState *tstate);
    static double elapsed_time(instr_time *starttime);
    static void explain_outNode(StringInfo str,
    				Plan *plan, PlanState *planstate,
    				Plan *outer_plan,
    				int indent, ExplainState *es);
    static void show_scan_qual(List *qual, const char *qlabel,
    			   int scanrelid, Plan *outer_plan,
    			   StringInfo str, int indent, ExplainState *es);
    static void show_upper_qual(List *qual, const char *qlabel,
    				const char *outer_name, int outer_varno, Plan *outer_plan,
    				const char *inner_name, int inner_varno, Plan *inner_plan,
    				StringInfo str, int indent, ExplainState *es);
    static void show_sort_keys(Plan *sortplan, int nkeys, AttrNumber *keycols,
    			   const char *qlabel,
    			   StringInfo str, int indent, ExplainState *es);
    
    /*
     * ExplainQuery -
     *	  execute an EXPLAIN command
     */
    void
    ExplainQuery(ExplainStmt *stmt, ParamListInfo params, DestReceiver *dest)
    {
    	Query	   *query = stmt->query;
    	TupOutputState *tstate;
    	List	   *rewritten;