Indeed, looking at it with your comments, definitely overkill. I meant to ask about this approach in the bug description but forgot, sorry.
Here is a simpler patch which works the same for my tests: ftp://ftp.openldap.org/incoming/jonathan-clarke-pcache-100727.patch
Hi. Your patch still looks a bit problematic to me. I'm not sure I understood the issue, since it doesn't work for me without further modifications to the code.
Suppose I'm searching with a filter that is related to the pcache attrset "cn uid", and my search lists the attributes
cn uid undefined
what you're trying to accomplish is that this search behaves as if one only requested
cn uid
right? Well, in this case (at least in HEAD code, I didn't check in re24 yet) it does not work, because all the tests you add work fine, but later the expected attrset will not be matched because the attribute name "undefined" will still be looked for inside the attribute set. You need to add a check that does not look for attributes for which no an_desc was found. However, this case also matches wildcards '*', '+', '1.1'.
Tentatively, the "right" patch would be like this
ftp://ftp.openldap.org/incoming/pierangelo-masarati-its6600.1.patch
Please test and report.
p.