BUG #16467: XX000 fun - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16467: XX000 fun
Date
Msg-id 16467-12cd2b5cdb4f90c5@postgresql.org
Whole thread Raw
Responses Re: BUG #16467: XX000 fun  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16467
Logged by:          Andrey Marinchuk
Email address:      radist.nt@gmail.com
PostgreSQL version: 9.6.17
Operating system:   Red Hat 4.8.5-39
Description:

Reproduced in:
"PostgreSQL 9.6.17 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5
20150623 (Red Hat 4.8.5-39), 64-bit"
"PostgreSQL 10.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5
20150623 (Red Hat 4.8.5-28), 64-bit"
Not reproduced in 12.2.

Steps to reproduce:
1. open two connections (#1 and #2)
2. in connection #1 run script 0
3. in connection #1 run script 1
4. in connection #2 start transaction and run query: select
textXX000.testXX000(public.textXX000_internal('iteration #'), 1);
5. in connection #1 run script 1 again
6. in connection #2 start savepoint and run query: select
textXX000.testXX000(public.textXX000_internal('iteration #'), 2);
7. in connection #2 rollback to savepoint and run query: select
textXX000.testXX000(public.textXX000_internal('iteration #'), 3);

Expected: query in 6 executed without error
Actual (9.6.17):
crm_com=# begin;
BEGIN
crm_com=# \set VERBOSITY verbose
crm_com=# select textXX000.testXX000(public.textXX000_internal('iteration
#'), 1);
  testxx000
--------------
 iteration #1
(1 line)


crm_com=# savepoint sp;
SAVEPOINT
crm_com=# select textXX000.testXX000(public.textXX000_internal('iteration
#'), 2);
ERROR:  XX000: cache lookup failed for function 182081751
Location:  simplify_function, clauses.c:3894
crm_com=# rollback to sp;
ROLLBACK
crm_com=# select textXX000.testXX000(public.textXX000_internal('iteration
#'), 3);
  testxx000
--------------
 iteration #3
(1 line)

script 0:
create or replace function public.textXX000_internal(t in text, flag in
boolean default true) returns text as $$
select case when flag then t else (select nspname::text from
pg_catalog.pg_namespace where nspname = 'public') end
$$ language sql stable called on null input;
script 1:
BEGIN;
DROP SCHEMA IF EXISTS textXX000 CASCADE;
CREATE SCHEMA textXX000;
GRANT USAGE ON SCHEMA textXX000 TO public;
ALTER DEFAULT PRIVILEGES IN SCHEMA textXX000 GRANT EXECUTE ON FUNCTIONS TO
public;
SET SEARCH_PATH TO testXX000;
create or replace function textXX000.testXX000(t in text, i integer) returns
text as $$
begin
  return t || i;
end;
$$ language plpgsql stable returns null on null input;
END;


Additional info: also tested with PostgreSQL 9.6.3 via JDBC, see
https://github.com/pgjdbc/pgjdbc/issues/1786


pgsql-bugs by date:

Previous
From: Alexander Lakhin
Date:
Subject: Re: BUG #16466: Valgrind detects an invalid read in dblink_open()with a cursor inside a transaction
Next
From: Tom Lane
Date:
Subject: Re: Explicit deterministic COLLATE fails with pattern matching operations on column with non-deterministic collation