PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/xact.h"
#include "catalog/pg_type.h"
#include "commands/createas.h"
#include "commands/prepare.h"
#include "funcapi.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
#include "tcop/pquery.h"
#include "tcop/utility.h"
#include "utils/builtins.h"
#include "utils/snapmgr.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Variables | |
static HTAB * | prepared_queries = NULL |
Definition at line 744 of file prepare.c.
References construct_array_builtin(), i, ObjectIdGetDatum(), palloc_array, and PointerGetDatum().
Referenced by pg_prepared_statement().
void DeallocateQuery | ( | DeallocateStmt * | stmt | ) |
Definition at line 502 of file prepare.c.
References DropAllPreparedStatements(), DropPreparedStatement(), and stmt.
Referenced by standard_ProcessUtility().
void DropAllPreparedStatements | ( | void | ) |
Definition at line 537 of file prepare.c.
References DropCachedPlan(), HASH_REMOVE, hash_search(), hash_seq_init(), hash_seq_search(), PreparedStatement::plansource, prepared_queries, and PreparedStatement::stmt_name.
Referenced by DeallocateQuery(), and DiscardAll().
void DropPreparedStatement | ( | const char * | stmt_name, |
bool | showError | ||
) |
Definition at line 516 of file prepare.c.
References DropCachedPlan(), FetchPreparedStatement(), HASH_REMOVE, hash_search(), PreparedStatement::plansource, prepared_queries, and PreparedStatement::stmt_name.
Referenced by DeallocateQuery(), and PostgresMain().
|
static |
Definition at line 278 of file prepare.c.
References assign_expr_collations(), COERCE_IMPLICIT_CAST, coerce_to_target_type(), COERCION_ASSIGNMENT, copyObject, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, ExecEvalExprSwitchContext(), ExecPrepareExprList(), EXPR_KIND_EXECUTE_PARAMETER, exprLocation(), exprType(), format_type_be(), GetPerTupleExprContext, i, ParamExternData::isnull, lfirst, list_length(), makeParamList(), CachedPlanSource::num_params, PARAM_FLAG_CONST, CachedPlanSource::param_types, ParamListInfoData::params, parser_errposition(), ParamExternData::pflags, PreparedStatement::plansource, ParamExternData::ptype, PreparedStatement::stmt_name, transformExpr(), and ParamExternData::value.
Referenced by ExecuteQuery(), and ExplainExecuteQuery().
void ExecuteQuery | ( | ParseState * | pstate, |
ExecuteStmt * | stmt, | ||
IntoClause * | intoClause, | ||
ParamListInfo | params, | ||
DestReceiver * | dest, | ||
QueryCompletion * | qc | ||
) |
Definition at line 147 of file prepare.c.
References CMD_SELECT, CachedPlanSource::commandTag, PlannedStmt::commandType, CreateExecutorState(), CreateNewPortal(), generate_unaccent_rules::dest, elog, ereport, errcode(), errmsg(), ERROR, EState::es_param_list_info, EvaluateParams(), FETCH_ALL, FetchPreparedStatement(), CachedPlanSource::fixed_result, FreeExecutorState(), GetActiveSnapshot(), GetCachedPlan(), GetIntoRelEFlags(), linitial_node, list_length(), MemoryContextStrdup(), CachedPlanSource::num_params, PreparedStatement::plansource, PortalData::portalContext, PortalDefineQuery(), PortalDrop(), PortalRun(), PortalStart(), CachedPlanSource::query_string, IntoClause::skipData, stmt, CachedPlan::stmt_list, and PortalData::visible.
Referenced by ExecCreateTableAs(), and standard_ProcessUtility().
void ExplainExecuteQuery | ( | ExecuteStmt * | execstmt, |
IntoClause * | into, | ||
ExplainState * | es, | ||
ParseState * | pstate, | ||
ParamListInfo | params | ||
) |
Definition at line 568 of file prepare.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, ExplainState::buffers, BufferUsageAccumDiff(), CMD_UTILITY, PlannedStmt::commandType, CreateExecutorState(), CurrentMemoryContext, CurrentResourceOwner, elog, ERROR, EState::es_param_list_info, EvaluateParams(), ExplainOnePlan(), ExplainOneUtility(), ExplainSeparatePlans(), FetchPreparedStatement(), CachedPlanSource::fixed_result, FreeExecutorState(), GetCachedPlan(), INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, IsA, lfirst_node, lnext(), make_parsestate(), ExplainState::memory, MemoryContextMemConsumed(), MemoryContextSwitchTo(), ExecuteStmt::name, CachedPlanSource::num_params, ParseState::p_queryEnv, ParseState::p_sourcetext, ExecuteStmt::params, pgBufferUsage, PreparedStatement::plansource, CachedPlanSource::query_string, ReleaseCachedPlan(), CachedPlan::stmt_list, and PlannedStmt::utilityStmt.
Referenced by ExplainOneUtility().
PreparedStatement* FetchPreparedStatement | ( | const char * | stmt_name, |
bool | throwError | ||
) |
Definition at line 431 of file prepare.c.
References ereport, errcode(), errmsg(), ERROR, HASH_FIND, hash_search(), and prepared_queries.
Referenced by DropPreparedStatement(), errdetail_execute(), exec_bind_message(), exec_describe_statement_message(), ExecuteQuery(), ExplainExecuteQuery(), FetchStatementTargetList(), GetCommandLogLevel(), UtilityReturnsTuples(), and UtilityTupleDescriptor().
TupleDesc FetchPreparedStatementResultDesc | ( | PreparedStatement * | stmt | ) |
Definition at line 463 of file prepare.c.
References Assert, CreateTupleDescCopy(), and stmt.
Referenced by UtilityTupleDescriptor().
List* FetchPreparedStatementTargetList | ( | PreparedStatement * | stmt | ) |
Definition at line 486 of file prepare.c.
References CachedPlanGetTargetList(), copyObject, and stmt.
Referenced by FetchStatementTargetList().
|
static |
Definition at line 369 of file prepare.c.
References HASHCTL::entrysize, hash_create(), HASH_ELEM, HASH_STRINGS, HASHCTL::keysize, NAMEDATALEN, and prepared_queries.
Referenced by StorePreparedStatement().
Datum pg_prepared_statement | ( | PG_FUNCTION_ARGS | ) |
Definition at line 682 of file prepare.c.
References BoolGetDatum(), build_regtype_array(), CStringGetTextDatum, PreparedStatement::from_sql, hash_seq_init(), hash_seq_search(), i, InitMaterializedSRF(), Int64GetDatumFast, TupleDescData::natts, CachedPlanSource::num_custom_plans, CachedPlanSource::num_generic_plans, CachedPlanSource::num_params, palloc_array, CachedPlanSource::param_types, PreparedStatement::plansource, PreparedStatement::prepare_time, prepared_queries, CachedPlanSource::query_string, CachedPlanSource::resultDesc, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, PreparedStatement::stmt_name, TimestampTzGetDatum(), TupleDescAttr, tuplestore_putvalues(), and values.
void PrepareQuery | ( | ParseState * | pstate, |
PrepareStmt * | stmt, | ||
int | stmt_location, | ||
int | stmt_len | ||
) |
Definition at line 56 of file prepare.c.
References CompleteCachedPlan(), CreateCachedPlan(), CreateCommandTag(), CURSOR_OPT_PARALLEL_OK, ereport, errcode(), errmsg(), ERROR, i, lfirst, list_length(), makeNode, ParseState::p_sourcetext, palloc_array, pg_analyze_and_rewrite_varparams(), RawStmt::stmt, stmt, RawStmt::stmt_len, RawStmt::stmt_location, StorePreparedStatement(), and typenameTypeId().
Referenced by standard_ProcessUtility().
void StorePreparedStatement | ( | const char * | stmt_name, |
CachedPlanSource * | plansource, | ||
bool | from_sql | ||
) |
Definition at line 389 of file prepare.c.
References ereport, errcode(), errmsg(), ERROR, PreparedStatement::from_sql, GetCurrentStatementStartTimestamp(), HASH_ENTER, hash_search(), InitQueryHashTable(), PreparedStatement::plansource, PreparedStatement::prepare_time, prepared_queries, and SaveCachedPlan().
Referenced by exec_parse_message(), and PrepareQuery().
|
static |
Definition at line 44 of file prepare.c.
Referenced by DropAllPreparedStatements(), DropPreparedStatement(), FetchPreparedStatement(), InitQueryHashTable(), pg_prepared_statement(), and StorePreparedStatement().