From 49acda22d986cb5e6730ac99d24e8d7362e4d7aa Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 15 Feb 2011 10:36:57 +0000
Subject: [PATCH] Fix issue OPENDJ-46: Extensible filters which use dnAttributes are not processed correctly when there is an existing index for the named attribute

---
 opends/src/server/org/opends/server/backends/jeb/IndexFilter.java |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/IndexFilter.java b/opends/src/server/org/opends/server/backends/jeb/IndexFilter.java
index b6b1655..6d5c2d0 100644
--- a/opends/src/server/org/opends/server/backends/jeb/IndexFilter.java
+++ b/opends/src/server/org/opends/server/backends/jeb/IndexFilter.java
@@ -23,6 +23,8 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
+ *      Portions copyright 2011 ForgeRock AS
+ *
  */
 package org.opends.server.backends.jeb;
 
@@ -659,17 +661,27 @@
   private EntryIDSet evaluateExtensibleFilter(SearchFilter extensibleFilter)
   {
     EntryIDSet candidates;
-    AttributeIndex attributeIndex =
-         entryContainer.getAttributeIndex(extensibleFilter.getAttributeType());
-    if (attributeIndex == null)
+
+    if (extensibleFilter.getDNAttributes())
     {
+      // This will always be unindexed since the filter potentially matches
+      // entries containing the specified attribute type as well as any entry
+      // containing the attribute in its DN as part of a superior RDN.
       candidates = IndexQuery.createNullIndexQuery().evaluate(null);
     }
     else
     {
-      candidates =
-          attributeIndex.evaluateExtensibleFilter(extensibleFilter, buffer,
-              monitor);
+      AttributeIndex attributeIndex = entryContainer
+          .getAttributeIndex(extensibleFilter.getAttributeType());
+      if (attributeIndex == null)
+      {
+        candidates = IndexQuery.createNullIndexQuery().evaluate(null);
+      }
+      else
+      {
+        candidates = attributeIndex.evaluateExtensibleFilter(extensibleFilter,
+            buffer, monitor);
+      }
     }
     return candidates;
   }

--
Gitblit v1.10.0