jackc / jackc/pgx

Pgx query changes a value to "..."

Open
#1,487 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs response
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

**Describe the bug**
Recently I ran into an issue where an **UPDATE** query I was executing via either **QueryContext/ExecContext** always changed the 30th argument to `...`, this resulted in a Postgres error thankfully as the 30th argument at the time was an enum so `...` was an invalid value.

Interestingly this issue come about after I added 3 more arguments to the query which brought the total number of arguments to 32. I haven't been able to reproduce it locally yet, but it was happening in production until I found the workaround noted below. I verified that it wasn't an error on my side by logging the args being passed before and after the called to `ExecContext`, before the 30th argument had a value of 'CONFIRMED' and after it was '...', no other code ran in between the logs.

One of the columns being set in the **UPDATE** query was a recurring rule (https://icalendar.org/iCalendar-RFC-5545/3-8-5-3-recurrence-rule.html) which can include `\n` and `;`, when the recurring rule argument was set to null the query executed fine. The query had always set this column and the error only came about after increasing the number of columns being set, perhaps this made the total data too long and was truncated?

**I managed to work around the issue by running the exact same query in a Batch operation.**

**To Reproduce**
Steps to reproduce the behavior:

- Create an UPDATE query with > 30 arguments

If possible, please provide runnable example such as:

```go
package main

import (
"context"
"log"
"os"

"github.com/jackc/pgx/v4"
)

func main() {
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatal(err)
}
defer conn.Close(context.Background())

// Your code here...
}
```

**Expected behavior**
A clear and concise description of what you expected to happen.
The `UPDATE` query executes without needing to be in a batch.

**Actual behavior**
A clear and concise description of what actually happened.
The 30th argument is changed to '...'.

**Version**
- Go: 1.19
- PostgreSQL: 14.4
- pgx: 5.2.0

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing an UPDATE with more than 30 arguments through QueryContext or ExecContext, using the provided Go example, and compare it with the Batch workaround. Trace how arguments are passed and verify the 30th argument remains unchanged; done when a regression test covers the failure and the query executes correctly without batching.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.