Invalid argument when you delete a record in doubles

I use BerkeleyDB 4.7 on Gentoo 2.6.24 - r7.

I have a database with keys duplicated which I access via a slider. When I try to delete one of the records duplicate the function c_del() returns the value 22 (EINVAL) which means a flag is not valid or the cursor is not initialized.

According to the documentation, the indicator (the second argument) should be zero. So the problem must be with the cursor, but him still said that the slider is very well.

I have distilled the problem of autonomous code below. You should be able to cut and paste into a file named deltest.c and compile it. The comments near the top shows how to compile and run it.

The code may seem long, but it's really very simple. He wrote just three records with duplicate keys and reads them. He tries to remove the second disk.

Help, please. I don't know what I'm missing.

-Code starts here-

#include < db.h >
#include < stdio.h >
#include < stdlib.h > to
#include < string.h >

#define FREE (V) if (V) {free (V); V = NULL ;}

/*
o deltest deltest.c-L /usr/local/BerkeleyDB.4.7 GCC - ldb
mkdir deltest_env
. / deltest
RM deltest_env
*/
main()
{
DB_ENV * envp;
DB * dbp;
DBC * cursor;
DBT key;
DBT data;
DB_TXN * txn;

int rc;

/*-----------------------
An open environment and the database; define indicators sorted duplicates
*/
RC = db_env_create (& envp, 0);
fprintf (stderr, "after the structure created environment: %d\n", rc);

RC = envp-> open (envp, 'duptest_env', DB_CREATE |) DB_INIT_TXN | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL, 0);
fprintf (stderr, "after the opening of environment: %d\n", rc);

RC = db_create (& dbp, envp, 0);
fprintf (stderr, "after the created database structure: %d\n", rc);

RC = dbp-> set_flags (dbp, DB_DUPSORT);
fprintf (stderr, "after the series of flags: %d\n", rc);

RC = dbp-> open (dbp, NULL, "deltest", NULL, DB_BTREE, DB_CREATE |) DB_AUTO_COMMIT, 0600);
fprintf (stderr, "after the opening of database: %d\n", rc);

/*-----------------------
BEGIN transaction, write three records with the same key, commit
*/
TXN = NULL;
RC = envp-> txn_begin (envp, NULL, & txn, 0);
fprintf (stderr, "after obtaining the transaction handle: %d\n", rc);

Memset (& key, 0, sizeof (DBT));
Memset (& data, 0, sizeof (DBT));

Key.Data = strdup ("key");
Key.Size = strlen (key.data);

Data.Data = strdup ("some arbitrary data");
Data.Size = strlen (data.data);

RC = dbp-> put (dbp, txn, key, & data, DB_NODUPDATA);
fprintf (stderr, "after the first written record: %d\n", rc);

