The following bug has been logged on the website:
Bug reference: 16698
Logged by: Miha Vrhovnik
Email address: miha.vrhovnik@gmail.com
PostgreSQL version: 13.0
Operating system: Linux
Description:
The documentation states, that I can use search_path to define in which
schema the extension is going to be created, but this is clearly not
true..
postgres=# CREATE DATABASE test;
CREATE DATABASE
postgres=# CREATE SCHEMA foo1;
CREATE SCHEMA
postgres=# SET search_path = 'foo1';
SET
postgres=# CREATE EXTENSION ltree;
CREATE EXTENSION
postgres=# CREATE SCHEMA foo2;
CREATE SCHEMA
postgres=# SET search_path = 'foo2';
SET
postgres=# CREATE EXTENSION ltree;
ERROR: extension "ltree" already exists
postgres=# SHOW search_path;
search_path
-------------
foo2
(1 row)
It's the same with example from the documentation.(This continues in the
same session, so search_path is set to foo2 at first create extension)
postgres=# CREATE EXTENSION hstore;
CREATE EXTENSION
postgres=# SET search_path = 'foo1';
SET
postgres=# CREATE EXTENSION hstore;
ERROR: extension "hstore" already exists
It's a shame that this doesn't work as documented as creating migrations or
tests where each test is run in different schema is more difficult.
BR,
Miha