1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

In predtest.c, install a limit on the number of branches we will process in

AND, OR, or equivalent clauses: if there are too many (more than 100) just
exit without proving anything.  This ensures that we don't spend O(N^2) time
trying (and most likely failing) to prove anything about very long IN lists
and similar cases.

Also, install a couple of CHECK_FOR_INTERRUPTS calls to ensure that a long
proof attempt can be interrupted.

Per gripe from Sergey Konoplev.

Back-patch the whole patch to 8.2 and just the CHECK_FOR_INTERRUPTS addition
to 8.1.  (The rest of the patch doesn't apply cleanly, and since 8.1 doesn't
show the complained-of behavior anyway, it doesn't seem necessary to work
hard on it.)
This commit is contained in:
Tom Lane
2008-11-12 23:08:55 +00:00
parent e82067890a
commit d7d81aa813

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.4 2005/10/15 02:49:21 momjian Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/util/predtest.c,v 1.4.2.1 2008/11/12 23:08:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -19,6 +19,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"
#include "optimizer/predtest.h"
#include "utils/catcache.h"
@ -482,6 +483,9 @@ predicate_refuted_by_recurse(Node *clause, Node *predicate)
static bool
predicate_implied_by_simple_clause(Expr *predicate, Node *clause)
{
/* Allow interrupting long proof attempts */
CHECK_FOR_INTERRUPTS();
/* First try the equal() test */
if (equal((Node *) predicate, clause))
return true;
@ -529,6 +533,9 @@ predicate_implied_by_simple_clause(Expr *predicate, Node *clause)
static bool
predicate_refuted_by_simple_clause(Expr *predicate, Node *clause)
{
/* Allow interrupting long proof attempts */
CHECK_FOR_INTERRUPTS();
/* First try the IS NULL case */
if (predicate && IsA(predicate, NullTest) &&
((NullTest *) predicate)->nulltesttype == IS_NULL)