Hi Chris, that is perfect!
Unfortunately, including pg_config.h and pg_config_manual.h generates a lot of preprocessor warnings about redefines (since both libzdb and postgres both use auto-tools and *.h.in). Besides we want to limit include to libpq-fe.h if possible as this is the official API interface for the Postgres lib. I thought version info was included in that interface, but apparently it is not. So as a compromise, I rewrote the patch to something in-between. There is also no test on postgres version, with the assumption that the user knows what he is doing. Though in difference to the first patch, application_name is not included if not specified in the URL.
In the process I also modified URL parsing to allow for spaces in property values so application name can have that (The connection URL need not adhere strictly to the RFC). So something like the following should now work;
postgresql://localhost:5432/test?user=root&password=root&application-name=my application name
Thanks for the patch and for the idea! I'm sure there are users out there who will find this useful.
Jan-Henrik
On Jan 4, 2011, at 6:15 PM, Chris Mayo wrote:
On 02/01/11 21:33, Jan-Henrik Haukeland wrote:
Seems useful. Though to avoid the risk of breaking anything backwards it should only be allowed for version 9 by using ifdefs. Also the patch need to 1) test if the application_name parameter is set otherwise it will pass a NULL pointer to the connection string 2) and if set, that the length of application_name is less than or equal to NAMEDATALEN - 1 and issue a warning or error if not.
Please have a look at the attached version.
On Jan 2, 2011, at 9:36 PM, Chris Mayo wrote:
PostgreSQL 9.0 adds the feature for connections to set an application name that shows up in logs and the system view pg_stat_activity.
http://www.postgresql.org/docs/9.0/static/runtime-config-logging.html#RUNTIM...
All previous versions of PostgreSQL back to 7.4 were patched in minor releases in December 2009 so that they ignore this parameter e.g. http://www.postgresql.org/docs/9.0/static/release-7-4-27.html
But I think it would cause problems for servers that hadn't been updated.
Patch attached that works for me (both with and without setting application_name). But it is just a quick copy and paste job!
Chris
<libzdb-2.7-appname.patch>-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general
-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general
<libzdb-2.7-appname1.patch>-- To unsubscribe: http://www.tildeslash.com/mailman/listinfo/libzdb-general