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

let limit and offset use bind parameter #6806

Merged
merged 14 commits into from
Feb 6, 2024
Merged

let limit and offset use bind parameter #6806

merged 14 commits into from
Feb 6, 2024

Conversation

jasonchuan
Copy link
Contributor

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

What did this pull request do?

two changes for solving the limt and offset problem which is possible to cause continuously increasing of prepared_stmt_count of mysql , max_prepared_stmt_count value range is 0 - 1048576 and default 16382.

User Case Description

the caller used while true ugly code to call our api , our api has bugs for no checking if the limit and offset is below the total row number . limit and offset was going far away from the row count . a number of sql would be prepared in mysql ,much more than max_prepared_stmt_count .
FATAL: MySQL error: 1461 "Can't create more than max_prepared_stmt_count statements (current value: 1048576 )"

@jinzhu
Copy link
Member

jinzhu commented Jan 29, 2024

Hi @jasonchuan

thank you for your pr, can you please fix those failed tests?

@jasonchuan
Copy link
Contributor Author

Hi @jasonchuan

thank you for your pr, can you please fix those failed tests?

Hi @jasonchuan

thank you for your pr, can you please fix those failed tests?

ok I'll fix those later!

chenchuan and others added 4 commits January 29, 2024 16:55
…e added a wrong one called pgx.QueryExecModeSimpleProtocol , causing the SQL with limit problem need 1 parameter ,but given two.
@jasonchuan
Copy link
Contributor Author

@jinzhu got the job done , please approve the postgress commit (go-gorm/postgres#239) first. because the stmt.Vars is polluted by gorm.io/driver/postgres@v1.5.4/migrator.go:598 ,we must get the vars ok for bindvar method of postgress driver first.

tests/go.mod Outdated Show resolved Hide resolved
@jinzhu jinzhu merged commit 9514d5f into go-gorm:master Feb 6, 2024
19 of 34 checks passed
@haunt98
Copy link

haunt98 commented Feb 13, 2024

Hi @jasonchuan, thanks for PR. But can I ask one more thing? Is the change LIMIT 123 to LIMIT ? helps MySQL checking with total row limit? Or do I need to check it also in layer above db?

iTanken added a commit to godoes/gorm-oracle that referenced this pull request Feb 18, 2024
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.

6 participants