2000-01-27:DISTINCT ON 重构,并可接受多个表达式
在 25 年前的今天(PostgreSQL 7.0 开发周期),DISTINCT ON
子句进行了重构,使其能够接受多个表达式。
commit dd979f66be20fc54aad06da743f788fbc505bbe1 Author: Tom Lane <tgl@sss.pgh.pa.us> Date: Thu Jan 27 18:11:50 2000 +0000 Redesign DISTINCT ON as discussed in pgsql-sql 1/25/00: syntax is now SELECT DISTINCT ON (expr [, expr ...]) targetlist ... and there is a check to make sure that the user didn't specify an ORDER BY that's incompatible with the DISTINCT operation. Reimplement nodeUnique and nodeGroup to use the proper datatype-specific equality function for each column being compared --- they used to do bitwise comparisons or convert the data to text strings and strcmp(). (To add insult to injury, they'd look up the conversion functions once for each tuple...) Parse/plan representation of DISTINCT is now a list of SortClause nodes. initdb forced by querytree change...
在此更改之前,该语法仅限于 SELECT ... DISTINCT [ ON column ]
。
有关此更改的详细信息,请参阅这封非常有信息量的邮件列表讨论 DISTINCT ON: speak now or forever hold your peace。