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 1fL0QX-0006PE-N8 for pgadmin-hackers@arkaria.postgresql.org; Tue, 22 May 2018 06:05:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fL0QV-0005Qv-JM for pgadmin-hackers@arkaria.postgresql.org; Tue, 22 May 2018 06:05:39 +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 1fL0QV-0005Ql-6a for pgadmin-hackers@lists.postgresql.org; Tue, 22 May 2018 06:05:39 +0000 Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fL0QR-0000Rw-J0 for pgadmin-hackers@postgresql.org; Tue, 22 May 2018 06:05:37 +0000 Received: by mail-lf0-x22e.google.com with SMTP id j193-v6so27302322lfg.6 for ; Mon, 21 May 2018 23:05:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=mc8TlmmsPpa6YK3JFeYQBjDzCEiOIkJnhHNk11bfMhM=; b=Bl/w6jCWtfVh9n7I4E1mu5RksN3M38KKiaYk5wMEeg/4cdn5/gyPkweerc0a+vnvin kX8KFGY0RFvwHm0miLBHWnqZg9uLoLs0bmg0hOiiN8IU1sphxy/1mD1niF+Gxj35px8G 7+BqqzqgVld8ZF/J6UKCY/qmbSHWz9Fjy8kqiE0g7eQjLnUVw9eCl2lr4JFmCxufV0B/ xWHCBgS2ifPYxPOoe5jNuG7nLf22ZhLmq9oZCAp8eyezzWbPGOL4CaZDZs3RxfC1wzzn GUtFDnH4V459LljvjlHzZgkJJg1QruH/3hp883vQYD4kobLnOTNXGyUn+Pzws5FSXhRN MK9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=mc8TlmmsPpa6YK3JFeYQBjDzCEiOIkJnhHNk11bfMhM=; b=GrzECJlQBTQKHtPJoIvoQt5cbSGAiCXqcBBalIX6k+eet0AT/AvcuEdtxe5iECS+Be QKZcL3kXtG13wgeSUQ/gf+T2HUbr5/lXfG4Vfzm3eokfZySL/0mePLhQYzeRuSrsS9Tk Uc921gpg3iq2T+drU54+VtfysqVmQt+xQ16H5vSEN5hA5MIIGm+NNnZ4N79elzbaCRqy i1V4bbylr48JsnYu9bHgOGiSPBmlMBZQ4R4fuaPGozeUMkr/mh8RUhVuPZqJl4tC8Y3B xbSFThcuMPiKnjArv2opZ4/EtNkNw3lrLgwaTAEFVZi1gQYE+GrGT8tuV6UnsGGVS6KL 3iXg== X-Gm-Message-State: ALKqPwfI3tfB0riTjlaxJdHZpUmRk3e8Pb7e4EbhSYm+ItxDl8t12LWb gRjNTHoMTgLHpJJlvFCjM18LYK7ttghq/pGfy/q68rg3 X-Google-Smtp-Source: AB8JxZr/axKd1v6y8EMYkH8OOZ2RwzN6esvhqaC/bPnXC5kkGyRV/wZJUvAMKM3Qtu6nCXnUcA40eDO9cS7OuH62MnM= X-Received: by 2002:a19:d9d5:: with SMTP id s82-v6mr7194428lfi.18.1526969133379; Mon, 21 May 2018 23:05:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.158.138 with HTTP; Mon, 21 May 2018 23:05:32 -0700 (PDT) From: Aditya Toshniwal Date: Tue, 22 May 2018 11:35:32 +0530 Message-ID: Subject: [pgAdmin4][RM#3289] Can't query SQL_ASCII database. To: pgadmin-hackers Content-Type: multipart/mixed; boundary="000000000000c78af7056cc5340c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000c78af7056cc5340c Content-Type: multipart/alternative; boundary="000000000000c78af2056cc5340a" --000000000000c78af2056cc5340a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Hackers, PFA patch for RM#3289 where decode error was thrown on querying a SQL_ASCII database table. Please note, this problem occurs only on windows. Sample insert - insert into test_tab values ('=C3=A9'); psycopg2 has a encodings dictionary where Postgres Database Encodings are mapped to python equivalent. It uses 'ascii' decoder of python to decode for SQL_ASCII encoding. If data has characters beyond the limit of ascii then it failed. The solution would be to use utf_8 decoder instead of ascii. I tried setting the client_encoding using set_client_encoding('UTF8') method of a psycopg2 connection but no luck (also its not allowed for async connection). I also tried executing "SET CLIENT_ENCODING=3D'UTF8'" but it didn't work too. So, as in the patch, I had to set encodings dict value directly to 'utf_8' and it seems to be working. Please note, the same is added to psycopg3 milestones https://github.com/psycopg/psycopg2/milestone/4 Also fixed a small glitch for sql editor connection status check. Kindly review. Thanks and Regards, Aditya Toshniwal Software Engineer | EnterpriseDB Software Solutions | Pune "Don't Complain about Heat, Plant a tree" --000000000000c78af2056cc5340a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Hackers,

PFA patch for RM= #3289 where decode error was thrown on querying a SQL_ASCII database table.= Please note, this problem occurs only on windows.
Sample insert = -=C2=A0insert into test_tab values ('=C3=A9');

=
psycopg2 has a encodings dictionary where Postgres Database Encodings = are mapped to python equivalent. It uses 'ascii' decoder of python = to decode for SQL_ASCII encoding. If data has characters beyond the limit o= f ascii then it failed. The solution would be to use utf_8 decoder instead = of ascii. I tried setting the client_encoding using set_client_encoding(= 9;UTF8') method of a psycopg2 connection but no luck (also its not allo= wed for async connection). I also tried executing "SET CLIENT_ENCODING= =3D'UTF8'" but it didn't work too.
So, as in the= patch, I had to set encodings dict value directly to 'utf_8' and i= t seems to be working. Please note, the same is added to psycopg3 milestone= s

A= lso fixed a small glitch for sql editor connection status check.
=
Kindly review.

Thanks and Regards,Aditya Toshniwal
Software Enginee= r |=C2=A0EnterpriseDB Software Solutions |=C2=A0Pune
"Don&#= 39;t Complain about Heat, Plant a tree"
--000000000000c78af2056cc5340a-- --000000000000c78af7056cc5340c Content-Type: application/octet-stream; name="RM3289.patch" Content-Disposition: attachment; filename="RM3289.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_jhh9yw3r0 ZGlmZiAtLWdpdCBhL3dlYi9wZ2FkbWluL3Rvb2xzL3NxbGVkaXRvci9fX2luaXRfXy5weSBiL3dl Yi9wZ2FkbWluL3Rvb2xzL3NxbGVkaXRvci9fX2luaXRfXy5weQppbmRleCBjNzI1MDVhNC4uYWVj M2ZhYmEgMTAwNjQ0Ci0tLSBhL3dlYi9wZ2FkbWluL3Rvb2xzL3NxbGVkaXRvci9fX2luaXRfXy5w eQorKysgYi93ZWIvcGdhZG1pbi90b29scy9zcWxlZGl0b3IvX19pbml0X18ucHkKQEAgLTE0NzQs NyArMTQ3NCw3IEBAIGRlZiBxdWVyeV90b29sX3N0YXR1cyh0cmFuc19pZCk6CiAgICAgICAgICAg ICBlcnJvcm1zZz1lcnJvcl9tc2cKICAgICAgICAgKQogCi0gICAgaWYgY29ubiBhbmQgdHJhbnNf b2JqIGFuZCBzZXNzaW9uX29iajoKKyAgICBpZiBjb25uIGFuZCB0cmFuc19vYmogYW5kIHNlc3Np b25fb2JqIGFuZCBjb25uLnRyYW5zYWN0aW9uX3N0YXR1cygpIGlzIG5vdCBOb25lOgogICAgICAg ICBzdGF0dXMgPSBjb25uLnRyYW5zYWN0aW9uX3N0YXR1cygpCiAgICAgICAgIHJldHVybiBtYWtl X2pzb25fcmVzcG9uc2UoCiAgICAgICAgICAgICBkYXRhPXsKZGlmZiAtLWdpdCBhL3dlYi9wZ2Fk bWluL3V0aWxzL2RyaXZlci9wc3ljb3BnMi9jb25uZWN0aW9uLnB5IGIvd2ViL3BnYWRtaW4vdXRp b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