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

Commitc48f2e3

Browse files
committed
Improve error messages from to_tsquery per yesterday's discussion:
provide the bad input, and be sure to mention that we are talking abouta tsearch query.
1 parent0d2aed9 commitc48f2e3

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

‎contrib/tsearch2/query.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ typedef struct NODE
8282

8383
typedefstruct
8484
{
85-
char*buf;
85+
char*buffer;/* entire string we are scanning */
86+
char*buf;/* current scan point */
8687
int4state;
8788
int4count;
8889
/* reverse polish notation in list (for temprorary usage) */
@@ -170,7 +171,8 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
170171
{
171172
ereport(ERROR,
172173
(errcode(ERRCODE_SYNTAX_ERROR),
173-
errmsg("error at start of operand")));
174+
errmsg("error at start of operand in tsearch query: \"%s\"",
175+
state->buffer)));
174176
}
175177
elseif (!t_isspace(state->buf))
176178
{
@@ -188,7 +190,8 @@ gettoken_query(QPRS_STATE * state, int4 *val, int4 *lenval, char **strval, int2
188190
else
189191
ereport(ERROR,
190192
(errcode(ERRCODE_SYNTAX_ERROR),
191-
errmsg("no operand")));
193+
errmsg("no operand in tsearch query: \"%s\"",
194+
state->buffer)));
192195
}
193196
break;
194197
caseWAITOPERATOR:
@@ -241,11 +244,13 @@ pushquery(QPRS_STATE * state, int4 type, int4 val, int4 distance, int4 lenval, i
241244
if (distance >=MAXSTRPOS)
242245
ereport(ERROR,
243246
(errcode(ERRCODE_SYNTAX_ERROR),
244-
errmsg("value is too big")));
247+
errmsg("value is too big in tsearch query: \"%s\"",
248+
state->buffer)));
245249
if (lenval >=MAXSTRLEN)
246250
ereport(ERROR,
247251
(errcode(ERRCODE_SYNTAX_ERROR),
248-
errmsg("operand is too long")));
252+
errmsg("operand is too long in tsearch query: \"%s\"",
253+
state->buffer)));
249254
tmp->distance=distance;
250255
tmp->length=lenval;
251256
tmp->next=state->str;
@@ -262,7 +267,8 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, int2 weight
262267
if (lenval >=MAXSTRLEN)
263268
ereport(ERROR,
264269
(errcode(ERRCODE_SYNTAX_ERROR),
265-
errmsg("word is too long")));
270+
errmsg("word is too long in tsearch query: \"%s\"",
271+
state->buffer)));
266272

267273
pushquery(state,type,crc32_sz(strval,lenval),
268274
state->curop-state->op,lenval,weight);
@@ -407,7 +413,8 @@ makepol(QPRS_STATE * state, void (*pushval) (QPRS_STATE *, int, char *, int, int
407413
default:
408414
ereport(ERROR,
409415
(errcode(ERRCODE_SYNTAX_ERROR),
410-
errmsg("syntax error")));
416+
errmsg("syntax error in tsearch query: \"%s\"",
417+
state->buffer)));
411418
returnERR;
412419

413420
}
@@ -621,6 +628,7 @@ static QUERYTYPE *
621628
#endif
622629

623630
/* init state */
631+
state.buffer=buf;
624632
state.buf=buf;
625633
state.state= (isplain) ?WAITSINGLEOPERAND :WAITFIRSTOPERAND;
626634
state.count=0;
@@ -644,7 +652,9 @@ static QUERYTYPE *
644652
pfree(state.valstate.word);
645653
if (!state.num)
646654
{
647-
elog(NOTICE,"query doesn't contain lexeme(s)");
655+
ereport(NOTICE,
656+
(errmsg("tsearch query doesn't contain lexeme(s): \"%s\"",
657+
state.buffer)));
648658
query= (QUERYTYPE*)palloc(HDRSIZEQT);
649659
query->len=HDRSIZEQT;
650660
query->size=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp