From 2ab93ef3a40365da894baed590516e1dd696c028 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Sat, 12 Sep 2015 09:53:23 -0700 Subject: [PATCH] Log the SQL for errors in wpsql_insert_id If the query produces an error, log the query which produced the error in addition to the insert statement which preceded it. This helped me track down an issue with a mis-named sequence from a bad MySQL->PostgreSQL migration. Signed-off-by: Kevin Locke --- pg4wp/driver_pgsql.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pg4wp/driver_pgsql.php b/pg4wp/driver_pgsql.php index 7b46d76..12dbf96 100644 --- a/pg4wp/driver_pgsql.php +++ b/pg4wp/driver_pgsql.php @@ -183,7 +183,9 @@ elseif( PG4WP_DEBUG || PG4WP_ERROR_LOG) { $log = '['.microtime(true)."] wpsql_insert_id() was called with '$table' and '$ins_field'". - " and generated an error. The latest INSERT query was :\n'$lastq'\n"; + " and returned the error:\n".pg_last_error(). + "\nFor the query:\n".$sql. + "\nThe latest INSERT query was :\n'$lastq'\n"; error_log( $log, 3, PG4WP_LOG.'pg4wp_errors.log'); } }