-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi,
We were struggling today with some java code binding values violating some constraints in a prepared statement. We don't own the code and couldn't make tests with it. So we tried to find if PostgreSQL was able to log binded values when the BIND operation fail and found that this is not possible in current release: the error raised while planing the statement is not caught. PFA a patch that catch any error while creating the query plan and add parameters values to the error message if log_statement or log_min_duration_statement would have logged it. Comments? - -- Jehan-Guillaume de Rorthais http://www.dalibo.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlBy/cgACgkQXu9L1HbaT6Li5QCdEa9Zc4g302znpHmrwB9dnRBI JSwAnR2Poil0QAP6b+TflM2ebDCPLq3G =HU3H -----END PGP SIGNATURE-----
*** a/src/backend/tcop/postgres.c --- b/src/backend/tcop/postgres.c *************** *** 1715,1726 **** exec_bind_message(StringInfo input_message) pq_getmsgend(input_message); ! /* ! * Obtain a plan from the CachedPlanSource. Any cruft from (re)planning ! * will be generated in MessageContext. The plan refcount will be ! * assigned to the Portal, so it will be released at portal destruction. ! */ ! cplan = GetCachedPlan(psrc, params, false); /* * Now we can define the portal. --- 1715,1738 ---- pq_getmsgend(input_message); ! PG_TRY(); ! { ! /* ! * Obtain a plan from the CachedPlanSource. Any cruft from (re)planning ! * will be generated in MessageContext. The plan refcount will be ! * assigned to the Portal, so it will be released at portal destruction. ! */ ! ! cplan = GetCachedPlan(psrc, params, false); ! } ! PG_CATCH(); ! { ! if (check_log_statement(portal->stmts) || check_log_duration(msec_str, false) == 2) ! errdetail_params(params); ! ! PG_RE_THROW(); ! } ! PG_END_TRY(); /* * Now we can define the portal.
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers