pgsql: Make CREATE INDEX run expression preprocessing on a proposed

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Make CREATE INDEX run expression preprocessing on a proposed
Date: 2010-05-27 15:59:15
Message-ID: 20100527155915.7F4C77541D2@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Make CREATE INDEX run expression preprocessing on a proposed index expression
before it checks whether the expression is immutable. This covers two cases
that were previously handled poorly:

1. SQL function inlining could reduce the apparent volatility of the
expression, allowing an expression to be accepted where it previously would
not have been. As an example, polymorphic functions must be marked with the
worst-case volatility they have for any argument type, but for specific
argument types they might not be so volatile, so indexing could be allowed.
(Since the planner will refuse to inline functions in cases where the
apparent volatility of the expression would increase, this won't break
any cases that were accepted before.)

2. A nominally immutable function could have default arguments that are
volatile expressions. In such a case insertion of the defaults will increase
both the apparent and actual volatility of the expression, so it is
*necessary* to check this before allowing the expression to be indexed.

Back-patch to 8.4, where default arguments were introduced.

Tags:
----
REL8_4_STABLE

Modified Files:
--------------
pgsql/src/backend/commands:
indexcmds.c (r1.185 -> r1.185.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/indexcmds.c?r1=1.185&r2=1.185.2.1)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-05-27 16:20:11 pgsql: Fix the volatility marking of textanycat() and anytextcat(): they
Previous Message Tom Lane 2010-05-27 15:59:10 pgsql: Make CREATE INDEX run expression preprocessing on a proposed