Re: Weird Error Using Euphoria Database System (EDS)

new topic     » goto parent     » topic index » view thread      » older message » newer message
euphoric said...

I'm hoping one of the devs can tell me how to resolve this issue. Everything was working smoothly all day, until suddenly this started happening:

I'll reboot and see if that helps. (It didn't help.) sad

Here's the test code I threw together. Using DB_LOCK_SHARED for db_open() causes it to crash with "wrong file mode for attempted operation" as you're getting. If you switch to DB_LOCK_EXCLUSIVE, it works fine.

include std/eds.e 
include std/error.e 
include std/filesys.e 
 
constant DB_NAME = "db_test.edb" 
constant DB_TABLE_NAME = "companies" 
constant DB_RECORDS = { 
    { 1, {"High Tech Forms, LLC", "hightechforms", ""} } 
} 
 
procedure main() 
    
    object key, value 
    
    if file_exists( DB_NAME ) then 
        delete_file( DB_NAME ) 
    end if 
    
    if db_create( DB_NAME, DB_LOCK_SHARED ) != DB_OK then 
        error:crash( "db_create() failed." ) 
    end if 
    
    if db_create_table( DB_TABLE_NAME ) != DB_OK then 
        error:crash( "db_create_table() failed." ) 
    end if 
    
    db_close() 
    
    -- 
    -- DB_LOCK_NO        : works 
    -- DB_LOCK_SHARED    : fails 
    -- DB_LOCK_EXCLUSIVE : works 
    -- 
    
    if db_open( DB_NAME, DB_LOCK_EXCLUSIVE ) != DB_OK then 
        error:crash( "db_open() failed." ) 
    end if 
    
    if db_select_table( DB_TABLE_NAME ) != DB_OK then 
        error:crash( "db_select_table() failed." ) 
    end if 
    
    for i = 1 to length( DB_RECORDS ) do 
        
        {key,value} = DB_RECORDS[i] 
        
        if db_insert( key, value ) != DB_OK then 
            error:crash( "db_insert() failed." ) 
        end if 
        
    end for 
    
    db_close() 
    
end procedure 
 
main() 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu