diff --git a/contrib/ltree/crc32.c b/contrib/ltree/crc32.c index 8fed3346e8..b035706c05 100644 --- a/contrib/ltree/crc32.c +++ b/contrib/ltree/crc32.c @@ -9,7 +9,15 @@ #include "postgres.h" -#ifdef LOWER_NODE +/* + * Below we ignore the fact that LOWER_NODE is defined when compiling with + * MSVC. The reason for this is that earlier versions of the MSVC build + * scripts failed to define LOWER_NODE. More recent version of the MSVC + * build scripts parse makefiles which results in LOWER_NODE now being + * defined. We check for _MSC_VER here so as not to break pg_upgrade when + * upgrading from versions MSVC versions where LOWER_NODE was not defined. + */ +#if defined(LOWER_NODE) && !defined(_MSC_VER) #include #define TOLOWER(x) tolower((unsigned char) (x)) #else diff --git a/contrib/ltree/ltree.h b/contrib/ltree/ltree.h index dc68a0c212..8c10384503 100644 --- a/contrib/ltree/ltree.h +++ b/contrib/ltree/ltree.h @@ -90,7 +90,15 @@ typedef struct #define LQL_NOT 0x10 /* level has '!' (NOT) prefix */ #define LQL_COUNT 0x20 /* level is non-'*' and has repeat counts */ -#ifdef LOWER_NODE +/* + * Below we ignore the fact that LOWER_NODE is defined when compiling with + * MSVC. The reason for this is that earlier versions of the MSVC build + * scripts failed to define LOWER_NODE. More recent version of the MSVC + * build scripts parse makefiles which results in LOWER_NODE now being + * defined. We check for _MSC_VER here so as not to break pg_upgrade when + * upgrading from versions MSVC versions where LOWER_NODE was not defined. + */ +#if defined(LOWER_NODE) && !defined(_MSC_VER) #define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME ) ) == 0 ) #else #define FLG_CANLOOKSIGN(x) ( ( (x) & ( LQL_NOT | LVAR_ANYEND | LVAR_SUBLEXEME | LVAR_INCASE ) ) == 0 )