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

Commit589647a

Browse files
author
Artur Zakirov
committed
pg_trgm's set_limit() now uses SetConfigOption()
1 parentd2e4622 commit589647a

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
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 amontonic boolean function,
333+
* As trigramsMatchGraph implements amonotonic 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
float4nlimit=PG_GETARG_FLOAT4(0);
84+
char*nlimit_str;
85+
Oidfunc_out_oid;
86+
boolis_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)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp