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

Commit433d8f4

Browse files
committed
Remove separate locale_is_c arguments
Sincee9931bf, ctype_is_c is part of pg_locale_t. Some functionspassed a pg_locale_t and a bool argument separately. This can now becombined into one argument.Since some callers call MatchText() with locale 0, it is a bitconfusing whether this is all correct. But it is the case that onlycallers that pass a non-zero locale object to MatchText() end upchecking locale->ctype_is_c. To make that flow a bit moreunderstandable, add the locale argument to MATCH_LOWER() and GETCHAR()in like_match.c, instead of implicitly taking it from the outer scope.Reviewed-by: Jeff Davis <pgsql@j-davis.com>Discussion:https://www.postgresql.org/message-id/84d415fc-6780-419e-b16c-61a0ca819e2b@eisentraut.org
1 parent2b67bdc commit433d8f4

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333

3434

3535
staticintSB_MatchText(constchar*t,inttlen,constchar*p,intplen,
36-
pg_locale_tlocale,boollocale_is_c);
36+
pg_locale_tlocale);
3737
statictext*SB_do_like_escape(text*pat,text*esc);
3838

3939
staticintMB_MatchText(constchar*t,inttlen,constchar*p,intplen,
40-
pg_locale_tlocale,boollocale_is_c);
40+
pg_locale_tlocale);
4141
statictext*MB_do_like_escape(text*pat,text*esc);
4242

4343
staticintUTF8_MatchText(constchar*t,inttlen,constchar*p,intplen,
44-
pg_locale_tlocale,boollocale_is_c);
44+
pg_locale_tlocale);
4545

4646
staticintSB_IMatchText(constchar*t,inttlen,constchar*p,intplen,
47-
pg_locale_tlocale,boollocale_is_c);
47+
pg_locale_tlocale);
4848

4949
staticintGenericMatchText(constchar*s,intslen,constchar*p,intplen,Oidcollation);
5050
staticintGeneric_Text_IC_like(text*str,text*pat,Oidcollation);
@@ -91,9 +91,9 @@ wchareq(const char *p1, const char *p2)
9191
* fold-on-the-fly processing, however.
9292
*/
9393
staticchar
94-
SB_lower_char(unsignedcharc,pg_locale_tlocale,boollocale_is_c)
94+
SB_lower_char(unsignedcharc,pg_locale_tlocale)
9595
{
96-
if (locale_is_c)
96+
if (locale->ctype_is_c)
9797
returnpg_ascii_tolower(c);
9898
else
9999
returntolower_l(c,locale->info.lt);
@@ -129,7 +129,7 @@ SB_lower_char(unsigned char c, pg_locale_t locale, bool locale_is_c)
129129
#include"like_match.c"
130130

131131
/* setup to compile like_match.c for single byte case insensitive matches */
132-
#defineMATCH_LOWER(t) SB_lower_char((unsigned char) (t), locale, locale_is_c)
132+
#defineMATCH_LOWER(t,locale) SB_lower_char((unsigned char) (t), locale)
133133
#defineNextChar(p,plen) NextByte((p), (plen))
134134
#defineMatchText SB_IMatchText
135135

@@ -158,11 +158,11 @@ GenericMatchText(const char *s, int slen, const char *p, int plen, Oid collation
158158
}
159159

160160
if (pg_database_encoding_max_length()==1)
161-
returnSB_MatchText(s,slen,p,plen,0, true);
161+
returnSB_MatchText(s,slen,p,plen,0);
162162
elseif (GetDatabaseEncoding()==PG_UTF8)
163-
returnUTF8_MatchText(s,slen,p,plen,0, true);
163+
returnUTF8_MatchText(s,slen,p,plen,0);
164164
else
165-
returnMB_MatchText(s,slen,p,plen,0, true);
165+
returnMB_MatchText(s,slen,p,plen,0);
166166
}
167167

