[pgjdbc/pgjdbc] 248b2e: fix: Update function volatility in SchemaTest setu...

Поиск
Список
Период
Сортировка
Искать

[pgjdbc/pgjdbc] 248b2e: fix: Update function volatility in SchemaTest setu...

От:
Rafi Shamim <noreply@github.com>
Дата:
  Branch: refs/heads/master
  Home:   https://github.com/pgjdbc/pgjdbc
  Commit: 248b2eec547f3411d17c37814165cb1cef9daa85
      https://github.com/pgjdbc/pgjdbc/commit/248b2eec547f3411d17c37814165cb1cef9daa85
  Author: Rafi Shamim 
  Date:   2023-02-14 (Tue, 14 Feb 2023)

  Changed paths:
    M pgjdbc/src/test/java/org/postgresql/test/jdbc4/jdbc41/SchemaTest.java

  Log Message:
  -----------
  fix: Update function volatility in SchemaTest setup (#2806)

PostgreSQL allows you to label a function as immutable even if it is
not. But this can lead to non-deterministic results. See:

https://www.postgresql.org/docs/current/sql-createfunction.html
```
IMMUTABLE indicates that the function cannot modify the database and
always returns the same result when given the same argument values;
that is, it does not do database lookups or otherwise use information
not directly present in its argument list. If this option is given,
any call of the function with all-constant arguments can be immediately
replaced with the function value.
```

And:
https://www.postgresql.org/docs/current/xfunc-volatility.html
```
Labeling a function IMMUTABLE when it really isn't might allow it
to be prematurely folded to a constant during planning, resulting
in a stale value being re-used during subsequent uses of the plan.
This is a hazard when using prepared statements or when using function
languages that cache plans (such as PL/pgSQL).
...
It is generally unwise to select from database tables within an IMMUTABLE
function at all, since the immutability will be broken if the table contents
ever change. However, PostgreSQL does not enforce that you do not do that.
```




FAQ