leonibr / community-extensions-cache-postgres

A PostgreSQL Implementation of IDistributedCache interface. Using Postgresql as distributed cache in Asp.Net Core. NetStandard 2.0
54 stars 17 forks source link

Avoid creation of schema if exists #53

Open Znakes opened 1 year ago

Znakes commented 1 year ago

Hello!

I have a very specific situation: my user can't execute

CREATE SCHEMA IF NOT EXISTS schema

from https://github.com/leonibr/community-extensions-cache-postgres/pull/10/commits/3e18e164fa0df5cc06519e57c6a655dff889245a due to insufficient rights. Although schema exists, this command just can't be executed. Therefore I get an exception. But user still have rights to create table! Do you think it is worth to change this query to

IF NOT EXISTS(
        SELECT schema_name
          FROM information_schema.schemata
          WHERE schema_name = '%schema%'
      )
      THEN
        EXECUTE 'CREATE SCHEMA %schema%';
END IF;

or somehting similar?

leonibr commented 12 months ago

Hi, which version of postgres are you in, and what privileges the db user has, but I would rather use CREATE SCHEMA IF NOT EXISTS %schema%, can you check that if it fix in your scenario?