From af5342c4958caf0f2dad029da1c3c18677470c9f Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 25 Mar 2011 11:19:15 +0000 Subject: [PATCH] fix for partial inband queries on MSSQL --- lib/core/agent.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/core/agent.py b/lib/core/agent.py index 894eaebac..c389e2f00 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -538,6 +538,12 @@ class Agent: inbandQuery = self.prefixQuery("UNION ALL SELECT ", prefix=prefix) if query.startswith("TOP"): + # TOP enumeration on DBMS.MSSQL is too specific and it has to go into it's own brackets + # because those NULLs cause problems with ORDER BY clause + if Backend.getIdentifiedDbms() == DBMS.MSSQL: + inbandQuery += ",".join(map(lambda x: char if x != position else '(SELECT %s)' % query, range(0, count))) + inbandQuery = self.suffixQuery(inbandQuery, comment, suffix) + return inbandQuery topNum = re.search("\ATOP\s+([\d]+)\s+", query, re.I).group(1) query = query[len("TOP %s " % topNum):] inbandQuery += "TOP %s " % topNum