Fix typmod exposed for scalar function in FROM, too.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 2 Jan 2020 19:02:46 +0000 (14:02 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 2 Jan 2020 19:02:55 +0000 (14:02 -0500)
On further reflection about commit 4d02eb017, it occurs to me that
expandRTE() had better agree with what addRangeTableEntryForFunction()
is doing.  So teach that about functions possibly having typmods, too.

src/backend/parser/parse_relation.c

index 2e0c278f355d687bfb5dafbb04566b4a4303fcf3..ceed0ceb482bc6a11e947aafba5135602958a171 100644 (file)
@@ -2616,7 +2616,8 @@ expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
                            Var        *varnode;
 
                            varnode = makeVar(rtindex, atts_done + 1,
-                                             funcrettype, -1,
+                                             funcrettype,
+                                             exprTypmod(rtfunc->funcexpr),
                                              exprCollation(rtfunc->funcexpr),
                                              sublevels_up);
                            varnode->location = location;