Added stub for database query profiling.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 5 Jan 2015 12:42:03 +0000 (13:42 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 8 Jan 2015 16:45:54 +0000 (17:45 +0100)
includes/db/connect_db.inc
includes/db/connect_db_mysql.inc
includes/db/connect_db_mysqli.inc
sql/alter2.4.php

index 91be72ce780aafc9121114644fd78294769a5fe7..98a18f59824085e7ca0f20366132549271904720 100644 (file)
@@ -116,4 +116,12 @@ function db_get_default_charset()
        return $var[0];
 }
 
-       
+/*
+       SQL db profiling stub
+*/
+if (!function_exists('db_profile'))
+{
+       function db_profile($sql=false)
+       {
+       }
+}
\ No newline at end of file
index e574362e1a6f23f280eaedbb26888df05fcc552c..6767cb25379dbd211fc109e6c35a00fa1925c882 100644 (file)
@@ -46,7 +46,7 @@ function db_query($sql, $err_msg=null)
 {
        global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax,
                $db_connections, $db_last_inserted_id;
-       
+
        // set current db prefix
        $comp = isset($_SESSION["wa_current_user"]->cur_con) ? $_SESSION["wa_current_user"]->cur_con : 0;
        $cur_prefix = $db_connections[$comp]['tbpref'];
@@ -58,17 +58,12 @@ function db_query($sql, $err_msg=null)
                $sql_queries .= "<pre>$sql</pre>\n<hr>";
        }
 
-       // mysql profiling
-       global $profile_sql;
-       if (@$profile_sql) 
-               get_usec();
+       db_profile(); // mysql profiling
+
        $result = mysql_query($sql, $db);
-       if (@$profile_sql)
-       {
-               $profile_sql= false;
-               _vd($sql.'<br>:'.db_num_rows($result).'rows, '.get_usec());
-       }
-       
+
+       db_profile($sql);
+
        if($sql_trail) {
                $db_last_inserted_id = mysql_insert_id($db);    // preserve in case trail insert is done
                if ($select_trail || (strstr($sql, 'SELECT') === false)) {
index c5c1d69b761ff3814ee1eeb6a032503bc8c597b8..bb452f2b2faa95543c51f21cbffce9c75f69954f 100644 (file)
@@ -9,6 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+define('SQL_MODE', 'STRICT_ALL_TABLES,NO_ZERO_IN_DATE');
 
 function set_global_connection($company=-1)
 {
@@ -32,8 +33,8 @@ function set_global_connection($company=-1)
        ///// This non empty sql_mode values can interphere with FA, so all is set empty during
        ///// our sessions.
        ///// We are, however, investigating the existing code to be compatible in the future.
-       if (strncmp(db_get_version(), "5.6", 3) >= 0) 
-               db_query("SET sql_mode = ''");
+//     if (strncmp(db_get_version(), "5.6", 3) >= 0) 
+               db_query("SET sql_mode = '".SQL_MODE."'");
        /////
        return $db;
 }
@@ -58,17 +59,12 @@ function db_query($sql, $err_msg=null)
                $sql_queries .= "<pre>$sql</pre>\n<hr>";
        }
 
-       // mysql profiling
-       global $profile_sql;
-       if (@$profile_sql) 
-               get_usec();
+       db_profile(); // mysql profiling
+
        $result = mysqli_query($db, $sql);
-       if (@$profile_sql)
-       {
-               $profile_sql= false;
-               _vd($sql.'<br>:'.db_num_rows($result).'rows, '.get_usec());
-       }
-       
+
+       db_profile($sql);
+
        if($sql_trail) {
                $db_last_inserted_id = mysqli_insert_id($db);   // preserve in case trail insert is done
                if ($select_trail || (strstr($sql, 'SELECT') === false)) {
index 5f87259ac3586a0a8afed6c5461d4b55f4e1fde5..c51f19962c7a347ee82d4abbafa951006674b8be 100644 (file)
@@ -146,7 +146,7 @@ class fa2_4 {
                 // site default encoding is presumed as encoding for all databases!
                $lang = array_search_value($dflt_lang, $installed_languages, 'code');
                $new_encoding = get_mysql_encoding_name(strtoupper($lang['encoding']));
-       //      get_usec();
+
                if ($test)
                        error_log('Switching database to utf8 encoding from '.$old_encoding);
                $collation = get_mysql_collation();
@@ -154,7 +154,6 @@ class fa2_4 {
                $tresult = db_query($tsql, "Cannot select all tables with prefix '$pref'");
                while($tbl = db_fetch($tresult)) {
                        $table = $tbl[0];
-               // if ($table != '1_chart_master') continue; _vd($table); get_usec(); // fast debug on single table
 
                        db_query("ALTER TABLE `$table` CONVERT TO CHARACTER SET $old_encoding"); // convert encoding on utf-8 tables