jeroenrinzema / psql-wire

PostgreSQL server wire protocol. Build your own server and start serving connections.
Mozilla Public License 2.0
109 stars 19 forks source link

Receiving error "got no result from the query" #45

Open kishaningithub opened 1 year ago

kishaningithub commented 1 year ago

Coping the content from https://github.com/jeroenrinzema/psql-wire/issues/40#issuecomment-1320869471 here for better visibility

I am getting the error got no result from the query even though the query actually wrote a result set (screenshot below)

Should i raise a separate issue or should this be reopened?

Screenshot 1

Screenshot 2022-11-19 at 5 22 30 PM

One interesting thing here is that if i fire the same query very fast i actually get the result "at times" (Screenshot below)

Screenshot 2

Screenshot 2022-11-19 at 5 24 26 PM

Something wierd is going on.

Logs when the error happens

{"level":"debug","timestamp":"2022-11-19T17:25:48.402488+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:67","msg":"incoming command","length":944,"type":"P"}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402723+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:276","msg":"incoming extended query","query":"SELECT n.nspname as \"Schema\",\n                    c.relname as \"Name\",\n                    CASE c.relkind\n                      WHEN 'r' THEN 'table' WHEN 'v' THEN 'view'\n                      WHEN 'p' THEN 'partitioned table'\n                      WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index'\n                      WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special'\n                      WHEN 'f' THEN 'foreign table' END\n                    as \"Type\",\n                    pg_catalog.pg_get_userbyid(c.relowner) as \"Owner\"\n          \n            FROM    pg_catalog.pg_class c\n                    LEFT JOIN pg_catalog.pg_namespace n\n                      ON n.oid = c.relnamespace\n            WHERE   c.relkind = ANY($1) \n            AND n.nspname <> 'pg_catalog'\n            AND n.nspname <> 'information_schema'\n            AND n.nspname !~ '^pg_toast'\n            AND pg_catalog.pg_table_is_visible(c.oid)  ORDER BY 1, 2","name":"","parameters":1}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402844+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:67","msg":"incoming command","length":36,"type":"B"}
{"level":"debug","timestamp":"2022-11-19T17:25:48.40287+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:344","msg":"reading parameters format codes","length":1}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402902+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:372","msg":"reading parameters values","length":1}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402913+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:386","msg":"incoming parameter","value":"{r,p,v,m,S,f,\"\"}"}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402923+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:397","msg":"reading result-column format codes","length":1}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402958+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:67","msg":"incoming command","length":6,"type":"D"}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402977+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:67","msg":"incoming command","length":9,"type":"E"}
{"level":"debug","timestamp":"2022-11-19T17:25:48.402986+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:435","msg":"executing","name":"","limit":0}
{"level":"debug","timestamp":"2022-11-19T17:25:49.791743+05:30","caller":"psql-wire@v0.4.1-0.20221115092616-2480a4e5fc17/command.go:67","msg":"incoming command","length":4,"type":"S"}

Originally posted by @kishaningithub in https://github.com/jeroenrinzema/psql-wire/issues/40#issuecomment-1320869471

jeroenrinzema commented 1 year ago

@kishaningithub I am not able to reproduce this issue anymore after the latest changes. Would you be able to check whether this issue has been resolved?

kishaningithub commented 1 year ago

@jeroenrinzema The above issue seems to be gone but instead i am getting this one from pgcli (screenshot below). Any idea on what might be causing it? Let me know if this should be a separate issue

Screenshot 2023-01-16 at 2 42 18 PM

Logs

{"level":"debug","timestamp":"2023-01-16T14:41:17.366398+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":944,"type":"P"}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366544+05:30","caller":"psql-wire@v0.5.1/command.go:278","msg":"incoming extended query","query":"SELECT n.nspname as \"Schema\",\n                    c.relname as \"Name\",\n                    CASE c.relkind\n                      WHEN 'r' THEN 'table' WHEN 'v' THEN 'view'\n                      WHEN 'p' THEN 'partitioned table'\n                      WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index'\n                      WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special'\n                      WHEN 'f' THEN 'foreign table' END\n                    as \"Type\",\n                    pg_catalog.pg_get_userbyid(c.relowner) as \"Owner\"\n          \n            FROM    pg_catalog.pg_class c\n                    LEFT JOIN pg_catalog.pg_namespace n\n                      ON n.oid = c.relnamespace\n            WHERE   c.relkind = ANY($1) \n            AND n.nspname <> 'pg_catalog'\n            AND n.nspname <> 'information_schema'\n            AND n.nspname !~ '^pg_toast'\n            AND pg_catalog.pg_table_is_visible(c.oid)  ORDER BY 1, 2","name":"","parameters":1}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366617+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":36,"type":"B"}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366632+05:30","caller":"psql-wire@v0.5.1/command.go:346","msg":"reading parameters format codes","length":1}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366722+05:30","caller":"psql-wire@v0.5.1/command.go:374","msg":"reading parameters values","length":1}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366732+05:30","caller":"psql-wire@v0.5.1/command.go:388","msg":"incoming parameter","value":"{r,p,v,m,S,f,\"\"}"}
{"level":"debug","timestamp":"2023-01-16T14:41:17.36674+05:30","caller":"psql-wire@v0.5.1/command.go:399","msg":"reading result-column format codes","length":1}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366827+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":6,"type":"D"}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366838+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":9,"type":"E"}
{"level":"debug","timestamp":"2023-01-16T14:41:17.366845+05:30","caller":"psql-wire@v0.5.1/command.go:437","msg":"executing","name":"","limit":0}
{"level":"debug","timestamp":"2023-01-16T14:41:18.890619+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":4,"type":"S"}
jeroenrinzema commented 1 year ago

