Thread: minor issue with psql keeping connections

minor issue with psql keeping connections

From
Robert Treat
Date:
pgsql running on port 5480, connect to template1 as non-superuser "phppgadmin"
who does not have createdb privileges. attempt to run a script that creates a
database "phppgadmin" and then do a \connect to that database.   this fails
(as it should) but when it does, it loses the connection to template1, and i
am not able to reconnect to any database, i think because it is looking on
port 5432 rather than the 5480 i specified when i originally connected.

postgres@phppgadmin:/usr/local/pgsql-8.0.0beta-4/bin$ ./psql -p5480 template1
-U phppgadmin
Welcome to psql 8.0.0beta4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=> select version();
                              version
--------------------------------------------------------------------
 PostgreSQL 8.0.0beta4 on i586-pc-linux-gnu, compiled by GCC 2.95.3
(1 row)

template1=> \i /usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql
ERROR:  permission denied to create database
psql:/usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql:7: ERROR:
permission denied to create database
FATAL:  database "phppgadmin" does not exist
psql:/usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql:9:
\connect: FATAL:  database "phppgadmin" does not exist
!> \c template1
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
!>
!>

relativily minor issue, but seems like it should either be able to retain the
connection when inside the script, or recall that it needs to connect on 5480
after failure.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

Re: minor issue with psql keeping connections

From
Robert Treat
Date:
On Sunday 31 October 2004 10:16, Robert Treat wrote:
> pgsql running on port 5480, connect to t\echo :PORTemplate1 as non-superuser
> "phppgadmin" who does not have createdb privileges. attempt to run a script
> that creates a database "phppgadmin" and then do a \connect to that
> database.   this fails (as it should) but when it does, it loses the
> connection to template1, and i am not able to reconnect to any database, i
> think because it is looking on port 5432 rather than the 5480 i specified
> when i originally connected.
>
> postgres@phppgadmin:/usr/local/pgsql-8.0.0beta-4/bin$ ./psql -p5480
> template1 -U phppgadmin
> Welcome to psql 8.0.0beta4, the PostgreSQL interactive terminal.
>
> Type:  \copyright for distribution terms
>        \h for help with SQL commands
>        \? for help with psql commands
>        \g or terminate with semicolon to execute query
>        \q to quit
>
> template1=> select version();
>                               version
> --------------------------------------------------------------------
>  PostgreSQL 8.0.0beta4 on i586-pc-linux-gnu, compiled by GCC 2.95.3
> (1 row)
>
> template1=> \i
> /usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql ERROR:
> permission denied to create database
> psql:/usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql:7:
> ERROR: permission denied to create database
> FATAL:  database "phppgadmin" does not exist
> psql:/usr/local/apache/htdocs/phppgadmin3cvs/sql/reports-pgsql.sql:9:
> \connect: FATAL:  database "phppgadmin" does not exist
> !> \c template1
> could not connect to server: No such file or directory
>         Is the server running locally and accepting
>         connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
> !>
> !>
>
> relativily minor issue, but seems like it should either be able to retain
> the connection when inside the script, or recall that it needs to connect
> on 5480 after failure.

little addition... the variable :PORT is unsert after the script bombs. psql
assumes that it should be connecting on 5432 rather than what would normally
be aqailable in :PORT and so it will reconnect if you are on a standard port.

--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL