1. Possible problem in EDS

Version 4.0.5 Windows 10
1. Open database
2. Print out table names and sizes returned by db_table_size()
3. Delete a table
4. Print out table names and sizes returned by db_table_size()
The sizes returned in 4. are different from the sizes returned in 2.
If one closes the database after step 3 and immediately reopens it the sizes returned are correct.

Just a curiosity!

Regards,
jd

new topic     » topic index » view message » categorize

2. Re: Possible problem in EDS

jessedavis said...

...

Just a curiosity!

Regards,
jd

This does not look good.

include std/eds.e 
include std/console.e 
include std/filesys.e 
 
    display( "cleanup first" ) 
     
? delete_file( current_dir() & "/" & "mydata.edb" )  
 
    display( "-- create a new database------ ") 
      
? db_create( "mydata", DB_LOCK_NO) 
 
    display(  "---- add tables with records to database ----------"  ) 
 
for i=1 to 5 do 
    ? db_create_table( sprintf( "my_%d_table", i ) ) 
 
    -- add some records 
    for j=1 to rand(20) do 
        ? db_insert( j, rand(100) ) 
    end for 
end for 
 
sequence names = db_table_list() 
 
for i=1 to length(names) do 
    printf(1, "%20s %d\n", {names[i], db_table_size( names[i] ) } ) 
end for 
 
    display( "\n======== delete one table =============" ) 
 
db_delete_table( "my_3_table" ) 
names = db_table_list() 
 
for i=1 to length(names) do 
    printf(1, "%20s %d\n", {names[i], db_table_size( names[i] ) } ) 
end for 
 
 
    display( "\n--------- close and open the database" ) 
 
db_close() 
? db_open( "mydata" ) 
     
names = db_table_list() 
 
for i=1 to length(names) do 
    printf(1, "%20s %d\n", {names[i], db_table_size( names[i] ) } ) 
end for 

Can not say way.

thanks

_tom

new topic     » goto parent     » topic index » view message » categorize

3. Re: Possible problem in EDS

Tried to do this using Phix without luck:

    ?  "cleanup first" 
     
{} =  delete_file( current_dir() & "/" & "mydata.edb" )  
 
    ? "-- create a new database------ " 
      
{} = db_create( "mydata", DB_LOCK_NO) 
 
    ?   "---- add tables with records to database ----------"  
    set_rand(1001) 
for i=1 to 5 do 
    sequence tablename = sprintf( "my_%d_table", i ) 
  --  ? tablename 
    {} = db_create_table( tablename ) 
    {} = db_select_table( tablename ) 
    -- add some records 
    integer rec_count = i + rand(20) 
    ? rec_count 
    for j=1 to rec_count do 
        {} = db_insert( j, rand(50) ) 
    end for 
end for 
 
 
 
sequence names = db_table_list() 
 
? names 
 
 
 
 
 
for i=1 to length(names) do 
 
    ? names[i] 
    {} = db_select_table( names[i] ) 
    ? db_table_size() 
end for 
 
 
/* 
"cleanup first" 
"-- create a new database------ " 
"---- add tables with records to database ----------" 
3 
4 
14 
12 
8 
{"my_1_table","my_2_table","my_3_table","my_4_table","my_5_table"} 
"my_1_table" 
3 
"my_2_table" 
4 
"my_3_table" 
Trace/breakpoint trap (core dumped) 
 
 
------------------ 
(program exited with code: 133) 
Press return to continu 
*/ 
 

_tom

new topic     » goto parent     » topic index » view message » categorize

4. Re: Possible problem in EDS

_tom said...

Tried to do this using Phix without luck:

There is a (linux-only) bug in builtins\VM\pfileioN.e around line 4130: when it calls sys_llseek it should save and restore edi like it does esi. Same deal for 64-bit around line 4285.

I have pushed that update to the repository, and the rebuilt files p32 and p64 to http://phix.x10.mx/download.php (so you need to run wget http://phix.x10.mx/p32 and mv p32 phix/p, ditto for 64 bit)

Pete

new topic     » goto parent     » topic index » view message » categorize

5. Re: Possible problem in EDS

Running this on Phix

?"cleanup first" 
 
{} = delete_file(current_dir() & "/" & "mydata.edb") 
 
?"-- create a new database------ " 
 
if db_create("mydata", DB_LOCK_NO)!=DB_OK then ?9/0 end if 
 
?"---- add tables with records to database ----------" 
 
for i=1 to 5 do 
    if db_create_table(sprintf("my_%d_table", i))!=DB_OK then ?9/0 end if 
 
    -- add some records  
    for j=1 to rand(20) do 
        if db_insert(j, rand(100))!=DB_OK then ?9/0 end if 
    end for 
end for 
 
sequence names = db_table_list() 
 
for i=1 to length(names) do 
--  printf(1, "%20s %d\n", {names[i], db_table_size( names[i] ) } )  
    if db_select_table(names[i])!=DB_OK then ?9/0 end if 
    printf(1, "%20s %d\n", {names[i], db_table_size()}) 
end for 
 
?"======== delete one table =============" 
 
db_delete_table("my_3_table") 
names = db_table_list() 
 
for i=1 to length(names) do 
    if db_select_table(names[i])!=DB_OK then ?9/0 end if 
    printf(1, "%20s %d\n", {names[i], db_table_size()}) 
end for 
 
?"--------- close and open the database" 
 
db_close() 
if db_open("mydata")!=DB_OK then ?9/0 end if 
 
names = db_table_list() 
 
for i=1 to length(names) do 
    if db_select_table(names[i])!=DB_OK then ?9/0 end if 
    printf(1, "%20s %d\n", {names[i], db_table_size()}) 
end for 

now gives me

"cleanup first" 
"-- create a new database------ " 
"---- add tables with records to database ----------" 
          my_1_table 15 
          my_2_table 7 
          my_3_table 19 
          my_4_table 14 
          my_5_table 17 
"======== delete one table =============" 
          my_1_table 15 
          my_2_table 7 
          my_4_table 14 
          my_5_table 17 
"--------- close and open the database" 
          my_1_table 15 
          my_2_table 7 
          my_4_table 14 
          my_5_table 17 

which looks fine to me

Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu