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

Re: back-sql sqlquery



On Wed, Oct 19, 2005 at 10:14:55AM +0200, Pierangelo Masarati wrote:
> 
> > Hello,
> >
> > Why do back-sql querys like
> > (2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND
> > ldap_entry_objclasses.oc_name='" /* '))
> >
> > For what is the 2=2 ? This makes my query very slow.
> 
> The "2=2" is a placeholder for "TRUE".  Different numbers indicate
> different places in the code where the replacement took place.  I'd be
> much more worried about the "ldap_entry_objclasses.oc_name='" /* '" which
> clearly indicates an error in the code, or some abnormal behavior at
> least.  Unfortunately you don't provide enough info to track where it
> might have happened.

I think the "ldap_entry_objclasses.oc_name='" /* '" ist not a bug. It
will fill out at the runtime the full query is:

SELECT DISTINCT ldap_entries.id,groups.id,text('posixGroup') AS
objectClass,ldap_entries.dn AS dn FROM ldap_entries,groups,ldap_entry_objclasses,posix_account,groups_users
WHERE groups.id=ldap_entries.keyval AND ldap_entries.oc_map_id=4 AND 9=9 AND groups_users.memberuid=posix_account.uidnumber AND
groups_users.gidnumber=groups.gidnumber AND ((2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND
ldap_entry_objclasses.oc_name='posixGroup')) AN ((posix_account.uid='lml34') OR 7=7));

It's from line 738 in servers/slapd/back-sql/search.c

Iam not an SQL-geek but what ist the sense to ask "true OR query" ?

Thomas