I see you point. I removed the guard. I updated the function to permit Lp admins
an exemption for all regexps that have the admin column assigned. This change
restores most of your performance suggestion.
+ # admins is a celebrity and its id is immutable.
+ admins_id = plpy.execute(
+ "SELECT id FROM Person WHERE name='admins'")[0]["id"]
+
+ SD["admin_select_plan"] = plpy.prepare("""
+ SELECT TRUE FROM TeamParticipation
+ WHERE
+ TeamParticipation.team = %d
+ AND TeamParticipation.person = $1
+ LIMIT 1
+ """ % admins_id, ["integer"])
+
+ # All the blacklist regexps except those that have an admin because
+ # members of ~admin can use any name that any other admin can use.
+ SD["admin_regexp_select_plan"] = plpy.prepare("""
+ SELECT id, regexp FROM NameBlacklist
+ WHERE admin IS NULL
+ ORDER BY id
+ """, ["integer"])
+
+
compiled = SD["compiled"]
- for row in plpy.execute(SD["regexp_select_plan"], [user_id]):
+ # Names are never blacklisted for Lauchpad admins.
+ if user_id is not None and plpy.execute(
+ SD["admin_select_plan"], [user_id]).nrows() > 0:
+ blacklist_plan = "admin_regexp_select_plan"
+ else:
+ blacklist_plan = "regexp_select_plan"
+
+ for row in plpy.execute(SD[blacklist_plan], [user_id]):
Hi Stuart.
I see you point. I removed the guard. I updated the function to permit Lp admins
an exemption for all regexps that have the admin column assigned. This change
restores most of your performance suggestion.
=== modified file 'database/ schema/ trusted. sql' schema/ trusted. sql 2011-01-10 18:27:20 +0000 schema/ trusted. sql 2011-01-10 19:24:26 +0000
SD["compiled" ] = {}
--- database/
+++ database/
@@ -765,9 +765,37 @@
# Storage for compiled regexps
+ # admins is a celebrity and its id is immutable. ")[0][" id"] select_ plan"] = plpy.prepare(""" on.team = %d on.person = $1 regexp_ select_ plan"] = plpy.prepare("""
+ admins_id = plpy.execute(
+ "SELECT id FROM Person WHERE name='admins'
+
+ SD["admin_
+ SELECT TRUE FROM TeamParticipation
+ WHERE
+ TeamParticipati
+ AND TeamParticipati
+ LIMIT 1
+ """ % admins_id, ["integer"])
+
+ # All the blacklist regexps except those that have an admin because
+ # members of ~admin can use any name that any other admin can use.
+ SD["admin_
+ SELECT id, regexp FROM NameBlacklist
+ WHERE admin IS NULL
+ ORDER BY id
+ """, ["integer"])
+
+
compiled = SD["compiled"]
- for row in plpy.execute( SD["regexp_ select_ plan"], [user_id]): select_ plan"], [user_id]).nrows() > 0: regexp_ select_ plan" select_ plan" SD[blacklist_ plan], [user_id]):
+ # Names are never blacklisted for Lauchpad admins.
+ if user_id is not None and plpy.execute(
+ SD["admin_
+ blacklist_plan = "admin_
+ else:
+ blacklist_plan = "regexp_
+
+ for row in plpy.execute(