P3
P3 copied to clipboard
Tag reading when the database does not exist
When the database you try to connect does not exist, the method
P3MessageBuffer>>#readFrom:
(called from P3Client>>#readMessageOnError:
)
fails because the readStream next
returns nil
and the internal error handling does not expect such case.
I get a clean error, instance of P3Error with message
P3Error PostgreSQL database "foo" does not exist
when I try to connect to a non existing DB
P3Client url: 'psql://sven@localhost/foo'
and then do #isWorking
I got this error while connecting using Glorp via P3DatabaseDriver. The password is set to nil
which may be part of the problem.
Then the issue raises from: P3Client>>#runAuthentication
, specifically from self readMessageCloseAfterError tag
. The socket is closed.
So the nil
password is not really an issue, it is set correctly. I was just confused by the fact that Glorp deletes the password from the Login instance after the first usage (and it does not use discardPassword message for it)
to reproduce in my setup, I just need to do
connection := P3Client new.
connection
host: 'localhost';
port: 5433;
database: 'pdmCC';
user: 'pdm';
password: 'somePassword'.
connection connect
Where everything except the database name is correct.
It is PostgreSQL 12
I was on 11.6, now also on 12.1
P3Client new
host: 'localhost';
port: 5432;
database: 'pdmCC';
user: 'sven';
"password: '';"
connect.
still gives me a clean P3Error.
Note that #readMessageCloseAfterError does a #close hence the connection will be nil (after the info is read - the dictionary is filled in correctly).
I am using https://postgresapp.com on macOS, Pharo 7.0.1 FWIW
We are on Pharo 9.0 and Windows...
This sometimes happens in regular use as well.
It seems that at that point the underlying socket stream is in the state 'otherEndClosedButNotThisEnd'.
It remains hard to reproduce though.