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

Exectuing pq.CopyIn fails with one of two errors depending on usage #1154

Open
bqback opened this issue Mar 16, 2024 · 0 comments
Open

Exectuing pq.CopyIn fails with one of two errors depending on usage #1154

bqback opened this issue Mar 16, 2024 · 0 comments

Comments

@bqback
Copy link

bqback commented Mar 16, 2024

Query is

  • defined as query := pq.CopyIn("public.foo", "col_foo", "col_bar")
  • prints as COPY "public.foo" ("col_foo", "col_bar") FROM STDIN.

Executing the prepared statement

  • prepared via tx.Prepare(query)
  • tx being defined as tx, err := db.Begin()
  • db is of type sqlx.DB, a connection established via sqlx.Connect if that matters

via _, err := statement.Exec("foo", "bar") returns either

  • sql: expected 0 arguments, got 2
    • This occurs when I use "pgx" as the driver when establishing the connection.
  • pq: relation "public.foo" does not exist when preparing
    • This occurs when I use "postgres" (pq) as the driver when establishing the connection. and is infinitely more puzzling, because not only does the relation exist when checked manually (SELECT * FROM public.foo; works fine in Postgres shell), but the application also contains a SELECT statement that leftjoins on public.foo, which works fine and returns no errors.

I don't really see a reason for why this would happen, no relevant issues for either of the two points. I'd prefer to use pq, because pgx's CopyFrom straight up does not support usage from transactions for whatever reason and requires a direct access to connection.

Let me know if I can provide anything else to elaborate.

@bqback bqback changed the title Exectuing pq.CopyIn fails with a variety of errors depending on usage Exectuing pq.CopyIn fails with one of two errors depending on usage Mar 16, 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

No branches or pull requests

1 participant