Skip to content

Commit 3fcb45f

Browse files
committed
issue2550549 Postgres error on message templating
Exception gets thrown and not captured if nodeid is too large on postgres. Added a check in rdbms_common layer that max nodeid is < 2^31 -1. This is also the limit for INTEGER on MySql. SqlLite can support up to 2^63-1, but I chose the smallest common denominator. Large nodeid should now returns no such id rather than a stack trace. Patch idea from: martin.v.loewis. (John Rouillard) This fixes the reason for patches: https://hg.python.org/tracker/roundup/rev/1548763e8273 and https://hg.python.org/tracker/roundup/rev/eb3be57f1ef2
1 parent 51ddd5b commit 3fcb45f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ Fixed:
113113
the codecs.
114114
- issue2550823 improve mailgw logging for node creation errors.
115115
Patch by r.david.murray (applied by John Rouillard).
116+
- issue2550549 Postgres error on message templating
117+
Exception gets thrown and not captured if nodeid is too large
118+
on postgres. Added a check in rdbms_common layer that max nodeid
119+
is < 2^31 -1. Large nodeid now return no such id error upstream.
120+
Patch idea from: martin.v.loewis. (John Rouillard)
121+
116122

117123
2016-01-11: 1.5.1
118124

roundup/backends/rdbms_common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,15 @@ def destroynode(self, classname, nodeid):
12281228
def hasnode(self, classname, nodeid):
12291229
""" Determine if the database has a given node.
12301230
"""
1231+
# nodeid (aka link) is sql type INTEGER. max positive value
1232+
# for INTEGER is 2^31-1 for Postgres and MySQL. The max
1233+
# positive value for SqLite is 2^63 -1, so arguably this check
1234+
# needs to adapt for the type of the RDBMS. For right now,
1235+
# choose lowest common denominator.
1236+
if int(nodeid) >= 2**31:
1237+
# value out of range return false
1238+
return 0
1239+
12311240
# If this node is in the cache, then we do not need to go to
12321241
# the database. (We don't consider this an LRU hit, though.)
12331242
if (classname, nodeid) in self.cache:

0 commit comments

Comments
 (0)