I think I got it. Looks like related to pgaudit.
I did an initdb and run the test case without issue
As soon as l add pgaudit and create the extension, the error is raised
You do not need any FK in the test schema to reproduce the problem.
shared_preload_libraries = 'pgaudit'
pgaudit.log = 'all'
pgaudit.log_catalog = on
pgaudit.log_parameter = on
pgaudit 1.3 is installed (the PG11 compatible version)
select * from pg_extension;
extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
--------------------+----------+--------------+----------------+------------+-----------+--------------
plpgsql | 10 | 11 | f | 1.0 | (NULL) | (NULL)
adminpack | 10 | 11 | f | 2.0 | (NULL) | (NULL)
lo | 10 | 16394 | t | 1.1 | (NULL) | (NULL)
postgres_fdw | 10 | 16394 | t | 1.0 | (NULL) | (NULL)
pg_stat_statements | 10 | 16394 | t | 1.6 | (NULL) | (NULL)
pgrowlocks | 10 | 16394 | t | 1.2 | (NULL) | (NULL)
pgstattuple | 10 | 16394 | t | 1.5 | (NULL) | (NULL)
pg_freespacemap | 10 | 16394 | t | 1.2 | (NULL) | (NULL)
pgaudit | 10 | 16432 | t | 1.3 | (NULL) | (NULL)
(9 rows)
You should now be able to reproduce it.
Regards, JML
Jean-Marc Lessard
Administrateur de base de données / Database Administrator
Ultra Electronics Forensic Technology Inc.
T +1 514 489 4247 x4164
www.ultra-forensictechnology.com
-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Friday, December 14, 2018 3:27 PM
To: Jean-Marc Lessard <Jean-Marc.Lessard@ultra-ft.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15553: "ERROR: cache lookup failed for type 2" with a function the first time it run.
PG Bug reporting form <noreply@postgresql.org> writes:
> I got an "ERROR: cache lookup failed for type 2" when a function is
> run for the first time in a session.
That certainly looks like a bug, but I can't replicate it from the given instructions.
The function seems to expect that the current schema contains some foreign key constraints, which it doesn't when I just follow your script exactly. However, even if I add a few more tables with foreign-key relationships, all seems well.
Please provide a complete script that will reproduce the problem starting from an empty database. Also, have you got any extensions loaded, or any unusual configuration settings?
regards, tom lane