Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQBOy-0005j3-Ui for pgadmin-hackers@arkaria.postgresql.org; Tue, 05 Jun 2018 12:49:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQBOx-0003FP-Fb for pgadmin-hackers@arkaria.postgresql.org; Tue, 05 Jun 2018 12:49:27 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQBOx-0003FF-22 for pgadmin-hackers@lists.postgresql.org; Tue, 05 Jun 2018 12:49:27 +0000 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fQBOt-0004jF-62 for pgadmin-hackers@postgresql.org; Tue, 05 Jun 2018 12:49:25 +0000 Received: by mail-lf0-x236.google.com with SMTP id d24-v6so3362678lfa.8 for ; Tue, 05 Jun 2018 05:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UJJ5omYQhDQmNqFpJdB/XQ4718m5ZOAAP03OafUWDKs=; b=qXx97/MJayNOwj3x+FngrjsLGLiNC7LE01bbdCVQxDjLCiMHRuS3xKsJbhDeXhG8pf 01IE42ygn5e2owFnmSPy7jOZqmwc3Hf7fUQSH5pMKiyckgoCqOQECrk0sqw8KYPkl2DY E5/pZV9LH8BhxwnWyxi5k8JK0E7tJLg30kSJ6ndvZQoCjIE6J7O4gOxdvbt3XFzg46TP B4ZdDvOw+v4gAKCCsJVpUY0UmaStTTtNGp9TkBCThWyyCVdYhra1tWZK+WMEH1BWUElP EPMqWyVMXxgMYIGh6paC53TK36TvVWoCEWYL3wdFUGGaXcLtv2GcWItIavbp85o+ZAOj kuIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UJJ5omYQhDQmNqFpJdB/XQ4718m5ZOAAP03OafUWDKs=; b=qJWVOrj4+V3tGimdiZFRIwj4jeG2SkyFsH9NKZDCjm3W1EBYMQltJ6N2pqYLC5aWz6 SsK0CagBkVqchBrfG+5mHaNKga2L8ojtFd1h2ZYKEMZ/3AqH/c+eW1UjBt3zQud9U/rJ hgpEMSBTrLrskgLZADhqwDPWNI5crQhyFa7SxOVGTZhAo1no+uWOI/xMoYLtHowoeb6B tbAy3ovF8k1TFjddPpQLBdECJ7gaMHdpzsuPdRLz1yT3CzTxQlkiVdDpMS2LpQgVcLkN swVQ3jDtze40IAgqPMvnvyaERe+zXD4rmYKHjp34+Eas5B0bJ6PnjXoVKaJp4vi2qWew kO1w== X-Gm-Message-State: APt69E0aaNxRQpf8+C4iAMVIOSKdeHl5hoMmSYby4JpJY1FhX0B34Umn VqIHHqxsgMGbPYhCwfvEUq1M2tTEyqSHxwP9W9c4rg== X-Google-Smtp-Source: ADUXVKIqbB4DyDkE+sZjygCqEisTdOSGKdINvJPW2c6H/dTB91pb1q2BdCwGFKt9oZALUUnlL17KKBaTaa9I9sB5V/A= X-Received: by 2002:a2e:f01:: with SMTP id 1-v6mr6969808ljp.47.1528202961475; Tue, 05 Jun 2018 05:49:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:9e8a:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 05:49:21 -0700 (PDT) In-Reply-To: References: From: Aditya Toshniwal Date: Tue, 5 Jun 2018 18:19:21 +0530 Message-ID: Subject: Re: [pgAdmin4][RM#3289] Can't query SQL_ASCII database. To: Dave Page Cc: Joao De Almeida Pereira , pgadmin-hackers Content-Type: multipart/alternative; boundary="000000000000a9f7ff056de47a6e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000a9f7ff056de47a6e Content-Type: text/plain; charset="UTF-8" Hi Dave, The problem of SQL ASCII is solved with the patch, and not related to setting the client encoding of the sql window. I can see there is no SET call in pgAdmin3 for client_encoding. I can remove the SET client_encoding='UNICODE'; that will solve the problem. But, can you please let me know why that was added. Will remove the set call and will send you the updated patch if everything works fine. Thanks and Regards, Aditya Toshniwal Software Engineer | EnterpriseDB Software Solutions | Pune "Don't Complain about Heat, Plant a tree" On Tue, Jun 5, 2018 at 6:05 PM, Dave Page wrote: > Hi > > On Tue, Jun 5, 2018 at 1:21 PM, Aditya Toshniwal enterprisedb.com> wrote: > >> Hi Dave, >> >> >> On Tue, Jun 5, 2018 at 4:56 PM, Dave Page wrote: >> >>> Hi >>> >>> On Tue, Jun 5, 2018 at 9:50 AM, Aditya Toshniwal < >>> aditya.toshniwal@enterprisedb.com> wrote: >>> >>>> Hi Hackers, >>>> >>>> PFA updated patch. The sqleditor change is sent separately and removed >>>> from current patch as suggested. >>>> The test cases were running fine when the module was specified using >>>> --pkg but were failing in complete run. Fixed that. >>>> >>> >>> I did a quick test by creating a SQL_ASCII database containing a simple >>> table: >>> >>> CREATE TABLE sql_ascii (id serial primary key, data text); >>> >>> And then populated it with data: >>> >>> /Library/PostgreSQL/9.4/bin/psql -d sql_ascii -U postgres -c "INSERT >>> INTO sql_acsii (data) VALUES ('[Windows-1252] Euro: \x80 Double dagger: >>> \x87');" >>> /Library/PostgreSQL/9.4/bin/psql -d sql_ascii -U postgres -c "INSERT >>> INTO sql_ascii (data) VALUES ('[Latin-1] Yen: \xa5 Half: \xbd');" >>> /Library/PostgreSQL/9.4/bin/psql -d sql_ascii -U postgres -c "INSERT >>> INTO sql_ascii (data) VALUES ('[Japanese] Ship: \xe8\x88\xb9');" >>> /Library/PostgreSQL/9.4/bin/psql -d sql_ascii -U postgres -c "INSERT >>> INTO sql_ascii (data) VALUES ('[Invalid UTF-8] Blob: \xf4\xa5\xa3\xa5');" >>> >>> I then right-clicked the table in the treeview, and selected the option >>> to view all rows, and immediately saw an error: >>> >>> 2018-06-05 12:23:27,319: SQL pgadmin: Execute (async) for server #1 - >>> CONN:1187535 (Query-id: 8522474): >>> SELECT * FROM public.sql_ascii >>> ORDER BY id ASC >>> 2018-06-05 12:23:27,320: ERROR pgadmin: Failed to execute query >>> (execute_async) for the server #1 - CONN:1187535(Query-id: 8522474): >>> Error Message:ERROR: invalid byte sequence for encoding "UTF8": 0x80 >>> SQL state: 22021 >>> >>> Running "SELECT * FROM sql_ascii" in the query tool resulted in the same >>> error, however, if I ran "SET client_encoding = 'SQL_ASCII';" first, I do >>> see results. >>> >>> I have confirmed that I've restarted the server after applying the patch. >>> >>> What am I missing? Why don't we just set the client_encoding to >>> SQL_ASCII if it's a SQL_ASCII database? >>> >> >> It is by default same as the server encoding. But, the following existing >> code in web/pgadmin/utils/driver/psycopg2/connection.py makes the >> client_encoding as UNICODE for every connection. I am not sure it should be >> removed. >> >> status = _execute(cur, "SET DateStyle=ISO;" >> >> "SET client_min_messages=notice;" >> >> "SET bytea_output=escape;" >> >> "SET client_encoding='UNICODE';") >> > > It was probably before you joined, but I have said a number of times that > pgAdmin 3 handled this differently and that maybe we should do it the same > way here. See https://git.postgresql.org/gitweb/?p=pgadmin3.git;a= > blob;f=pgadmin/db/pgConn.cpp, in the pgConn::Initialize() function. > > Either way, your patch isn't working for me. > > >> >> >> Note that this testing was on Python 2.7.10 on MacOS. >>> >>> >>>> >>>> Kindly review. >>>> >>>> Thanks and Regards, >>>> Aditya Toshniwal >>>> Software Engineer | EnterpriseDB Software Solutions | Pune >>>> "Don't Complain about Heat, Plant a tree" >>>> >>>> On Tue, Jun 5, 2018 at 10:15 AM, Aditya Toshniwal < >>>> aditya.toshniwal@enterprisedb.com> wrote: >>>> >>>>> Hi >>>>> >>>>> On Tue, Jun 5, 2018 at 1:08 AM, Joao De Almeida Pereira < >>>>> jdealmeidapereira@pivotal.io> wrote: >>>>> >>>>>> Hello Aditya, >>>>>> >>>>>>> >>>>>>> >>>>>>> There is no change related to notifications in this patch. >>>>>>> The below code is minor fix related to connection status of sql >>>>>>> editor. Can you please share the code snippet if it is not the below. >>>>>>> >>>>>>> - # Check for the asynchronous notifies statements. >>>>>>> - conn.check_notifies(True) >>>>>>> - notifies = conn.get_notifies() >>>>>>> + if status is not None: >>>>>>> + # Check for the asynchronous notifies statements. >>>>>>> + conn.check_notifies(True) >>>>>>> + notifies = conn.get_notifies() >>>>>>> >>>>>>> >>>>>> This is a minor fix, but is it related to querying SQL_ASCII database? >>>>>> >>>>> No its not. It is something I found when I was working on SQL_ASCII >>>>> related changes. >>>>> Well then, will send a separate patch for it. >>>>> >>>>>> >>>>>> Thanks >>>>>> Victoria && Joao >>>>>> >>>>> >>>>> >>>> >>> >>> >>> -- >>> Dave Page >>> Blog: http://pgsnake.blogspot.com >>> Twitter: @pgsnake >>> >>> EnterpriseDB UK: http://www.enterprisedb.com >>> The Enterprise PostgreSQL Company >>> >> >> > > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > --000000000000a9f7ff056de47a6e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Dave,

The problem of SQL ASCII is solved = with the patch, and not related to setting the client encoding of the sql w= indow. I can see there is no SET call in pgAdmin3 for client_encoding.=C2= =A0 I can remove the=C2=A0SET client_encoding=3D= 'UNICODE'; that will solve the pro= blem. But, can you please let me know why that was added.=C2=A0
=

Will remove the set ca= ll and will send you the updated patch if everything works fine.
=

Thanks and Regards,
Aditya Toshniwal
Software En= gineer |=C2=A0EnterpriseDB Software Solutions |=C2=A0Pune
"Do= n't Complain about Heat, Plant a tree"

On Tue, Jun 5, 2018 at 6:05 PM, Dave Page <= dpage@pgadmin.org> wrote:
<= div dir=3D"ltr">Hi

On Tue, Jun 5, 2018 at 1:21 PM, Aditya Toshniwa= l <aditya.toshniwal@enterprisedb.com> w= rote:
Hi Dave,


= On Tue, Jun 5, 2018 at 4:56 PM, Dave Page <dpage@pgadmin.org> wrote:
Hi

On Tue, Jun 5, 2018 at 9:= 50 AM, Aditya Toshniwal <aditya.toshniwal@enterprisedb.com> wrote:
Hi Hackers,

PFA updated patch. Th= e sqleditor change is sent separately and removed from current patch as sug= gested.
The test cases were running fine when the module was spec= ified using --pkg but were failing in complete run. Fixed that.
=

I did a quick test by creating a SQ= L_ASCII database containing a simple table:

CREATE= TABLE sql_ascii (id serial primary key, data text);

And then populated it with data:

/Library/= PostgreSQL/9.4/bin/psql -d sql_ascii -U postgres -c "INSERT INTO = sql_acsii (data) VALUES ('[Windows-1252]=C2=A0 =C2=A0Euro: \x80=C2=A0 = =C2=A0Double dagger: \x87');"
/Library/PostgreSQL/9.4/bi= n/psql -d sql_ascii -U postgres -c "INSERT INTO sql_ascii (data) = VALUES ('[Latin-1]=C2=A0 =C2=A0Yen: \xa5=C2=A0 =C2=A0Half: \xbd');&= quot;
/Library/PostgreSQL/9.4/bin/psql -d sql_ascii -U postg= res -c "INSERT INTO sql_ascii (data) VALUES ('[Japanese]=C2=A0 =C2= =A0Ship: \xe8\x88\xb9');"
/Library/PostgreSQL/9.4/bin/ps= ql -d sql_ascii -U postgres -c "INSERT INTO sql_ascii (data) VALU= ES ('[Invalid UTF-8]=C2=A0 Blob: \xf4\xa5\xa3\xa5');"

I then right-clicked the table in the treeview, and = selected the option to view all rows, and immediately saw an error:

2018-06-05 12:23:27,319: SQL pgadmin: E= xecute (async) for server #1 - CONN:1187535 (Query-id: 8522474):
= SELECT * FROM public.sql_ascii
ORDER BY id ASC=C2=A0
20= 18-06-05 12:23:27,320: ERROR pg= admin: Failed to execute query = (execute_async) for the server #1 - CONN:1187535(Query-id: 8522474):
<= div>Error Message:ERROR:=C2=A0 invalid byte sequence for encoding "UTF= 8": 0x80
SQL state: 22021

Run= ning "SELECT * FROM sql_ascii" in the query tool resulted in the = same error, however, if I ran "SET client_encoding =3D 'SQL_ASCII&= #39;;" first, I do see results.

I have confir= med that I've restarted the server after applying the patch.
=
What am I missing? Why don't we just set the client_enco= ding to SQL_ASCII if it's a SQL_ASCII database?
=C2=A0
It is by default same as the serv= er encoding. But, the following existing code in=C2=A0=C2=A0

=C2=A0 = =C2=A0 =C2=A0 =C2=A0 status =3D _execute(cur, "SET DateStyle=3D= ISO;"

=C2=A0=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 "SET client_min_messages=3Dnotice;&= quot;

=C2=A0=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 "SET bytea_output=3Descape;"

=C2=A0=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 "SET client_encoding=3D'UNICODE= ';")

It was probably before you joined, but I have said= a number of times that pgAdmin 3 handled this differently and that maybe w= e should do it the same way here. See=C2=A0https://git.postgresql.org/gitweb/?p=3Dpgadmin3.git;a=3Dblob;f=3Dpgadmin/db/pgConn.cpp, in the pgConn::Initialize() function= .

Either way, your patch isn't working for me.=
=C2=A0


Note that this testing was on Python 2.7.10 on MacOS.
=C2=A0

Kindly review.

Thanks and Regar= ds,
Aditya Toshniwal=
= Softwa= re Engineer |=C2=A0EnterpriseDB Software Solutions |=C2=A0Pune
&qu= ot;Don't Complain about Heat, Plant a tree"

On Tue, Jun = 5, 2018 at 10:15 AM, Aditya Toshniwal <aditya.toshniwal@en= terprisedb.com> wrote:
Hi

On Tue, Jun 5, 2018 at 1:08 AM, Joao De Almeida= Pereira <jdealmeidapereira@pivotal.io> wrote:
Hello A= ditya,


There is no chan= ge related to notifications in this patch.=C2=A0
The below code i= s minor fix related to connection status of sql editor. Can you please shar= e the code snippet if it is not the below.

-= =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Check for the asynchronous notifies statement= s.
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 conn.check_notifies(True)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 notifies =3D conn.get_notifies()
= +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if status is not None:
+=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Check for the asynchronous notifies state= ments.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 conn.check_noti= fies(True)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 notifies = =3D conn.get_notifies()

<= br>
This is a minor fix, but is it related to querying SQL= _ASCII database?
No its not. It i= s something I found when I was working on SQL_ASCII related changes.
<= div>Well then, will send a separate patch for it.
<= div>
Thanks
Victoria && Joao





--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @= pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL= Company




--
= Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB = UK: http://www.en= terprisedb.com
The Enterprise PostgreSQL Company

--000000000000a9f7ff056de47a6e--