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!

comparison function returns incorrect data

3333809Oct 21 2016 — edited Nov 1 2016

i have modified the examples/c/ex_heap.c to read from one db and insert/delete in another.  For some reason one of the keys that the comparison function receives is either truncated or doesn't match any records in the db.  This is my comparison function

int compare_cmid(dbp, a, b, lob)

        DB *dbp;

        const DBT *a, *b;

        size_t *lob;

{

       //char* temp_a = (char*)a->data;

       //char* temp_b = (char*)b->data;

       //printf("temp_a = %s\n", temp_a);

       //printf("temp_b = %s\n", temp_b);

        char key_a[25];

        char key_b[25];

        memset(key_a,'\0',sizeof(key_a));

        memset(key_b,'\0',sizeof(key_b));

       int ascii_a[256];

       int ascii_b[256];

       int i;

       memset(ascii_a, 0, sizeof(ascii_a));

       memset(ascii_b, 0, sizeof(ascii_b));

       strcpy(key_a, a->data);

       strcpy(key_b, b->data);

       printf("key_a = %s\n", key_a);

       printf("key_b = %s\n", key_b);

       int l_a;

       l_a =  strlen(key_a);

       int l_b;

       l_b = strlen(key_b);

       int value;

       for (i=0; i<l_a; i++) {

         value = key_a[i];

         ascii_a[value]++;

       }

       for(i=0; i<l_b; i++) {

         value = key_b[i];

         ascii_b[value]++;

        }

       for(i=0; i<256; i++) {

         if(ascii_a[i] > ascii_b[i]) {

             return 1;

         } else if (ascii_a[i] < ascii_b[i]) {

             return -1;

         }

       }

       return 0;

}

b is often messed up.  I'm setting the comparison function before opening the db and it gets called fine but just not with the expected keys.  Please assist.

This post has been answered by userBDBDMS-Oracle on Oct 21 2016
Jump to Answer

Comments

User_K2PC5
Answer

Looks like I was able to figure it out using the following connection string after digging deeper into one of the threads here.
User Id=proxy;Data Source=dbhostname:1521/DBSERVICENAME;Proxy User Id=userid; Proxy Password=userpassword;

Source of the answer was the following, as provided by Kristian Vinther on dba.stackexchange (I can't post links or I would just provide the hyperlink)

finally found out how to represent the proxy user login via my connection string.
Proxy User ID = MyUser
Proxy Password = MyUser password
User Id = SchemaName
User Password not set.

SELECT SYS_CONTEXT('USERENV', 'PROXY_USER'), SYS_CONTEXT('USERENV', 'SESSION_USER') FROM dual
Marked as Answer by User_K2PC5 · Nov 19 2020
Christian.Shay -Oracle

Hi,
Thanks for posting. It is no longer needed to use the workaround of using an ODP.NET Connection String to connect using a proxy user name and password like you show above..
As of version 19.3.3, we added a Show more options checkbox that will reveal the proxy username and password fields.
So, to connect using a proxy, in the connection dialog, check the Show more options checkbox and provide the proxy username and password in the fields that are revealed.

emanuele mattiolo

Hi and sorry, I couldn't log in with my proxy user. See screenshot of the sql developer configuration and that of VS. where am I wrong? Thank you

Documento1.pdf

Christian.Shay -Oracle

Looks like you have a new issue. Next time, please start a new thread instead of adding to an old one.

In your screenshot you are using brackets. With this VS Code extension you do not use brackets.

From the documentation:

In other tools, you may have connected using this format: proxyusername[username]/ [proxypassword]

With Oracle Developer Tools for VS Code, fill the connection dialog like so:

Username: Enter database username. ("/" (forward slash) is not allowed with proxy connections).

Password: Enter the database password. Leave blank for single-session proxy. Password is required for two-session proxy.

Show more options: Check this box

Proxy Username: The proxy username. (Other tools use the format proxyusername[username]/ [proxypassword]). Use "/" (forward slash) if using external authentication (i.e. OS/Kerberos/Certificate) or if using SEPS wallet for database username and password.

Proxy Password: The proxy password. (Other tools use the format proxyusername[username]/ [proxypassword]). Leave blank if Proxy Username field is "/" (forward slash) .

1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 29 2016
Added on Oct 21 2016
23 comments
1,109 views