]> granicus.if.org Git - postgresql/commitdiff
Fix array_typanalyze to work for domains over arrays.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Sep 2012 04:31:40 +0000 (00:31 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Sep 2012 04:31:40 +0000 (00:31 -0400)
Not sure how we missed this case, but we did.  Per bug #7551 from
Diego de Lima.

src/backend/utils/adt/array_typanalyze.c

index 604b86ca644490212b2bcd5bac1a13d078231b97..e4c94086bca9513b7e5139f8234fb501b5c66951 100644 (file)
@@ -19,6 +19,7 @@
 #include "commands/vacuum.h"
 #include "utils/array.h"
 #include "utils/datum.h"
+#include "utils/lsyscache.h"
 #include "utils/typcache.h"
 
 
@@ -108,11 +109,10 @@ array_typanalyze(PG_FUNCTION_ARGS)
                PG_RETURN_BOOL(false);
 
        /*
-        * Check attribute data type is a varlena array.
+        * Check attribute data type is a varlena array (or a domain over one).
         */
-       element_typeid = stats->attrtype->typelem;
-
-       if (!OidIsValid(element_typeid) || stats->attrtype->typlen != -1)
+       element_typeid = get_base_element_type(stats->attrtypid);
+       if (!OidIsValid(element_typeid))
                elog(ERROR, "array_typanalyze was invoked for non-array type %u",
                         stats->attrtypid);