Thread: ICU bool problem

ICU bool problem

From
Peter Eisentraut
Date:
You might find that ICU 69 (pretty new, see 
http://site.icu-project.org/download/69) will cause compile failures 
with PG 10 (pretty old).  ICU 69 has switched to using stdbool.h, which 
conflicts with the home-made definitions that we used until PG10. 
Compile errors look like this:

pg_collation.c:47:1: error: conflicting types for 'CollationCreate'
    47 | CollationCreate(const char *collname, Oid collnamespace,
       | ^~~~~~~~~~~~~~~
In file included from pg_collation.c:25:
../../../src/include/catalog/pg_collation_fn.h:17:12: note: previous 
declaration of 'CollationCreate' was here
    17 | extern Oid CollationCreate(const char *collname, Oid collnamespace,
       |            ^~~~~~~~~~~~~~~
pg_collation.c: In function 'CollationCreate':
pg_collation.c:171:41: warning: passing argument 3 of 'heap_form_tuple' 
from incompatible pointer type [-Wincompatible-pointer-types]
   171 |  tup = heap_form_tuple(tupDesc, values, nulls);
       |                                         ^~~~~
       |                                         |
       |                                         _Bool *
In file included from pg_collation.c:19:
../../../src/include/access/htup_details.h:802:26: note: expected 'bool 
*' {aka 'char *'} but argument is of type '_Bool *'
   802 |     Datum *values, bool *isnull);
       |                    ~~~~~~^~~~~~

The fix is like what we used to use for plperl back then:

diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index f3e04d4d8c..499ada2b69 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -17,6 +17,9 @@
  #endif
  #ifdef USE_ICU
  #include <unicode/ucol.h>
+#ifdef bool
+#undef bool
+#endif
  #endif

  #include "utils/guc.h"

I'll prepare a full patch in a bit.



Re: ICU bool problem

From
Bruce Momjian
Date:
On Mon, May 17, 2021 at 10:56:54PM +0200, Peter Eisentraut wrote:
> The fix is like what we used to use for plperl back then:
> 
> diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
> index f3e04d4d8c..499ada2b69 100644
> --- a/src/include/utils/pg_locale.h
> +++ b/src/include/utils/pg_locale.h
> @@ -17,6 +17,9 @@
>  #endif
>  #ifdef USE_ICU
>  #include <unicode/ucol.h>
> +#ifdef bool
> +#undef bool
> +#endif
>  #endif
> 
>  #include "utils/guc.h"
> 
> I'll prepare a full patch in a bit.

Yes, that seems like a good plan.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




Re: ICU bool problem

From
Peter Eisentraut
Date:
On 17.05.21 23:01, Bruce Momjian wrote:
> On Mon, May 17, 2021 at 10:56:54PM +0200, Peter Eisentraut wrote:
>> The fix is like what we used to use for plperl back then:
>>
>> diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
>> index f3e04d4d8c..499ada2b69 100644
>> --- a/src/include/utils/pg_locale.h
>> +++ b/src/include/utils/pg_locale.h
>> @@ -17,6 +17,9 @@
>>   #endif
>>   #ifdef USE_ICU
>>   #include <unicode/ucol.h>
>> +#ifdef bool
>> +#undef bool
>> +#endif
>>   #endif
>>
>>   #include "utils/guc.h"
>>
>> I'll prepare a full patch in a bit.
> 
> Yes, that seems like a good plan.

I have committed a fix for this.