[boinc] 01/02: Investigating implementation of db abstraction layer
Steffen Möller
moeller at moszumanska.debian.org
Thu Nov 28 14:37:06 UTC 2013
This is an automated email from the git hooks/post-receive script.
moeller pushed a commit to branch master
in repository boinc.
commit b95cbabf5f1848b191b18569e4fcfb9644539956
Author: Steffen Moeller <steffen_moeller at gmx.de>
Date: Thu Nov 28 15:31:29 2013 +0100
Investigating implementation of db abstraction layer
Seems straight forward, motivation is introduction of mysqli,
in contact with upstream about it.
---
debian/patches/db_interface_use.patch | 204 ++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 205 insertions(+)
diff --git a/debian/patches/db_interface_use.patch b/debian/patches/db_interface_use.patch
new file mode 100644
index 0000000..5af83a6
--- /dev/null
+++ b/debian/patches/db_interface_use.patch
@@ -0,0 +1,204 @@
+Index: boinc/html/inc/db_conn.inc
+===================================================================
+--- boinc.orig/html/inc/db_conn.inc
++++ boinc/html/inc/db_conn.inc
+@@ -56,7 +56,7 @@
+ return mysql_affected_rows($this->db_conn);
+ }
+
+- function lookup_fields($table, $classname, $fields, $clause) {
++ function lookup_fields($table, $classname="stdClass", $fields, $clause) {
+ $query = "select $fields from ".$this->db_name.".$table where $clause";
+ $result = $this->do_query($query);
+ if (!$result) {
+@@ -67,7 +67,7 @@
+ return $obj;
+ }
+
+- function lookup($table, $classname, $clause) {
++ function lookup($table, $classname="stdClass", $clause) {
+ $query = "select * from ".$this->db_name.".$table where $clause";
+ $result = $this->do_query($query);
+ if (!$result) {
+@@ -78,11 +78,11 @@
+ return $obj;
+ }
+
+- function lookup_id($id, $table, $classname) {
++ function lookup_id($id, $table, $classname="stdClass") {
+ return $this->lookup($table, $classname, "id=$id");
+ }
+
+- function enum_general($classname, $query) {
++ function enum_general($classname="stdClass", $query) {
+ $result = $this->do_query($query);
+ if (!$result) return null;
+ $x = array();
+@@ -91,6 +91,17 @@
+ }
+ mysql_free_result($result);
+ return $x;
++ }
++
++ function enum_general_assoc($query) {
++ $result = $this->do_query($query);
++ if (!$result) return null;
++ $x = array();
++ while ($row = mysql_fetch_assoc($result)) {
++ $x[] = $row;
++ }
++ mysql_free_result($result);
++ return $x;
+ }
+
+ function enum_fields(
+Index: boinc/html/user/server_status.php
+===================================================================
+--- boinc.orig/html/user/server_status.php
++++ boinc/html/user/server_status.php
+@@ -129,26 +129,20 @@
+ return 0;
+ }
+
+-function get_mysql_count($query) {
+- $count = unserialize(get_cached_data(3600, "get_mysql_count".$query));
++function get_mysql_count($table,$clause) {
++ $count = unserialize(get_cached_data(3600, "get_mysql_count".$table."_where_".$clause));
+ if ($count == false) {
+- $result = mysql_query("select count(*) as count from " . $query);
+- $count = mysql_fetch_object($result);
+- mysql_free_result($result);
+- $count = $count->count;
+- set_cached_data(3600, serialize($count), "get_mysql_count".$query);
++ $count = count($table,$clause);
++ set_cached_data(3600, serialize($count), "get_mysql_count".$table."_where_".$clause);
+ }
+ return $count;
+ }
+
+-function get_mysql_value($query) {
+- $value = unserialize(get_cached_data(3600, "get_mysql_value".$query));
++function get_mysql_sum($table,$attribute) {
++ $value = unserialize(get_cached_data(3600, "get_mysql_sum".$table."_".$attribute));
+ if ($value == false) {
+- $result = mysql_query($query);
+- $row = mysql_fetch_object($result);
+- mysql_free_result($result);
+- $value = $row->value;
+- set_cached_data(3600, serialize($value), "get_mysql_value".$query);
++ $value = sum($table,$attribute);
++ set_cached_data(3600, serialize($value), "get_mysql_sum".$table."_".$attribute);
+ }
+ return $value;
+ }
+@@ -156,12 +150,7 @@
+ function get_mysql_assoc($query) {
+ $assoc = unserialize(get_cached_data(3600, "get_mysql_assoc".$query));
+ if ($assoc == false) {
+- $sql = "SELECT * FROM app WHERE deprecated != 1";
+- $result = mysql_query($sql);
+- while($row = mysql_fetch_assoc($result)) {
+- $assoc[] = $row;
+- }
+- mysql_free_result($result);
++ $assoc = enum_general_assoc(query);
+ set_cached_data(3600, serialize($assoc), "get_mysql_assoc".$query);
+ }
+ return $assoc;
+@@ -340,32 +329,32 @@
+ show_counts(
+ tra("Tasks ready to send"),
+ "results_ready_to_send",
+- get_mysql_count("result where server_state = 2")
++ get_mysql_count("result","server_state = 2")
+ );
+ show_counts(
+ tra("Tasks in progress"),
+ "results_in_progress",
+- get_mysql_count("result where server_state = 4")
++ get_mysql_count("result","server_state = 4")
+ );
+ show_counts(
+ tra("Workunits waiting for validation"),
+ "workunits_waiting_for_validation",
+- get_mysql_count("workunit where need_validate=1")
++ get_mysql_count("workunit","need_validate=1")
+ );
+ show_counts(
+ tra("Workunits waiting for assimilation"),
+ "workunits_waiting_for_assimilation",
+- get_mysql_count("workunit where assimilate_state=1")
++ get_mysql_count("workunit","assimilate_state=1")
+ );
+ show_counts(
+ tra("Workunits waiting for file deletion"),
+ "workunits_waiting_for_deletion",
+- get_mysql_count("workunit where file_delete_state=1")
++ get_mysql_count("workunit","file_delete_state=1")
+ );
+ show_counts(
+ tra("Tasks waiting for file deletion"),
+ "results_waiting_for_deletion",
+- get_mysql_count("result where file_delete_state=1")
++ get_mysql_count("result","file_delete_state=1")
+ );
+
+ $gap = unserialize(get_cached_data(3600, "transitioner_backlog"));
+@@ -391,39 +380,39 @@
+ show_counts(
+ tra("with recent credit"),
+ "users_with_recent_credit",
+- get_mysql_count("user where expavg_credit>1")
++ get_mysql_count("user","expavg_credit>1")
+ );
+ show_counts(
+ tra("with credit"),
+ "users_with_credit",
+- get_mysql_count("user where total_credit>0")
++ get_mysql_count("user","total_credit>0")
+ );
+ show_counts(
+ tra("registered in past 24 hours"),
+ "users_registered_in_past_24_hours",
+- get_mysql_count("user where create_time > (unix_timestamp() - (24*3600))")
++ get_mysql_count("user","create_time > (unix_timestamp() - (24*3600))")
+ );
+ echo "<tr><th>".tra("Computers")."</th><th>#</th></tr>";
+ show_counts(
+ tra("with recent credit"),
+ "hosts_with_recent_credit",
+- get_mysql_count("host where expavg_credit>1")
++ get_mysql_count("host","expavg_credit>1")
+ );
+ show_counts(
+ tra("with credit"),
+ "hosts_with_credit",
+- get_mysql_count("host where total_credit>0")
++ get_mysql_count("host","total_credit>0")
+ );
+ show_counts(
+ tra("registered in past 24 hours"),
+ "hosts_registered_in_past_24_hours",
+- get_mysql_count("host where create_time > (unix_timestamp() - (24*3600))")
++ get_mysql_count("host","create_time > (unix_timestamp() - (24*3600))")
+ );
+ // 200 cobblestones = 1 GigaFLOPS
+ show_counts(
+ tra("current GigaFLOPs"),
+ "current_floating_point_speed",
+- get_mysql_value("SELECT sum(expavg_credit)/200 as value FROM user")
++ get_mysql_sum("user","expavg_credit")/200
+ );
+
+ end_table();
+@@ -445,8 +434,8 @@
+ $appid = $app["id"];
+ $uf_name = $app["user_friendly_name"];
+ echo "<tr><td>$uf_name</td>
+- <td>" . number_format(get_mysql_count("result where server_state = 2 and appid = $appid")) . "</td>
+- <td>" . number_format(get_mysql_count("result where server_state = 4 and appid = $appid")) . "</td>
++ <td>" . number_format(get_mysql_count("result","server_state = 2 and appid = $appid")) . "</td>
++ <td>" . number_format(get_mysql_count("result","server_state = 4 and appid = $appid")) . "</td>
+ <td>"
+ ;
+ $info = get_runtime_info($appid);
diff --git a/debian/patches/series b/debian/patches/series
index 4c02662..185a037 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,5 @@
# patches to get Debian going
+db_interface_use.patch
make_project_overcomes_Apache24_security.patch
libnotify-0.7.patch
# undisputed patches above
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-boinc/boinc.git
More information about the pkg-boinc-commits
mailing list