postgres/src
Tom Lane beae7d5f0e Fix interval_transform so it doesn't throw away non-no-op casts.
interval_transform() contained two separate bugs that caused it to
sometimes mistakenly decide that a cast from interval to restricted
interval is a no-op and throw it away.

First, it was wrong to rely on dt.h's field type macros to have an
ordering consistent with the field's significance; in one case they do
not.  This led to mistakenly treating YEAR as less significant than MONTH,
so that a cast from INTERVAL MONTH to INTERVAL YEAR was incorrectly
discarded.

Second, fls(1<<k) produces k+1 not k, so comparing its output directly
to SECOND was wrong.  This led to supposing that a cast to INTERVAL
MINUTE was really a cast to INTERVAL SECOND and so could be discarded.

To fix, get rid of the use of fls(), and make a function based on
intervaltypmodout to produce a field ID code adapted to the need here.

Per bug #14479 from Piotr Stefaniak.  Back-patch to 9.2 where transform
functions were introduced, because this code was born broken.

Discussion: https://postgr.es/m/20161227172307.10135.7747@wrigleys.postgresql.org
2016-12-27 15:43:55 -05:00
..
backend Fix interval_transform so it doesn't throw away non-no-op casts. 2016-12-27 15:43:55 -05:00
bin pg_dumpall: Include --verbose option in --help output 2016-12-24 01:42:16 -05:00
include Stamp 9.2.19. 2016-10-24 16:17:41 -04:00
interfaces Fix buffer overflow on particularly named files and clarify documentation about 2016-12-22 08:34:07 +01:00
makefiles Don't use deprecated dllwrap on Cygwin. 2014-02-01 16:13:46 -05:00
pl Be more careful about Python refcounts while creating exception objects. 2016-12-09 15:27:23 -05:00
port Make pgwin32_putenv() visit debug CRTs. 2016-12-03 15:47:52 -05:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:02:18 -04:00
test Fix interval_transform so it doesn't throw away non-no-op casts. 2016-12-27 15:43:55 -05:00
timezone Sync our copy of the timezone library with IANA release tzcode2016j. 2016-12-15 14:33:19 -05:00
tools Remove vestigial references to "zic" in favor of "IANA database". 2016-09-04 19:42:47 -04:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:27 -04:00
.gitignore
bcc32.mak
DEVELOPERS
Makefile
Makefile.global.in Make numeric form of PG version number readily available in Makefiles. 2015-07-05 12:01:01 -04:00
Makefile.shlib Make the AIX case of Makefile.shlib safe for parallel make. 2016-07-23 20:30:55 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak