File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ All work was done by Teodor Sigaev (teodor@stack.net) and Oleg Bartunov
6
6
7
7
CHANGES:
8
8
9
+ August 22, 2002
10
+ Fix works with 'bad' queries
9
11
August 13, 2002
10
12
Use parser of OpenFTS v0.33.
11
13
Original file line number Diff line number Diff line change @@ -231,6 +231,9 @@ gtxtidx_consistent(PG_FUNCTION_ARGS) {
231
231
((GISTENTRY * )PG_GETARG_POINTER (0 ))-> key
232
232
);
233
233
234
+ if ( !query -> size )
235
+ PG_RETURN_BOOL (false);
236
+
234
237
if ( ISSIGNKEY (key ) ) {
235
238
if ( ISALLTRUE (key ) )
236
239
PG_RETURN_BOOL (true);
Original file line number Diff line number Diff line change @@ -419,7 +419,7 @@ execqtxt(PG_FUNCTION_ARGS)
419
419
CHKVAL chkval ;
420
420
bool result ;
421
421
422
- if (!val -> size )
422
+ if (!val -> size || ! query -> size )
423
423
{
424
424
PG_FREE_IF_COPY (val , 0 );
425
425
PG_FREE_IF_COPY (query , 1 );
@@ -593,8 +593,9 @@ mqtxt_in(PG_FUNCTION_ARGS)
593
593
res = clean_fakeval (GETQUERY (query ), & len );
594
594
if (!res )
595
595
{
596
- pfree (query );
597
- PG_RETURN_NULL ();
596
+ query -> len = HDRSIZEQT ;
597
+ query -> size = 0 ;
598
+ PG_RETURN_POINTER (query );
598
599
}
599
600
memcpy ((void * ) GETQUERY (query ), (void * ) res , len * sizeof (ITEM ));
600
601
#ifdef BS_DEBUG
@@ -738,8 +739,11 @@ qtxt_out(PG_FUNCTION_ARGS)
738
739
QUERYTYPE * query = (QUERYTYPE * ) DatumGetPointer (PG_DETOAST_DATUM (PG_GETARG_DATUM (0 )));
739
740
INFIX nrm ;
740
741
741
- if (query -> size == 0 )
742
- elog (ERROR , "Empty" );
742
+ if (query -> size == 0 ) {
743
+ char * b = palloc (1 );
744
+ * b = '\0' ;
745
+ PG_RETURN_POINTER (b );
746
+ }
743
747
nrm .curpol = GETQUERY (query );
744
748
nrm .buflen = 32 ;
745
749
nrm .cur = nrm .buf = (char * ) palloc (sizeof (char ) * nrm .buflen );
@@ -765,8 +769,11 @@ querytree(PG_FUNCTION_ARGS)
765
769
int4 len ;
766
770
767
771
768
- if (query -> size == 0 )
769
- elog (ERROR , "Empty" );
772
+ if (query -> size == 0 ) {
773
+ res = (text * ) palloc (VARHDRSZ );
774
+ VARATT_SIZEP (res ) = VARHDRSZ ;
775
+ PG_RETURN_POINTER (res );
776
+ }
770
777
771
778
q = clean_NOT (GETQUERY (query ), & len );
772
779
Original file line number Diff line number Diff line change @@ -283,7 +283,7 @@ clean_fakeval(ITEM * ptr, int4 *len)
283
283
resroot = clean_fakeval_intree (root , & result );
284
284
if (result != V_UNKNOWN )
285
285
{
286
- elog (ERROR , "Your query contained only stopword(s), ignored" );
286
+ elog (NOTICE , "Query contains only stopword(s) or doesn't contain lexem (s), ignored" );
287
287
* len = 0 ;
288
288
return NULL ;
289
289
}
You can’t perform that action at this time.
0 commit comments