ldb error codes
Simo Sorce
idra at samba.org
Mon Oct 31 14:46:09 GMT 2005
On Mon, 2005-10-31 at 11:58 +1100, tridge at samba.org wrote:
> Simo (and other interested parties),
>
> I've just been discussing ldb error codes a bit with Andrew
> Bartlett and wanted to get your opinion on how to fix it.
>
> As you know, the current situation is a bit of a mess. When I first
> wrote ldb I screwed up by paying very little attention to error
> codes. We were able to recover OK for most ldb calls, as we just
> defined the return value as being a LDB_ERR* value, or LDB_SUCCESS. We
> still haven't fixed all the places that need to set these values, but
> at least the major ones are fixed.
>
> The tricky one is ldb_search(). In the ldap API equivalent
> ldap_search_s() returns an error code and then uses functions like
> ldap_count_messages() to count the replies. Our ldb_search() function
> returns a message count directly, which leaves no room for an error
> code.
>
> So I have a few possible proposals for fixing this:
>
> 1) change the sign of the LDB_ERR* values, and make all functions
> then return a ldb error value. For ldb_search() if the value is >=
> 0 then its a search count, if its < 0 then its an error code. Not
> pretty, but requires very little code modification.
>
> 2) change ldb_search() to only return a error code, and add a
> ldb_count_messages() function. This requires changing all existing
> calls to ldb_search(). We'd also have to ensure that all backends
> NULL terminate the result list, as otherwise ldb_count_messages()
> would not be possible to implemenet.
>
> 3) we could have a ldb_errorcode() function that returns the last
> error code.
>
> I know you are also working towards the new ldb_request() API, and
> that won't have this problem, but I think we should also keep the
> current API working, which means we need to fix this anyway.
>
> Do you have a preference? Metze and Andrew, any comments?
Hi tridge,
There's a 4th option I like to explore, change the return value of
ldb_search into a structure, and have both error code and count hanging
on this structure.
Simo.
--
Simo Sorce - idra at samba.org
Samba Team - http://www.samba.org
Italian Site - http://samba.xsec.it
More information about the samba-technical
mailing list