[open-ils-commits] [GIT] Evergreen ILS branch master updated. 8410fdace48ceb10f0cb9e84294d15a8f5adff9a

Evergreen Git git at git.evergreen-ils.org
Tue Jan 30 15:49:45 EST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  8410fdace48ceb10f0cb9e84294d15a8f5adff9a (commit)
      from  982d999ccd391abf811f2cc4fbb0f7108b5f5fc1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8410fdace48ceb10f0cb9e84294d15a8f5adff9a
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date:   Thu Jan 25 16:58:33 2018 -0500

    LP#1745486: avoid retrieving user by id::numeric during auth init
    
    During open-ils.auth.authenticate.init, if looking up the user by barcode,
    the actor.usr row is subsequently fetched by ID. However, the ID was
    turned into a float, meaning that the query as sent to the database
    was equivalent to
    
      SELECT * FROM actor.usr WHERE id = 123.0000;
    
    While PostgreSQL will accept this, it ends up doing a sequential
    scan of the actor.usr table rather than an index lookup, making the
    retrieval up to two orders of magnitude slower than it needs to be
    and adding a couple percent unecessary I/O load on large, heavily
    used database. This patch fixes that.
    
    To test
    -------
    [1] Turn on PostgreSQL statment logging and log in as a user
        by barcode. Note that there's a retrieval of actor.usr by
        a float form of the ID.
    [2] Apply the patch and repeat step 1. This time, the query
        retrieves the row by the integer form of the ID.
    
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
    Signed-off-by: Bill Erickson <berickxx at gmail.com>

diff --git a/Open-ILS/src/c-apps/oils_utils.c b/Open-ILS/src/c-apps/oils_utils.c
index 4074d9e..5492dbf 100644
--- a/Open-ILS/src/c-apps/oils_utils.c
+++ b/Open-ILS/src/c-apps/oils_utils.c
@@ -393,16 +393,16 @@ jsonObject* oilsUtilsFetchUserByBarcode(osrfMethodContext* ctx, const char* barc
 	if(!card)
 		return NULL;   // No such card
 
-	// Get the user's id as a double
+	// Get the user's id as a long
 	char* usr = oilsFMGetString(card, "usr");
 	jsonObjectFree(card);
 	if(!usr)
 		return NULL;   // No user id (shouldn't happen)
-	double iusr = strtod(usr, NULL);
+	long iusr = strtol(usr, NULL, 10);
 	free(usr);
 
 	// Look up the user in actor.usr
-	params = jsonParseFmt("[%f]", iusr);
+	params = jsonParseFmt("[%d]", iusr);
 	jsonObject* user = oilsUtilsQuickReqCtx(
 		ctx, "open-ils.cstore", "open-ils.cstore.direct.actor.user.retrieve", params);
 

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/c-apps/oils_utils.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list