Thread: How does Postgres support backwards compatibility

How does Postgres support backwards compatibility

From
Josh Innis
Date:
Hello Everyone,

I work on an extension for Postgres. We originally developed the extension for Postgres 11. Now we are looking into supporting newer versions of Postgres. We would like our extension to be compatible with multiple versions of Postgres. Is there a document that explains how the Postgres community handles releases and supports older versions? Any information on how Postgres handles this will give us guidance on how to best approach this subject.

Thank You.

Re: How does Postgres support backwards compatibility

From
"David G. Johnston"
Date:
On Tue, Feb 8, 2022 at 11:51 AM Josh Innis <joshinnis@gmail.com> wrote:

I work on an extension for Postgres. We originally developed the extension for Postgres 11. Now we are looking into supporting newer versions of Postgres. We would like our extension to be compatible with multiple versions of Postgres. Is there a document that explains how the Postgres community handles releases and supports older versions? Any information on how Postgres handles this will give us guidance on how to best approach this subject.


This really isn't the right place to ask this kind of question.  -general would be a good place, you'll still reach the people who can respond intelligently.  I'll toss out my $0.02 here though I'm not that deep in the weeds on the topic.

Major releases don't really make any promises but we do try not to break things that worked in older versions gratuitously.  Usually you need your code to perform version detection and adapt its behavior accordingly.  But since the library code needs to be compiled for a particular version there is some room customization there if desired.  You will want your extension to directly support at least two major version simultaneously so people can upgrade the extension alongside the PostgreSQL version upgrade without having to change their code on-the-fly.

David J.

Re: How does Postgres support backwards compatibility

From
Josh Innis
Date:
Thank you David. I was unsure if this had already been discussed and documented somewhere already. I will reask in general.

On Tue, Feb 8, 2022 at 11:04 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tue, Feb 8, 2022 at 11:51 AM Josh Innis <joshinnis@gmail.com> wrote:

I work on an extension for Postgres. We originally developed the extension for Postgres 11. Now we are looking into supporting newer versions of Postgres. We would like our extension to be compatible with multiple versions of Postgres. Is there a document that explains how the Postgres community handles releases and supports older versions? Any information on how Postgres handles this will give us guidance on how to best approach this subject.


This really isn't the right place to ask this kind of question.  -general would be a good place, you'll still reach the people who can respond intelligently.  I'll toss out my $0.02 here though I'm not that deep in the weeds on the topic.

Major releases don't really make any promises but we do try not to break things that worked in older versions gratuitously.  Usually you need your code to perform version detection and adapt its behavior accordingly.  But since the library code needs to be compiled for a particular version there is some room customization there if desired.  You will want your extension to directly support at least two major version simultaneously so people can upgrade the extension alongside the PostgreSQL version upgrade without having to change their code on-the-fly.

David J.

Re: How does Postgres support backwards compatibility

From
Laurenz Albe
Date:
On Tue, 2022-02-08 at 10:50 -0800, Josh Innis wrote:
> I work on an extension for Postgres. We originally developed the extension for Postgres 11.
> Now we are looking into supporting newer versions of Postgres. We would like our extension
> to be compatible with multiple versions of Postgres. Is there a document that explains how
> the Postgres community handles releases and supports older versions? Any information on how
> Postgres handles this will give us guidance on how to best approach this subject.

PostgreSQL won't break APIs wantonly, but particularly with server internal functions
this happens occasionally.

So it depends a lot on what your extension does.  If it is written in SQL, the odds
are good that it will just continue working.  If it is written in C and you use a lot
of server functions, chances are that you will have to decorate your code with conditional
directives like

#if PG_VERSION_NUM < 130000
...
#else
...
#endif

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com