Bug 6981 - barcode not incrementing
Summary: barcode not incrementing
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Galen Charlton
QA Contact: Bugs List
Depends on:
Reported: 2011-10-06 12:35 UTC by Nicole C. Engard
Modified: 2015-12-03 22:00 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Note You need to log in before you can comment on or make changes to this bug.
Description Nicole C. Engard 2011-10-06 12:35:27 UTC
I have autobarcode on to just increment by 1 and in recent releases of master I have noticed that it stopped incrementing at 2345678765345431
Comment 1 Magnus Enger 2011-10-06 12:46:46 UTC
Could this be similar to the problem described in bug 6944?
Comment 2 Nicole C. Engard 2011-10-06 12:56:47 UTC
that's why i included the barcode in question .. in case it is the same problem, but i don't know how to find out.
Comment 3 Magnus Enger 2011-10-06 13:09:41 UTC
Try something like "update <table> set <column> = 2345678765345432 where <column> = 2345678765345431;" and see what happens, maybe?
Comment 4 Nicole C. Engard 2011-10-06 13:22:42 UTC
mysql> update items set barcode = 2345678765345432 where barcode = 2345678765345431;
Query OK, 0 rows affected (0.01 sec)
Rows matched: 0  Changed: 0  Warnings: 0
Comment 5 Marc Véron 2012-04-15 13:35:39 UTC
It seems that it is an issue of representation of numbers in Perl.
Up to a certain value they are repersented as integers, then as float, and that leads to a loss of precision.

I did the following test:

Using MySQL, set the highest value in the table to 2345678765345430

Adding an item, the form displays 2345678765345431 (as expected)
Following item sticks with 2345678765345431 (as described in the bug report)

I you set the value to 2345678765345435 the form will show a value of 2345678765345441  (!)

This is the code snippet in barcode.pl (around line 90):
	elsif ($autoBarcodeType eq 'incremental') {
		# not the best, two catalogers could add the same barcode easily this way :/
		$query = "select max(abs(barcode)) from items";
        my $sth = $dbh->prepare($query);
		while (my ($count)= $sth->fetchrow_array) {
			$nextnum = $count;
----end snip----

About numbers in Perl:

Maybe the issue could be solved with 

Following questions should be considered:
- Side effects with BigInt?
- If the correct new number can be transferred into the java script code, what happens when writing back the number into the database?
- What about the comment in the code snippet: # not the best, two catalogers could add the same barcode easily this way :/ ?
Comment 6 Marc Véron 2012-06-09 07:10:12 UTC
Could be resolved together with Bug 7911 - Greater flexibility in auto barcode number generation
Comment 7 Marc Véron 2015-01-05 16:35:12 UTC
Could no longer reproduce the issue on current master