You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Lorenz Breu (JIRA)" <ji...@apache.org> on 2008/12/20 14:46:44 UTC

[jira] Created: (DIRSERVER-1296) integer attribute types are not compared correctly

integer attribute types are not compared correctly
--------------------------------------------------

                 Key: DIRSERVER-1296
                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
             Project: Directory ApacheDS
          Issue Type: Bug
          Components: core
            Reporter: Lorenz Breu


When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.

Example:
dn: cn = foo, dc = example
cn: foo
integerAttribute: 435


now a search using "(integerAttribute<=500)" will correctly return the entry....
but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Resolved: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by Emmanuel Lecharny <el...@gmail.com>.
On Wed, Jan 7, 2009 at 5:40 PM, Alex Karasulu <ak...@gmail.com> wrote:
> So with this comparator missing we were defaulting to the use of lexographic
> comparisons on the INTEGER syntax when an index was built on the syntax?

yes, and also if we don't have index. In fact, the comparison was done
against the selected values.

If an index is built, then I guess that the optimizer would only
return values matching the filter (to be checked. in any case, that
would be an interesting optimization if it's not already implemented,
as we would not have to do another check against the filter)

> Makes sense since the index needs to be ordered using the ORDERING
> comparator for the integerMatch matching rule.  Just curious if this is your
> conclusion as well.

So far, I can say that the IntegerOrderingComparator is used to
compare the filter value with the selected values from the backend. I
don't know if those returned values are already matched against the
filter by the underlying optimizer...

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: [jira] Resolved: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by Alex Karasulu <ak...@gmail.com>.
So with this comparator missing we were defaulting to the use of lexographic
comparisons on the INTEGER syntax when an index was built on the syntax?

Makes sense since the index needs to be ordered using the ORDERING
comparator for the integerMatch matching rule.  Just curious if this is your
conclusion as well.

Thanks,
Alex

On Tue, Jan 6, 2009 at 4:13 PM, Emmanuel Lecharny (JIRA) <ji...@apache.org>wrote:

>
>     [
> https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Emmanuel Lecharny resolved DIRSERVER-1296.
> ------------------------------------------
>
>    Resolution: Fixed
>
> Patch applied, and fix done : a IntegerOrderingComparator has been added
> and registred.
>
> > integer attribute types are not compared correctly
> > --------------------------------------------------
> >
> >                 Key: DIRSERVER-1296
> >                 URL:
> https://issues.apache.org/jira/browse/DIRSERVER-1296
> >             Project: Directory ApacheDS
> >          Issue Type: Bug
> >          Components: core
> >    Affects Versions: 1.5.4
> >            Reporter: Lorenz Breu
> >             Fix For: 1.5.5
> >
> >         Attachments: ComparableComparator.java, patch_SearchIT.txt,
> SearchIT.java
> >
> >
> > When searching for entries that have attributes with the INTEGER syntax,
> the values are compared lexicographically, not numerically. This happens
> even if the ordering and equality types are explicitly set to their integer
> versions when injecting the attribute types into ADS.
> > Example:
> > dn: cn = foo, dc = example
> > cn: foo
> > integerAttribute: 435
> > now a search using "(integerAttribute<=500)" will correctly return the
> entry....
> > but a search using "(integerAttribute<=44)" will ALSO return the entry,
> which it clearly should not.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

[jira] Closed: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRSERVER-1296.
----------------------------------------


closed

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, patch_SearchIT.txt, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Lorenz Breu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lorenz Breu updated DIRSERVER-1296:
-----------------------------------

    Attachment: patch_SearchIT.txt

hope this worked...

should be a diff between my working copy and the repo version of SearchIT.java in core-integ.

I added an AT "integerAttribute" with "integerOrderingMatch", added the OC "extensibleObject" to the test oranizationalUnits and gave them new integerAttributes matching their number. In addition I added 3 new such test OUs... The old tests still pass.

Now the integerComaprisonTests test for the right issue. They fail without the "fix" in ComparableComparator and pass if it is there, so my initial fix does work...

However, I do realize it is a hack. The problem is, that the "integerOrderingMatch" MatchingRule is assigned a ComparableComparator in the ComparatorRegistry. I do not know, where this happens, but if somebody does, then it would be much nicer to change that to some NumericalComparator there, than trying to parse the strings as I have done.

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, patch_SearchIT.txt, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny resolved DIRSERVER-1296.
------------------------------------------

    Resolution: Fixed

Patch applied, and fix done : a IntegerOrderingComparator has been added and registred.

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, patch_SearchIT.txt, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12660973#action_12660973 ] 

Emmanuel Lecharny commented on DIRSERVER-1296:
----------------------------------------------

Sadly, the test is not demonstrating the bug : The gidNumber AttributeType does not contains a integerOrderingMatch ORDERING, thus using a filter like (gidNumber<=42) is simply not using an integer comparator, but the default String comparator.

You should define your own AttributeType, containing the ORDERING parameter, and run another test.

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12661163#action_12661163 ] 

Emmanuel Lecharny commented on DIRSERVER-1296:
----------------------------------------------

As far as I can tell, if the AT is not indexed, then we fail back to a standard String comparator. Not very good ...

I'm currently debugging the server to be sure that explains the problem you have.

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, patch_SearchIT.txt, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Lorenz Breu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lorenz Breu updated DIRSERVER-1296:
-----------------------------------

    Attachment: SearchIT.java
                ComparableComparator.java

apacheds-trunk/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ComparableComparator.java
Tracked the integer comparison to the "ComparableComparator" which treats them as Strings, so I added a quick fix to first try to parse arguments as integers. There may be a more elegant solution, but at least now it works correctly ;)

apacheds-trunk/apacheds/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
I also added 4 quick tests to SearchIT as the two existing tests fail to spot the error as they stay below 10. I did a fresh install of mina and apacheds without the fix -> fail. I then applied the fix and ran the complete set of integration tests on the whole apacheds project -> success. Tests I use in my ADS-based project, which spotted the problem in the first place, now also pass. So I guess this does actually work...



> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>         Attachments: ComparableComparator.java, SearchIT.java
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DIRSERVER-1296) integer attribute types are not compared correctly

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRSERVER-1296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny updated DIRSERVER-1296:
-----------------------------------------

    Affects Version/s: 1.5.4
        Fix Version/s: 1.5.5

> integer attribute types are not compared correctly
> --------------------------------------------------
>
>                 Key: DIRSERVER-1296
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-1296
>             Project: Directory ApacheDS
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.5.4
>            Reporter: Lorenz Breu
>             Fix For: 1.5.5
>
>
> When searching for entries that have attributes with the INTEGER syntax, the values are compared lexicographically, not numerically. This happens even if the ordering and equality types are explicitly set to their integer versions when injecting the attribute types into ADS.
> Example:
> dn: cn = foo, dc = example
> cn: foo
> integerAttribute: 435
> now a search using "(integerAttribute<=500)" will correctly return the entry....
> but a search using "(integerAttribute<=44)" will ALSO return the entry, which it clearly should not.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.