postgres.git / summary / log / commit / refs

commit    8b65e0a33fdb6846d17a9200709dc3d64cf4d23a
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sat Aug 09 22:40:34 2014 +0000
First released in: 9.2.10, 9.3.6

    Fix conversion of domains to JSON in 9.3 and 9.2.
    
    In commit 0ca6bda8e7501947c05f30c127f6d12ff90b5a64, I rewrote the json.c
    code that decided how to convert SQL data types into JSON values, so that
    it no longer relied on typcategory which is a pretty untrustworthy guide
    to the output format of user-defined datatypes.  However, I overlooked the
    fact that CREATE DOMAIN inherits typcategory from the base type, so that
    the old coding did have the desirable property of treating domains like
    their base types --- but only in some cases, because not all its decisions
    turned on typcategory.  The version of the patch that went into 9.4 and
    up did a getBaseType() call to ensure that domains were always treated
    like their base types, but I omitted that from the older branches, because
    it would result in a behavioral change for domains over json or hstore;
    a change that's arguably a bug fix, but nonetheless a change that users
    had not asked for.  What I overlooked was that this meant that domains
    over numerics and boolean were no longer treated like their base types,
    and that we *did* get a complaint about, ie bug #11103 from David Grelaud.
    So let's do the getBaseType() call in the older branches as well, to
    restore their previous behavior in these cases.  That means 9.2 and 9.3
    will now make these decisions just like 9.4.  We could probably kluge
    things to still ignore the domain's base type if it's json etc, but that
    seems a bit silly.


src/backend/utils/adt/json.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 97ef135ba91..53a011d50b4 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -1232,9 +1232,8 @@ json_categorize_type(Oid typoid, { bool typisvarlena; - /* - * We should look through domains here, but we'll wait till 9.4. - */ + /* Look through any domain */ + typoid = getBaseType(typoid); /* We'll usually need to return the type output function */ getTypeOutputInfo(typoid, outfuncoid, &typisvarlena); [parent: 7a9c8cefb829]