[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#3629) patch for problem with aggregated attributes in sql-back

kjellm@linpro.no wrote:

>Full_Name: Kjell-Magne Oierud
>Version: 2.2.24
>OS: linux
>URL: ftp://ftp.openldap.org/incoming/kjell-magne-oierud-050404.patch.1
>Submission from: (NULL) (
>I've upped a patchfile named kjell-magne-oierud-050404.patch.1 in
>It's a patch against servers/slapd/back-sql/schema-map.c
>The problem:
>sql-back fails if you define some of an objectclass' attributes to be
>aggregates. More precisely, if you in ldap_attr_mapings define sel_expr to be
>anything like SUM(foo). sql-back will then try to exequte queries with invalid
>ORDER BY clauses: 
>  SELECT SUM(foo) AS bar ... ORDER BY SUM(foo)
>                                      ^^^^^^^^
>The solution:
>My patch fixes this by instead using the alias:
>  SELECT SUM(foo) AS bar ... ORDER BY bar
The patch looks fine, although I'm not sure that ordering by the alias 
name will work on all RDBMSes; while (although not being a good enough 
reason) with PostgreSQL the order by clause works fine with both 
aggregate data and alias name.  Maybe we'd better provide an extra 
switch in ldap_attr_mappings to handle these cases.


    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497