From 8c378335b9aea40f26cbaabc73aea29bf455264b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 3 Aug 2010 00:10:58 +0000 Subject: 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 blindly applying QTNodeCompare to random data past the end of the datums. Also, change QTNodeCompare to be a little less trusting: use an actual test rather than just Assert'ing that the input is sane. Problem encountered while investigating another issue (I saw a core dump in autoanalyze on a table containing multiple empty tsquery values). Back-patch to all branches with tsquery support. In HEAD, also fix some bizarre (though not outright wrong) coding in tsq_mcontains(). --- src/backend/utils/adt/tsquery_op.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/utils/adt/tsquery_op.c') diff --git a/src/backend/utils/adt/tsquery_op.c b/src/backend/utils/adt/tsquery_op.c index a0b103984dd..f3c40de5f2e 100644 --- a/src/backend/utils/adt/tsquery_op.c +++ b/src/backend/utils/adt/tsquery_op.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.3.2.2 2008/03/09 10:42:48 teodor Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.3.2.3 2010/08/03 00:10:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -149,7 +149,7 @@ CompareTSQ(TSQuery a, TSQuery b) { return (VARSIZE(a) < VARSIZE(b)) ? -1 : 1; } - else + else if (a->size != 0) { QTNode *an = QT2QTN(GETQUERY(a), GETOPERAND(a)); QTNode *bn = QT2QTN(GETQUERY(b), GETOPERAND(b)); -- cgit v1.2.3