1. Problems with EDB
- Posted by evanmars Feb 06, 2014
- 2431 views
With this small program:
include std/eds.e include std/io.e include std/text.e db_create("Test.edb",DB_LOCK_NO) db_create_table("Table1",DB_LOCK_NO) atom fn object KeyName sequence Data1, Data2, Data3 integer result sequence file_name fn = open("Test1.txt","r") while 1 do KeyName = gets(fn) if atom(KeyName) then exit end if KeyName = KeyName[1..$-1] Data1 = gets(fn) Data1 = Data1[1..$-1] Data2 = gets(fn) Data2 = Data2[1..$-1] Data3 = gets(fn) Data3 = Data3[1..$-1] if db_find_key(KeyName) < 0 then result = db_insert(KeyName,{Data1,Data2,Data3}) printf(1,"db_insert: %d\n",result) end if end while close(fn) while get_key() != 'n' do end while
I get this error:
c:\Euphoria\include\std\eds.e:2181 in function db_insert() repetition count must not be less than 0 ... called from C:\Users\evanmars\Programming\Eu\Programs\EuBrew\TestDB.ex:30 --> See ex.err Press Enter...
Test1.txt contains:
Key1
Data1
Data2
Data3
Key2
Data4
Data5
Data6
Key3
Data7
Data8, Data9
Data10
Key1
Data1
Data2
Data3
2. Re: Problems with EDB
- Posted by gbonvehi Feb 06, 2014
- 2365 views
Hi Evans,
I think the problem is that you're giving the wrong parameter to db_create_table.
As you can see in the manual, http://openeuphoria.org/docs/std_eds.html#_4237_db_create_table , the second parameter is the default reserved records space, DB_LOCK_NO is 0 which is wrong, the default is 50 defined as DEF_INIT_RECORDS.
This should probably be fixed because a table with 0 reserved space should grow gracefuly, but you can skip this and pass the correct value to start working :)
Cheers,
Guillermo
PS: You can skip db_find_key, db_insert will fail returning DB_EXISTS_ALREADY in the second Key1 insertion.
3. Re: Problems with EDB
- Posted by DerekParnell (admin) Feb 07, 2014
- 2369 views
This should probably be fixed ...
Yes. Although not strictly a bug, we can do better. I'd propose that if the parameter supplied is less than 1, then the library should use DEF_INIT_RECORDS.
4. Re: Problems with EDB
- Posted by gbonvehi Feb 07, 2014
- 2374 views
This should probably be fixed ...
Yes. Although not strictly a bug, we can do better. I'd propose that if the parameter supplied is less than 1, then the library should use DEF_INIT_RECORDS.
Actually, it doesn't work with 1 neither, there must be some allocation that is not taking that into account.
I did a quick patch so if the parameter is less that DEF_INIT_RECORDS then is set to it: http://openeuphoria.org/pastey/235.wc
Cheers,
Guillermo
Edit: The init parameters should've been 0, I was trying with 1 and could reproduce the problem (there was already a check for < 1 that setted it to 1) that's why I bumped the default to DEF_INIT_RECORDS.
Edit 2: The problem actually occurs on the index part, it takes the minimum of init_records and MAX_INDEX, it cannot be less than 2 in the code, corrected patch: http://openeuphoria.org/pastey/237.wc
Edit 3: Better way to solve, no need to make init_index = 2 http://openeuphoria.org/pastey/240.wc
5. Re: Problems with EDB
- Posted by evanmars Feb 07, 2014
- 2335 views
Thanks guys. I couldn't see that error, even when I compared this to a previous piece of code that I had written that did work. Probably because I "knew" that part was right, the difference didn't even register in my feeble brain.
6. Re: Problems with EDB
- Posted by gbonvehi Feb 07, 2014
- 2355 views
You're welcome evans, those are the hardest to find bugs heh :)
After further testing, the best way to handle this without deeping into EDS internals is to set the default to DEF_INIT_RECORDS if the init_records parameters is less than it.
Here's a patch for it with an improved test over prior attempts: http://openeuphoria.org/pastey/241.wc
Cheers,
Guillermo
Edit: And again... I don't understand the relation in EDS internals, but setting init_records to a minimum of MAX_INDEX also works,
http://openeuphoria.org/pastey/242.wc
http://openeuphoria.org/pastey/243.wc this fixes also clear_table
7. Re: Problems with EDB
- Posted by CraigWelch May 18, 2017
- 1730 views
I've run into this same problem (repetition count must not be less than 0).
Frankly, I don't know how to apply the patch to eds.e
Should I be downloading a new one, and if so, where from. I'm using that obtained in euphoria-4.1.0-OSX-x64.
Or should I manually edit the file, replacing the lines '-' with the lines '+'?
8. Re: Problems with EDB
- Posted by petelomax May 19, 2017
- 1738 views
I've run into this same problem (repetition count must not be less than 0).
Frankly, I don't know how to apply the patch to eds.e
Should I be downloading a new one, and if so, where from. I'm using that obtained in euphoria-4.1.0-OSX-x64.
Or should I manually edit the file, replacing the lines '-' with the lines '+'?
The first thing I'd try is renaming the existing eds.e (just in case) and grabbing the one from http://scm.openeuphoria.org/hg/euphoria/raw-file/ba0fec61913e/include/std/eds.e
Pete
9. Re: Problems with EDB
- Posted by CraigWelch May 20, 2017
- 1681 views
That seems to have sorted things out, many thanks.
10. Re: Problems with EDB
- Posted by DerekParnell (admin) May 21, 2017
- 1657 views
I'm currently looking into eds.e and will be releasing a patched version soon. Its basically an improvement to reliability rather than performance or functionality.
11. Re: Problems with EDB
- Posted by CraigWelch May 23, 2017
- 1607 views
Excellent! Look forward to it.
Any problems I've had with eds, although rare, have been where I have been careless with locking and inadvertently allowed two programs to write to the database at the same time. Errors are rare, but when there are programs running for days, there have to be conflicts.
When I have fixed such situations, there have been no integrity errors at all.