Skip to content

Commit

Permalink
change mysql table definitions to BLOB, MEDIUMBLOB
Browse files Browse the repository at this point in the history
* the mentioned maximum row length of 64kb in MyISAM does not include
  BLOBish fields.

  http://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html
    The maximum size of a row in a MyISAM table is 65,535 bytes. This
    figure excludes BLOB or TEXT columns, which contribute only 9 to 12
    bytes toward this size.

* change from TEXT to BLOB since we store binary data. we do not want
  MySQL to try to convert charsets if the connection charset differs
  from the table charset. This is most obvious for the compressed data
  but also applies to our ordinary serialization
* change to MEDIUMBLOB for perfdata since it lessens the chance of
  truncation bugs and only adds 1 byte per row to the fixed storage
  requirement
* remove mention of MySQL/MyISAM specific requirements from other DB
  classes
  • Loading branch information
chrono authored and preinheimer committed Apr 22, 2011
1 parent 1488106 commit 9af7df6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
9 changes: 4 additions & 5 deletions xhprof_lib/utils/xhprof_runs.php
Expand Up @@ -115,11 +115,11 @@ protected function db()
`c_url` varchar(255) default NULL, `c_url` varchar(255) default NULL,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`server name` varchar(64) default NULL, `server name` varchar(64) default NULL,
`perfdata` text, `perfdata` MEDIUMBLOB,
`type` tinyint(4) default NULL, `type` tinyint(4) default NULL,
`cookie` text, `cookie` BLOB,
`post` text, `post` BLOB,
`get` text, `get` BLOB,
`pmu` int(11) default NULL, `pmu` int(11) default NULL,
`wt` int(11) default NULL, `wt` int(11) default NULL,
`cpu` int(11) default NULL, `cpu` int(11) default NULL,
Expand Down Expand Up @@ -412,7 +412,6 @@ public function save_run($xhprof_data, $type, $run_id = null, $xhprof_details =
$sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : ''; $sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';




//The MyISAM table type has a maxmimum row length of 65,535bytes, without compression XHProf data can exceed that.
// The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on // The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on
// full production code. // full production code.
$sql['data'] = mysqli_real_escape_string($this->linkID, gzcompress(serialize($xhprof_data), 2)); $sql['data'] = mysqli_real_escape_string($this->linkID, gzcompress(serialize($xhprof_data), 2));
Expand Down
1 change: 0 additions & 1 deletion xhprof_lib/utils/xhprof_runs_mssql.php
Expand Up @@ -415,7 +415,6 @@ public function save_run($xhprof_data, $type, $run_id = null, $xhprof_details =
$sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : ''; $sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';




//The MyISAM table type has a maxmimum row length of 65,535bytes, without compression XHProf data can exceed that.
// The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on // The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on
// full production code. // full production code.
$sql['data'] = addslashes(gzcompress(serialize($xhprof_data), 2)); $sql['data'] = addslashes(gzcompress(serialize($xhprof_data), 2));
Expand Down
9 changes: 4 additions & 5 deletions xhprof_lib/utils/xhprof_runs_mysql.php
Expand Up @@ -106,11 +106,11 @@ protected function db()
`c_url` varchar(255) default NULL, `c_url` varchar(255) default NULL,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`server name` varchar(64) default NULL, `server name` varchar(64) default NULL,
`perfdata` text, `perfdata` MEDIUMBLOB,
`type` tinyint(4) default NULL, `type` tinyint(4) default NULL,
`cookie` text, `cookie` BLOB,
`post` text, `post` BLOB,
`get` text, `get` BLOB,
`pmu` int(11) default NULL, `pmu` int(11) default NULL,
`wt` int(11) default NULL, `wt` int(11) default NULL,
`cpu` int(11) default NULL, `cpu` int(11) default NULL,
Expand Down Expand Up @@ -403,7 +403,6 @@ public function save_run($xhprof_data, $type, $run_id = null, $xhprof_details =
$sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : ''; $sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';




//The MyISAM table type has a maxmimum row length of 65,535bytes, without compression XHProf data can exceed that.
// The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on // The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on
// full production code. // full production code.
$sql['data'] = mysql_real_escape_string(gzcompress(serialize($xhprof_data), 2)); $sql['data'] = mysql_real_escape_string(gzcompress(serialize($xhprof_data), 2));
Expand Down
9 changes: 4 additions & 5 deletions xhprof_lib/utils/xhprof_runs_mysqli.php
Expand Up @@ -106,11 +106,11 @@ protected function db()
`c_url` varchar(255) default NULL, `c_url` varchar(255) default NULL,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`server name` varchar(64) default NULL, `server name` varchar(64) default NULL,
`perfdata` text, `perfdata` MEDIUMBLOB,
`type` tinyint(4) default NULL, `type` tinyint(4) default NULL,
`cookie` text, `cookie` BLOB,
`post` text, `post` BLOB,
`get` text, `get` BLOB,
`pmu` int(11) default NULL, `pmu` int(11) default NULL,
`wt` int(11) default NULL, `wt` int(11) default NULL,
`cpu` int(11) default NULL, `cpu` int(11) default NULL,
Expand Down Expand Up @@ -403,7 +403,6 @@ public function save_run($xhprof_data, $type, $run_id = null, $xhprof_details =
$sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : ''; $sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';




//The MyISAM table type has a maxmimum row length of 65,535bytes, without compression XHProf data can exceed that.
// The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on // The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on
// full production code. // full production code.
$sql['data'] = mysqli_real_escape_string($this->linkID, gzcompress(serialize($xhprof_data), 2)); $sql['data'] = mysqli_real_escape_string($this->linkID, gzcompress(serialize($xhprof_data), 2));
Expand Down
1 change: 0 additions & 1 deletion xhprof_lib/utils/xhprof_runs_sqlsrv.php
Expand Up @@ -436,7 +436,6 @@ public function save_run($xhprof_data, $type, $run_id = null, $xhprof_details =
$sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : ''; $sql['cpu'] = isset($xhprof_data['main()']['cpu']) ? $xhprof_data['main()']['cpu'] : '';




//The MyISAM table type has a maxmimum row length of 65,535bytes, without compression XHProf data can exceed that.
// The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on // The value of 2 seems to be light enugh that we're not killing the server, but still gives us lots of breathing room on
// full production code. // full production code.
$sql['data'] = gzcompress(serialize($xhprof_data), 2); $sql['data'] = gzcompress(serialize($xhprof_data), 2);
Expand Down

0 comments on commit 9af7df6

Please sign in to comment.