884
884
def __init__(self, log, abort_time=None):
885
885
super(SourcePackageReleaseDscBinariesUpdater, self).__init__(
888
887
self.store = IMasterStore(SourcePackageRelease)
889
self.store.execute("DROP TABLE IF EXISTS MatchedSourcePackageRelease")
890
self.store.execute("""
891
CREATE TEMPORARY TABLE MatchedSourcePackageRelease AS
893
FROM SourcePackageRelease
894
-- Get all SPR IDs which have an incorrectly-separated
895
-- dsc_binaries value (space rather than comma-space).
896
WHERE dsc_binaries ~ '[a-z0-9+.-] '
897
-- Skip rows with dsc_binaries in dependency relationship
898
-- format. This is a different bug.
899
AND dsc_binaries NOT LIKE '%(%'
901
self.store.execute("""
902
CREATE INDEX matchedsourcepackagerelease__spr__idx
903
ON MatchedSourcePackageRelease(spr)
905
self.matched_spr_count = self.store.execute("""
906
SELECT COUNT(*) FROM MatchedSourcePackageRelease
890
SourcePackageRelease.id,
891
# Get all SPR IDs which have an incorrectly-separated
892
# dsc_binaries value (space rather than comma-space).
893
SQL("dsc_binaries ~ '[a-z0-9+.-] '"),
894
# Skip rows with dsc_binaries in dependency relationship
895
# format. This is a different bug.
896
SQL("dsc_binaries NOT LIKE '%(%'")))
909
898
def isDone(self):
910
899
"""See `TunableLoop`."""
911
return self.offset >= self.matched_spr_count
900
return len(self.ids) == 0
913
902
def __call__(self, chunk_size):
914
903
"""See `TunableLoop`."""
904
chunk_ids = self.ids[:chunk_size]
905
del self.ids[:chunk_size]
915
906
self.store.execute("""
916
907
UPDATE SourcePackageRelease
917
908
SET dsc_binaries = regexp_replace(
918
909
dsc_binaries, '([a-z0-9+.-]) ', E'\\\\1, ', 'g')
921
FROM MatchedSourcePackageRelease
925
) AS MatchedSourcePackageRelease
926
WHERE SourcePackageRelease.id = MatchedSourcePackageRelease.spr
927
""" % (self.offset, chunk_size), noresult=True)
928
self.offset += chunk_size
910
WHERE id IN %s""" % sqlvalues(chunk_ids), noresult=True)
929
911
transaction.commit()