#1 2021-09-23 12:21:40

wxinix
Member
Registered: 2020-09-07
Posts: 121

Potential bug? mormot.db.sql.postgres does not allow to set Port

Line 293 of mormot.db.sql.postgres

fPGConn := PQ.SetDBLogin(pointer(Properties.ServerName), nil, nil, nil,  pointer(Properties.DatabaseName), pointer(Properties.UserID),
      pointer(Properties.PassWord));

When Propertyies.ServerName is set to be "localhost:5432" , it will thrown exception "Connection to database postgres failed [could not translate host name "localhost:5432" to address: Unknownhost]'.

To make it work,  Properties.ServerName must NOT include the port, like this "localhost".  Port cannot be specified as part of the ServerName.

The second parameter of libpq API,  PQ.SetDBLogin is actually for specifying the port. But it is not used by mORMot (i.e., nil for the default 5432)

Hence,  this is a missing piece here that a user cannot specify a port other than the default 5432.

Last edited by wxinix (2021-09-23 12:23:09)

Offline

#2 2021-09-23 13:44:36

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Potential bug? mormot.db.sql.postgres does not allow to set Port

I have just included this "host:port" parsing.

Offline

#3 2021-09-23 14:51:06

wxinix
Member
Registered: 2020-09-07
Posts: 121

Re: Potential bug? mormot.db.sql.postgres does not allow to set Port

ab wrote:

I have just included this "host:port" parsing.

Thank you it works.

Offline

#4 2021-09-23 17:38:09

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: Potential bug? mormot.db.sql.postgres does not allow to set Port

Ah, also missed in mORMot1. I miss it there mostly because I always use a DatabaseName (it can accept a full Postgres URI ) and keep a serverName empty.

Offline

#5 2021-09-23 19:21:41

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Potential bug? mormot.db.sql.postgres does not allow to set Port

I have just backported it to mORMot 1 too.

Offline

Board footer

Powered by FluxBB