Skip to content

Deallocate prepared statements #6665

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

Merged
merged 20 commits into from
Oct 17, 2022

Conversation

fpoy
Copy link
Contributor

@fpoy fpoy commented Oct 11, 2022

Fixes #1256

Description

Implement a common method in each database connector to destroy the prepared query when we're done with it

Cf Issue #1256 : TODO Deallocate prepared statements

To closes a prepared statement :

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added wrong branch PRs sent to wrong branch enhancement PRs that improve existing functionalities labels Oct 11, 2022
@kenjis
Copy link
Member

kenjis commented Oct 11, 2022

Thank you for contribution!

This is not a bug fix, so this should go to 4.3 branch.
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#if-you-sent-to-the-wrong-branch

@fpoy fpoy force-pushed the FEAT_deallocate_prepared_statements branch from a4e2442 to 3bd2a24 Compare October 11, 2022 13:47
@fpoy fpoy changed the base branch from develop to 4.3 October 11, 2022 13:48
@fpoy
Copy link
Contributor Author

fpoy commented Oct 11, 2022

@kenjis that's done, I've rebased the PR to 4.3 branch

@kenjis
Copy link
Member

kenjis commented Oct 11, 2022

@fpoy There are four commits made by Paul and me. Please drop them.
You can do it with git rebase.
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#updating-your-branch

@kenjis kenjis added docs needed Pull requests needing documentation write-ups and/or revisions. 4.3 and removed wrong branch PRs sent to wrong branch labels Oct 11, 2022
@fpoy fpoy force-pushed the FEAT_deallocate_prepared_statements branch from 45334d0 to 95bbed1 Compare October 12, 2022 07:17
@fpoy
Copy link
Contributor Author

fpoy commented Oct 12, 2022

@fpoy There are four commits made by Paul and me. Please drop them. You can do it with git rebase. See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#updating-your-branch

@kenjis it's done, there are only my commits left on the branch...

@kenjis kenjis added the database Issues or pull requests that affect the database layer label Oct 12, 2022
@kenjis
Copy link
Member

kenjis commented Oct 12, 2022

Thank you. The commits are okay.

  1. We need the documentation. Please add changelog.
  2. If possible, please reduce rather than increase phpstan-baseline.neon.dist.

@fpoy
Copy link
Contributor Author

fpoy commented Oct 12, 2022

The documentation on this subject already exists
What should be added to it ?
image

@fpoy
Copy link
Contributor Author

fpoy commented Oct 12, 2022

in user_guide_src/source/database/queries/020.php

$error = $pQuery->close();

Would that be sufficient ?

@kenjis
Copy link
Member

kenjis commented Oct 12, 2022

Please add about this enhancement in the Enhancements section:
https://github.com/codeigniter4/CodeIgniter4/blob/4.3/user_guide_src/source/changelogs/v4.3.0.rst#database

@MGatner
Copy link
Member

MGatner commented Oct 12, 2022

Thanks @fpoy this looks like great stuff! @kenjis has already covered most of it but summoning the rest of the @codeigniter4/database-team so they can see this too.

@kenjis
Copy link
Member

kenjis commented Oct 12, 2022

The documentation on this subject already exists
What should be added to it ?

https://codeigniter4.github.io/CodeIgniter4/database/queries.html#close

It seems the close() method does nothing with some DBMS before this PR.
How about adding the note for it?
Something like this:

Since v4.3.0, the close() method deallocates the prepared query in all DBMS. In previous versions, the prepared query was not deallocated in xxx and xxx.

@fpoy fpoy force-pushed the FEAT_deallocate_prepared_statements branch from 6281a97 to d258714 Compare October 12, 2022 10:23
@sclubricants
Copy link
Member

LGMT

The only thing is you might add to the test to check that the statement is actually cleared. For MySQL:

SHOW GLOBAL STATUS LIKE '%prepared_stmt_count%';
# 0

SQLITE https://www.sqlite.org/c3ref/stmt_status.html

Postgres https://www.postgresql.org/docs/current/view-pg-prepared-statements.html

@kenjis kenjis removed the docs needed Pull requests needing documentation write-ups and/or revisions. label Oct 13, 2022
@MGatner
Copy link
Member

MGatner commented Oct 13, 2022

This is looking great everyone. Thanks for all the collaboration!

@fpoy fpoy force-pushed the FEAT_deallocate_prepared_statements branch from e9f022b to f859e46 Compare October 17, 2022 07:50
@kenjis kenjis removed the stale Pull requests with conflicts label Oct 17, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

Looks great! I can't tell if that last thread is resolved yet.

Whoever merges: please squash this one.

@kenjis kenjis merged commit 1a82717 into codeigniter4:4.3 Oct 17, 2022
@fpoy fpoy deleted the FEAT_deallocate_prepared_statements branch October 18, 2022 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Issues or pull requests that affect the database layer enhancement PRs that improve existing functionalities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants