Page 1 of 1

PostgreSQLDirect and pg logging

Posted: Thu 22 Dec 2005 05:14
by Guest
When using PostgreSQLDirect.NET to talk to postgres, I use code of this nature:

dbCmd = New PgSqlCommand("INSERT INTO seriesEntry(id,dateOf,kindOf,amount)" & _
" VALUES (@id,@dateOf,@kindOf,@amount);", dbCon)
dbCmd.Parameters.Add("@id", mId)
dbCmd.Parameters.Add("@dateOf", entry.dateOf)
dbCmd.Parameters.Add("@kindOf", entry.kindOf)
dbCmd.Parameters.Add("@amount", entry.amount)
'dbCmd.Parameters.Add("@indexOf", entry.indexOf)
'dbCmd.Parameters.Add("@apy", entry.apy)
dbCmd.ExecuteNonQuery()

etc. When I look at my postgres log files, I see:

2005-12-22 04:05:59 LOG: statement: INSERT INTO seriesEntry(id,dateOf,kindOf,amount) VALUES ($1,$2,$3,$4);

How can I get the log file to show the actual parameter values, instead of the placeholders $1,$2,$3,$4 ???

Posted: Thu 22 Dec 2005 08:29
by SecureGen
You should switch to text protocol in order to see parameter values. It can be done using protocol=2 parameter in connection string.

Posted: Fri 23 Dec 2005 06:03
by jsiegel5
SecureGen wrote:You should switch to text protocol in order to see parameter values. It can be done using protocol=2 parameter in connection string.
Tried this and it does work. However, I'm uncomfortable with having to use an older protocol version to communicate with the database. Is there no way to get postgres to log the parameters when using the current (v3.0) protocol?

Regards,
Jeff

Posted: Fri 23 Dec 2005 10:32
by SecureGen
DBMonitor shows SQL statements exactly as they are sent to server. In the binary protocol parameters are attached to query using binding mechanism. So in the case of binary protocol you see SQL statements with parameter placeholders. You can see values of parameters in the corresponding tab, which is located at the bottom of DBMonitor application.