PostgreSQL Source Code git master
|
#include "postgres.h"
#include <math.h>
#include "access/htup_details.h"
#include "catalog/pg_type.h"
#include "common/pg_prng.h"
#include "executor/spi.h"
#include "fmgr.h"
#include "funcapi.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "utils/builtins.h"
Go to the source code of this file.
Data Structures | |
struct | normal_rand_fctx |
struct | crosstab_cat_desc |
struct | crosstab_hashent |
Macros | |
#define | xpfree(var_) |
#define | xpstrdup(tgtvar_, srcvar_) |
#define | xstreq(tgtvar_, srcvar_) |
#define | INT32_STRLEN 12 |
#define | MAX_CATNAME_LEN NAMEDATALEN |
#define | INIT_CATS 64 |
#define | crosstab_HashTableLookup(HASHTAB, CATNAME, CATDESC) |
#define | crosstab_HashTableInsert(HASHTAB, CATDESC) |
#define | CONNECTBY_NCOLS 4 |
#define | CONNECTBY_NCOLS_NOBRANCH 3 |
Typedefs | |
typedef struct crosstab_cat_desc | crosstab_cat_desc |
typedef struct crosstab_hashent | crosstab_HashEnt |
Functions | |
static HTAB * | load_categories_hash (char *cats_sql, MemoryContext per_query_ctx) |
static Tuplestorestate * | get_crosstab_tuplestore (char *sql, HTAB *crosstab_hash, TupleDesc tupdesc, bool randomAccess) |
static void | validateConnectbyTupleDesc (TupleDesc td, bool show_branch, bool show_serial) |
static void | compatCrosstabTupleDescs (TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) |
static void | compatConnectbyTupleDescs (TupleDesc ret_tupdesc, TupleDesc sql_tupdesc) |
static void | get_normal_pair (float8 *x1, float8 *x2) |
static Tuplestorestate * | connectby (char *relname, char *key_fld, char *parent_key_fld, char *orderby_fld, char *branch_delim, char *start_with, int max_depth, bool show_branch, bool show_serial, MemoryContext per_query_ctx, bool randomAccess, AttInMetadata *attinmeta) |
static void | build_tuplestore_recursively (char *key_fld, char *parent_key_fld, char *relname, char *orderby_fld, char *branch_delim, char *start_with, char *branch, int level, int *serial, int max_depth, bool show_branch, bool show_serial, MemoryContext per_query_ctx, AttInMetadata *attinmeta, Tuplestorestate *tupstore) |
PG_FUNCTION_INFO_V1 (normal_rand) | |
Datum | normal_rand (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (crosstab) | |
Datum | crosstab (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (crosstab_hash) | |
Datum | crosstab_hash (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (connectby_text) | |
Datum | connectby_text (PG_FUNCTION_ARGS) |
PG_FUNCTION_INFO_V1 (connectby_text_serial) | |
Datum | connectby_text_serial (PG_FUNCTION_ARGS) |
Variables | |
PG_MODULE_MAGIC | |
#define CONNECTBY_NCOLS 4 |
Definition at line 970 of file tablefunc.c.
#define CONNECTBY_NCOLS_NOBRANCH 3 |
Definition at line 971 of file tablefunc.c.
#define crosstab_HashTableInsert | ( | HASHTAB, | |
CATDESC | |||
) |
Definition at line 142 of file tablefunc.c.
#define crosstab_HashTableLookup | ( | HASHTAB, | |
CATNAME, | |||
CATDESC | |||
) |
Definition at line 128 of file tablefunc.c.
#define INIT_CATS 64 |
Definition at line 126 of file tablefunc.c.
#define INT32_STRLEN 12 |
Definition at line 116 of file tablefunc.c.
#define MAX_CATNAME_LEN NAMEDATALEN |
Definition at line 125 of file tablefunc.c.
#define xpfree | ( | var_ | ) |
Definition at line 94 of file tablefunc.c.
#define xpstrdup | ( | tgtvar_, | |
srcvar_ | |||
) |
Definition at line 103 of file tablefunc.c.
#define xstreq | ( | tgtvar_, | |
srcvar_ | |||
) |
Definition at line 111 of file tablefunc.c.
typedef struct crosstab_cat_desc crosstab_cat_desc |
typedef struct crosstab_hashent crosstab_HashEnt |
|
static |
Definition at line 1185 of file tablefunc.c.
References appendStringInfo(), appendStringInfoString(), build_tuplestore_recursively(), BuildTupleFromCStrings(), compatConnectbyTupleDescs(), CONNECTBY_NCOLS, CONNECTBY_NCOLS_NOBRANCH, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, heap_freetuple(), i, initStringInfo(), INT32_STRLEN, palloc(), quote_literal_cstr(), relname, resetStringInfo(), SPI_execute(), SPI_getvalue(), SPI_OK_SELECT, SPI_processed, SPI_tuptable, sprintf, SPITupleTable::tupdesc, AttInMetadata::tupdesc, tuplestore_puttuple(), SPITupleTable::vals, values, and xpfree.
Referenced by build_tuplestore_recursively(), and connectby().
Definition at line 1464 of file tablefunc.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, format_type_with_typemod(), TupleDescData::natts, and TupleDescAttr().
Referenced by build_tuplestore_recursively().
Definition at line 1517 of file tablefunc.c.
References Assert, ereport, errcode(), errdetail(), errmsg(), ERROR, format_type_with_typemod(), i, TupleDescData::natts, and TupleDescAttr().
Referenced by crosstab().
|
static |
Definition at line 1134 of file tablefunc.c.
References build_tuplestore_recursively(), MemoryContextSwitchTo(), relname, SPI_connect(), SPI_finish(), tuplestore_begin_heap(), and work_mem.
Referenced by connectby_text(), and connectby_text_serial().
Datum connectby_text | ( | PG_FUNCTION_ARGS | ) |
Definition at line 974 of file tablefunc.c.
References ReturnSetInfo::allowedModes, connectby(), CreateTupleDescCopy(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, if(), IsA, MemoryContextSwitchTo(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, pstrdup(), relname, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, text_to_cstring(), TupleDescGetAttInMetadata(), and validateConnectbyTupleDesc().
Datum connectby_text_serial | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1052 of file tablefunc.c.
References ReturnSetInfo::allowedModes, connectby(), CreateTupleDescCopy(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, if(), IsA, MemoryContextSwitchTo(), PG_GETARG_INT32, PG_GETARG_TEXT_PP, pstrdup(), relname, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, text_to_cstring(), TupleDescGetAttInMetadata(), and validateConnectbyTupleDesc().
Datum crosstab | ( | PG_FUNCTION_ARGS | ) |
Definition at line 355 of file tablefunc.c.
References ReturnSetInfo::allowedModes, BuildTupleFromCStrings(), compatCrosstabTupleDescs(), CreateTupleDescCopy(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errdetail(), errmsg(), ERROR, ExprEndResult, get_call_result_type(), heap_freetuple(), i, if(), IsA, ReturnSetInfo::isDone, MemoryContextSwitchTo(), palloc0(), pfree(), PG_GETARG_TEXT_PP, PG_RETURN_NULL, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, SPI_connect(), SPI_execute(), SPI_finish(), SPI_getvalue(), SPI_OK_SELECT, SPI_processed, SPI_tuptable, text_to_cstring(), SPITupleTable::tupdesc, TupleDescGetAttInMetadata(), tuplestore_begin_heap(), tuplestore_puttuple(), TYPEFUNC_COMPOSITE, TYPEFUNC_RECORD, values, work_mem, xpfree, xpstrdup, and xstreq.
Datum crosstab_hash | ( | PG_FUNCTION_ARGS | ) |
Definition at line 633 of file tablefunc.c.
References ReturnSetInfo::allowedModes, CreateTupleDescCopy(), crosstab_hash(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, ereport, errcode(), errdetail(), errmsg(), ERROR, ReturnSetInfo::expectedDesc, get_crosstab_tuplestore(), if(), IsA, load_categories_hash(), MemoryContextSwitchTo(), PG_GETARG_TEXT_PP, ReturnSetInfo::returnMode, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, SFRM_Materialize_Random, and text_to_cstring().
Referenced by crosstab_hash(), get_crosstab_tuplestore(), and load_categories_hash().
|
static |
Definition at line 788 of file tablefunc.c.
References crosstab_cat_desc::attidx, BuildTupleFromCStrings(), crosstab_hash(), crosstab_HashTableLookup, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, hash_get_num_entries(), i, j, TupleDescData::natts, palloc0(), SPI_connect(), SPI_execute(), SPI_finish(), SPI_getvalue(), SPI_OK_FINISH, SPI_OK_SELECT, SPI_processed, SPI_tuptable, SPITupleTable::tupdesc, TupleDescGetAttInMetadata(), tuplestore_begin_heap(), tuplestore_puttuple(), SPITupleTable::vals, values, work_mem, xpfree, xpstrdup, and xstreq.
Referenced by crosstab_hash().
Definition at line 284 of file tablefunc.c.
References pg_global_prng_state, and pg_prng_double().
Referenced by normal_rand().
|
static |
Definition at line 702 of file tablefunc.c.
References crosstab_cat_desc::attidx, crosstab_cat_desc::catname, crosstab_hash(), crosstab_HashTableInsert, ctl, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_STRINGS, i, INIT_CATS, MAX_CATNAME_LEN, MemoryContextSwitchTo(), TupleDescData::natts, palloc(), SPI_connect(), SPI_execute(), SPI_finish(), SPI_getvalue(), SPI_OK_FINISH, SPI_OK_SELECT, SPI_processed, SPI_tuptable, SPITupleTable::tupdesc, and SPITupleTable::vals.
Referenced by crosstab_hash().
Datum normal_rand | ( | PG_FUNCTION_ARGS | ) |
Definition at line 173 of file tablefunc.c.
References FuncCallContext::call_cntr, normal_rand_fctx::carry_val, ereport, errcode(), errmsg(), ERROR, Float8GetDatum(), get_normal_pair(), FuncCallContext::max_calls, normal_rand_fctx::mean, MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc(), PG_GETARG_FLOAT8, PG_GETARG_INT32, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, normal_rand_fctx::stddev, normal_rand_fctx::use_carry, and FuncCallContext::user_fctx.
PG_FUNCTION_INFO_V1 | ( | connectby_text | ) |
PG_FUNCTION_INFO_V1 | ( | connectby_text_serial | ) |
PG_FUNCTION_INFO_V1 | ( | crosstab | ) |
PG_FUNCTION_INFO_V1 | ( | crosstab_hash | ) |
PG_FUNCTION_INFO_V1 | ( | normal_rand | ) |
|
static |
Definition at line 1404 of file tablefunc.c.
References CONNECTBY_NCOLS, CONNECTBY_NCOLS_NOBRANCH, ereport, errcode(), errdetail(), errmsg(), ERROR, format_type_be(), TupleDescData::natts, and TupleDescAttr().
Referenced by connectby_text(), and connectby_text_serial().
PG_MODULE_MAGIC |
Definition at line 47 of file tablefunc.c.