Dept of second thoughts: the IQ of estimate_array_length() needs to be
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jan 2007 02:53:34 +0000 (02:53 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Jan 2007 02:53:34 +0000 (02:53 +0000)
kept on par with that of scalararraysel(), else estimates that should
track might not.  Hence teach it about binary-compatible cases, too.

src/backend/utils/adt/selfuncs.c

index 7bf135c2b242b49a7ebd1d0654d55536ac886f11..0780e52a89683323beab881efb3895e9569c9452 100644 (file)
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.222 2007/01/28 01:37:38 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.223 2007/01/28 02:53:34 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1698,6 +1698,9 @@ scalararraysel(PlannerInfo *root,
 int
 estimate_array_length(Node *arrayexpr)
 {
+   /* look through any binary-compatible relabeling of arrayexpr */
+   arrayexpr = strip_array_coercion(arrayexpr);
+
    if (arrayexpr && IsA(arrayexpr, Const))
    {
        Datum       arraydatum = ((Const *) arrayexpr)->constvalue;