Skip to content

Installation fails if datname contains "-"

We (sadly) have a database with a hypen in it's name, were the extension can not be installed, example:

Works

postgres=# create database demo;

CREATE DATABASE

postgres=# alter database demo set session_preload_libraries = 'anon';

ALTER DATABASE

postgres=# \c demo

You are now connected to database "demo" as user "postgres".

demo=# create extension anon;

CREATE EXTENSION

Fails

postgres=# create database "demo-foo";

CREATE DATABASE

postgres=# alter database "demo-foo" set session_preload_libraries = 'anon';

ALTER DATABASE

postgres=# \c "demo-foo"

You are now connected to database "demo-foo" as user "postgres".

demo-foo=# create extension anon;

ERROR: syntax error at or near "-"

LINE 1: ALTER DATABASE demo-foo SET anon.shift TO 399391412

QUERY: ALTER DATABASE demo-foo SET anon.shift TO 399391412

CONTEXT: PL/pgSQL function anon.set_shift(integer) line 6 at EXECUTE

I think that current_database() needs to be quoted while creating the extension.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information