mediprtl commented on issue #4319:
URL: https://github.com/apache/arrow-adbc/issues/4319#issuecomment-4476870671
Worth noting that this is **not** specific to the COPY-protocol code path.
The same `PostgresCopyListFieldWriter` is reused for parameterized prepared
statements via `MakeCopyFieldWriter` at `c/driver/postgresql/bind_stream.h:166`:
```cpp
MakeCopyFieldWriter(bind_schema->children[i], array_view->children[i],
type_resolver, &writer, &na_error);
...
bind_field_writers[i] = std::move(writer);
```
`BindStream::BindAndExecuteCurrentRow` then calls
`bind_field_writers[col]->Write(¶m_buffer.value, current_row, &na_error)`
with `current_row` as a logical row index (lines 218–233), so the same
forgotten `array_view_->offset + index` produces the same drift on `INSERT` /
`UPDATE` / `DELETE` / **upsert** when the bound list array is sliced.
Empirical confirmation in the same environment as the original repro
(`postgres-test` from `compose.yaml`, `adbc-driver-postgresql 1.11.0`):
```python
upsert_sql = """
INSERT INTO upsert_bug (pk, tags) VALUES ($1, $2)
ON CONFLICT (pk) DO UPDATE SET tags = EXCLUDED.tags
"""
for off in range(0, N, batch):
sliced_batch = tbl.slice(off, batch).to_batches()[0] # parent.offset =
off
cur.adbc_prepare(upsert_sql)
cur.executemany(upsert_sql, sliced_batch)
```
Produces the identical drift signature: pk 3 gets row 0's `tags`, pk 4 gets
row 1's, pk 5 gets row 2's — same shifted-by-offset pattern, including the
variable-length structure mismatch. After swapping in a driver built from
#4320, both the COPY and the bind-path repros are clean.
Mechanically the PR's existing unit tests (in
`postgres_copy_writer_test.cc`) already cover this — they exercise the *same
writer class* with `array_view_->offset > 0` — but I'll add an integration test
in `postgresql_test.cc` that drives the bind path explicitly so this scope is
documented in the test suite, not just in this comment.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]