Skip to content

#62489: dba_insert not working as expected #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

#62489: dba_insert not working as expected #125

wants to merge 1 commit into from

Conversation

marc-mabe
Copy link
Contributor

removed warnings if dba_insert failed because of an already existing key.

fixed handlers are:

  • flatfile
  • gdbm
  • inifile
  • qdbm

@smalyshev
Copy link
Contributor

Please add a test.

@marc-mabe
Copy link
Contributor Author

@smalyshev: Tests added now

The test for the inifile handler fails because this handler insert items even if the item already exists.
I removed the waring "Key already exists" within DBA_UPDATE_FUNC(inifile) but the switch case never occur because inifile_append doesn't implement such functionality.

I'm not a C developer so it would be the best merging this but leaving the bug open so another person can fix it.

@marc-mabe
Copy link
Contributor Author

Hello guys, is there someone could review this ?

if(gdbm_store(dba->dbf, gkey, gval,
mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0)
switch(gdbm_store(dba->dbf, gkey, gval, mode == 1 ? GDBM_INSERT : GDBM_REPLACE)) {
case -1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indenting is wrong here.

@lstrojny
Copy link
Contributor

lstrojny commented Jan 6, 2013

@marc-mabe sorry for the long delay. Please fix the coding style issues after that it looks good for merge.

@marc-mabe
Copy link
Contributor Author

@lstrojny : thank you for review! Updated coding style issues now

case -1:
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno));
return FAILURE;
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really correct? Shouldn’t be the default case just throw some error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default case should be impossible - it was copied from DBA_UPDATE_FUNC(flatfile)

  • What should the message say on this case ?
  • "Unknown return value %value% by %lib-function%" ?
  • error, warning or notice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Unknown return value" is fine. Warning seems appropriate to me.

@lstrojny
Copy link
Contributor

After fixing the switch case, could you rebase and squash?

…ected handlers are flatfile, inifile, qdbm and gdbm)
@marc-mabe
Copy link
Contributor Author

done! - updated the switch statements and squashed all commits together


result = dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER);
if (result)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

@lstrojny
Copy link
Contributor

Merged into 5.5 and master. Cannot close it now as GitHub seems to be in trouble.

@php-pulls
Copy link

Comment on behalf of lstrojny at php.net:

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants