[PATCH] [REVIEW:3-5] fdo#45249 cannot use aggregate functions in with PostgreSQL

Lionel Elie Mamane lionel at mamane.lu
Thu Feb 9 09:44:53 PST 2012


With a PostgreSQL-SDBC database, Base query design does not allow the
user to use groupings and aggregate functions.

Change PostgreSQL-SDBC so that it declares to support Core SQL.

Please apply to libreoffice-3-5

See dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx

OSelectionBrowseBox::initialize

        if ( lcl_SupportsCoreSQLGrammar(xConnection) )
        {
            xub_StrLen nCount   = m_aFunctionStrings.GetTokenCount();
            for (xub_StrLen nIdx = 0; nIdx < nCount; nIdx++)
                m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(nIdx));
        }

where m_aFunctionStrings has been prepopulated by:

        IParseContext::InternationalKeyCode eFunctions[] = { IParseContext::KEY_AVG,IParseContext::KEY_COUNT,IParseContext::KEY_MAX
            ,IParseContext::KEY_MIN,IParseContext::KEY_SUM
            ,IParseContext::KEY_EVERY
            ,IParseContext::KEY_ANY
            ,IParseContext::KEY_SOME
            ,IParseContext::KEY_STDDEV_POP
            ,IParseContext::KEY_STDDEV_SAMP
            ,IParseContext::KEY_VAR_SAMP
            ,IParseContext::KEY_VAR_POP
            ,IParseContext::KEY_COLLECT
            ,IParseContext::KEY_FUSION
            ,IParseContext::KEY_INTERSECTION
        };

       for (size_t i = 0; i < SAL_N_ELEMENTS(eFunctions); ++i)
        {
            m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
            m_aFunctionStrings += String(ByteString(rContext.getIntlKeywordAscii(eFunctions[i])),RTL_TEXTENCODING_UTF8);

        }

and also

OSelectionBrowseBox::setFunctionCell:

    if ( xConnection.is() )
    {
        // Diese Funktionen stehen nur unter CORE zur Verf�gung
        }
        else
        {
            // nur COUNT(*) erlaubt
    }

-- 
Lionel


More information about the LibreOffice mailing list