'Take in input a query string and return its fields (columns) and
more details.
Example:
Input:  SELECT user, password FROM mysql.user
Output: user,password
@param query: query to be processed
@type query: C{str}
@return: query fields (columns) and more details
@rtype: C{str}'

def getFields(self, query):

    prefixRegex = '(?:\\s+(?:FIRST|SKIP|LIMIT(?:    \\d+)?)\\s+\\d+)*'
    fieldsSelectTop = re.search('\\ASELECT\\s+TOP\\s+[\\d]+\\s+(.+?)\\s+FROM', query, re.I)
    fieldsSelectRownum = re.search('\\ASELECT\\s+([^()]+?),\\s*ROWNUM    AS    LIMIT    FROM', query, re.I)
    fieldsSelectDistinct = re.search(('\\ASELECT%s\\s+DISTINCT\\((.+?)\\)\\s+FROM' % prefixRegex), query, re.I)
    fieldsSelectCase = re.search(('\\ASELECT%s\\s+(\\(CASE    WHEN\\s+.+\\s+END\\))' % prefixRegex), query, re.I)
    fieldsSelectFrom = re.search(('\\ASELECT%s\\s+(.+?)\\s+FROM    ' % prefixRegex), query, re.I)
    fieldsExists = re.search('EXISTS\\(([^)]*)\\)\\Z', query, re.I)
    fieldsSelect = re.search(('\\ASELECT%s\\s+(.*)' % prefixRegex), query, re.I)
    fieldsSubstr = re.search('\\A(SUBSTR|MID\\()', query, re.I)
    fieldsMinMaxstr = re.search('(?:MIN|MAX)\\(([^\\(\\)]+)\\)', query, re.I)
    fieldsNoSelect = query
    _ = zeroDepthSearch(query, '    FROM    ')
    if (not _):
        fieldsSelectFrom = None
    fieldsToCastStr = fieldsNoSelect
    if fieldsSubstr:
        fieldsToCastStr = query
    elif fieldsMinMaxstr:
        fieldsToCastStr = fieldsMinMaxstr.group(1)
    elif fieldsExists:
        if fieldsSelect:
            fieldsToCastStr = fieldsSelect.group(1)
    elif fieldsSelectTop:
        fieldsToCastStr = fieldsSelectTop.group(1)
    elif fieldsSelectRownum:
        fieldsToCastStr = fieldsSelectRownum.group(1)
    elif fieldsSelectDistinct:
        if (Backend.getDbms() in (DBMS.HSQLDB,)):
            fieldsToCastStr = fieldsNoSelect
        else:
            fieldsToCastStr = fieldsSelectDistinct.group(1)
    elif fieldsSelectCase:
        fieldsToCastStr = fieldsSelectCase.group(1)
    elif fieldsSelectFrom:
        fieldsToCastStr = (query[:unArrayizeValue(_)] if _ else query)
        fieldsToCastStr = re.sub(('\\ASELECT%s\\s+' % prefixRegex), '', fieldsToCastStr)
    elif fieldsSelect:
        fieldsToCastStr = fieldsSelect.group(1)
    fieldsToCastStr = (fieldsToCastStr or '')
    if (re.search('\\A\\w+\\(.*\\)', fieldsToCastStr, re.I) or (fieldsSelectCase and ('WHEN    use' not in query)) or fieldsSubstr):
        fieldsToCastList = [fieldsToCastStr]
    else:
        fieldsToCastList = splitFields(fieldsToCastStr)
    return (fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsSelectTop, fieldsSelectCase, fieldsToCastList, fieldsToCastStr, fieldsExists)
