Thread: FATAL: no such database

FATAL: no such database

From
BeeRich Lists
Date:
For some reason I cannot create a database.  I use Sequel, Postico, and psql, and all three won’t create a database.
Thefirst two write the syntax for me, and they too return errors.  Here is an example in psql: 

rich=# CREATE DATABASE alpha;
CREATE DATABASE
rich=# \c alpha;
FATAL:  no such database: alpha
Previous connection kept
rich=# \l
                                List of databases
     Name     | Owner | Encoding |   Collate   |    Ctype    | Access privileges
--------------+-------+----------+-------------+-------------+-------------------
 alpha        | rich  | UTF8     | C           | C           |
 postgres     | rich  | UTF8     | C           | C           |
 rich         | rich  | UTF8     | C           | C           |
 template0    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
 template1    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
(5 rows)

rich=# DROP DATABASE alpha;
DROP DATABASE
rich=# \l
                                List of databases
     Name     | Owner | Encoding |   Collate   |    Ctype    | Access privileges
--------------+-------+----------+-------------+-------------+-------------------
 postgres     | rich  | UTF8     | C           | C           |
 rich         | rich  | UTF8     | C           | C           |
 template0    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
 template1    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
(4 rows)

rich=# CREATE DATABASE alpha;
CREATE DATABASE
rich=# \l
                                List of databases
     Name     | Owner | Encoding |   Collate   |    Ctype    | Access privileges
--------------+-------+----------+-------------+-------------+-------------------
 alpha        | rich  | UTF8     | C           | C           |
 postgres     | rich  | UTF8     | C           | C           |
 rich         | rich  | UTF8     | C           | C           |
 template0    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
 template1    | rich  | UTF8     | C           | C           | =c/rich          +
              |       |          |             |             | rich=CTc/rich
(5 rows)

rich=# \c alpha;
FATAL:  no such database: alpha
Previous connection kept
rich=#

I have reinstalled PostgreSQL 12 both through homebrew as well as using the Postgres.app on MacOS.  Both have the same
issue.  

Anybody have any insight into what I should try?  Thanks for your time.



Cheers, Bee




Re: FATAL: no such database

From
Tom Lane
Date:
BeeRich Lists <bee.lists@gmail.com> writes:
> For some reason I cannot create a database.  I use Sequel, Postico, and psql, and all three won’t create a database.
Thefirst two write the syntax for me, and they too return errors.  Here is an example in psql: 
> rich=# CREATE DATABASE alpha;
> CREATE DATABASE
> rich=# \c alpha;
> FATAL:  no such database: alpha
> Previous connection kept

Well, that's just odd.  Do you have any nondefault extensions loaded into
the database?  I notice that the normal message for a missing database
looks different:

alpha=# \c alpha2
FATAL:  database "alpha2" does not exist
Previous connection kept

and in fact the string "no such database" appears nowhere in the core
Postgres code.  So I'm not sure what's throwing that error, but I guess
it must be some add-on code.

BTW, the semicolon is superfluous, although I suspect that removing
it won't change anything.

            regards, tom lane



Re: FATAL: no such database

From
Tom Lane
Date:
[ please keep the list cc'd ]

BeeRich Lists <bee.lists@gmail.com> writes:
>> On Feb 21, 2022, at 3:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Well, that's just odd.  Do you have any nondefault extensions loaded into
>> the database?

> I have installed the following (what I remember, just a handful).  I’m unclear which ones :

>  cube          | 1.4     | public     | data type for multidimensional cubes
>  earthdistance | 1.1     | public     | calculate great-circle distances on the surface of the Earth
>  hstore        | 1.6     | public     | data type for storing sets of (key, value) pairs
>  pg_trgm       | 1.4     | public     | text similarity measurement and index searching based on trigrams
>  plpgsql       | 1.0     | pg_catalog | PL/pgSQL procedural language
>  uuid-ossp     | 1.1     | public     | generate universally unique identifiers (UUIDs)

None of those contain that string, either.

In any case, a generic extension wouldn't cause this problem,
it'd have to be something that adds code to session start.
I'm pretty sure that could only be modules that are listed
in shared_preload_libraries or session_preload_libraries;
have you got entries in either one?

[ thinks for a bit... ]  Another possibility perhaps is that
you've got something in front of the server, like a connection
pooler, and it's not coping.

            regards, tom lane



Re: FATAL: no such database

From
BeeRich Lists
Date:
On Feb 21, 2022, at 7:54 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> [ please keep the list cc'd ]
>
> BeeRich Lists <bee.lists@gmail.com> writes:
>>> On Feb 21, 2022, at 3:43 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> Well, that's just odd.  Do you have any nondefault extensions loaded into
>>> the database?
>
>> I have installed the following (what I remember, just a handful).  I’m unclear which ones :
>
>> cube          | 1.4     | public     | data type for multidimensional cubes
>> earthdistance | 1.1     | public     | calculate great-circle distances on the surface of the Earth
>> hstore        | 1.6     | public     | data type for storing sets of (key, value) pairs
>> pg_trgm       | 1.4     | public     | text similarity measurement and index searching based on trigrams
>> plpgsql       | 1.0     | pg_catalog | PL/pgSQL procedural language
>> uuid-ossp     | 1.1     | public     | generate universally unique identifiers (UUIDs)
>
> None of those contain that string, either.
>
> In any case, a generic extension wouldn't cause this problem,
> it'd have to be something that adds code to session start.
> I'm pretty sure that could only be modules that are listed
> in shared_preload_libraries or session_preload_libraries;
> have you got entries in either one?
>
> [ thinks for a bit... ]  Another possibility perhaps is that
> you've got something in front of the server, like a connection
> pooler, and it's not coping.

Oops, sorry about that.

Yes, just tested my pgbouncer (a pooler).  That was it.  Tested both ports and pgbouncer didn’t respond accordingly.

Thank you!



Cheers, Bee