Page 1 of 1

no postgresql user name specified in startup packet

Posted: Fri 23 Oct 2009 20:56
by coderdan
Hi guys,

anyone else have this issue? I have an application (D7). I can generally force this to happen if I change my bound IP address (such as connect to a VPN and then disconnect).

I typically will notice this when I call 'FStoredProc.PrepareSQL;' Where FStoredProc is a TpgStoredProcedure. If I on the other hand create all of the params by hand and then fill them this issue does NOT occur.

Thoughts?

Thanks,

Dan

BTW -- High praise for Devart :) Your components are great.

Solution

Posted: Sun 25 Oct 2009 18:21
by coderdan
By switching from:
FStoredProc.Connection := Conn;
FStoredProc.StoredProcName := 'spLog';
FStoredProc.Prepare; // or PrepareSQL

FStoredProc.Params[1].AsInteger := FMessageType;
FStoredProc.Params[2].AsString := FMessage;
FStoredProc.Params[3].AsInteger := FUserID;

FStoredProc.Execute;


To:
FStoredProc.Connection := Conn;
FStoredProc.StoredProcName := 'spLog';
FStoredProc.Params.CreateParam(ftInteger,'result',ptResult);
FStoredProc.Params.CreateParam(ftInteger, 'log_type',ptInput);
FStoredProc.Params.CreateParam(ftString,'log_msg',ptInput);
FStoredProc.Params.CreateParam(ftInteger,'log_user', ptInput);

FStoredProc.Params[1].AsInteger := FMessageType;
FStoredProc.Params[2].AsString := FMessage;
FStoredProc.Params[3].AsInteger := FUserID;

FStoredProc.Execute;

I only find this to be a problem when called from with a thread. Ok, well I suppose it's the finesse of the style :)

Posted: Tue 27 Oct 2009 08:04
by Plash
When your IP address is changed, the PostgreSQL server cannot detect that data you send belongs to the same connection. The server thinks that it is a new connection. So it returns an error.

Thank you -- and so...

Posted: Tue 27 Oct 2009 17:26
by coderdan
is there a connection event that can trap this?

Thanks

Dan

Posted: Wed 28 Oct 2009 09:42
by Plash
You can try to use the OnConnectionLost event. Set the LocalFailover option of TPgConnection to True to enable this event. See the "Using PgDAC / Working in an Unstable Network" topic in the PgDAC help for details.