dbTalk Databases Forums  

structs with int members

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss structs with int members in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pbour
 
Posts: n/a

Default structs with int members - 09-18-2006 , 05:09 AM






I am having a strange problem.

I define the following struct to be the value of a BDB database record

typedef struct my_struct
{
int a;
int b;
} MY_STRUCT;


BUT the procedure of inserting a new record in the database actually
does not work. I am thinking whether there is a general problem of BDB
with integers, because if I use char * for the members of the struct,
the record is inserted. Or maybe I don't set correctly the value
object.

MY_STRUCT test;

test.a = given_a;
test.b = given_b;
tuple.data = &test;
tuple.size = sizeof(test);

dbp->put(dbp, NULL, &key, &tuple, 0)

The key is also an integer but it works fine.

Any ideas?


I also have associated two secondary databases with my primary using
key extractors (in case of integer members) like

skey->data = ((MY_STRUCT*)pdata->data)->a;
skey->size = sizeof(((MY_STRUCT*)pdata->data)->a);

Is it possible that the association of secondary databases is
responsible for the problem?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.