Skip to content
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

test: invalid cache plan with prepare stmt #5778

Merged
merged 4 commits into from Oct 20, 2022

Conversation

a631807682
Copy link
Member

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

related to go-gorm/postgres#137

User Case Description

@jinzhu
Copy link
Member

jinzhu commented Oct 19, 2022

Hello @a631807682

I think we might need to provide a Reset func for *PreparedStmtDB, after migrated columns we need to reset prepared statements.

@a631807682
Copy link
Member Author

@jinzhu Reset is unnecessary, it will create prepared stmt for the same query.
https://github.com/go-gorm/postgres/pull/137/files#diff-a5ca21254ced8196f81a4c4e926af32db03cb0ea78a1f853835300f6dda3f0c6R552
However, we can provide a method in PreparedStmtDB to remove a prepared stmt or support skipping prepare when the current query is executed

@jinzhu
Copy link
Member

jinzhu commented Oct 19, 2022

@jinzhu Reset is unnecessary, it will create prepared stmt for the same query. https://github.com/go-gorm/postgres/pull/137/files#diff-a5ca21254ced8196f81a4c4e926af32db03cb0ea78a1f853835300f6dda3f0c6R552 However, we can provide a method in PreparedStmtDB to remove a prepared stmt or support skipping prepare when the current query is executed

The Reset func from my opinion can just remove all cached statements, replace .Stmts with a empty map.

Only remove the select limit 1 SQL seems can't completely avoid the issue.

@a631807682
Copy link
Member Author

@jinzhu I created a pr for it #5782
The current failure is because there is only one place in postgres driver that queries the actual table data, to completely avoid the issue, we need to perform Reset after the table changed.

@jinzhu jinzhu merged commit 9d82aa5 into go-gorm:master Oct 20, 2022
@a631807682 a631807682 deleted the test_invalid_cache_preprare branch October 20, 2022 06:49
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.

None yet

2 participants