From 3f3ddd5437e6abdef237a4e97a765bc0f6f32b96 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 9 Mar 2010 13:14:43 +0000 Subject: [PATCH] fix for that SELECT DISTINCT(LENGTH(...)) "misbehavior" --- lib/utils/resume.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils/resume.py b/lib/utils/resume.py index 63d679d8a..d011a7d90 100644 --- a/lib/utils/resume.py +++ b/lib/utils/resume.py @@ -26,6 +26,7 @@ import re from lib.core.common import dataToSessionFile from lib.core.common import safeStringFormat +from lib.core.common import randomStr from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger @@ -62,7 +63,9 @@ def queryOutputLength(expression, payload): if ( select and re.search("\A(COUNT|LTRIM)\(", regExpr, re.I) ) or len(regExpr) <= 1: return None, None, None - if select: + if selectDistinctExpr: + lengthExpr = "SELECT %s FROM (%s) AS T%s" % (lengthQuery % regExpr, expression, randomStr(4)) + elif select: lengthExpr = expression.replace(regExpr, lengthQuery % regExpr, 1) else: lengthExpr = lengthQuery % expression @@ -82,7 +85,7 @@ def queryOutputLength(expression, payload): if length == " ": length = 0 - + return count, length, regExpr def resume(expression, payload):