Take the 2-minute tour ×
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.

I'm building PostgreSQL(version 9.3.1) from source code in Ubuntu. I'd like to create several builds of Postgres, like pg1, pg2, etc. How can I do it? Thanks in advance.

share|improve this question
    
By the way, I'm using Ubuntu. –  zli89 Feb 7 at 20:58
1  
I don't see why you'd need different builds. Just run initdb on multiple data directory and start the same binary using different data directories (and ports of course) –  a_horse_with_no_name Feb 7 at 21:48
    

2 Answers 2

up vote 1 down vote accepted

Which os and version are you using?

Even though I disagree with you on doing this, my approach would be to build them and keep the destination directory different from one build to the other. Something like /usr/local/postgresl-9.3, /usr/local/postgresql-8.4 etc. This would avoid overwriting executable files such as psql or initdb for example. In order to better control the installation then use a package manager to build the packages for your system and install them. (For example in slackware we use the createpkg command to bundle up a package so that it can then be handled by the package manager slackpkg.

Then for every version you would have to issue an initdb on a different base directory and manually start postgres taking care of using the relative `pg_ctl' command.

Be sure to use the full path to the various executable files of the different database versions.

Another issue you will have to take care of is to modify postgresql.conf of every instance that you are running in order to make them listen on different ports, should you required to run every database instance simultaneously. Otherwise you can run them one at a time on the default port 5432.

share|improve this answer
    
Thanks for your answer Fabrizio. I'm using Red Hat Enterprise Linux Server release 6.4 (Santiago) and I want to build the same version(9.3.1) of PostgreSQL. The reason to do so is that I need to modify the source code and I want different builds behave differently. So I'm thinking maybe just one executable file would change according to the change in the source code, others like createdb, dropuser should stay the same. Is there any way to keep most of the installation the same, just change the main executable file name which reflects the change in the source code? –  zli89 Feb 10 at 19:55
1  
Ok. I don't know the effect but if you tell me this, I would build and install a base version of postgresql. Then modify the source, recompile only the new psql, and copy it to the bin directory with a different name, say psql-V1. So if you want to call that specific modified version of psql you'd use /path/to/bin/psql-V1 whereas if you want to use the normal one installed with standard installation the a simple /path/to/bin/psql would do. –  Fabrizio Mazzoni Feb 11 at 8:40
    
I already figured it out last night. I used a similar way as you said. But I didn't touch the psql, instead I rename postgres as pg1, pg2,etc. And it works. I think the executable file postgres is the one which reflects changes in source code because you start the server by /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data, psql is just the PostgreSQL command line SQL interpreter. By replacing postgres with pg1, pg2, etc in the command to start the server, I can see the difference in different builds. Anyways, thanks for your help! –  zli89 Feb 11 at 14:50
    
BTW, as you are an expert in PostgreSQL, can you ask you something else? It's about the PREPARE statement in Postgres. I know by PREPARE, the server will save the execution plan and if the similar query being executed again, the server will use the plan it saves instead of optimizing again. Any chance you know where the execution plan is saved? It must be saved in a file in disk, right? I want to know the file name and location. It would be great if you know that. Thanks in advance! –  zli89 Feb 11 at 14:55
    
No unfortunately I cannot help you on this one. Why don't you post a question. It seems a very pertinent one to ask as it is a very interesting topic. I'm sure someone will be able to help you. –  Fabrizio Mazzoni Feb 11 at 15:32

If you use the --prefix=PREFIX option while building from source, won't that help? You would also need to look at other options such as --with-pgport=NUMBER to ensure that you don't end up forgetting to change the port in postgresql.conf. Please have a look at http://www.postgresql.org/docs/current/static/install-procedure.html for other options you might want to change.

share|improve this answer
    
Exactly; that's all you need to do. Different --prefix for each install, initdb each to a separate directory, and set PGPORT, edit postgresql.conf to set a unique port, or compile in a different default port. –  Craig Ringer Feb 12 at 0:32

Your Answer

 
discard

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.