Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e85fa2

Browse files
committed
patternsel() was improperly stripping RelabelType from the derived
expressions it constructed, causing scalarineqsel to become confusedif the underlying variable was of a domain type. Per report fromKevin Grittner.
1 parent7148de1 commit1e85fa2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.178 2005/04/25 01:30:14 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.179 2005/06/01 17:05:11 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -163,7 +163,7 @@ static void examine_variable(Query *root, Node *node, int varRelid,
163163
staticdoubleget_variable_numdistinct(VariableStatData*vardata);
164164
staticboolget_variable_maximum(Query*root,VariableStatData*vardata,
165165
Oidsortop,Datum*max);
166-
staticSelectivityprefix_selectivity(Query*root,VariableStatData*vardata,
166+
staticSelectivityprefix_selectivity(Query*root,Node*variable,
167167
Oidopclass,Const*prefix);
168168
staticSelectivitypattern_selectivity(Const*patt,Pattern_Typeptype);
169169
staticDatumstring_to_datum(constchar*str,Oiddatatype);
@@ -812,6 +812,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
812812
List*args= (List*)PG_GETARG_POINTER(2);
813813
intvarRelid=PG_GETARG_INT32(3);
814814
VariableStatDatavardata;
815+
Node*variable;
815816
Node*other;
816817
boolvaronleft;
817818
Datumconstval;
@@ -836,6 +837,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
836837
ReleaseVariableStats(vardata);
837838
returnDEFAULT_MATCH_SEL;
838839
}
840+
variable= (Node*)linitial(args);
839841

840842
/*
841843
* If the constant is NULL, assume operator is strict and return zero,
@@ -939,7 +941,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
939941

940942
if (eqopr==InvalidOid)
941943
elog(ERROR,"no = operator for opclass %u",opclass);
942-
eqargs=list_make2(vardata.var,prefix);
944+
eqargs=list_make2(variable,prefix);
943945
result=DatumGetFloat8(DirectFunctionCall4(eqsel,
944946
PointerGetDatum(root),
945947
ObjectIdGetDatum(eqopr),
@@ -958,7 +960,7 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype)
958960
Selectivityselec;
959961

960962
if (pstatus==Pattern_Prefix_Partial)
961-
prefixsel=prefix_selectivity(root,&vardata,opclass,prefix);
963+
prefixsel=prefix_selectivity(root,variable,opclass,prefix);
962964
else
963965
prefixsel=1.0;
964966
restsel=pattern_selectivity(rest,ptype);
@@ -3694,7 +3696,7 @@ pattern_fixed_prefix(Const *patt, Pattern_Type ptype,
36943696
* more useful to use the upper-bound code than not.
36953697
*/
36963698
staticSelectivity
3697-
prefix_selectivity(Query*root,VariableStatData*vardata,
3699+
prefix_selectivity(Query*root,Node*variable,
36983700
Oidopclass,Const*prefixcon)
36993701
{
37003702
Selectivityprefixsel;
@@ -3706,7 +3708,7 @@ prefix_selectivity(Query *root, VariableStatData *vardata,
37063708
BTGreaterEqualStrategyNumber);
37073709
if (cmpopr==InvalidOid)
37083710
elog(ERROR,"no >= operator for opclass %u",opclass);
3709-
cmpargs=list_make2(vardata->var,prefixcon);
3711+
cmpargs=list_make2(variable,prefixcon);
37103712
/* Assume scalargtsel is appropriate for all supported types */
37113713
prefixsel=DatumGetFloat8(DirectFunctionCall4(scalargtsel,
37123714
PointerGetDatum(root),
@@ -3728,7 +3730,7 @@ prefix_selectivity(Query *root, VariableStatData *vardata,
37283730
BTLessStrategyNumber);
37293731
if (cmpopr==InvalidOid)
37303732
elog(ERROR,"no < operator for opclass %u",opclass);
3731-
cmpargs=list_make2(vardata->var,greaterstrcon);
3733+
cmpargs=list_make2(variable,greaterstrcon);
37323734
/* Assume scalarltsel is appropriate for all supported types */
37333735
topsel=DatumGetFloat8(DirectFunctionCall4(scalarltsel,
37343736
PointerGetDatum(root),
@@ -3743,7 +3745,7 @@ prefix_selectivity(Query *root, VariableStatData *vardata,
37433745
prefixsel=topsel+prefixsel-1.0;
37443746

37453747
/* Adjust for double-exclusion of NULLs */
3746-
prefixsel+=nulltestsel(root,IS_NULL,vardata->var,0);
3748+
prefixsel+=nulltestsel(root,IS_NULL,variable,0);
37473749

37483750
/*
37493751
* A zero or slightly negative prefixsel should be converted into

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp