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

Commit57641a1

Browse files
committed
Fix core dump in QTNodeCompare when tsquery_cmp() is applied to two empty
tsqueries. CompareTSQ has to have a guard for the case rather than blindlyapplying QTNodeCompare to random data past the end of the datums. Also,change QTNodeCompare to be a little less trusting: use an actual test ratherthan just Assert'ing that the input is sane. Problem encountered whileinvestigating another issue (I saw a core dump in autoanalyze on a tablecontaining multiple empty tsquery values).Back-patch to all branches with tsquery support.In HEAD, also fix some bizarre (though not outright wrong) coding intsq_mcontains().
1 parent57d9aef commit57641a1

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.8 2010/01/02 16:57:55 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.9 2010/08/03 00:10:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -149,7 +149,7 @@ CompareTSQ(TSQuery a, TSQuery b)
149149
{
150150
return (VARSIZE(a)<VARSIZE(b)) ?-1 :1;
151151
}
152-
else
152+
elseif (a->size!=0)
153153
{
154154
QTNode*an=QT2QTN(GETQUERY(a),GETOPERAND(a));
155155
QTNode*bn=QT2QTN(GETQUERY(b),GETOPERAND(b));
@@ -247,20 +247,20 @@ tsq_mcontains(PG_FUNCTION_ARGS)
247247
PG_RETURN_BOOL(false);
248248
}
249249

250+
iq=GETQUERY(query);
250251
ie=GETQUERY(ex);
251252

252253
for (i=0;i<ex->size;i++)
253254
{
254-
iq=GETQUERY(query);
255255
if (ie[i].type!=QI_VAL)
256256
continue;
257257
for (j=0;j<query->size;j++)
258-
if (iq[j].type==QI_VAL&&ie[i].qoperand.valcrc==iq[j].qoperand.valcrc)
259-
{
260-
j=query->size+1;
258+
{
259+
if (iq[j].type==QI_VAL&&
260+
ie[i].qoperand.valcrc==iq[j].qoperand.valcrc)
261261
break;
262-
}
263-
if (j==query->size)
262+
}
263+
if (j>=query->size)
264264
{
265265
PG_FREE_IF_COPY(query,0);
266266
PG_FREE_IF_COPY(ex,1);

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.13 2010/01/02 16:57:55 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.14 2010/08/03 00:10:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -113,20 +113,23 @@ QTNodeCompare(QTNode *an, QTNode *bn)
113113
}
114114
return0;
115115
}
116-
else
116+
elseif (an->valnode->type==QI_VAL)
117117
{
118118
QueryOperand*ao=&an->valnode->qoperand;
119119
QueryOperand*bo=&bn->valnode->qoperand;
120120

121-
Assert(an->valnode->type==QI_VAL);
122-
123121
if (ao->valcrc!=bo->valcrc)
124122
{
125123
return (ao->valcrc>bo->valcrc) ?-1 :1;
126124
}
127125

128126
returntsCompareString(an->word,ao->length,bn->word,bo->length, false);
129127
}
128+
else
129+
{
130+
elog(ERROR,"unrecognized QueryItem type: %d",an->valnode->type);
131+
return0;/* keep compiler quiet */
132+
}
130133
}
131134

132135
staticint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp