Skip to content
Snippets Groups Projects
  • Tom Lane's avatar
    5a86e5e1
    Make CREATE INDEX run expression preprocessing on a proposed index expression · 5a86e5e1
    Tom Lane authored
    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.
    5a86e5e1
    History
    Make CREATE INDEX run expression preprocessing on a proposed index expression
    Tom Lane authored
    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.