Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10 - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10
Date
Msg-id a55b6a41-7942-312d-1471-1668e8855b8d@proxel.se
Whole thread Raw
In response to [HACKERS] 'text' instead of 'unknown' in Postgres 10  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: [HACKERS] 'text' instead of 'unknown' in Postgres 10  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List pgsql-hackers
On 02/07/2017 03:14 PM, Daniele Varrazzo wrote:
> In psycopg '{}'::unknown is treated specially as an empty array and
> converted into an empty list, which allows empty lists to be passed to
> the server as arrays and returned back to python. Without the special
> case, empty lists behave differently from non-empty ones. It seems
> this behaviour cannot be maintained on PG 10 and instead users need to
> specify some form of cast for their placeholder. Previously this would
> have worked "as expected" and the 4th argument would have been an
> empty list:
>
> cur.execute("SELECT %s, %s, %s, %s", (['x'], [42], [date(2017,1,1)],
> [])); cur.fetchone()
> (['x'], [42], [datetime.date(2017, 1, 1)], '{}')

As Tom wrote this is the result of an intentional change, but no matter 
if that change is a good thing or not the above behavior sounds rather 
fragile. To me it does not seem safe to by default just assume that '{}' 
means the empty array, it might also have been intended to be the Python 
string "{}", the empty JSON object, or entirely something different.

Andreas




pgsql-hackers by date:

Previous
From: Pavel Raiskup
Date:
Subject: [HACKERS] [PATCH] configure-time knob to set default ssl ciphers
Next
From: Fujii Masao
Date:
Subject: Re: [HACKERS] Cannot shutdown subscriber after DROP SUBSCRIPTION