[Koha-bugs] [Bug 10454] Lack of critical section could generate duplicate card numbers
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Jun 13 20:36:33 CEST 2013
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10454
--- Comment #3 from M. Tompsett <mtompset at hotmail.com> ---
Based on an idea from gmcharlt.
Here's Pseudo-code of something I have in mind for fixup_cardnumber. I'm
writing this so I don't forget it when I switch computers later to actually
attempt implementing it.
Already done elsewhere:
CREATE TABLE cardnumber (UID autoincrement,PID string,Value string)
my_cardnumber = select max(cardnumber) from borrowers
check = select cardnumber from borrowers where cardnumber=my_cardnumber;
while the check for the cardnumber exists {
INSERT into cardnumber (PID) values (randomly generated PID string)
my_uid = SELECT max(UID) from cardnumber where PID= the randomly generated
PID string
earliest uid = select min(uid) from cardnumber where value='';
while there is an earliest uid {
previous_value = select value from cardnumber where uid=earliest uid-1;
# the assumption is that f(previous value) will always return the
# same new value regardless of how many times or when it is called.
new value = f(previous value);
update cardnumber set value=new value where uid=earliest uid;
earliest uid = select min(uid) from cardnumber where value='';
}
my_cardnumber = select Value from cardnumber where uid=my_uid
check = select cardnumber from borrowers where cardnumber=my_cardnumber;
}
return my_cardnumber;
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list