Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to apply a patch in PostgreSQL? I found an advice, but it seems to be suited for *NIX only. My PostgreSQL (9.3.1 EDIT: 9.3.4 now) was installed from an exe installer on Windows XP (32 bit), so I didn't find my case in the advice.

I'm not talking about minor version upgrade now - I can download the installer through Stack Builder, and there is already a well answered question on what to do with it. But what can I do if I need something that is not available through the StackBuilder, or even without an executable installer (in my case, a patch distributed only in a .patch file)?

share|improve this question
You should urgently upgrade to 9.3.4; there's a serious data corruption bug that affects replication in 9.3 prior to 9.3.0. – Craig Ringer Apr 8 '14 at 11:40
up vote 7 down vote accepted

This answer applies to modifying the PostgreSQL source code by applying a "diff" or "patch". It's not about installing minor version updates; to do that, just download and run the installer.

To alter the PostgreSQL server its self or its procedural language runtimes, you will generally need to recompile PostgreSQL from scratch.

On Windows that's a bit of a rough job. The postgresql documentation covers the process, but it doesn't really deal with the dependencies etc.

I've written some tools and documentation to make it easier, but they don't yet compile all the dependencies like OpenSSL, so the resulting binaries aren't as feature-complete as the stock installer. They're also not guaranteed to be binary-compatible with extensions.

If you just need to patch an extension that's a little bit easier, though far from trivial. I spent some time a while ago figuring out how to build PostgreSQL extensions on Windows without recompiling all of PostgreSQL. A similar approach might work for recompiling things like pg_dump and pg_restore but I have not tested this.

Add-ons, clients and utilities like PostGIS, PgRouting, PgAdmin-III, psqlODBC, pgJDBC, psycopg2, the Ruby Pg gem, DBD::Pg, PgPool, etc etc etc are all compiled separately using different procedures. You'll want to look up the tool in question for details.

Frankly, if you're doing any kind of development work on PostgreSQL, I don't recommend Windows as a platform.

share|improve this answer
I need to apply the patch to pgAdmin, so I hope it counts as an "extension" for this purpose. Anyway, a good answer and excellent links/tools. +1 and accepted. – Pavel V. Apr 8 '14 at 11:32
@Pavel No, PgAdmin-III is an entirely separate project, it's not a server extension. Recompiling PgAdmin-III will be totally different. Start here: . The good news is that you don't have to change PostgreSQL its self, as PgAdmin-III is just another libpq based client. – Craig Ringer Apr 8 '14 at 11:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.