Re: is it bug? - printing boolean domains in sql/xml function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: is it bug? - printing boolean domains in sql/xml function
Date: 2013-02-21 16:44:04
Message-ID: CAFj8pRCqQ9R-VyMn=0o6e111aFwDAtvXRL_jkqVreND14q63yA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

here is patch

where it should be pushed - 9.3 or 9.4 ?

I vote 9.3 - I know a users, that should to do workarounds (he should
not to use domains) now, so early is better. And this patch is one
line size patch

Regards

Pavel

2013/2/16 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
> 2013/2/16 Noah Misch <noah(at)leadboat(dot)com>:
>> On Sun, Jan 13, 2013 at 07:54:11AM +0100, Pavel Stehule wrote:
>>> related to http://www.postgresql.org/message-id/CAFj8pRDTAVfNrAzwEt+ewMfRBDZFfVa8W17Kk_E12fb6T-ZNXQ@mail.gmail.com
>>>
>>> boolean domains is serialised to string different than boolean
>>>
>>> postgres=# CREATE DOMAIN booldomain as bool;
>>> CREATE DOMAIN
>>>
>>> -- fully expected behave
>>> postgres=# select true, true::booldomain;
>>> bool | booldomain
>>> ------+------------
>>> t | t
>>> (1 row)
>>>
>>> postgres=# select true::text, true::booldomain::text;
>>> text | text
>>> ------+------
>>> true | true
>>> (1 row)
>>>
>>> -- unexpected behave
>>> postgres=# select xmlforest(true as bool, true::booldomain as booldomain);
>>> xmlforest
>>> ---------------------------------------------
>>> <bool>true</bool><booldomain>t</booldomain>
>>> (1 row)
>>>
>>> is it expected behave?
>>
>> There is a bug here. map_sql_type_to_xmlschema_type() has special treatment
>> for domains, but map_sql_value_to_xml_value() and its callers have no
>> corresponding logic. In the same vein, this yields a schema that does not
>> validate its corresponding document:
>>
>> set datestyle = 'sql, dmy';
>> create domain datedom as date;
>> create table t as select current_date AS a, current_date::datedom AS b;
>> select table_to_xml('t', true, true, '');
>> select table_to_xmlschema('t', true, true, '');
>>
>> One could debate whether the schema generation or the data generation should
>> be the one to change, but I tentatively vote for the latter.
>
> yes, I am thinking so it is bug too.
>
> if we will agree so it should be fixed I'll write fix
>
> Regards
>
> Pavel
>
>
>
>>
>> Thanks,
>> nm
>>
>> --
>> Noah Misch
>> EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
fix-xmlmap.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2013-02-21 16:44:56 Re: is it bug? - printing boolean domains in sql/xml function
Previous Message Merlin Moncure 2013-02-21 15:51:18 Re: JSON Function Bike Shedding