FREE (data.data)
Memset (& data, 0, sizeof (DBT));
Data.Data = strdup ("some other arbitrary data');
Data.Size = strlen (data.data);

RC = dbp-> put (dbp, txn, key, & data, DB_NODUPDATA);
fprintf (stderr, "after the first record in double writes: %d\n", rc);

FREE (data.data)
Memset (& data, 0, sizeof (DBT));
Data.Data = strdup ("Some data more arbitrary");
Data.Size = strlen (data.data);

RC = dbp-> put (dbp, txn, key, & data, DB_NODUPDATA);
fprintf (stderr, "after the second written duplicate: %d\n", rc);

RC = txn-> commit (txn, 0);
fprintf (stderr, "after the transaction are committed: %d\n", rc);


/*-----------------------
Create a cursor and read back the three records.
After reading the other, we try to remove it.
Then we read for the fourth time just show that there is more no record.
*/
RC = dbp-> cursor (dbp, NULL, & slider, 0);
fprintf (stderr, "after the cursor created: %d\n", rc);

FREE (key.data)
FREE (data.data)
Memset (& key, 0, sizeof (DBT));
Key.Flags = DB_DBT_MALLOC;
Memset (& data, 0, sizeof (DBT));
Data.Flags = DB_DBT_MALLOC;

RC =-> c_get cursor (cursor, & key and data, DB_NEXT);
fprintf (stderr, "after the first EEG: %d - % s: %s\n", rc, key.data, data.data);

FREE (data.data)
FREE (key.data)
Memset (& key, 0, sizeof (DBT));
Key.Flags = DB_DBT_MALLOC;
Memset (& data, 0, sizeof (DBT));
Data.Flags = DB_DBT_MALLOC;

RC =-> c_get cursor (cursor, & key and data, DB_NEXT);
fprintf (stderr, "after the second get: %d - % s: %s\n", rc, key.data, data.data);

/ * Here, we try to delete the current record * /.
RC = cursor-> c_del (cursor, 0);
fprintf (stderr, "after delete: %d\n", rc);
/ * The return code is EINVAL (22), but I see nothing wrong with the arguments to the c_del() function * /.



FREE (data.data)
FREE (key.data)
Memset (& key, 0, sizeof (DBT));
Key.Flags = DB_DBT_MALLOC;
Memset (& data, 0, sizeof (DBT));
Data.Flags = DB_DBT_MALLOC;

RC =-> c_get cursor (cursor, & key and data, DB_NEXT);
fprintf (stderr, "after the third get: %d - % s: %s\n", rc, key.data, data.data);




FREE (data.data)
FREE (key.data)
Memset (& key, 0, sizeof (DBT));
Key.Flags = DB_DBT_MALLOC;
Memset (& data, 0, sizeof (DBT));
Data.Flags = DB_DBT_MALLOC;

RC =-> c_get cursor (cursor, & key and data, DB_NEXT);
fprintf (stderr, "after the fourth get: %d - % s: %s\n", rc, key.data, data.data);



/*-------------------------------------------
Close the cursor, data base and the environment
*/

RC = cursor-> c_close (cursor);
fprintf (stderr, "after the cursor close: %d\n", rc);

RC = dbp-> close (dbp, 0);
fprintf (stderr, "after the closing of the database: %d\n", rc);

RC = envp-> close (envp, 0);
fprintf (stderr, "after the closure of environment: %d\n", rc);

Exit (0);
}

Published by: user8104091 on June 23, 2009 16:45

Make a Berkeley DB error output? If this is not the case, try adding this call before opening the environment:

envp->set_errfile(envp, stderr);

Nevertheless, it seems that the problem is that you open the transactional database, then open the cursor without a transaction. Nontransactional cursors can read a transactional database (in isolation 'read committed'), but cannot perform updates. To update a transactional database, you must include a transaction.

Here, you can open the cursor in a transaction that is configured with the DB_READ_COMMITTED flag to avoid read - lock the database entire when you scan through it.

Kind regards
Michael Cahill, Oracle Berkeley DB.

Tags: Database

