adelsz / pgtyped

pgTyped - Typesafe SQL in TypeScript
https://pgtyped.dev
MIT License
2.91k stars 94 forks source link

error: bind message has 1158 parameter formats but 0 parameters #542

Closed timvandam closed 1 year ago

timvandam commented 1 year ago

Describe the bug My query that uses a parameter list usually works fine, but when passing a lot of parameters it fails. I've updated my code to instead query in batches of 1000 parameters, and it now works

Expected behavior It should be able to send all parameters to postgres (its limit is 65535 params)

Test case I cannot provide the actual query/schema, but it is similar to this:

WITH "Assignment" AS (
    SELECT "table1Id", "table2Id"
    FROM (VALUES (0, 0), :assignments! OFFSET 1) "Assignment" ("table1Id", "table2Id")
)
UPDATE "Table1"
SET "table2Id" = "Assignment"."table2Id"
FROM "Assignment"
WHERE "Table1"."id" = "Assignment"."table1Id"

With "Table1" (id, "table2Id" REFERENCES "Table2" ("id")) and "Table2" (id)

timvandam commented 1 year ago

After adding some logs I see now that I was actually using around 250,000 parameters, way over Postgres' limit. However, using batches of 65530 (below the limit) still fails: error: bind message has 65524 parameter formats but 0 parameters

timvandam commented 1 year ago

Nevermind, turns out my installation has a limit of 32767 bind parameters, not 65535