From: | Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com> |
---|---|
To: | akshay(dot)joshi(at)enterprisedb(dot)com |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: Copy command hangs in poll() function |
Date: | 2018-10-04 10:26:11 |
Message-ID: | CA+mi_8Z0EYtyayOYzerwjZww2zFGE=f0oQdvW7P92ZOUvdRhQA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Thu, Oct 4, 2018 at 6:35 AM Akshay Joshi <akshay(dot)joshi(at)enterprisedb(dot)com>
wrote:
> Hello
>
> As per documentation http://initd.org/psycopg/docs/advanced.html Copy
> commands are not supported in asynchronous mode, but this will be probably
> implemented in a future release. In pgAdmin4 (open source) we have used
> async connection to run the SQL query on PostgreSQL database and uses
> poll() function to poll the results. When user runs any *COPY *command
> application hangs at poll() function.
>
> If copy command not supported then at least it should not hang the
> application. poll() function should return the proper error message.
>
> Can you please provide that fix until support for copy command won't come.
>
Uhm, I see:
In [2]: cnn = psycopg2.connect("")
In [3]: cur = cnn.cursor()
In [4]: cur.execute("copy (select 1 as x) to stdout")
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call
last)
<ipython-input-4-62e3af3d121e> in <module>()
----> 1 cur.execute("copy (select 1 as x) to stdout")
ProgrammingError: can't execute COPY TO: use the copy_to() method
instead
but:
In [6]: cnn = psycopg2.connect("", async=True)
In [7]: cnn.poll()
Out[7]: 2
In [8]: cnn.poll()
Out[8]: 1
In [9]: cnn.poll()
Out[9]: 0
In [12]: cur.execute("copy (select 1 as x) to stdout")
In [14]: cnn.poll()
^C -- hung
So yes, I'll take a look if there is a way to detect we get in this state.
But I'm not sure it's possible, because we might not have received a result
yet that tells we are in a state not allowed (in a COPY).
Observation: maybe EnterpriseDB has resources enough to help us debugging
and fixing this issue, or maybe even implement async copy?
-- Daniele
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2018-10-04 10:29:12 | Re: Copy command hangs in poll() function |
Previous Message | Federico Di Gregorio | 2018-10-04 10:24:54 | Re: Integration of Psycopg with XTA |