summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tsquery_op.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-08-03 00:10:44 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-08-03 00:10:44 +0000
commit2f203642f817e596bdfab2158cf32ce2e5c0eca5 (patch)
treed708df4589099a173b8414822429733bb0c5bd51 /src/backend/utils/adt/tsquery_op.c
parent3e3ee1dfc35b4b2449f36bc31a32388951142f61 (diff)
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().
Diffstat (limited to 'src/backend/utils/adt/tsquery_op.c')
-rw-r--r--src/backend/utils/adt/tsquery_op.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/tsquery_op.c b/src/backend/utils/adt/tsquery_op.c
index 2b453e02868..81874fb812a 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.8 2010/01/02 16:57:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_op.c,v 1.8.6.1 2010/08/03 00:10:44 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));