PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/htup_details.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_opfamily.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/lsyscache.h"
#include "utils/pg_locale.h"
#include "utils/selfuncs.h"
#include "utils/varlena.h"
Go to the source code of this file.
Macros | |
#define | FIXED_CHAR_SEL 0.20 /* about 1/5 */ |
#define | CHAR_RANGE_SEL 0.25 |
#define | ANY_CHAR_SEL 0.9 /* not 1, since it won't match end-of-string */ |
#define | FULL_WILDCARD_SEL 5.0 |
#define | PARTIAL_WILDCARD_SEL 2.0 |
Enumerations | |
enum | Pattern_Type { Pattern_Type_Like , Pattern_Type_Like_IC , Pattern_Type_Regex , Pattern_Type_Regex_IC , Pattern_Type_Prefix } |
enum | Pattern_Prefix_Status { Pattern_Prefix_None , Pattern_Prefix_Partial , Pattern_Prefix_Exact } |
#define ANY_CHAR_SEL 0.9 /* not 1, since it won't match end-of-string */ |
Definition at line 1310 of file like_support.c.
#define CHAR_RANGE_SEL 0.25 |
Definition at line 1309 of file like_support.c.
#define FIXED_CHAR_SEL 0.20 /* about 1/5 */ |
Definition at line 1308 of file like_support.c.
#define FULL_WILDCARD_SEL 5.0 |
Definition at line 1311 of file like_support.c.
#define PARTIAL_WILDCARD_SEL 2.0 |
Definition at line 1312 of file like_support.c.
Enumerator | |
---|---|
Pattern_Prefix_None | |
Pattern_Prefix_Partial | |
Pattern_Prefix_Exact |
Definition at line 67 of file like_support.c.
enum Pattern_Type |
Enumerator | |
---|---|
Pattern_Type_Like | |
Pattern_Type_Like_IC | |
Pattern_Type_Regex | |
Pattern_Type_Regex_IC | |
Pattern_Type_Prefix |
Definition at line 58 of file like_support.c.
|
static |
Definition at line 1513 of file like_support.c.
Referenced by make_greater_string().
Datum iclikejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 918 of file like_support.c.
References Pattern_Type_Like_IC, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum iclikesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 827 of file like_support.c.
References Pattern_Type_Like_IC, patternsel(), and PG_RETURN_FLOAT8.
Datum icnlikejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 954 of file like_support.c.
References Pattern_Type_Like_IC, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum icnlikesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 863 of file like_support.c.
References Pattern_Type_Like_IC, patternsel(), and PG_RETURN_FLOAT8.
Datum icregexeqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 891 of file like_support.c.
References Pattern_Type_Regex_IC, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum icregexeqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 799 of file like_support.c.
References Pattern_Type_Regex_IC, patternsel(), and PG_RETURN_FLOAT8.
Datum icregexnejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 936 of file like_support.c.
References Pattern_Type_Regex_IC, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum icregexnesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 845 of file like_support.c.
References Pattern_Type_Regex_IC, patternsel(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 989 of file like_support.c.
References Assert, Const::consttype, DatumGetByteaPP, DatumGetPointer(), ereport, errcode(), errhint(), errmsg(), ERROR, like_selectivity(), locale, OidIsValid, palloc(), pattern_char_isalpha(), Pattern_Prefix_Exact, Pattern_Prefix_None, Pattern_Prefix_Partial, pfree(), pg_database_encoding_max_length(), pg_newlocale_from_collation(), string_to_bytea_const(), string_to_const(), TextDatumGetCString, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Referenced by pattern_fixed_prefix().
|
static |
Definition at line 156 of file like_support.c.
References FuncExpr::args, OpExpr::args, SupportRequestSelectivity::args, Assert, DEFAULT_MATCH_SEL, SupportRequestSelectivity::funcid, SupportRequestIndexCondition::indexarg, SupportRequestIndexCondition::indexcollation, SupportRequestSelectivity::inputcollid, InvalidOid, is_funcclause(), SupportRequestSelectivity::is_join, is_opclause(), IsA, linitial, list_length(), lsecond, match_pattern_prefix(), SupportRequestIndexCondition::node, SupportRequestIndexCondition::opfamily, patternsel_common(), SupportRequestSelectivity::root, s1, SupportRequestSelectivity::selectivity, and SupportRequestSelectivity::varRelid.
Referenced by text_starts_with_support(), texticlike_support(), texticregexeq_support(), textlike_support(), and textregexeq_support().
|
static |
Definition at line 1315 of file like_support.c.
References ANY_CHAR_SEL, FIXED_CHAR_SEL, and FULL_WILDCARD_SEL.
Referenced by like_fixed_prefix().
Datum likejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 900 of file like_support.c.
References Pattern_Type_Like, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum likesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 808 of file like_support.c.
References Pattern_Type_Like, patternsel(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 1563 of file like_support.c.
References Assert, byte_increment(), Const::consttype, DatumGetBool(), DatumGetByteaPP, DatumGetCString(), DatumGetPointer(), DirectFunctionCall1, FunctionCall2Coll(), len, nameout(), palloc(), pfree(), pg_database_encoding_character_incrementer(), pg_mbcliplen(), pg_newlocale_from_collation(), PointerGetDatum(), SET_VARSIZE, string_to_bytea_const(), string_to_const(), TextDatumGetCString, VARDATA, VARDATA_ANY, VARHDRSZ, VARSIZE_ANY_EXHDR, and varstr_cmp().
Referenced by match_pattern_prefix(), and prefix_selectivity().
|
static |
Definition at line 241 of file like_support.c.
References Assert, Const::consttype, exprType(), fmgr_info(), get_collation_isdeterministic(), get_opcode(), InvalidOid, IsA, lappend(), list_make1, make_greater_string(), make_opclause(), NIL, OidIsValid, op_in_opfamily(), pattern_fixed_prefix(), Pattern_Prefix_Exact, Pattern_Prefix_None, and pg_newlocale_from_collation().
Referenced by like_regex_support().
Datum nlikejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 945 of file like_support.c.
References Pattern_Type_Like, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum nlikesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 854 of file like_support.c.
References Pattern_Type_Like, patternsel(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 1493 of file like_support.c.
References IS_HIGHBIT_SET, isalpha_l, and locale.
Referenced by like_fixed_prefix().
|
static |
Definition at line 1159 of file like_support.c.
References Const::consttype, datumCopy(), elog, ERROR, like_fixed_prefix(), makeConst(), Pattern_Prefix_None, Pattern_Prefix_Partial, Pattern_Type_Like, Pattern_Type_Like_IC, Pattern_Type_Prefix, Pattern_Type_Regex, Pattern_Type_Regex_IC, and regex_fixed_prefix().
Referenced by match_pattern_prefix(), and patternsel_common().
|
static |
Definition at line 872 of file like_support.c.
References DEFAULT_MATCH_SEL.
Referenced by iclikejoinsel(), icnlikejoinsel(), icregexeqjoinsel(), icregexnejoinsel(), likejoinsel(), nlikejoinsel(), prefixjoinsel(), regexeqjoinsel(), and regexnejoinsel().
|
static |
Definition at line 757 of file like_support.c.
References generate_unaccent_rules::args, elog, ERROR, get_negator(), InvalidOid, OidIsValid, patternsel_common(), PG_GET_COLLATION, PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, and root.
Referenced by iclikesel(), icnlikesel(), icregexeqsel(), icregexnesel(), likesel(), nlikesel(), prefixsel(), regexeqsel(), and regexnesel().
|
static |
Definition at line 483 of file like_support.c.
References generate_unaccent_rules::args, Assert, CLAMP_PROBABILITY, Const::consttype, DatumGetPointer(), DEFAULT_MATCH_SEL, fmgr_info(), get_opcode(), get_restriction_variable(), GETSTRUCT, HeapTupleIsValid, histogram_selectivity(), IsA, mcv_selectivity(), OidIsValid, oprid(), pattern_fixed_prefix(), Pattern_Prefix_Exact, Pattern_Prefix_Partial, pfree(), prefix_selectivity(), prefixsel(), ReleaseVariableStats, root, VariableStatData::statsTuple, var_eq_const(), and VariableStatData::vartype.
Referenced by like_regex_support(), and patternsel().
|
static |
Definition at line 1224 of file like_support.c.
References Assert, Const::consttype, DEFAULT_MATCH_SEL, fmgr_info(), get_opcode(), ineq_histogram_selectivity(), make_greater_string(), Max, prefixsel(), root, and var_eq_const().
Referenced by patternsel_common().
Datum prefixjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 909 of file like_support.c.
References Pattern_Type_Prefix, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum prefixsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 817 of file like_support.c.
References Pattern_Type_Prefix, patternsel(), and PG_RETURN_FLOAT8.
Referenced by patternsel_common(), prefix_selectivity(), and regex_selectivity().
|
static |
Definition at line 1091 of file like_support.c.
References Const::consttype, DatumGetTextPP, ereport, errcode(), errmsg(), ERROR, Pattern_Prefix_Exact, Pattern_Prefix_None, Pattern_Prefix_Partial, pfree(), regex_selectivity(), regexp_fixed_prefix(), string_to_const(), and TextDatumGetCString.
Referenced by pattern_fixed_prefix().
|
static |
Definition at line 1447 of file like_support.c.
References CLAMP_PROBABILITY, FIXED_CHAR_SEL, FULL_WILDCARD_SEL, prefixsel(), and regex_selectivity_sub().
Referenced by regex_fixed_prefix().
|
static |
Definition at line 1352 of file like_support.c.
References ANY_CHAR_SEL, CHAR_RANGE_SEL, check_stack_depth(), FIXED_CHAR_SEL, and PARTIAL_WILDCARD_SEL.
Referenced by regex_selectivity().
Datum regexeqjoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 882 of file like_support.c.
References Pattern_Type_Regex, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum regexeqsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 790 of file like_support.c.
References Pattern_Type_Regex, patternsel(), and PG_RETURN_FLOAT8.
Datum regexnejoinsel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 927 of file like_support.c.
References Pattern_Type_Regex, patternjoinsel(), and PG_RETURN_FLOAT8.
Datum regexnesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 836 of file like_support.c.
References Pattern_Type_Regex, patternsel(), and PG_RETURN_FLOAT8.
|
static |
Definition at line 1777 of file like_support.c.
References InvalidOid, makeConst(), palloc(), PointerGetDatum(), SET_VARSIZE, str, VARDATA, and VARHDRSZ.
Referenced by like_fixed_prefix(), and make_greater_string().
Definition at line 1734 of file like_support.c.
References elog, ERROR, InvalidOid, makeConst(), NAMEDATALEN, str, and string_to_datum().
Referenced by like_fixed_prefix(), make_greater_string(), and regex_fixed_prefix().
Definition at line 1714 of file like_support.c.
References Assert, byteain(), CStringGetDatum(), CStringGetTextDatum, DirectFunctionCall1, namein(), and str.
Referenced by string_to_const().
Datum text_starts_with_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 147 of file like_support.c.
References like_regex_support(), Pattern_Type_Prefix, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum texticlike_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 123 of file like_support.c.
References like_regex_support(), Pattern_Type_Like_IC, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum texticregexeq_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 139 of file like_support.c.
References like_regex_support(), Pattern_Type_Regex_IC, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum textlike_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 115 of file like_support.c.
References like_regex_support(), Pattern_Type_Like, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum textregexeq_support | ( | PG_FUNCTION_ARGS | ) |
Definition at line 131 of file like_support.c.
References like_regex_support(), Pattern_Type_Regex, PG_GETARG_POINTER, and PG_RETURN_POINTER.