denodrivers / postgres

PostgreSQL driver for Deno

Home Page:https://denodrivers.github.io/postgres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid EXPLAIN results

coreybutler opened this issue · comments

It appears the EXPLAIN command isn't parsing/processing results correctly.

Consider the following statement executed in DBeaver:

image

Now consider the same thing in Deno-Postgres:

await conn.connect()

const r = await conn.query(`
  EXPLAIN SELECT *
  FROM account.acct a
      JOIN account.acct_user au on a.id = au.acct_id;`
)

console.log(JSON.stringify(r, null, 2))

image

Only the second result exists in the Deno-postgres output (I expected the results to match the output of DBeaver).

Hello there @coreybutler. I'm testing with the latest driver version https://raw.githubusercontent.com/denodrivers/postgres/72f523cb9d8f863204a3fa02f52d534e7ce30ccf/mod.ts and I can't seem to be able to replicate this problem

I believe this had to do with the way I was evaluating arrays when coming as a response from Postgres, which was recently refactored

Try and see if you can replicate locally, I'll assume this issue is closed in the meanwhile

@Soremwar - Unfortunately, the problem remains. Here are the results:

Expected:
image

Actual
image

Can you send me a reproduction example? Something like the following:

await client.queryArray`CREATE TEMP TABLE A (X INT)`;
await client.queryArray`CREATE TEMP TABLE B (Y INT)`;
const {rows} = await client.queryArray`EXPLAIN SELECT A.X FROM A JOIN B ON A.X = B.Y`;

As I just told you, I can't replicate the issue by using latest main

In a simple demo, I also cannot recreate the problem. However; I have a class with a function that executes a serializable transaction. When executing the exact same code from that class, there are missing results. I'll keep hunting today and post my findings when I narrow down the problem.

I found the issue, and it isn't related to this library. In my case, the query results are written to stdout as part of an error/informational message in a unit testing suite. The suite produces TAP output. The raw TAP output displays the results correctly:

image

However; displaying pretty results with tap-spec yield output like those from my prior messages. Clearly this is the result of using tap-spec, not deno-postgres.

Thanks for your time, and thanks for your work on this library.