Re: Proposal for Prototype Implementation to Enhance C/C++ Interoperability in PostgreSQL - Mailing list pgsql-hackers

From 盏一
Subject Re: Proposal for Prototype Implementation to Enhance C/C++ Interoperability in PostgreSQL
Date
Msg-id tencent_5E4A400F23994D0D5C93CAE7@qq.com
Whole thread Raw
In response to Re: Proposal for Prototype Implementation to Enhance C/C++ Interoperability in PostgreSQL  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
(Sorry, there was a problem with the format of the previous email content. I will send it in plain text format this
time

> It seems extremely specific to one particular C++ implementation

To perform a force unwind during longjmp, the _Unwind_ForcedUnwind function is used. This function is defined in the
[ItaniumC++ ABI Standard](https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html#base-throw), which is followed by all
C++implementations. Additionally, the glibc
[nptl/unwind.c](https://elixir.bootlin.com/glibc/latest/source/nptl/unwind.c#L130)file shows that on all platforms,
pthread_exitis also implemented using _Unwind_ForcedUnwind.
 

Furthermore, the Itanium C++ ABI specification also defines _Unwind_RaiseException as the entry point for all C++
exceptionsthrown.
 

> you've thrown in a new dependency on pthreads

The reason for the dependence on pthread is due to the overloading of _Unwind_RaiseException, which serves as the entry
pointfor all C++ throwing exceptions. Some third-party C++ libraries may create threads internally and throw
exceptions.

Overloading _Unwind_RaiseException is done to convert uncaught exceptions into elog(ERROR). If we require that all
exceptionsmust be caught, we can remove the overloading of _Unwind_RaiseException and all pthread dependencies.
 

The overloading of _Unwind_RaiseException is just a fallback measure to prevent uncaught exceptions from terminating
theprocess. In our code, this path is rarely taken, and once we encounter an exception that is not caught, we will fix
thecode to catch the exception.
 

> doesn't this require us to move our minimum language requirement to C++-something?

No, all code has no dependency on C++.

regards, 盏一

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Add two missing tests in 035_standby_logical_decoding.pl
Next
From: Amit Kapila
Date:
Subject: Re: [DOC] Update ALTER SUBSCRIPTION documentation