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

Commit236404f

Browse files
committed
Our interface code for Spencer's regexp package was checking for regexp
error conditions during regexp compile, but not during regexp execution;any sort of "can't happen" errors would be treated as no-match insteadof being reported as they should be. Noticed while trying to duplicatea reported Tcl bug.
1 parentcf796cc commit236404f

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.54 2004/08/29 04:12:52 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/regexp.c,v 1.55 2004/11/24 22:44:07 tgl Exp $
1212
*
1313
*Alistair Crooks added the code for the regex caching
1414
*agc - cached the regular expressions used - there's a good chance
@@ -107,6 +107,7 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
107107
intregcomp_result;
108108
intregexec_result;
109109
cached_re_strre_temp;
110+
charerrMsg[100];
110111

111112
/* Convert data string to wide characters */
112113
data= (pg_wchar*)palloc((dat_len+1)*sizeof(pg_wchar));
@@ -144,7 +145,17 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
144145

145146
pfree(data);
146147

147-
return (regexec_result==0);
148+
if (regexec_result!=REG_OKAY&&regexec_result!=REG_NOMATCH)
149+
{
150+
/* re failed??? */
151+
pg_regerror(regexec_result,&re_array[0].cre_re,
152+
errMsg,sizeof(errMsg));
153+
ereport(ERROR,
154+
(errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
155+
errmsg("regular expression failed: %s",errMsg)));
156+
}
157+
158+
return (regexec_result==REG_OKAY);
148159
}
149160
}
150161

@@ -166,11 +177,9 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
166177

167178
pfree(pattern);
168179

169-
if (regcomp_result!=0)
180+
if (regcomp_result!=REG_OKAY)
170181
{
171182
/* re didn't compile */
172-
charerrMsg[100];
173-
174183
pg_regerror(regcomp_result,&re_temp.cre_re,errMsg,sizeof(errMsg));
175184
/* XXX should we pg_regfree here? */
176185
ereport(ERROR,
@@ -222,7 +231,17 @@ RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len,
222231

223232
pfree(data);
224233

225-
return (regexec_result==0);
234+
if (regexec_result!=REG_OKAY&&regexec_result!=REG_NOMATCH)
235+
{
236+
/* re failed??? */
237+
pg_regerror(regexec_result,&re_array[0].cre_re,
238+
errMsg,sizeof(errMsg));
239+
ereport(ERROR,
240+
(errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
241+
errmsg("regular expression failed: %s",errMsg)));
242+
}
243+
244+
return (regexec_result==REG_OKAY);
226245
}
227246

228247

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp