[Fusionforge-commits] r15210 - in trunk: . src/common/include src/etc/config.ini.d

Roland Mas lolando at fusionforge.org
Mon Mar 26 10:52:31 CEST 2012


Author: lolando
Date: 2012-03-26 10:52:30 +0200 (Mon, 26 Mar 2012)
New Revision: 15210

Modified:
   trunk/
   trunk/src/common/include/database-pgsql.php
   trunk/src/common/include/extras-debug.php
   trunk/src/common/include/pre.php
   trunk/src/etc/config.ini.d/debug.ini
Log:
Merged from Evolvis: better DB query tracing


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/Branch_4_7:6879,6881,6884,6897,6899,6902,6904,6906,6909,6911,6922,6932,6936,6939,6942,6944,6946-6948,6954,6956,6959,7000-7001,7012,7111,7130-7131,7133-7134,7138,7140-7142,7147-7148,7159-7160,7163,7168,7177,7179,7203,7205,7207,7210,7212,7251-7253,7255,7284,7287,7291,7293,7295-7296,7300,7355,7365-7366,7375-7376,7378,7395,7423-7426,7435,7458,7504,7567,7577,7623-7624,7638,7659-7660,7662,7665,7668,7674,7699,7746-7748,7771,7774,7786,7838
/shelves/aljeux:15005,15012,15150,15154-15160,15177-15179,15203
/trunk:8721-8727
/shelves/alain_peyrat:14997-15003
/branches/Branch_4_8:7334-7335,7344-7345,7382,7387,7389-7390,7396,7398,7401-7402,7428-7429,7437,7440,7443,7449-7455,7459,7462,7466,7469-7470,7476-7478,7480,7485,7490-7492,7505,7540,7556-7560,7568,7570-7571,7573,7576,7580,7609-7611,7613,7615,7618,7621-7622,7625-7627,7639,7658,7661,7663-7664,7666-7667,7673,7675,7678,7680,7685,7688-7689,7693,7700,7706-7708,7713,7725,7728-7742,7760,7763-7764,7767,7769-7770,7773,7776,7784-7785,7791,7797,7799,7802-7808,7810-7811,7816,7818,7825-7828,7839,7846-7847,7850,7894,7902,7920-7922,7927-7928,7932,7936-7937,7939,7942,7944-7945,7947,7951,7956,7958,7960,8064,8079-8080,8108,8113,8119,8121,8127-8128,8145,8197,8201-8202,8216,8224,8226,8228,8247-8250,8252,8271-8272,8310-8311,8328,8337,8339-8357,8361,8371,8373-8375,8378-8379,8383-8396,8415,8427-8431,8438-8441,8449,8452-8453,8458,8461,8477-8478,8480,8482,8492,8514,8530,8604-8605,8608,8637,8662,8674,8751,8754,8756,8760-8761,8812,8850,8945,8995,8998,9004-9006,9124,9137,9141,9317,9443,9469,9670,9701,9726,9934,10013,10310,10314,10366,12790,13085
/branches/Branch_5_1:11607-11609,11621,11625,11627,11631,11638,11644,11647-11651,11677,11680-11681,11683-11684,11719-11720,11724,11754,11780,11783,11792,11794,11802,11808-11816,11818,11822-11824,11827-11829,11834-11835,11847,11849,11851-11852,11855,11858,11862,11867,11869-11872,11876,11880,11893,11902-11905,11915,11923-11927,11929-11930,11932,11934-11941,11943,11948-11949,11952-11954,11956-11960,11962,11965-11966,11972,11975,11980,11983-11984,11986-11987,11990,11992-11997,12003-12004,12010-12013,12015,12018-12024,12043-12044,12046-12061,12063,12065,12070,12073-12076,12081-12083,12093-12094,12102,12105,12118,12124,12127-12128,12139,12141,12143,12148-12149,12153,12157-12159,12168-12169,12175-12180,12190,12194-12198,12203,12208-12213,12217-12258,12262,12264-12266,12274-12277,12281-12282,12287-12290,12340,12345-12346,12352,12359,12472-12473,12594,12634,12636-12638,12658-12659,12684-12712,12714-12715,12733,12780-12783,12785-12786,12795,12797,12800-12802,12815-12816,12840-12856,12860,12882-12883,12888-12892,12897,12904,12914-12917,12922-12926,12929-12936,12939,12959-12965,12967-12971,13011,13022,13025,13031-13032,13034,13043-13046,13048-13050,13053,13056,13058,13061,13068-13070,13075,13088,13090-13091,13101,13103-13104,13106,13108-13109,13111-13114,13116-13117,13120,13125,13127-13128,13148,13153-13161,13163,13165-13166,13174-13175,13188,13190,13211-13212,13219,13221,13231-13234,13236-13238,13253,13257-13270,13272-13274,13287-13300,13302-13342,13355-13374,13377-13379,13386-13389,13391-13400,13404,13408,13410,13412,13415-13416,13420,13422-13426,13429-13432,13452,13456,13461-13464,13466,13468-13470,13472-13477,13492,13517-13519,13527-13532,13589-13590,13624-13628,13645,13661-13663,13666,13684,13689-13690,13697,13699,13704,13745,13761,13766-13767,13769-13770,13772-13801,13808,13817-13818,13820-13823,13830-13831,13838,13854,13861,13984,13986-13988,14009,14013-14015,14020-14021,14036,14039-14045,14047,14051-14053,14056-14059,14065,14072,14080-14084,14086-14090,14095-14099,14101-14121,14130-14136,14162-14167,14172-14173,14184,14215-14220,14238-14241,14266-14269,14273-14278,14285,14288-14289,14303,14305,14307,14309,14311,14313-14316,14318-14320,14322,14358,14391-14392,14444-14446,14461-14462,14472,14476-14480,14496,14498,14505-14506,14511,14515,14538-14554,14558-14574,14577-14578,14582-14597,14599-14602,14614-14616,14686-14687,14698,14702,14705,14736,14738,14740,14742-14743,14747,14784-14786,14802-14809,14812-14813,14898-14904,14908-14909,14929-14931,15014-15015,15024-15028,15032,15044-15049,15056-15058,15070,15081-15082,15087,15092-15095,15121-15125,15128-15135,15138-15139,15141,15144,15147-15148,15169-15173,15175,15182,15186-15188,15190
/branches/Branch_5_0:8892,8895,8897-8898,8900,8903-8904,8906-8907,8910,8915,8922,8924,8926,8929,8931-8933,8941,8946,8951,8955,8972-8977,8981,8997,8999,9002,9031-9032,9050,9080-9081,9084-9086,9093-9095,9102-9104,9108,9113-9115,9117-9118,9123,9125,9127-9131,9135-9136,9139,9146,9148-9150,9179-9191,9193-9195,9198,9200,9202,9204,9207,9209,9211,9213,9215,9220-9222,9231,9234-9235,9243,9251,9254,9259,9287,9315,9318,9347-9349,9358,9396,9427,9429,9431-9433,9441-9442,9444-9445,9462,9464,9468,9522-9523,9549,9551-9552,9576-9577,9579,9615,9633-9634,9672-9673,9675-9676,9684,9686-9687,9689,9699,9727,9729,9731,9930-9932,9935,9956,9980,10005-10006,10021,10024,10027,10064,10081-10082,10273,10285,10820-10824,10868,10872,10876-10878,10880,10918,11015,11017,11058-11060,11085-11086,11160-11165,11252-11253,11287,11294,11581,11619-11620,11679,11722-11723,11907,11974,12789,12940,12986,13023-13024,13086,13121-13122,13162,13465,13496,13501,13503,13660

   + /trunk:8721-8727
/shelves/aljeux:15005,15012,15150,15154-15160,15177-15179,15203
/branches/Branch_4_7:6879,6881,6884,6897,6899,6902,6904,6906,6909,6911,6922,6932,6936,6939,6942,6944,6946-6948,6954,6956,6959,7000-7001,7012,7111,7130-7131,7133-7134,7138,7140-7142,7147-7148,7159-7160,7163,7168,7177,7179,7203,7205,7207,7210,7212,7251-7253,7255,7284,7287,7291,7293,7295-7296,7300,7355,7365-7366,7375-7376,7378,7395,7423-7426,7435,7458,7504,7567,7577,7623-7624,7638,7659-7660,7662,7665,7668,7674,7699,7746-7748,7771,7774,7786,7838
/shelves/alain_peyrat:14997-15003
/branches/Branch_4_8:7334-7335,7344-7345,7382,7387,7389-7390,7396,7398,7401-7402,7428-7429,7437,7440,7443,7449-7455,7459,7462,7466,7469-7470,7476-7478,7480,7485,7490-7492,7505,7540,7556-7560,7568,7570-7571,7573,7576,7580,7609-7611,7613,7615,7618,7621-7622,7625-7627,7639,7658,7661,7663-7664,7666-7667,7673,7675,7678,7680,7685,7688-7689,7693,7700,7706-7708,7713,7725,7728-7742,7760,7763-7764,7767,7769-7770,7773,7776,7784-7785,7791,7797,7799,7802-7808,7810-7811,7816,7818,7825-7828,7839,7846-7847,7850,7894,7902,7920-7922,7927-7928,7932,7936-7937,7939,7942,7944-7945,7947,7951,7956,7958,7960,8064,8079-8080,8108,8113,8119,8121,8127-8128,8145,8197,8201-8202,8216,8224,8226,8228,8247-8250,8252,8271-8272,8310-8311,8328,8337,8339-8357,8361,8371,8373-8375,8378-8379,8383-8396,8415,8427-8431,8438-8441,8449,8452-8453,8458,8461,8477-8478,8480,8482,8492,8514,8530,8604-8605,8608,8637,8662,8674,8751,8754,8756,8760-8761,8812,8850,8945,8995,8998,9004-9006,9124,9137,9141,9317,9443,9469,9670,9701,9726,9934,10013,10310,10314,10366,12790,13085
/branches/Branch_5_1:11607-11609,11621,11625,11627,11631,11638,11644,11647-11651,11677,11680-11681,11683-11684,11719-11720,11724,11754,11780,11783,11792,11794,11802,11808-11816,11818,11822-11824,11827-11829,11834-11835,11847,11849,11851-11852,11855,11858,11862,11867,11869-11872,11876,11880,11893,11902-11905,11915,11923-11927,11929-11930,11932,11934-11941,11943,11948-11949,11952-11954,11956-11960,11962,11965-11966,11972,11975,11980,11983-11984,11986-11987,11990,11992-11997,12003-12004,12010-12013,12015,12018-12024,12043-12044,12046-12061,12063,12065,12070,12073-12076,12081-12083,12093-12094,12102,12105,12118,12124,12127-12128,12139,12141,12143,12148-12149,12153,12157-12159,12168-12169,12175-12180,12190,12194-12198,12203,12208-12213,12217-12258,12262,12264-12266,12274-12277,12281-12282,12287-12290,12340,12345-12346,12352,12359,12472-12473,12594,12634,12636-12638,12658-12659,12684-12712,12714-12715,12733,12780-12783,12785-12786,12795,12797,12800-12802,12815-12816,12840-12856,12860,12882-12883,12888-12892,12897,12904,12914-12917,12922-12926,12929-12936,12939,12959-12965,12967-12971,13011,13022,13025,13031-13032,13034,13043-13046,13048-13050,13053,13056,13058,13061,13068-13070,13075,13088,13090-13091,13101,13103-13104,13106,13108-13109,13111-13114,13116-13117,13120,13125,13127-13128,13148,13153-13161,13163,13165-13166,13174-13175,13188,13190,13211-13212,13219,13221,13231-13234,13236-13238,13253,13257-13270,13272-13274,13287-13300,13302-13342,13355-13374,13377-13379,13386-13389,13391-13400,13404,13408,13410,13412,13415-13416,13420,13422-13426,13429-13432,13452,13456,13461-13464,13466,13468-13470,13472-13477,13492,13517-13519,13527-13532,13589-13590,13624-13628,13645,13661-13663,13666,13684,13689-13690,13697,13699,13704,13745,13761,13766-13767,13769-13770,13772-13801,13808,13817-13818,13820-13823,13830-13831,13838,13854,13861,13984,13986-13988,14009,14013-14015,14020-14021,14036,14039-14045,14047,14051-14053,14056-14059,14065,14072,14080-14084,14086-14090,14095-14099,14101-14121,14130-14136,14162-14167,14172-14173,14184,14215-14220,14238-14241,14266-14269,14273-14278,14285,14288-14289,14303,14305,14307,14309,14311,14313-14316,14318-14320,14322,14358,14391-14392,14444-14446,14461-14462,14472,14476-14480,14496,14498,14505-14506,14511,14515,14538-14554,14558-14574,14577-14578,14582-14597,14599-14602,14614-14616,14686-14687,14698,14702,14705,14736,14738,14740,14742-14743,14747,14784-14786,14802-14809,14812-14813,14898-14904,14908-14909,14929-14931,15014-15015,15024-15028,15032,15044-15049,15056-15058,15070,15081-15082,15087,15092-15095,15121-15125,15128-15135,15138-15139,15141,15144,15147-15148,15169-15173,15175,15182,15186-15188,15190
/branches/Branch_5_0:8892,8895,8897-8898,8900,8903-8904,8906-8907,8910,8915,8922,8924,8926,8929,8931-8933,8941,8946,8951,8955,8972-8977,8981,8997,8999,9002,9031-9032,9050,9080-9081,9084-9086,9093-9095,9102-9104,9108,9113-9115,9117-9118,9123,9125,9127-9131,9135-9136,9139,9146,9148-9150,9179-9191,9193-9195,9198,9200,9202,9204,9207,9209,9211,9213,9215,9220-9222,9231,9234-9235,9243,9251,9254,9259,9287,9315,9318,9347-9349,9358,9396,9427,9429,9431-9433,9441-9442,9444-9445,9462,9464,9468,9522-9523,9549,9551-9552,9576-9577,9579,9615,9633-9634,9672-9673,9675-9676,9684,9686-9687,9689,9699,9727,9729,9731,9930-9932,9935,9956,9980,10005-10006,10021,10024,10027,10064,10081-10082,10273,10285,10820-10824,10868,10872,10876-10878,10880,10918,11015,11017,11058-11060,11085-11086,11160-11165,11252-11253,11287,11294,11581,11619-11620,11679,11722-11723,11907,11974,12789,12940,12986,13023-13024,13086,13121-13122,13162,13465,13496,13501,13503,13660


Modified: trunk/src/common/include/database-pgsql.php
===================================================================
--- trunk/src/common/include/database-pgsql.php	2012-03-26 08:32:06 UTC (rev 15209)
+++ trunk/src/common/include/database-pgsql.php	2012-03-26 08:52:30 UTC (rev 15210)
@@ -5,6 +5,8 @@
  * Copyright 1999-2001, VA Linux Systems, Inc.
  * Copyright 2002, GForge, LLC
  * Copyright 2009, Roland Mas
+ * Copyright (c) 2011, 2012
+ *	Thorsten Glaser <t.glaser at tarent.de>
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -160,6 +162,8 @@
  *  @return int result set handle.
  */
 function db_query_from_file($file,$limit='-1',$offset=0,$dbserver=NULL) {
+	global $sysdebug_dbquery, $sysdebug_dberrors;
+
 	db_connect_if_needed();
 	$dbconn = db_switcher($dbserver) ;
 
@@ -168,7 +172,17 @@
 
 	$qstring = file_get_contents($file);
 	if (!$qstring) {
-		error_log('db_query_from_file(): Cannot read file $file!');
+		if ($sysdebug_dbquery) {
+			ffDebug("warning",
+			    "aborted call of db_query_from_file():",
+			    "Cannot read file: " . $file .
+			    "\n\n" . debug_string_backtrace());
+		} else if ($sysdebug_dberrors) {
+			ffDebug("warning", "db_query_from_file() aborted (" .
+			    "Cannot read file: " . $file . ")", false);
+		} else {
+			error_log("db_query_from_file(): Cannot read file: " . $file);
+		}
 		return false;
 	}
 	if (!$limit || !is_numeric($limit) || $limit < 0) {
@@ -180,9 +194,19 @@
 		}
 		$qstring=$qstring." LIMIT $limit OFFSET $offset";
 	}
-	$res = @pg_query($dbconn,$qstring);
-	if (!$res) {
-		error_log('SQL: ' . preg_replace('/\n\t+/', ' ',$qstring));
+	$res = @pg_query($dbconn, $qstring);
+	if ($res) {
+		if ($sysdebug_dbquery) {
+			ffDebug("trace",
+			    "successful call of db_query_from_file(), SQL: " .
+			    $qstring, debug_string_backtrace());
+		}
+	} else if ($sysdebug_dbquery || $sysdebug_dberrors) {
+		ffDebug("warning", "db_query_from_file() failed (" .
+		    db_error($dbserver) . "), SQL: " . $qstring,
+		    $sysdebug_dbquery ? debug_string_backtrace() : false);
+	} else {
+		error_log('SQL: ' . preg_replace('/\n\t+/', ' ', $qstring));
 		error_log('SQL> ' . db_error($dbserver));
 	}
 	return $res;
@@ -199,7 +223,7 @@
  *	@return int result set handle.
  */
 function db_query_params($qstring, $params, $limit = '-1', $offset = 0, $dbserver = NULL) {
-	global $sysdebug_dbquery;
+	global $sysdebug_dbquery, $sysdebug_dberrors;
 
 	db_connect_if_needed();
 	$dbconn = db_switcher($dbserver) ;
@@ -217,17 +241,24 @@
 		$qstring=$qstring." LIMIT $limit OFFSET $offset";
 	}
 
-	$res = @pg_query_params($dbserver,$qstring,$params);
-	if ($sysdebug_dbquery) {
-		ffDebug('trace', "tracing " .
-		    ($res ? "successful" : sprintf("failed(%s)", db_error())) .
-		    " call of db_query_params():\n", debug_string_backtrace());
-		ffDebug('SQL: '.db_query_to_string($qstring,$params).'; ');
+	$res = @pg_query_params($dbserver, $qstring, $params);
+	if ($res) {
+		if ($sysdebug_dbquery) {
+			ffDebug("trace",
+			    "successful call of db_query_params():",
+			    debug_string_backtrace());
+		}
+	} else if ($sysdebug_dbquery) {
+		ffDebug("warning", "failed call of db_query_params():",
+		    db_error($dbserver) . "\n\n" . debug_string_backtrace());
+	} else if ($sysdebug_dberrors) {
+		ffDebug("warning", "db_query_params() failed (" .
+		    db_error($dbserver) . "), SQL: " . $qstring,
+		    print_r(array("params" => $params), 1));
+	} else {
+		error_log('SQL: ' . preg_replace('/\n\t+/', ' ', $qstring));
+		error_log('SQL> ' . db_error($dbserver));
 	}
-	if (!$res) {
-		error_log('SQL: ' . preg_replace('/\n\t+/', ' ',$qstring));
-		error_log('SQL> '.db_error($dbserver));
-	}
 	return $res;
 }
 

Modified: trunk/src/common/include/extras-debug.php
===================================================================
--- trunk/src/common/include/extras-debug.php	2012-03-26 08:32:06 UTC (rev 15209)
+++ trunk/src/common/include/extras-debug.php	2012-03-26 08:52:30 UTC (rev 15210)
@@ -1,5 +1,6 @@
 <?php
 
+$sysdebug_dberrors = forge_get_config('sysdebug_dberrors');
 $sysdebug_dbquery = forge_get_config('sysdebug_dbquery');
 $sysdebug_ignored = forge_get_config('sysdebug_ignored');
 if (!isset($ffErrors))

Modified: trunk/src/common/include/pre.php
===================================================================
--- trunk/src/common/include/pre.php	2012-03-26 08:32:06 UTC (rev 15209)
+++ trunk/src/common/include/pre.php	2012-03-26 08:52:30 UTC (rev 15210)
@@ -161,6 +161,8 @@
 forge_set_config_item_bool ('sysdebug_backtraces', 'core') ;
 forge_define_config_item ('sysdebug_ignored', 'core', 'false') ;
 forge_set_config_item_bool ('sysdebug_ignored', 'core') ;
+forge_define_config_item ('sysdebug_dberrors', 'core', 'true') ;
+forge_set_config_item_bool ('sysdebug_dberrors', 'core') ;
 forge_define_config_item ('sysdebug_dbquery', 'core', 'false') ;
 forge_set_config_item_bool ('sysdebug_dbquery', 'core') ;
 forge_define_config_item ('sysdebug_xmlstarlet', 'core', 'false') ;
@@ -207,6 +209,7 @@
 if ($sysdebug_enable && getenv('SERVER_SOFTWARE')) {
 	require $gfcommon.'include/extras-debug.php';
 } else {
+	$sysdebug_dberrors = false;
 	$sysdebug_dbquery = false;
 
 	function sysdebug_off($hdr=false, $replace=true, $resp=false) {

Modified: trunk/src/etc/config.ini.d/debug.ini
===================================================================
--- trunk/src/etc/config.ini.d/debug.ini	2012-03-26 08:32:06 UTC (rev 15209)
+++ trunk/src/etc/config.ini.d/debug.ini	2012-03-26 08:52:30 UTC (rev 15210)
@@ -15,7 +15,9 @@
 ; also report (display) ignored errors, e.g. from @call
 sysdebug_ignored = false
 
-; tracing (if sysdebug_enable)
+; report errors to pink-popup instead of syslog (if sysdebug_enable)
+sysdebug_dberrors = true
+; tracing (if sysdebug_enable); implies sysdebug_dberrors
 sysdebug_dbquery = false
 
 ; output validation (if sysdebug_enable)




More information about the Fusionforge-commits mailing list