On Thu, Mar 3, 2016 at 7:27 AM, Michael Paquier <michael.paqu...@gmail.com> wrote:
> On Wed, Mar 2, 2016 at 7:04 PM, Rajkumar Raghuwanshi > <rajkumar.raghuwan...@enterprisedb.com> wrote: > > On Wed, Mar 2, 2016 at 2:35 PM, Ashutosh Bapat > > <ashutosh.ba...@enterprisedb.com> wrote: > >> > >> Thanks Rajkumar for your report. Let me know if the attached patch fixes > >> the issue. > > if (pathkey->pk_nulls_first) > appendStringInfoString(buf, " NULLS FIRST"); > + else > + appendStringInfoString(buf, " NULLS LAST"); > Per explain.c, this looks inconsistent to me. Shouldn't NULLS LAST be > applied only if DESC is used in this ORDER BY clause? > I assume that you are referring to show_sortorder_options(). As per PG documentation http://www.postgresql.org/docs/9.4/static/queries-order.html, "By default, null values sort as if larger than any non-null value; that is, NULLS FIRST is the default for DESC order, and NULLS LAST otherwise." What show_sortorder_options() is doing is just trying to avoid printing the defaults, which is arguably fine for an explain output; it leaves defaults to be interpreted by user. In this case we are constructing a query to be sent to the foreign server and it's better not to leave the defaults to be interpreted by the foreign server; in case it interprets them in different fashion. get_rule_orderby() also explicitly adds these options. -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company