Recently was uncovered that pgcrypto does not include right header file to get BYTE_ORDER define on Cygwin and MINGW, and the missing define does not result in build failures, but random combinations of little and big-endian code sections.
This patch adds missing sys/param.h include for md5.c, sha1.c and rijndael.c plus also check to catch undefined BYTE_ORDER. The patch applies cleanly and is tested on branches for versions 7.2, 7.3, 7.4 and 8.0. There are also no failures on buildfarm for HEAD, where this patch is already included. -- marko
Index: contrib/pgcrypto/md5.c =================================================================== RCS file: /opt/arc/cvs2/pgsql/contrib/pgcrypto/md5.c,v retrieving revision 1.9 diff -u -c -r1.9 md5.c *** contrib/pgcrypto/md5.c 29 Nov 2001 19:40:37 -0000 1.9 --- contrib/pgcrypto/md5.c 13 Jul 2005 14:14:07 -0000 *************** *** 31,40 **** */ #include "postgres.h" - #include "px.h" #include "md5.h" #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) #define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) --- 31,47 ---- */ #include "postgres.h" + #include <sys/param.h> + + #include "px.h" #include "md5.h" + /* sanity check */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) + #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN + #endif + #define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s)))) #define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z))) Index: contrib/pgcrypto/rijndael.c =================================================================== RCS file: /opt/arc/cvs2/pgsql/contrib/pgcrypto/rijndael.c,v retrieving revision 1.9 diff -u -c -r1.9 rijndael.c *** contrib/pgcrypto/rijndael.c 5 Sep 2002 21:08:26 -0000 1.9 --- contrib/pgcrypto/rijndael.c 13 Jul 2005 14:15:43 -0000 *************** *** 38,48 **** */ ! #include <postgres.h> #include "px.h" #include "rijndael.h" #define PRE_CALC_TABLES #define LARGE_TABLES --- 38,56 ---- */ ! #include "postgres.h" ! ! #include <sys/param.h> ! #include "px.h" #include "rijndael.h" + /* sanity check */ + #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) + #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN + #endif + #define PRE_CALC_TABLES #define LARGE_TABLES Index: contrib/pgcrypto/sha1.c =================================================================== RCS file: /opt/arc/cvs2/pgsql/contrib/pgcrypto/sha1.c,v retrieving revision 1.11 diff -u -c -r1.11 sha1.c *** contrib/pgcrypto/sha1.c 29 Nov 2001 19:40:37 -0000 1.11 --- contrib/pgcrypto/sha1.c 13 Jul 2005 14:15:05 -0000 *************** *** 36,53 **** */ #include "postgres.h" #include "px.h" #include "sha1.h" /* sanity check */ ! #if BYTE_ORDER != BIG_ENDIAN ! #if BYTE_ORDER != LITTLE_ENDIAN ! #define unsupported 1 #endif - #endif - - #ifndef unsupported /* constant table */ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; --- 36,52 ---- */ #include "postgres.h" + + #include <sys/param.h> + #include "px.h" #include "sha1.h" /* sanity check */ ! #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) ! #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN #endif /* constant table */ static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; *************** *** 347,350 **** #endif } - #endif /* unsupported */ --- 346,348 ----
---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match