Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

bulk loading B-tree with unsigned long keys does not work.

User_2ZA3ODec 25 2020

Hi,
I am trying to bulk load and read from BDB-Btree with "unsigned long int" keys.
When I make some minor modifications in the Bulkexample code, the tree is not being generated correctly.
What I have done: I changed the key type as u_int32_t and changed the variables type in compare_int function as well.
It seemed to me the problem is about alignment.
Then, I put my key data in byte array and used marshalling/unmarshalling techniques, still I cannot read data sorted by key :(
The code has something like the below
u_int32_t keyvalue=rnd->nextUniformUnsignedLong(); // rnd is my random generator
uint32_t sizeOfKey = sizeof(u_int32_t);
uint8_t *bufkey = new uint8_t[sizeOfKey]; // allocate a buffer area.
uint8_t *it = bufkey; // pointer variable to iterate over the buffer.
memcpy(it, &keyvalue, sizeOfKey);

uint8_t *bufdata = new uint8_t[DATALEN]; // allocate a buffer area.
it = bufdata; // pointer variable to iterate over the buffer.
memcpy(it, &(data_val->id), sizeof(int));
it += sizeof(int);
memcpy(it, data_val->str, STRLEN);
...
if (ptrkd->append(bufkey, sizeOfKey,
bufdata, DATALEN) == false)
throwException(dbenv,
txnp, EXIT_FAILURE,...)

In the compare function:
uint32_t sizeOfKey = sizeof(u_int32_t); //uint_fast32_t
uint8_t *it = (uint8_t *)a->get_data(); // allocate a total buffer area. Write explicit size for the array, do not use sizeof()
memcpy(&ai, it, sizeOfKey);
it=nullptr;
it = (uint8_t*) b->get_data(); // allocate a total buffer area. Write explicit size for the array, do not use sizeof()
memcpy(&bi, it, sizeOfKey);

// memcpy(&ai, a->get_data(), sizeof(int));
// memcpy(&bi, b->get_data(), sizeof(int));
return (ai - bi);
Similiar problems occur when I try to load b-tree with double keys..It does not sort correctly.
Thanks for the help. Good holidays..

Comments

MartinBach-Oracle Jan 8 2025

Hi Salomon,

please have a look at this blog post written by @ulrike-schwinn-oracle :

https://blogs.oracle.com/coretec/post/easy-sql-statement-tracking-in23c

I hope this answers your question, if not, please shout!

- Martin

Solomon Yakobson Jan 8 2025

@martinbach-oracle - No, it doesn't answer my question. Article you pointed to shows uses:

SQL> alter system set sql_history_enabled=true scope=both;

And in my post I said “Works fine when enabled on system level”. My question was about

SQL> ALTER SESSION SET SQL_HISTORY_ENABLED = TRUE;

where I showed SQL history was NOT captured even though it should be based on SQL_HISTORY_ENABLED:

Modifiable **ALTER SESSION**, ALTER SYSTEM

SY.

MartinBach-Oracle Jan 8 2025

As per the article I shared the situation is as follows at the moment

  • You must enable SQL history PDB-wide (only a DBA can do that) so there's a certain level of control over the feature
  • Your session has access to the SQL history
  • If you don't want to record anything, set sql_history_enabled to false.

I'm currently assessing if that's intended behaviour (in which case the documentation should be amended) or a feature not working as it should (in which case it needs fixing). The parameter is indeed session-modifyable, but not in the sense you expected.

We'll keep you posted.

- Martin

Solomon Yakobson Jan 8 2025

Do you mean it must be enabled on system level and not on session level and all session can do is disabe it for the session?

SY.

MartinBach-Oracle Jan 14 2025

Yes,

that's correct as of Oracle Database Free 23.6.

- Martin

Solomon Yakobson Jan 14 2025

Thanks Martin, I hope this will be added to 23AI docs soon.

SY.

1 - 6

Post Details

Added on Dec 25 2020
1 comment
235 views