]> granicus.if.org Git - postgresql/commitdiff
Ooops, got only one of the two ArrayExpr variants correct in first
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Mar 2007 01:15:55 +0000 (01:15 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 17 Mar 2007 01:15:55 +0000 (01:15 +0000)
cut at exprTypmod support.  Also, experimentation shows that we need
to label the type of Const nodes that are numeric with a specific
typmod.

src/backend/parser/parse_expr.c
src/backend/utils/adt/ruleutils.c

index 3da003fd09a17cb5210f2a32e77e554719101d9b..9f0a501dc53096d0509c63fde8d031f2efc9366e 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.213 2007/03/17 00:11:04 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.214 2007/03/17 01:15:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1958,7 +1958,7 @@ exprTypmod(Node *expr)
                                 * typmod, else use -1
                                 */
                                ArrayExpr  *arrayexpr = (ArrayExpr *) expr;
-                               Oid                     arraytype = arrayexpr->array_typeid;
+                               Oid                     commontype;
                                int32           typmod;
                                ListCell   *elem;
 
@@ -1967,11 +1967,15 @@ exprTypmod(Node *expr)
                                typmod = exprTypmod((Node *) linitial(arrayexpr->elements));
                                if (typmod < 0)
                                        return -1;      /* no point in trying harder */
+                               if (arrayexpr->multidims)
+                                       commontype = arrayexpr->array_typeid;
+                               else
+                                       commontype = arrayexpr->element_typeid;
                                foreach(elem, arrayexpr->elements)
                                {
                                        Node       *e = (Node *) lfirst(elem);
 
-                                       if (exprType(e) != arraytype)
+                                       if (exprType(e) != commontype)
                                                return -1;
                                        if (exprTypmod(e) != typmod)
                                                return -1;
index b1294b6d3222239cf8ad55596ff055cdac33ddda..d97cfee3751aad978245f72876835b1b7985815a 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.254 2007/03/17 00:11:05 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.255 2007/03/17 01:15:55 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -4427,8 +4427,11 @@ get_const_expr(Const *constval, deparse_context *context, bool showtype)
                        needlabel = false;
                        break;
                case NUMERICOID:
-                       /* Float-looking constants will be typed as numeric */
-                       needlabel = !isfloat;
+                       /*
+                        * Float-looking constants will be typed as numeric, but if
+                        * there's a specific typmod we need to show it.
+                        */
+                       needlabel = !isfloat || (constval->consttypmod >= 0);
                        break;
                default:
                        needlabel = true;