168168
staticinlineint
@@ -212,17 +212,17 @@ Generic_Text_IC_like(text *str, text *pat, Oid collation)
212212
s=VARDATA_ANY(str);
213213
slen=VARSIZE_ANY_EXHDR(str);
214214
if (GetDatabaseEncoding()==PG_UTF8)
215-
returnUTF8_MatchText(s,slen,p,plen,0, true);
215+
returnUTF8_MatchText(s,slen,p,plen,0);
216216
else
217-
returnMB_MatchText(s,slen,p,plen,0, true);
217+
returnMB_MatchText(s,slen,p,plen,0);
218218
}
219219
else
220220
{
221221
p=VARDATA_ANY(pat);
222222
plen=VARSIZE_ANY_EXHDR(pat);
223223
s=VARDATA_ANY(str);
224224
slen=VARSIZE_ANY_EXHDR(str);
225-
returnSB_IMatchText(s,slen,p,plen,locale,locale->ctype_is_c);
225+
returnSB_IMatchText(s,slen,p,plen,locale);
226226
}
227227
}
228228

@@ -330,7 +330,7 @@ bytealike(PG_FUNCTION_ARGS)
330330
p=VARDATA_ANY(pat);
331331
plen=VARSIZE_ANY_EXHDR(pat);
332332

333-
result= (SB_MatchText(s,slen,p,plen,0, true)==LIKE_TRUE);
333+
result= (SB_MatchText(s,slen,p,plen,0)==LIKE_TRUE);
334334

335335
PG_RETURN_BOOL(result);
336336
}
@@ -351,7 +351,7 @@ byteanlike(PG_FUNCTION_ARGS)
351351
p=VARDATA_ANY(pat);
352352
plen=VARSIZE_ANY_EXHDR(pat);
353353

354-
result= (SB_MatchText(s,slen,p,plen,0, true)!=LIKE_TRUE);
354+
result= (SB_MatchText(s,slen,p,plen,0)!=LIKE_TRUE);
355355

356356
PG_RETURN_BOOL(result);
357357
}

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,13 @@
7171
*/
7272

7373
#ifdefMATCH_LOWER
74-
#defineGETCHAR(t) MATCH_LOWER(t)
74+
#defineGETCHAR(t,locale) MATCH_LOWER(t, locale)
7575
#else
76-
#defineGETCHAR(t) (t)
76+
#defineGETCHAR(t,locale) (t)
7777
#endif
7878

7979
staticint
80-
MatchText(constchar*t,inttlen,constchar*p,intplen,
81-
pg_locale_tlocale,boollocale_is_c)
80+
MatchText(constchar*t,inttlen,constchar*p,intplen,pg_locale_tlocale)
8281
{
8382
/* Fast path for match-everything pattern */
8483
if (plen==1&&*p=='%')
@@ -106,7 +105,7 @@ MatchText(const char *t, int tlen, const char *p, int plen,
106105
ereport(ERROR,
107106
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
108107
errmsg("LIKE pattern must not end with escape character")));
109-
if (GETCHAR(*p)!=GETCHAR(*t))
108+
if (GETCHAR(*p,locale)!=GETCHAR(*t,locale))
110109
returnLIKE_FALSE;
111110
}
112111
elseif (*p=='%')
@@ -166,17 +165,16 @@ MatchText(const char *t, int tlen, const char *p, int plen,
166165
ereport(ERROR,
167166
(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
168167
errmsg("LIKE pattern must not end with escape character")));
169-
firstpat=GETCHAR(p[1]);
168+
firstpat=GETCHAR(p[1],locale);
170169
}
171170
else
172-
firstpat=GETCHAR(*p);
171+
firstpat=GETCHAR(*p,locale);
173172

174173
while (tlen>0)
175174
{
176-
if (GETCHAR(*t)==firstpat)
175+
if (GETCHAR(*t,locale)==firstpat)
177176
{
178-
intmatched=MatchText(t,tlen,p,plen,
179-
locale,locale_is_c);
177+
intmatched=MatchText(t,tlen,p,plen,locale);
180178

181179
if (matched!=LIKE_FALSE)
182180
returnmatched;/* TRUE or ABORT */
@@ -198,7 +196,7 @@ MatchText(const char *t, int tlen, const char *p, int plen,
198196
NextByte(p,plen);
199197
continue;
200198
}
201-
elseif (GETCHAR(*p)!=GETCHAR(*t))
199+
elseif (GETCHAR(*p,locale)!=GETCHAR(*t,locale))
202200
{
203201
/* non-wildcard pattern char fails to match text char */
204202
returnLIKE_FALSE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp