[CalendarServer-changes] [8120] CalendarServer/trunk/txdav/common/datastore/sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 26 12:44:23 PDT 2011
Revision: 8120
http://trac.macosforge.org/projects/calendarserver/changeset/8120
Author: cdaboo at apple.com
Date: 2011-09-26 12:44:23 -0700 (Mon, 26 Sep 2011)
Log Message:
-----------
Fix doc strings and make sure diagnostic output can be redirected.
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/sql.py
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2011-09-26 17:16:16 UTC (rev 8119)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2011-09-26 19:44:23 UTC (rev 8120)
@@ -81,6 +81,7 @@
from sqlparse import parse
import collections
+import sys
import time
current_sql_schema = getModule(__name__).filePath.sibling("sql_schema").child("current.sql").getContent()
@@ -189,22 +190,22 @@
self.statement = None
self.tstamp = None
- def printReport(self):
+ def printReport(self, toFile=sys.stdout):
- print "*** SQL Stats ***"
- print
- print "Unique statements: %d" % (len(self.count,),)
- print "Total statements: %d" % (sum(self.count.values()),)
- print "Total time (ms): %.3f" % (sum(self.times.values()) * 1000.0,)
- print
+ toFile.write("*** SQL Stats ***\n")
+ toFile.write("\n")
+ toFile.write("Unique statements: %d\n" % (len(self.count,),))
+ toFile.write("Total statements: %d\n" % (sum(self.count.values()),))
+ toFile.write("Total time (ms): %.3f\n" % (sum(self.times.values()) * 1000.0,))
+ toFile.write("\n")
for k, v in self.count.items():
- print k
- print "Count: %s" % (v,)
- print "Total Time (ms): %.3f" % (self.times[k] * 1000.0,)
+ toFile.write("%s\n" % (k,))
+ toFile.write("Count: %s\n" % (v,))
+ toFile.write("Total Time (ms): %.3f\n" % (self.times[k] * 1000.0,))
if v > 1:
- print "Average Time (ms): %.3f" % (self.times[k] * 1000.0 / v,)
- print
- print "***"
+ toFile.write("Average Time (ms): %.3f\n" % (self.times[k] * 1000.0 / v,))
+ toFile.write("\n")
+ toFile.write("***\n")
class CommonStoreTransaction(object):
"""
@@ -248,6 +249,7 @@
self.paramstyle = sqlTxn.paramstyle
self.dialect = sqlTxn.dialect
+ # FIXME: want to pass a "debug" option in to enable this via config - off for now
self._stats = None #TransactionStatsCollector()
@@ -423,6 +425,9 @@
"""
Execute a block of SQL by parsing it out into individual statements and execute
each of those.
+
+ FIXME: temporary measure for handling large schema upgrades. This should NOT be used
+ for regular SQL operations - only upgrades.
"""
parsed = parse(sql)
for stmt in parsed:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110926/790e7466/attachment-0001.html>
More information about the calendarserver-changes
mailing list