pg_partman icon indicating copy to clipboard operation
pg_partman copied to clipboard

Windows Installation

Open sbutlerjr opened this issue 11 years ago • 9 comments

It was a struggle to get this installed in windows. Below is how I successfully was able to install it. Would be nice to add to the documentation. Windows installs done through the Windows Installer don't support 'make' commands for installation of Postgres extensions. So these instructions will replace the 2 make step commands. These could be put into a Windows bat file for easier installation.

  • Download the zip from of this project, and unzip it.
  • Open the pg_partman.control file in a text editor. Make note of the default_version value. At the time of writing, it is 1.8.3.
  • Open up a Windows command prompt. Navigate to the location where you unzipped it. For example:
cd C:\Users\Scott\Downloads\pg_jobmon-master\pg_jobmon-master
  • Run this command to copy all the sql files into 1 file sql file. Change '1.8.3' to the version noted in the above step. If using Postgres 9.2 or higher:
copy sql\types\*.sql + sql\tables\*.sql + sql\functions\*.sql + sql\92\tables\*.sql pg_partman--1.8.3.sql /B

If using Postgres 9.1 or lower

copy sql\types\*.sql + sql\tables\*.sql + sql\functions\*.sql pg_partman--1.8.3.sql /B
  • Now move or copy the the pg_partman--1.8.3.sql and pg_partman.control files into the {postgres_install}\share\extension folder.

That completes the equivelant of the 'make' steps from the instructions. You can now proceed to the next steps creating the extension.

sbutlerjr avatar Mar 31 '15 13:03 sbutlerjr

Appreciate these steps. Future versions will contain some C code, though, so it won't be quite a simple as this. Trying to keep it optional. Also, for the 9.1 and lower versions, you can't just simply use the resulting file as is. You have to go through and replace all instances of @extschema@ with whatever schema you install the extension to (even if it's public). Similar to how Josh Berkus blogged the installation on postgres as a service systems http://www.databasesoup.com/2014/12/loading-pgpartman-on-rds-or-heroku.html Also, I use many syntax options that only exist in later versions of postgres, so that is why at this time I only officially support 9.1 and higher. Also, version 2.0.0 will be 9.4 and higher only.

Curious, have you tried using cygwin? I believe that's how people typically build postgres from source on windows. http://www.postgresql.org/docs/current/static/installation-platform-notes.html#INSTALLATION-NOTES-MINGW

keithf4 avatar Mar 31 '15 13:03 keithf4

Thanks for the tip on @extschema. I'll give that a try. I did try cygwin and some other tools to attempt to build using make. However they didn't work. According to: https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules if you install Postgres on Windows using the Windows installer, it is "not compatible with and do not include the PGXS infrastructure". So the PGXS line in the make file fails.

sbutlerjr avatar Mar 31 '15 13:03 sbutlerjr

You only have to do that @extschema@ swap if you're installing it on versions lower than 9.1 (which i do not support) or installing it on a system that doesn't support third-party extensions (RDS, Heroku, etc). Otherwise, you just need to put the files in the proper location and then use the CREATE EXTENSION command as normal.

keithf4 avatar Mar 31 '15 14:03 keithf4

Sorry, read your commends again. I tried some other Windows tools to run Make, but they failed. As you mentioned, you have to reinstall postgres from source using cygwin to get support for these types of extensions that use PGXS. If installed through the Windows installer, they don't work. Thats a lot of work to add a new extension :)

sbutlerjr avatar Mar 31 '15 14:03 sbutlerjr

Installed on Postgres 9.1, with the instructions in original post above. So far, its working well. Thanks for the help.

sbutlerjr avatar Mar 31 '15 14:03 sbutlerjr

Yeah unfortunately PostgreSQL itself is built around an open source environment that easily allows building code from source. The Windows one-click installer had to make sacrifices to allow it to work the way it does. Are you running PostgreSQL in production on Windows or just experimenting? If installing third-party extensions is going to be something you want to do regularly, I'd recommend building it from source vs the installer.

keithf4 avatar Mar 31 '15 14:03 keithf4

I have a big installation in production that was done with the installer. I might switch to the build from source when we upgrade to the next postgres version so I don't have these kinds of problems.

sbutlerjr avatar Mar 31 '15 14:03 sbutlerjr

Thanks for sharing!

Hi, A little Update on pg_partman extension for (Windows installation) for latest Postgres version.

  • download the latest version from pgnx network link https://pgxn.org/dist/pg_partman/ OR zip it from GitHub repo.

  • once you download and extract

  • go to cd C:\Program Files\PostgreSQL\16\data\pg_partman-4.7.3 wherever you've extracted file

  • Run CMD as administrator and execute the below COPY command (that is what Makefile does).

copy sql\types\*.sql + sql\tables\*.sql + sql\functions\*.sql + sql\procedures\*.sql pg_partman--4.7.3.sql /B

  • Now move or copy the the pg_partman--4.7.3.sql and pg_partman.control files into the {postgres_install}\share\extension folder. like: C:\Program Files\PostgreSQL\16\share\extension
postgres=# create schema partman;
CREATE SCHEMA
postgres=# CREATE EXTENSION pg_partman SCHEMA partman;
CREATE EXTENSION
postgres=#

You will see all the procedures, functions, tables, types, etc. are created under partman schema.

thanks!

chrajeshdagur avatar Mar 06 '24 04:03 chrajeshdagur

Instead of calling manually the COPY command I would suggest:

  • call make from cygwin, and use the build process specified in the official Makefile

esanya avatar Mar 06 '25 09:03 esanya