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

Exec() now provides access to status of multiple statements. #1309

Merged
merged 5 commits into from
May 29, 2023

Commits on Feb 20, 2022

  1. Exec() now provides access to status of multiple statements.

    It now reports the last inserted ID and affected row count for all statements,
    not just the last one. This is useful to execute batches of statements such as
    UPDATE with minimal roundtrips.
    
    The approach taken is to track last insert id and affected rows using []int64
    instead of a int64. Both are set in `mysqlResult`, and a new `mysql.Result`
    interface makes them accessible to callers calling `Exec()` via `sql.Conn.Raw`.
    For example:
    
    ```
    conn.Raw(func(conn interface{}) error {
            ex := conn.(driver.Execer)
            res, err := ex.Exec(`
            UPDATE point SET x = 1 WHERE y = 2;
            UPDATE point SET x = 2 WHERE y = 3;
            `, nil)
            // Both slices have 2 elements.
            log.Print(res.(mysql.Result).AllRowsAffected())
            log.Print(res.(mysql.Result).AllLastInsertIds())
          })
    ```
    mherr-google committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    4acde0d View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2022

  1. Configuration menu
    Copy the full SHA
    cd621b1 View commit details
    Browse the repository at this point in the history

Commits on May 28, 2023

  1. Configuration menu
    Copy the full SHA
    5b66fdb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    621c150 View commit details
    Browse the repository at this point in the history

Commits on May 29, 2023

  1. Update README.md

    methane committed May 29, 2023
    Configuration menu
    Copy the full SHA
    3eb80e0 View commit details
    Browse the repository at this point in the history