Similar Questions

  • Thunderbird no longer responds when you delete messages SOLVED caused by attachment tree addon

    Thunderbird "does not" for a few minutes when you delete one or more messages. All messages are downloaded via POP3, deleted items folder is usually empty, but sometimes there are 2-5 emails in there. For the most part occurs after the beginning of the new computer and first use of Thunderbird running on Windows 8.1 with a material more really fast.
    There is no Add-ons installed. And it is not related to the virus. the problem is with any antivirus or without it.

    It's a simple bug.

    It becomes a similar problem (less often) when sending emails with inline images or when the SSL certificate on the server and the exception has not been accepted yet. That's the problem since 2013 when I started using Thunderbird.

    It is not present on some of the slower laptops that I use.

    Start * Windows * safe mode with active network
    -win8 http://windows.microsoft.com/en-us/windows-8/windows-startup-settings-safe-mode
    -win7 http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-7
    - Http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/boot_failsafe.mspx XP

    Always in Windows safe mode, start thunderbird in safe mode
    - http://support.mozillamessaging.com/en-US/kb/safe-mode

    Problem disappear?

    -If no, then the problem is either: bug in Thunderbird, in your Thunderbird profile, your email provider. Please post the help content in the topic. Troubleshooting | copy the text to the Clipboard

    -If so, (always in Windows safe mode)... Start Thunderbird normally

       -- If problem is still gone, then cause is a program loaded during windows startup.  Possibilities include: antivirus SW, virus/malware, background downloads such as program updates
       -- If problem is NOT gone, then cause is likely a Thunderbird addon - eliminate them by disabling each one at a time in Tools | addons | extensions and restarting
    
  • TB crashes when you delete e-mail messages. Only the anti-virus is Windows Defender.

    When I click on an e-mail message and click one of the buttons < delete > the little blue circle lights up and I get a message "(ne répond pas)". " This is a < delete > click for the line of a message. Usually occurs after removing a few previous emails

    24.4.0 TB. Windows8.1. Windows Defender. All up to date.

    I checked. Do _not_ have McAfee, Norton, Avast, etc. system or in the form of modules.

    Tried to reboot Windows 8.1. a couple of times. Problem remains.

    Your initial problem was talking about freezing when you delete messages from Thunderbird.
    Still you see that now?

  • Mail crashes when you delete an email, sparking a boot, running El Capitan on a MacBook Pro 13 inch, mid-2012.

    Mail, Version 9.2 (3112), crashes when you delete an email, sparking a boot on a MacBook Pro running E Capitan, 13-inch, mid-2012, is 2.9 GHz Intel Core i7 processor, memory is 8 GB 1600 MHz DDR3 and trash is clear. It's frustrating! I was unable to copy a part of the final report to include and cannot find where are stored copies of the reported errors. Thank you!

    Start Safe Mode removes the system caches that can help.

    Upper left corner of your screen, click on the Apple  > Shut Down.

    After your Mac stops, wait 10 seconds, then press the power button.

    As soon as you hear the startup tone, hold down the SHIFT key. You must press the SHIFT key as soon as possible once you hear the startup tone, but not before.

    Release the SHIFT key when you see the gray Apple logo and progress indicator.

    Once you are in Mode without failure, return to the menu Apple . In the drop-down list, click: reboot

    Then try to delete an e-mail message.

    On Safe Mode

  • Is it possible to cut the warning you get when you delete a photo?

    Is it possible to cut the warning you get when you delete a photo?  It slows down the process so when you have thousands of pass by...

    Use the combination of keys ⌘⌫ (ccommand - delete) to remove a photo from a time or an album.  That will move the photo directly on the album recently deleted without any question.

    But don't forget to check the album recently removed carefully before you clear, if you use this method of removal.

  • When you delete a file in Vista, the dialog box remove does not close until the computer is restarted

    When you delete a file in Windows Vista, the dialog box remove don't close until the computer is restarted. It is sometimes possible to remove it by closing tha task list. When this is done, the Explorer is closed and restarted.

    Hi Brian,.

    (1) since when are you facing this problem?

    (2) remember to make changes?

    Method 1: Run the fixit available in the link below and check if that makes a difference

    Difficulty of broken desktop shortcuts and common system maintenance tasks


    Note:
    Fixit would attempt to recover bad sectors on the hard disk, in the course of this process there are chances of data loss from that particular area.

    Method 2: If a Protection of resources Windows (WRP) file is missing or is damaged, Windows may not behave as expected. Auditor of file system (CFS) scan to fix all of the corrupted system files. To do this, follow the steps mentioned in the link below:

    How to use the System File Checker tool to resolve missing or damaged on Windows Vista or Windows system files

    http://support.Microsoft.com/kb/929833

    Method 3:  Select the boot and then check if the problem persists

    Follow step 1 in the link below,
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    Important: n ' forget not to put the computer to a normal startup follow step 7 in the link.

  • When you delete files (in Windows 7) Explorer hangs on 'calculate' the size of the files to delete. This problem also occurs in Windows Vista (out and included SP1).

    When this problem happens:
    * You try to delete files, from any folder: a folder user protected (such as your desktop), a protected windows folder (such as program files) or an unprotected folder you created yourself (for example, a folder named "test" on your C permit)
    * The problem only occurs when you try to delete files using Windows Explorer. The problem only IS NOT OCCUR when you delete the files from another system using one hand (log on to another computer, open a shared folder, for example by opening \\windows7system\c$\test and try to remove this folder).

    What's happening:
    * Explorer crashes when 'Calculating' the features of folder.

    Question:
    * Why is this happening? It seems to be a problem in Explorer, not in the delete code actually (since the problem does not occur with one hand)

    I don't know the underlying cause or how to fix it. However, something like Unlocker would work.
    http://ccollomb.free.fr/Unlocker/

    Tom

  • How will I know where the time goes when you delete a line?

    Dear experts,

    Removal of certain rows in a table (approx. 4.9 GB / 2.9 Millon lines) takes an average of.5 seconds each line (on average).

    This table contains 3 clues, just I just rebuild. Statistics from a couple of the day before.

    I have imported/exported the table to a new schema and destruction prend.002 seconds each line (on average).

    How will I know where the time goes when you delete a line?

    BTW, this is ORACLE 10 g

    Thank you
    Serra

    There the child tables of this table with FK defined as DELETE CASCADE?

  • When you delete an email is far from stop the next e-mail to open.

    When I delete an email that I read and remove it is there a way to keep the side an automatic opening.

    You can use this addon:
    "Clear delete".
    https://addons.Mozilla.org/en-GB/Thunderbird/addon/deselect-on-delete/

    Download addon xpi file to the downloads or desktop folder.

    How to install:
    'Tools > "Add-ons"
    or
    'The menu icon ' > 'Add-ons'

    • Click the gear icon and select 'install module file.
    • Find the downloaded *.xpi file and click 'open '.
    • You have as much need to restart Thunderbird when you are prompted.
  • When you delete an email, often both enamel stressed I want to delete and the following e-mail are both deleted, not one only. How to change that?

    When I delete an email which is highlighted and displayed on my screen, several times but not always, the following e-mail that is displayed is also deleted. It just started doing this a few weeks ago. How to return to the removal of all email that appears? I appreciate all help.

    Try a new/other mouse. Looks like yours is to give a double click when you just click.
    If you use the DEL key on the keyboard is only the removal of a message?

  • When you delete an email I get a message "unable to forward the message to the trash?" Why?

    When I delete an email, I get a message "unable to forward the message to the trash?" How to fix this problem?

    Try this. Settings > Mail, contacts, calendars > your e-mail account name > account > advanced (swipe down to see this) > deleted mailbox > Trash and make sure that move you the rejected Messages in > deleted mailbox.

  • Field image cannot refresh when you move between records in a jsf page

    In jdev 12.1.2

    I have a formlayout in a jsf page, there is an af:image that bind to a url of the image file, the source code is like this:

    ("#{bindings.") Headpicurl.inputValue}')

    < f: facet = '3' tab name >

    < af:panelFormLayout id = "pfl1" >

    < af:inputText value = "#{bindings." Id.inputValue}"label =" #{bindings. " ID.hints.label}.

    required = "#{bindings." ReadOnly ID.hints.Mandatory}' = 'true '.

    columns = "#{bindings." Id.hints.displayWidth}.

    maximumLength = "#{bindings." ID.hints.Precision}.

    shortDesc = "#{bindings." ID.hints.ToolTip}"id ="it1">

    < f: validator binding = "#{bindings." ID. Validator} "/ >"

    < / af:inputText >

    < af:image shortDesc = "#{bindings." Headpicurl.hints.ToolTip}"id ="it4.

    source = "#{bindings." Headpicurl.inputValue} "/>"

    < f: facet name = "footer" >

    < af:panelGroupLayout layout = "horizontal" id = "pgl1" >

    < af:button actionListener = "#{bindings." First.Execute text}"="First"

    Disabled = "#{!}" bindings. PartialSubmit First.enabled}"="true"id ="b1"/ >

    < af:button actionListener = "#{bindings." Previous.Execute text}"="previous ".

    Disabled = "#{!}" bindings. PartialSubmit Previous.enabled}"="true"id ="b2"/ >

    < af:button actionListener = "#{bindings." Next.Execute text}"="next ".

    Disabled = "#{!}" bindings. PartialSubmit Next.enabled}"="true"id ="b3"/ >

    < af:button actionListener = "#{bindings." Last.Execute text}"="Last ".

    Disabled = "#{!}" bindings. PartialSubmit Last.enabled}"="true"id ="b4"/ >

    < / af:panelGroupLayout >

    < / f: facet >

    < / af:panelFormLayout >

    < / f: facet >

    But when I browse the records on the page, other areas will be update correctly, except for the field of the image - the image field showing will not refresh.

    Can someone help?

    Thank you.

    so I the records of buttons and update Navigation to set null values from Headpicurl to a valid value, the value of the PartialTriggers property of this image tag.

    Then, the page will be updated correctly for all areas, including the field of view when do the record navigation.

    But after I have erased the property PartialTriggers of this image tag and reload the page, or even restart the jdev, it still works OK now!

    -Then setting this property PartialTriggers the real cause of the previous question of no image field refresh?

    Well, you also updated your nulls to the actual URL so maybe posing (in combination with the caching of the browser)?

    General approach to prevent caching of web resources is the addition of random string to the url of the resource (as suggested by Cvele) or you can write custom servlet which will serve as a proxy and add http headers (non-cache, non-store, must-revalidate expires,...) to prevent caching.

    Anyway, now I have to get rid of the question above. However, a new problem emerges:

    When I update and validation records the attributes of the database. the fields in the jsf page will not display the newly modified database records even if I refreshed the browser or press F5.

    Only after that I open the jsf page in a new browser window, database changes will appear.

    -Is caused by the caching of the browser? and how to fix it?

    How you exactly "update and validation" records (in the same application or a different app/session)?

    If you do this session or different application then you must run query VO again.

    Dario

  • crashes when you delete the keyframe!

    my old project from the previous version crashes when I delete a keyframe also, I can't directly delete transitions. so bugs

    Thanks, stimulus creative cloud was the solution.

    Thank you!

    Andrea

  • Make it visible to a field when you delete a page in Livecycle

    Hello world

    When adding a page, the last page footer is automatically deleted. It works perfectly. But I wish that the footer appears again on the last page when I delete the current page.

    Here's the code used with the initialize event:

    for (var i = 0; i < xfa.resolveNode("ira._Page1").count; i ++)

    {

    If (I < xfa.resolveNode("ira._Page1").count - 1).

    {

    xfa.resolveNode ("ira. Page 1 ["+ I.ToString +" '].. Presence footer') = 'hidden ';

    }

    on the other

    {

    xfa.resolveNode ("ira. Page 1 ["+ I.ToString +" '].. Presence footer') = 'visible ';

    }

    }

    This is used with the to a page adding click event:

    _Page1.addInstance ();

    xfa.host.pageDown ();

    app.execMenuItem ("FitPage");

    and at least for the deletion of a page

    This.parent.parent._Page1.removeInstance (this.parent.index);

    This.parent.parent._Carte.removeInstance ();

    Thanks in advance for your help.

    Hi phil,.

    You must remember, whenever you delete instances, you must always remove it finally in your code. Because if you delete the subform or page where the code works well the code no longer exists.

    If you need to make sure you make all the rest with other objects before deleting the instance of its parent.

  • Invalid number when you use to_number function

    Hello
    Both in SQL * more and SQL Deveoper when I type and run

    Select to_number ('1234.64 ','9999.9 ') of double;

    I get ORA-01722: invalid number error. What can be the reason for this error?

    Mikhail says:
    SQL > select to_number('1234.64','9999D9') from double;
    Select double to_number('1234.64','9999D9')
    *
    ERROR on line 1:
    ORA-01722: invalid number

    You pass it a string ("1234.64'") with two digits to the right of the decimal separator, but you tell it that you have only one digit to the right of the decimal separator ('9999 D 9')

Maybe you are looking for

  • How to find and remove the files in 'other' storage on Macbook Air?

    I already cleaned everything that's obvious files... trash, downloads, etc. But I still 65 GB of the file in 'others '. How can I find large files in 'Other' and delete them?

  • User profile of repair

    How can I fix a user profile? I'm having problems with my Adobe products and had an Adobe agent through my question.He told me that the problem comes from my user profile. I have tried repairing permissions and running, Onyx etc... But I still have p

  • Error in the printer - Deskjet 6840

    My printer displays the message - "Not compatible with the printer ink cartridge" and will not print a document. I use HP 94 and 95 cartridges. They were new a month ago. The printer has been my reliable MAC since the purchase of this issue four or f

  • "User profile Service service has no logon. User profile cannot be loaded. »

    So, here's the deal. Yesterday I logged my (Administrator) account and Firefox was doing some update. Now, here's what happened. I logged the update, because the cell phone was MAJORLY slow. So, the next time I try to login, I get the above error mes

  • I can open an .aspx file, but I can't print the file?

    I open an .aspx file and fill in the empty fields.  When I go to print the file he ask is if I want to record on documents.  I click on Ok, but then I can't find the file.  What should I do to print the file directly?