@@ -59,13 +59,14 @@ static int compare_lexeme_textfreq(const void *e1, const void *e2);
5959
6060
6161/*
62- * tsmatchsel -- Selectivity of "@@"
62+ * tsvector2_matchsel -- Selectivity of "@@"
6363 *
64- * restriction selectivity function for tsvector @@ tsquery and
65- * tsquery @@ tsvector
64+ * restriction selectivity function for tsvector2 @@ tsquery and
65+ * tsquery @@ tsvector2
6666 */
67+ PG_FUNCTION_INFO_V1 (tsvector2_matchsel );
6768Datum
68- tsmatchsel (PG_FUNCTION_ARGS )
69+ tsvector2_matchsel (PG_FUNCTION_ARGS )
6970{
7071 PlannerInfo * root = (PlannerInfo * ) PG_GETARG_POINTER (0 );
7172
@@ -111,17 +112,10 @@ tsmatchsel(PG_FUNCTION_ARGS)
111112 * check this because the Var might be the TSQuery not the TSVector.
112113 */
113114 if (((Const * ) other )-> consttype == TSQUERYOID )
114- {
115- /* tsvector @@ tsquery or the other way around */
116- Assert (vardata .vartype == TSVECTOROID );
117-
118115 selec = tsquerysel (& vardata , ((Const * ) other )-> constvalue );
119- }
120116 else
121- {
122117 /* If we can't see the query structure, must punt */
123118 selec = DEFAULT_TS_MATCH_SEL ;
124- }
125119
126120 ReleaseVariableStats (vardata );
127121
@@ -132,20 +126,21 @@ tsmatchsel(PG_FUNCTION_ARGS)
132126
133127
134128/*
135- * tsmatchjoinsel -- join selectivity of "@@"
129+ * tsvector2_matchjoinsel -- join selectivity of "@@"
136130 *
137- * join selectivity function for tsvector @@ tsquery and tsquery @@ tsvector
131+ * join selectivity function for tsvector2 @@ tsquery and tsquery @@ tsvector2
138132 */
133+ PG_FUNCTION_INFO_V1 (tsvector2_matchjoinsel );
139134Datum
140- tsmatchjoinsel (PG_FUNCTION_ARGS )
135+ tsvector2_matchjoinsel (PG_FUNCTION_ARGS )
141136{
142137 /* for the moment we just punt */
143138 PG_RETURN_FLOAT8 (DEFAULT_TS_MATCH_SEL );
144139}
145140
146141
147142/*
148- * @@ selectivity for tsvector var vs tsquery constant
143+ * @@ selectivity for tsvector2 var vs tsquery constant
149144 */
150145static Selectivity
151146tsquerysel (VariableStatData * vardata , Datum constval )
@@ -167,13 +162,13 @@ tsquerysel(VariableStatData *vardata, Datum constval)
167162
168163 stats = (Form_pg_statistic ) GETSTRUCT (vardata -> statsTuple );
169164
170- /* MCELEM will be an array of TEXT elements for a tsvector column */
165+ /* MCELEM will be an array of TEXT elements for a tsvector2 column */
171166 if (get_attstatsslot (& sslot , vardata -> statsTuple ,
172167 STATISTIC_KIND_MCELEM , InvalidOid ,
173168 ATTSTATSSLOT_VALUES | ATTSTATSSLOT_NUMBERS ))
174169 {
175170 /*
176- * There is a most-common-elements slot for the tsvector Var, so
171+ * There is a most-common-elements slot for the tsvector2 Var, so
177172 * use that.
178173 */
179174 selec = mcelem_tsquery_selec (query , sslot .values , sslot .nvalues ,
@@ -219,7 +214,7 @@ mcelem_tsquery_selec(TSQuery query, Datum *mcelem, int nmcelem,
219214 *
220215 * (Note: the MCELEM statistics slot definition allows for a third extra
221216 * number containing the frequency of nulls, but we're not expecting that
222- * to appear for a tsvector column.)
217+ * to appear for a tsvector2 column.)
223218 */
224219 if (nnumbers != nmcelem + 2 )
225220 return tsquery_opr_selec_no_stats (query );
@@ -271,7 +266,7 @@ mcelem_tsquery_selec(TSQuery query, Datum *mcelem, int nmcelem,
271266 * The MCELEM array is already sorted (see ts_typanalyze.c), so we can use
272267 * binary search for determining freq[MCELEM].
273268 *
274- * If we don't have stats for the tsvector , we still use this logic,
269+ * If we don't have stats for the tsvector2 , we still use this logic,
275270 * except we use default estimates for VAL nodes. This case is signaled
276271 * by lookup == NULL.
277272 */
0 commit comments