You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "wjywbs (via GitHub)" <gi...@apache.org> on 2026/02/19 19:19:11 UTC

[I] flightsql/driver: tx.QueryContext with no args appears to ignore active transaction handle [arrow-go]

wjywbs opened a new issue, #667:
URL: https://github.com/apache/arrow-go/issues/667

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   I was using GPT-5.3-Codex to generate code for querying db using Arrow Flight SQL, and it found a possible bug in the arrow-go client. All the text below and the title is generated by Codex.
   
   **Description**  
   I’m seeing inconsistent transaction behavior in `github.com/apache/arrow-go/v18/arrow/flight/flightsql/driver` (`v18.5.1`) when using `database/sql`.
   
   In a transaction, queries with parameters behave correctly, but zero-argument `tx.QueryRowContext(...)` appears to execute outside the transaction.
   
   This is easy to reproduce with tx-local DDL:
   
   1. `BEGIN`
   2. `CREATE TABLE tx_tmp (id BIGINT, v BIGINT)`
   3. `INSERT INTO tx_tmp VALUES (1, 10)`
   4. `tx.QueryRowContext(ctx, "SELECT COUNT(*) FROM tx_tmp")`  -> fails (`table does not exist`)
   5. `tx.QueryRowContext(ctx, "SELECT COUNT(*) FROM tx_tmp WHERE id >= ?", 1)` -> works (returns `1`)
   
   Expected:
   - Both queries run in the same active transaction and return `1`.
   
   Actual:
   - Zero-arg query can behave as if it is outside the tx (cannot see uncommitted DDL/data).
   
   From code inspection, this may be because `Connection.QueryContext` uses `c.client.Execute(...)` directly and does not branch on `c.txn`, while prepared-statement paths do use `txn.Prepare(...)`.
   
   Likely affected code:
   - `arrow/flight/flightsql/driver/driver.go`
     - `Connection.QueryContext(...)`
     - compare with `Connection.PrepareContext(...)` transaction handling
   
   Suggested fix:
   - In `Connection.QueryContext`, when `c.txn != nil && c.txn.ID().IsValid()`, execute through transaction handle (or force transaction-bound prepared execution path), so no-arg tx queries stay transaction-scoped.
   
   Suggested tests:
   - Add regression test for tx-local DDL visibility with:
     - zero-arg `tx.QueryRowContext(...)`
     - parameterized `tx.QueryRowContext(..., arg)`  
   - Both should see uncommitted tx-local table/data consistently.
   
   ### Component(s)
   
   Integration, Other


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] flightsql/driver: tx.QueryContext with no args appears to ignore active transaction handle [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on issue #667:
URL: https://github.com/apache/arrow-go/issues/667#issuecomment-3947595152

   Would you be up to submitting a PR for this?
   
   Also, the flightsql driver in here isn't well maintained as the preference is for users to leverage the ADBC FlightSQL driver instead.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] flightsql/driver: tx.QueryContext with no args appears to ignore active transaction handle [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade closed issue #667: flightsql/driver: tx.QueryContext with no args appears to ignore active transaction handle
URL: https://github.com/apache/arrow-go/issues/667


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] flightsql/driver: tx.QueryContext with no args appears to ignore active transaction handle [arrow-go]

Posted by "wjywbs (via GitHub)" <gi...@apache.org>.
wjywbs commented on issue #667:
URL: https://github.com/apache/arrow-go/issues/667#issuecomment-3953850142

   Thanks for your reply. Codex only generated the patch below. Is this ok? Also, is [this link](https://github.com/apache/arrow-adbc/tree/main/go/adbc/sqldriver/flightsql) the ADBC FlightSQL driver?
   
   ```
   diff --git a/arrow/flight/flightsql/driver/driver.go b/arrow/flight/flightsql/driver/driver.go
   --- a/arrow/flight/flightsql/driver/driver.go
   +++ b/arrow/flight/flightsql/driver/driver.go
   @@ -505,7 +505,15 @@
    		defer cancel()
    	}
    
   -	info, err := c.client.Execute(execCtx, query)
   +	var (
   +		info *flight.FlightInfo
   +		err  error
   +	)
   +	if c.txn != nil && c.txn.ID().IsValid() {
   +		info, err = c.txn.Execute(execCtx, query)
   +	} else {
   +		info, err = c.client.Execute(execCtx, query)
   +	}
    	if err != nil {
    		return nil, err
    	}
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org