[prev in list] [next in list] [prev in thread] [next in thread]
List: calendarserver-changes
Subject: [CalendarServer-changes] [8802] CalendarServer/branches/users/glyph/case-insensitive-uid
From: source_changes () macosforge ! org
Date: 2012-02-29 18:16:38
Message-ID: 20120229181638.5AB2057C85A7 () lists ! macosforge ! org
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Revision: 8802
http://trac.macosforge.org/projects/calendarserver/changeset/8802
Author: glyph@apple.com
Date: 2012-02-29 10:16:38 -0800 (Wed, 29 Feb 2012)
Log Message:
-----------
Update everywhere that touches something == OWNER_UID to instead do Lower(something) \
== OWNER_UID. Also, make notification homes case-insensitive as well.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py
CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/case-insensitive-uid/
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -62,6 +62,7 @@
import os
import sys
import time
+from twext.enterprise.dal.syntax import Lower
def usage(e=None):
if e:
@@ -266,7 +267,7 @@
cb, type="inner", on=(ch.RESOURCE_ID == \
cb.CALENDAR_HOME_RESOURCE_ID).And( cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == \
co.CALENDAR_RESOURCE_ID)),
- Where=(ch.OWNER_UID == Parameter("UID"))
+ Where=(ch.OWNER_UID == Lower(Parameter("UID")))
).on(self.txn, **kwds))
returnValue(int(rows[0][0]) if rows else 0)
@@ -339,7 +340,7 @@
cb, type="inner", on=(ch.RESOURCE_ID == \
cb.CALENDAR_HOME_RESOURCE_ID)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == \
co.CALENDAR_RESOURCE_ID).And( cb.BIND_MODE == _BIND_MODE_OWN).And(
- cb.CALENDAR_RESOURCE_NAME != "inbox")),
+ cb.CALENDAR_RESOURCE_NAME != Lower("inbox"))),
GroupBy=(ch.OWNER_UID, co.RESOURCE_ID, co.ICALENDAR_UID, co.MD5, \
co.ORGANIZER,), ).on(self.txn, **kwds))
returnValue(tuple(rows))
@@ -352,9 +353,9 @@
ch = schema.CALENDAR_HOME
kwds = {"uuid": uuid}
if len(uuid) != 36:
- where = (ch.OWNER_UID.StartsWith(Parameter("uuid")))
+ where = (ch.OWNER_UID.StartsWith(Lower(Parameter("uuid"))))
else:
- where = (ch.OWNER_UID == Parameter("uuid"))
+ where = (ch.OWNER_UID == Lower(Parameter("uuid")))
rows = (yield Select(
[ch.OWNER_UID, co.RESOURCE_ID, co.ICALENDAR_UID, co.MD5, co.ORGANIZER,],
From=ch.join(
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -43,6 +43,7 @@
import os
import sys
import traceback
+from twext.enterprise.dal.syntax import Lower
def usage(e=None):
if e:
@@ -520,7 +521,7 @@
cb, type="inner", on=(ch.RESOURCE_ID == \
cb.CALENDAR_HOME_RESOURCE_ID).And( cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == \
co.CALENDAR_RESOURCE_ID)),
- Where=(ch.OWNER_UID == Parameter("UID")),
+ Where=(ch.OWNER_UID == Lower(Parameter("UID"))),
).on(txn, **{"UID": uid}))
returnValue(tuple(rows))
@@ -571,7 +572,7 @@
cb, type="inner", on=(ch.RESOURCE_ID == \
cb.CALENDAR_HOME_RESOURCE_ID).And( cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == \
co.CALENDAR_RESOURCE_ID)),
- Where=((ch.OWNER_UID == Parameter("UID")).And(cb.CALENDAR_RESOURCE_NAME \
== Parameter("NAME"))), + Where=((ch.OWNER_UID == \
Lower(Parameter("UID"))).And(cb.CALENDAR_RESOURCE_NAME == Parameter("NAME"))), \
).on(txn, **{"UID": uid, "NAME": name})) returnValue(tuple(rows))
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -109,7 +109,7 @@
%(object_name)s = '%(resource)s' and %(object_bind_id)s = (
select %(bind_id)s from %(bind_table)s where
%(bind_name)s = '%(collection)s' and %(bind_home_id)s = (
- select RESOURCE_ID from %(home_table)s where OWNER_UID = '%(uid)s'
+ select RESOURCE_ID from %(home_table)s where OWNER_UID = \
lower('%(uid)s') )
);""" % sqlstrings[datatype]
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -71,6 +71,7 @@
from twext.enterprise.dal.syntax import SavepointAction
from twext.enterprise.dal.syntax import Select
from twext.enterprise.dal.syntax import Update
+from twext.enterprise.dal.syntax import Lower
from txdav.base.propertystore.base import PropertyName
from txdav.base.propertystore.none import PropertyStore as NonePropertyStore
@@ -842,7 +843,7 @@
def _resourceIDFromOwnerQuery(cls): #@NoSelf
home = cls._homeSchema
return Select([home.RESOURCE_ID],
- From=home, Where=home.OWNER_UID == Parameter("ownerUID"))
+ From=home, Where=home.OWNER_UID == \
Lower(Parameter("ownerUID")))
@classproperty
def _ownerFromFromResourceID(cls): #@NoSelf
@@ -909,7 +910,7 @@
try:
resourceid = (yield Insert(
{
- cls._homeSchema.OWNER_UID: uid,
+ cls._homeSchema.OWNER_UID: Lower(uid),
cls._homeSchema.DATAVERSION: cls._dataVersionValue,
},
Return=cls._homeSchema.RESOURCE_ID).on(txn))[0][0]
@@ -3008,11 +3009,11 @@
_resourceIDFromUIDQuery = Select(
[_homeSchema.RESOURCE_ID], From=_homeSchema,
- Where=_homeSchema.OWNER_UID == Parameter("uid"))
+ Where=_homeSchema.OWNER_UID == Lower(Parameter("uid")))
_provisionNewNotificationsQuery = Insert(
- {_homeSchema.OWNER_UID: Parameter("uid")},
+ {_homeSchema.OWNER_UID: Lower(Parameter("uid"))},
Return=_homeSchema.RESOURCE_ID
)
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -56,6 +56,7 @@
from pycalendar.duration import PyCalendarDuration
+from twext.enterprise.dal.syntax import Lower
log = Logger()
@@ -220,7 +221,8 @@
inv = schema.INVITE
home = cls._homeSchema
return cls._allColumnsQuery(
- (inv.RESOURCE_ID == Parameter("resourceID")).And(home.OWNER_UID == \
Parameter("principalUID")) + (inv.RESOURCE_ID == Parameter("resourceID"))
+ .And(home.OWNER_UID == Lower(Parameter("principalUID")))
)
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -90,7 +90,8 @@
create table NOTIFICATION_HOME (
RESOURCE_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- \
implicit index
- OWNER_UID varchar(255) not null unique -- \
implicit index + OWNER_UID varchar(255) not null unique, \
-- implicit index + constraint NOTIFICATION_HOME_CASE check(OWNER_UID = \
lower(OWNER_UID)) );
create table NOTIFICATION (
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -27,3 +27,8 @@
alter table ADDRESSBOOK_HOME
add constraint ADDRESSBOOK_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
+
+update NOTIFICATION_HOME set OWNER_UID = lower(OWNER_UID);
+
+alter table NOTIFICATION_HOME
+add constraint NOTIFICATION_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -27,3 +27,8 @@
alter table ADDRESSBOOK_HOME
add constraint ADDRESSBOOK_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
+
+update NOTIFICATION_HOME set OWNER_UID = lower(OWNER_UID);
+
+alter table NOTIFICATION_HOME
+add constraint NOTIFICATION_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py 2012-02-29 \
18:16:38 UTC (rev 8802) @@ -322,6 +322,7 @@
# that differ only by case and re-name one of them to 'x.old'.
yield self.renameCaseDuplicates(sqlTxn, 'CALENDAR')
yield self.renameCaseDuplicates(sqlTxn, 'ADDRESSBOOK')
+ yield self.renameCaseDuplicates(sqlTxn, 'NOTIFICATION')
yield sqlTxn.execSQLBlock(sql)
if caseFix:
# This does not fit neatly into the existing upgrade machinery,
@@ -329,7 +330,7 @@
# upgrade system could take something like this into account,
# though.
yield self.mergeCaseDuplicates(sqlTxn, 'CALENDAR')
- yield self.mergeCaseDuplicates(sqlTxn, 'ADDRESSBOOK')
+ # yield self.mergeCaseDuplicates(sqlTxn, 'ADDRESSBOOK')
yield sqlTxn.commit()
except RuntimeError:
yield sqlTxn.abort()
@@ -341,15 +342,17 @@
"""
Re-name case duplicates.
- Prior to schema version 9, home UIDs were case-sensitive.
+ Prior to schema version 9, home UIDs were case-sensitive. This method
+ re-names any names which are equivalent except for case differences, so
+ that adding the uniform-case constraint will succeed.
@param type: The type of home to scan; 'CALENDAR' or 'ADDRESSBOOK'
@type type: C{str}
"""
- # This is using the most recent 'schema' object, which happens to work for
- # the moment, but will fail if the schema changes too radically. Ideally
- # this should be pointed at a schema object parsed from an older version of
- # the schema.
+ # This is using the most recent 'schema' object, which happens to work
+ # for the moment, but will fail if the schema changes too radically.
+ # Ideally this should be pointed at a schema object parsed from an older
+ # version of the schema.
home = getattr(schema, type + '_HOME')
left = home.alias()
right = home.alias()
@@ -368,6 +371,7 @@
both.sort(key=lambda x: x[1])
# Note: determineNewest may return None sometimes.
older = both[0][0]
+ self.log_warn("Moving aside case-duplicate home " + repr(older))
yield Update({home.OWNER_UID: _CASE_DUPLICATE_PREFIX + older},
Where=home.OWNER_UID == older).on(sqlTxn)
@@ -375,8 +379,8 @@
@inlineCallbacks
def mergeCaseDuplicates(self, sqlTxn, type):
"""
- Merge together homes which were previously case-duplicates of each other,
- once the schema is upgraded.
+ Merge together homes which were previously case-duplicates of each
+ other, once the schema is upgraded.
"""
home = getattr(schema, type + '_HOME')
oldHomes = yield Select(
@@ -414,6 +418,15 @@
@param type: The type of home to scan; 'CALENDAR' or 'ADDRESSBOOK'
@type type: C{str}
"""
+ if type == 'NOTIFICATION':
+ return Select(
+ [Max(schema.NOTIFICATION.MODIFIED)],
+ From=schema.NOTIFICATION_HOME.join(
+ schema.NOTIFICATION,
+ on=schema.NOTIFICATION_HOME.RESOURCE_ID ==
+ schema.NOTIFICATION.NOTIFICATION_HOME_RESOURCE_ID),
+ Where=schema.NOTIFICATION_HOME.OWNER_UID == uid
+ )
home = getattr(schema, type + "_HOME")
bind = getattr(schema, type + "_BIND")
child = getattr(schema, type)
[Attachment #5 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[8802] CalendarServer/branches/users/glyph/case-insensitive-uid</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://trac.macosforge.org/projects/calendarserver/changeset/8802">8802</a></dd>
<dt>Author</dt> <dd>glyph@apple.com</dd>
<dt>Date</dt> <dd>2012-02-29 10:16:38 -0800 (Wed, 29 Feb 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update everywhere that touches something == OWNER_UID to instead do \
Lower(something) == OWNER_UID. Also, make notification homes case-insensitive as \
well.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidcalendarservertoolscal \
verifypy">CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidcalendarservertoolsdb \
inspectpy">CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidcontribtoolssqldata_f \
rom_pathpy">CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastores \
qlpy">CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastores \
ql_legacypy">CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastores \
ql_schemacurrentsql">CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastores \
ql_schemaupgradesoracledialectupgrade_from_8_to_9sql">CalendarServer/branches/users/gl \
yph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastores \
ql_schemaupgradespostgresdialectupgrade_from_8_to_9sql">CalendarServer/branches/users/ \
glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql</a></li>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoreu \
pgradesqlupgradepy">CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServerbranchesusersglyphcaseinsensitiveuid">CalendarServer/branches/users/glyph/case-insensitive-uid/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidcalendarservertoolscalverifypy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/calverify.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> import os
</span><span class="cx"> import sys
</span><span class="cx"> import time
</span><ins>+from twext.enterprise.dal.syntax import Lower
</ins><span class="cx">
</span><span class="cx"> def usage(e=None):
</span><span class="cx"> if e:
</span><span class="lines">@@ -266,7 +267,7 @@
</span><span class="cx"> cb, type="inner", \
on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And( </span><span class="cx"> \
cb.BIND_MODE == _BIND_MODE_OWN)).join( </span><span class="cx"> co, \
type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)), \
</span><del>- Where=(ch.OWNER_UID == Parameter("UID")) \
</del><ins>+ Where=(ch.OWNER_UID == Lower(Parameter("UID"))) \
</ins><span class="cx"> ).on(self.txn, **kwds)) </span><span class="cx"> \
returnValue(int(rows[0][0]) if rows else 0) </span><span class="cx">
</span><span class="lines">@@ -339,7 +340,7 @@
</span><span class="cx"> cb, type="inner", \
on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID)).join( </span><span class="cx"> \
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == \
co.CALENDAR_RESOURCE_ID).And( </span><span class="cx"> \
cb.BIND_MODE == _BIND_MODE_OWN).And( </span><del>- \
cb.CALENDAR_RESOURCE_NAME != "inbox")), </del><ins>+ \
cb.CALENDAR_RESOURCE_NAME != Lower("inbox"))), </ins><span class="cx"> \
GroupBy=(ch.OWNER_UID, co.RESOURCE_ID, co.ICALENDAR_UID, co.MD5, co.ORGANIZER,), \
</span><span class="cx"> ).on(self.txn, **kwds)) </span><span class="cx"> \
returnValue(tuple(rows)) </span><span class="lines">@@ -352,9 +353,9 @@
</span><span class="cx"> ch = schema.CALENDAR_HOME
</span><span class="cx"> kwds = {"uuid": uuid}
</span><span class="cx"> if len(uuid) != 36:
</span><del>- where = \
(ch.OWNER_UID.StartsWith(Parameter("uuid"))) </del><ins>+ where \
= (ch.OWNER_UID.StartsWith(Lower(Parameter("uuid")))) </ins><span \
class="cx"> else: </span><del>- where = (ch.OWNER_UID == \
Parameter("uuid")) </del><ins>+ where = (ch.OWNER_UID == \
Lower(Parameter("uuid"))) </ins><span class="cx"> rows = (yield \
Select( </span><span class="cx"> [ch.OWNER_UID, co.RESOURCE_ID, \
co.ICALENDAR_UID, co.MD5, co.ORGANIZER,], </span><span class="cx"> \
From=ch.join( </span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidcalendarservertoolsdbinspectpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> import os
</span><span class="cx"> import sys
</span><span class="cx"> import traceback
</span><ins>+from twext.enterprise.dal.syntax import Lower
</ins><span class="cx">
</span><span class="cx"> def usage(e=None):
</span><span class="cx"> if e:
</span><span class="lines">@@ -520,7 +521,7 @@
</span><span class="cx"> cb, type="inner", \
on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And( </span><span class="cx"> \
cb.BIND_MODE == _BIND_MODE_OWN)).join( </span><span class="cx"> co, \
type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)), \
</span><del>- Where=(ch.OWNER_UID == Parameter("UID")), \
</del><ins>+ Where=(ch.OWNER_UID == Lower(Parameter("UID"))), \
</ins><span class="cx"> ).on(txn, **{"UID": uid})) </span><span \
class="cx"> returnValue(tuple(rows)) </span><span class="cx">
</span><span class="lines">@@ -571,7 +572,7 @@
</span><span class="cx"> cb, type="inner", \
on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And( </span><span class="cx"> \
cb.BIND_MODE == _BIND_MODE_OWN)).join( </span><span class="cx"> co, \
type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)), \
</span><del>- Where=((ch.OWNER_UID == \
Parameter("UID")).And(cb.CALENDAR_RESOURCE_NAME == \
Parameter("NAME"))), </del><ins>+ Where=((ch.OWNER_UID == \
Lower(Parameter("UID"))).And(cb.CALENDAR_RESOURCE_NAME == \
Parameter("NAME"))), </ins><span class="cx"> ).on(txn, \
**{"UID": uid, "NAME": name})) </span><span class="cx"> \
returnValue(tuple(rows)) </span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidcontribtoolssqldata_from_pathpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/contrib/tools/sqldata_from_path.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx"> %(object_name)s = '%(resource)s' and %(object_bind_id)s \
= ( </span><span class="cx"> select %(bind_id)s from %(bind_table)s where
</span><span class="cx"> %(bind_name)s = '%(collection)s' and \
%(bind_home_id)s = ( </span><del>- select RESOURCE_ID from \
%(home_table)s where OWNER_UID = '%(uid)s' </del><ins>+ select \
RESOURCE_ID from %(home_table)s where OWNER_UID = lower('%(uid)s') </ins><span \
class="cx"> ) </span><span class="cx"> );""" % \
sqlstrings[datatype] </span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> from twext.enterprise.dal.syntax import SavepointAction
</span><span class="cx"> from twext.enterprise.dal.syntax import Select
</span><span class="cx"> from twext.enterprise.dal.syntax import Update
</span><ins>+from twext.enterprise.dal.syntax import Lower
</ins><span class="cx">
</span><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><span class="cx"> from txdav.base.propertystore.none import PropertyStore as \
NonePropertyStore </span><span class="lines">@@ -842,7 +843,7 @@
</span><span class="cx"> def _resourceIDFromOwnerQuery(cls): #@NoSelf
</span><span class="cx"> home = cls._homeSchema
</span><span class="cx"> return Select([home.RESOURCE_ID],
</span><del>- From=home, Where=home.OWNER_UID == \
Parameter("ownerUID")) </del><ins>+ From=home, \
Where=home.OWNER_UID == Lower(Parameter("ownerUID"))) </ins><span \
class="cx"> </span><span class="cx"> @classproperty
</span><span class="cx"> def _ownerFromFromResourceID(cls): #@NoSelf
</span><span class="lines">@@ -909,7 +910,7 @@
</span><span class="cx"> try:
</span><span class="cx"> resourceid = (yield Insert(
</span><span class="cx"> {
</span><del>- cls._homeSchema.OWNER_UID: uid,
</del><ins>+ cls._homeSchema.OWNER_UID: Lower(uid),
</ins><span class="cx"> cls._homeSchema.DATAVERSION: \
cls._dataVersionValue, </span><span class="cx"> },
</span><span class="cx"> \
Return=cls._homeSchema.RESOURCE_ID).on(txn))[0][0] </span><span class="lines">@@ \
-3008,11 +3009,11 @@ </span><span class="cx">
</span><span class="cx"> _resourceIDFromUIDQuery = Select(
</span><span class="cx"> [_homeSchema.RESOURCE_ID], From=_homeSchema,
</span><del>- Where=_homeSchema.OWNER_UID == Parameter("uid"))
</del><ins>+ Where=_homeSchema.OWNER_UID == Lower(Parameter("uid")))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> _provisionNewNotificationsQuery = Insert(
</span><del>- {_homeSchema.OWNER_UID: Parameter("uid")},
</del><ins>+ {_homeSchema.OWNER_UID: Lower(Parameter("uid"))},
</ins><span class="cx"> Return=_homeSchema.RESOURCE_ID
</span><span class="cx"> )
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoresql_legacypy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> from pycalendar.duration import PyCalendarDuration
</span><ins>+from twext.enterprise.dal.syntax import Lower
</ins><span class="cx">
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="lines">@@ -220,7 +221,8 @@
</span><span class="cx"> inv = schema.INVITE
</span><span class="cx"> home = cls._homeSchema
</span><span class="cx"> return cls._allColumnsQuery(
</span><del>- (inv.RESOURCE_ID == \
Parameter("resourceID")).And(home.OWNER_UID == \
Parameter("principalUID")) </del><ins>+ (inv.RESOURCE_ID == \
Parameter("resourceID")) + .And(home.OWNER_UID == \
Lower(Parameter("principalUID"))) </ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/current.sql 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -90,7 +90,8 @@
</span><span class="cx">
</span><span class="cx"> create table NOTIFICATION_HOME (
</span><span class="cx"> RESOURCE_ID integer primary key default \
nextval('RESOURCE_ID_SEQ'), -- implicit index </span><del>- OWNER_UID varchar(255) \
not null unique -- implicit index </del><ins>+ \
OWNER_UID varchar(255) not null unique, -- implicit \
index + constraint NOTIFICATION_HOME_CASE check(OWNER_UID = lower(OWNER_UID))
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table NOTIFICATION (
</span></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_8_to_9sql"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -27,3 +27,8 @@
</span><span class="cx">
</span><span class="cx"> alter table ADDRESSBOOK_HOME
</span><span class="cx"> add constraint ADDRESSBOOK_HOME_CASE check(OWNER_UID = \
lower(OWNER_UID)); </span><ins>+
+update NOTIFICATION_HOME set OWNER_UID = lower(OWNER_UID);
+
+alter table NOTIFICATION_HOME
+add constraint NOTIFICATION_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
</ins></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_8_to_9sql"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_8_to_9.sql 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -27,3 +27,8 @@
</span><span class="cx">
</span><span class="cx"> alter table ADDRESSBOOK_HOME
</span><span class="cx"> add constraint ADDRESSBOOK_HOME_CASE check(OWNER_UID = \
lower(OWNER_UID)); </span><ins>+
+update NOTIFICATION_HOME set OWNER_UID = lower(OWNER_UID);
+
+alter table NOTIFICATION_HOME
+add constraint NOTIFICATION_HOME_CASE check(OWNER_UID = lower(OWNER_UID));
</ins></span></pre></div>
<a id="CalendarServerbranchesusersglyphcaseinsensitiveuidtxdavcommondatastoreupgradesqlupgradepy"></a>
<div class="modfile"><h4>Modified: \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py \
(8801 => 8802)</h4> <pre class="diff"><span>
<span class="info">--- \
CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py 2012-02-29 \
18:16:31 UTC (rev 8801)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py 2012-02-29 \
18:16:38 UTC (rev 8802) </span><span class="lines">@@ -322,6 +322,7 @@
</span><span class="cx"> # that differ only by case and re-name one \
of them to 'x.old'. </span><span class="cx"> yield \
self.renameCaseDuplicates(sqlTxn, 'CALENDAR') </span><span class="cx"> \
yield self.renameCaseDuplicates(sqlTxn, 'ADDRESSBOOK') </span><ins>+ \
yield self.renameCaseDuplicates(sqlTxn, 'NOTIFICATION') </ins><span class="cx"> \
yield sqlTxn.execSQLBlock(sql) </span><span class="cx"> if caseFix:
</span><span class="cx"> # This does not fit neatly into the existing \
upgrade machinery, </span><span class="lines">@@ -329,7 +330,7 @@
</span><span class="cx"> # upgrade system could take something like \
this into account, </span><span class="cx"> # though.
</span><span class="cx"> yield self.mergeCaseDuplicates(sqlTxn, \
'CALENDAR') </span><del>- yield self.mergeCaseDuplicates(sqlTxn, \
'ADDRESSBOOK') </del><ins>+ # yield self.mergeCaseDuplicates(sqlTxn, \
'ADDRESSBOOK') </ins><span class="cx"> yield sqlTxn.commit()
</span><span class="cx"> except RuntimeError:
</span><span class="cx"> yield sqlTxn.abort()
</span><span class="lines">@@ -341,15 +342,17 @@
</span><span class="cx"> """
</span><span class="cx"> Re-name case duplicates.
</span><span class="cx">
</span><del>- Prior to schema version 9, home UIDs were case-sensitive.
</del><ins>+ Prior to schema version 9, home UIDs were case-sensitive. This \
method + re-names any names which are equivalent except for case differences, \
so + that adding the uniform-case constraint will succeed.
</ins><span class="cx">
</span><span class="cx"> @param type: The type of home to scan; 'CALENDAR' or \
'ADDRESSBOOK' </span><span class="cx"> @type type: C{str}
</span><span class="cx"> """
</span><del>- # This is using the most recent 'schema' object, which happens \
to work for
- # the moment, but will fail if the schema changes too radically. Ideally
- # this should be pointed at a schema object parsed from an older version of
- # the schema.
</del><ins>+ # This is using the most recent 'schema' object, which happens to \
work + # for the moment, but will fail if the schema changes too radically.
+ # Ideally this should be pointed at a schema object parsed from an older
+ # version of the schema.
</ins><span class="cx"> home = getattr(schema, type + '_HOME')
</span><span class="cx"> left = home.alias()
</span><span class="cx"> right = home.alias()
</span><span class="lines">@@ -368,6 +371,7 @@
</span><span class="cx"> both.sort(key=lambda x: x[1])
</span><span class="cx"> # Note: determineNewest may return None \
sometimes. </span><span class="cx"> older = both[0][0]
</span><ins>+ self.log_warn("Moving aside case-duplicate home " \
+ repr(older)) </ins><span class="cx"> yield Update({home.OWNER_UID: \
_CASE_DUPLICATE_PREFIX + older}, </span><span class="cx"> \
Where=home.OWNER_UID == older).on(sqlTxn) </span><span class="cx">
</span><span class="lines">@@ -375,8 +379,8 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def mergeCaseDuplicates(self, sqlTxn, type):
</span><span class="cx"> """
</span><del>- Merge together homes which were previously case-duplicates of \
each other,
- once the schema is upgraded.
</del><ins>+ Merge together homes which were previously case-duplicates of \
each + other, once the schema is upgraded.
</ins><span class="cx"> """
</span><span class="cx"> home = getattr(schema, type + '_HOME')
</span><span class="cx"> oldHomes = yield Select(
</span><span class="lines">@@ -414,6 +418,15 @@
</span><span class="cx"> @param type: The type of home to scan; 'CALENDAR' or \
'ADDRESSBOOK' </span><span class="cx"> @type type: C{str}
</span><span class="cx"> """
</span><ins>+ if type == 'NOTIFICATION':
+ return Select(
+ [Max(schema.NOTIFICATION.MODIFIED)],
+ From=schema.NOTIFICATION_HOME.join(
+ schema.NOTIFICATION,
+ on=schema.NOTIFICATION_HOME.RESOURCE_ID ==
+ schema.NOTIFICATION.NOTIFICATION_HOME_RESOURCE_ID),
+ Where=schema.NOTIFICATION_HOME.OWNER_UID == uid
+ )
</ins><span class="cx"> home = getattr(schema, type + "_HOME")
</span><span class="cx"> bind = getattr(schema, type + "_BIND")
</span><span class="cx"> child = getattr(schema, type)
</span></span></pre>
</div>
</div>
</body>
</html>
_______________________________________________
calendarserver-changes mailing list
calendarserver-changes@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/calendarserver-changes
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic