Pastey EDS: create_table error when init_records < MAX_INDEX with loop test
- Posted by gbonvehi
Feb 07, 2014
# HG changeset patch
# User Guillermo Bonvehi
# Date 1391759568 10800
# Node ID b76ebbe7416c0912f496fedb3146ef59442fb8f8
# Parent 2c379fb63e7481d4e7aa1330b5d4789af612a163
EDS: create_table error when init_records < MAX_INDEX
diff -r 2c379fb63e74 -r b76ebbe7416c include/std/eds.e
--- a/include/std/eds.e Wed Jan 29 11:00:14 2014 -0500
+++ b/include/std/eds.e Fri Feb 07 04:52:48 2014 -0300
@@ -1646,10 +1646,10 @@
putn(repeat(0, init_records * 4))
-- allocate initial space for the index
- index_ptr = db_allocate(init_index * 8)
+ index_ptr = db_allocate((init_index+1) * 8)
put4(0) -- 0 records
put4(records_ptr) -- point to 1st block
- putn(repeat(0, (init_index-1) * 8))
+ putn(repeat(0, init_index * 8))
-- store new table
name_ptr = db_allocate(length(name)+1)
diff -r 2c379fb63e74 -r b76ebbe7416c tests/t_database.e
--- a/tests/t_database.e Wed Jan 29 11:00:14 2014 -0500
+++ b/tests/t_database.e Fri Feb 07 04:52:48 2014 -0300
@@ -372,6 +372,25 @@
end procedure
test_dump()
+procedure test_create_table_init_records()
+ sequence the_db = "create_table_init_records.edb"
+ sequence test_table
+ db_fatal_id = routine_id( "db_fatal_error" )
+ db_close()
+ if file_exists( the_db ) then
+ delete_file( the_db )
+ end if
+ test_equal( "create " & the_db, DB_OK, db_create( the_db ) )
+ for i = 0 to 10 do
+ test_table = sprintf( "table%d", i )
+ test_equal( "create " & the_db & " " & test_table, DB_OK, db_create_table( test_table, i ) )
+ db_insert( "dummy", "data" )
+ db_clear_table( test_table )
+ end for
+ db_close()
+ delete_file( the_db )
+end procedure
+test_create_table_init_records()
test_report()