@kishaningithub are you getting this error after reproducing the steps above? Would you be able to include the --echo-hidden flag to the pgcli in order to inspect the queries the client is generating?

kishaningithub commented 1 year ago

Sorry for my delay in response. There does not seem to be an --echo-hidden flag or an equivalent in pgcli. So I ran the same in both psql and pgcli. psql one succeeded whereas the pgcli one failed (Screenshot below)

image

Following is the query that is being run by pgcli (got from the debug logs of psql-wire)

SELECT n.nspname as "Schema",
                    c.relname as "Name",
                    CASE c.relkind
                      WHEN 'r' THEN 'table' WHEN 'v' THEN 'view'
                      WHEN 'p' THEN 'partitioned table'
                      WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index'
                      WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special'
                      WHEN 'f' THEN 'foreign table' END
                    as "Type",
                    pg_catalog.pg_get_userbyid(c.relowner) as "Owner"

            FROM    pg_catalog.pg_class c
                    LEFT JOIN pg_catalog.pg_namespace n
                      ON n.oid = c.relnamespace
            WHERE   c.relkind = ANY($1) 
            AND n.nspname <> 'pg_catalog'
            AND n.nspname <> 'information_schema'
            AND n.nspname !~ '^pg_toast'
            AND pg_catalog.pg_table_is_visible(c.oid)  ORDER BY 1, 2

Parameters

$1 => {r,p,v,m,S,f,""}

Log lines

{"level":"debug","timestamp":"2023-02-24T14:36:32.279674+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":944,"type":"P"}
{"level":"debug","timestamp":"2023-02-24T14:36:32.279971+05:30","caller":"psql-wire@v0.5.1/command.go:278","msg":"incoming extended query","query":"SELECT n.nspname as \"Schema\",\n                    c.relname as \"Name\",\n                    CASE c.relkind\n                      WHEN 'r' THEN 'table' WHEN 'v' THEN 'view'\n                      WHEN 'p' THEN 'partitioned table'\n                      WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index'\n                      WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special'\n                      WHEN 'f' THEN 'foreign table' END\n                    as \"Type\",\n                    pg_catalog.pg_get_userbyid(c.relowner) as \"Owner\"\n          \n            FROM    pg_catalog.pg_class c\n                    LEFT JOIN pg_catalog.pg_namespace n\n                      ON n.oid = c.relnamespace\n            WHERE   c.relkind = ANY($1) \n            AND n.nspname <> 'pg_catalog'\n            AND n.nspname <> 'information_schema'\n            AND n.nspname !~ '^pg_toast'\n            AND pg_catalog.pg_table_is_visible(c.oid)  ORDER BY 1, 2","name":"","parameters":1}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280147+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":36,"type":"B"}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280161+05:30","caller":"psql-wire@v0.5.1/command.go:346","msg":"reading parameters format codes","length":1}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280219+05:30","caller":"psql-wire@v0.5.1/command.go:374","msg":"reading parameters values","length":1}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280244+05:30","caller":"psql-wire@v0.5.1/command.go:388","msg":"incoming parameter","value":"{r,p,v,m,S,f,\"\"}"}
{"level":"debug","timestamp":"2023-02-24T14:36:32.28025+05:30","caller":"psql-wire@v0.5.1/command.go:399","msg":"reading result-column format codes","length":1}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280291+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":6,"type":"D"}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280301+05:30","caller":"psql-wire@v0.5.1/command.go:67","msg":"incoming command","length":9,"type":"E"}
{"level":"debug","timestamp":"2023-02-24T14:36:32.280308+05:30","caller":"psql-wire@v0.5.1/command.go:437","msg":"executing","name":"","limit":0}