Skip to content

Commit b3aede4

Browse files
committed
Merge branch 'PGPRO_pg_trgm' into PGPRO9_5
2 parents 42e1017 + 589647a commit b3aede4

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

contrib/pg_trgm/data/trgm2.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,4 @@ Maramech Hill
693693
Maramech Woods Nature Preserve
694694
Oued Karakech
695695
Samarra School
696-
Jangal-e Marakeh Sar
696+
Jangal-e Marakeh Sar

contrib/pg_trgm/trgm_gin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
210210
* And again, c (ntrue) is a lower bound of len2, but c <= len1
211211
* just by definition and, consequently, upper bound of
212212
* similarity is just c / len1.
213-
* So, independly on DIVUNION the upper bound formula is the same.
213+
* So, independently on DIVUNION the upper bound formula is the same.
214214
*/
215215
res = (nkeys == 0) ? false :
216216
(((((float4) ntrue) / ((float4) nkeys))) >= nlimit);
@@ -330,7 +330,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
330330
else
331331
{
332332
/*
333-
* As trigramsMatchGraph implements a montonic boolean function,
333+
* As trigramsMatchGraph implements a monotonic boolean function,
334334
* promoting all GIN_MAYBE keys to GIN_TRUE will give a
335335
* conservative result.
336336
*/

contrib/pg_trgm/trgm_op.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "catalog/pg_type.h"
1111
#include "tsearch/ts_locale.h"
12+
#include "utils/lsyscache.h"
1213
#include "utils/memutils.h"
1314
#include "utils/pg_crc.h"
1415

@@ -80,12 +81,17 @@ Datum
8081
set_limit(PG_FUNCTION_ARGS)
8182
{
8283
float4 nlimit = PG_GETARG_FLOAT4(0);
84+
char *nlimit_str;
85+
Oid func_out_oid;
86+
bool is_varlena;
87+
88+
getTypeOutputInfo(FLOAT4OID, &func_out_oid, &is_varlena);
89+
90+
nlimit_str = OidOutputFunctionCall(func_out_oid, Float4GetDatum(nlimit));
91+
92+
SetConfigOption("pg_trgm.similarity_threshold", nlimit_str,
93+
PGC_USERSET, PGC_S_SESSION);
8394

84-
if (nlimit < 0 || nlimit > 1.0)
85-
ereport(ERROR,
86-
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
87-
errmsg("wrong threshold, should be between 0 and 1")));
88-
similarity_threshold = nlimit;
8995
PG_RETURN_FLOAT4(similarity_threshold);
9096
}
9197

@@ -622,7 +628,7 @@ calc_word_similarity(char *str1, int slen1, char *str2, int slen2,
622628

623629

624630
/*
625-
* Extract the next non-wildcard part of a search string, ie, a word bounded
631+
* Extract the next non-wildcard part of a search string, i.e. a word bounded
626632
* by '_' or '%' meta-characters, non-word characters or string end.
627633
*
628634
* str: source string, of length lenstr bytes (need not be null-terminated)

doc/src/sgml/pgtrgm.sgml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@
9292
<entry><type>real</type></entry>
9393
<entry>
9494
Returns a number that indicates how similar the first string
95-
to the most similar word of the second string. The range of
96-
the result is zero (indicating that the two strings are completely
97-
dissimilar) to one (indicating that the first string is identical
98-
to one of the word of the second string).
95+
to the most similar word of the second string. The function searches in
96+
the second string a most similar word not a most similar substring. The
97+
range of the result is zero (indicating that the two strings are
98+
completely dissimilar) to one (indicating that the first string is
99+
identical to one of the word of the second string).
99100
</entry>
100101
</row>
101102
<row>
@@ -155,9 +156,9 @@
155156
<entry><type>text</> <literal>%&gt;</literal> <type>text</></entry>
156157
<entry><type>boolean</type></entry>
157158
<entry>
158-
Returns <literal>true</> if its first argument have a word which is the
159-
similar word to the second argument and they have a similarity
160-
that is greater than the current word similarity threshold set by
159+
Returns <literal>true</> if its first argument has the similar word in
160+
the second argument and they have a similarity that is greater than the
161+
current word similarity threshold set by
161162
<varname>pg_trgm.word_similarity_threshold</> parameter.
162163
</entry>
163164
</row>

0 commit comments

Comments
 (0)