Steps for installing Postgresql in Eclipse
Modified from http://wiki.postgresql.org/wiki/Working_with_Eclipse
you can use this link to see the snapshots of the proceedings wherever applicable.
Requirements:
- Ubuntu OS: 8.4+, Eclipse for C/C++, Concurrent Versions System
NOTE: We will be using CVS so that It will become easy to track whatever changes we make to original postgresql code. We can actually have a "diff" with original code so that
we get to know where the actual changes are in the large Postgresql code.
Setting up CVS:
-
Download the postgresql-9.1.2 source from http://www.cse.iitb.ac.in/infolab/Data/Courses/CS631/PostgreSQL-Resources/
Extract the downloaded postgresql source (mostly present in $HOME/Downloads)
- We will be using CVS for managing the versions of the code. It uses the environment variable CVSROOT to denote repository (the place to manage versions of the code).
Open terminal, then go to home folder and set CVSROOT by running
- $mkdir cvsrepo
- $export CVSROOT=$HOME/cvsrepo
Thus cvsrepo will be our repository folder.
- Install CVS from "Ubuntu Software Center" or "Synaptic Package Manager" by typing "cvs" in search textbox.
Then run the command
This should create a folder named CVSROOT in the folder cvsrepo.
- To start the project repository,
In terminal, go to the extracted postgresql source folder (postgresql-9.1.2/) and run
- $cvs import -d prj_name vendor_name initial
where in our case, prj_name is folder "postgresql-9.1.2"
vendor_name can be anything ( "postgres" for example)
"initial" is just the tagging to denote the original source.
This commnad will ask you to write some LOG message, write something or exit directly
- Now you can delete source in Downloads folder (or wherever downloaded)
More information about CVS can be obtained at http://owen.sj.ca.us/~rk/howto/cvs.html
- Make the copy of the project in the repository by typing in following commands
from location of home folder in terminal.
- $ mkdir project
- $ cd project
- $ cvs co postgresql-9.1.2
Thus folder "project" will be in home directory and it will contain copy of the project postgresql-9.1.2.
Installing the softwares needed:
-
Install the following softwares either from Ubuntu software center or from synaptic package manager.
- libreadline5-dev
- zlib1g-dev
- bison
- flex
- In terminal, go to $HOME/project/postgresql-9.1.2 and type following command
- $ ./configure --prefix=$HOME/project --enable-depend --enable-cassert --enable-debug
- Download and install OpenJDK Java 6 Runtime either from Ubuntu Software Center or from
Synaptic package manager.
Setting up Eclipse:
- Download Eclipse (www.eclipse.org) having support for C/C++. Un-tar the downloaded eclipse (mostly in $HOME/Downloads folder).
- After Extracting eclipse, click on kite shaped icon "eclipse" to help start eclipse.
- Use the default workspace (of course, you can change it) and click on workbench to proceed.
Importing Postgresql Code in Eclipse:
- Click on File>import. In the new window select
"C/C++ >> Existing Code as Makefile Project" and click the "next" button.
- In the next window click browse, and choose the $HOME/project/postgresql-9.1.2 folder.
Name project as postgresql-9.1.2. "Language" is "C" and for "Toolchain for Indexer Settings" select "Linux GCC". At the end click finish.
- "Make" will start automatically (this can take several minutes). If every components work well you should have the following message in you console:
"All of PostgreSQL successfully made, Ready to install"
- Furthermore you can see the Project "postgresql-9.1.2" on the left side of your workbench in the project explorer view.
Adding Make Target:
- Open the Make Target view. If this you cannot find this view, simply click on the Button in the left bottom
- Add Target: In the Make-Target-view right click on the project name and select "New". In the new window "Create Make Target" type at "Target name:" "install" and click "OK".
- If this was successful in the Make-Target-view at the end of the list a green dot appears with the label install. Double-click this, so you start the installation of PostgreSQL.
If the installation was successful in the console you can read:
"PostgreSQL installation complete".
Launch initdb in the terminal:
- Switch back to the terminal and change to the path "$HOME/project/postgresql-9.1.2". Before starting initdb you should set some environment variables.
- $export PATH=$HOME/project/bin:$PATH
- $export PGDATA=DemoDir
- $initdb
Run Configurations in Eclipse:
-
Switch back to Eclipse.
Select the Project Explorer view. If you cannot see it, add it with the button in the left bottom.
In the Project Explorer view right click on the Projectname (postgresql-9.1.2), and select "Run As >> Run Configurations".
-
Double-click "C/C++ Application" so a subfolder is created with the name "postgresql-9.1.2Default". Now fill in the form on the right side. At "C/C++ Application:" the path: "src/backend/postgres" and project should be: "postgresql-9.1.2".
- Switch to the tab "Arguments". At "Program arguments" type the arguments
"--single -D DemoDir " where is the name of the database you should create following the instructions in
http://www.cse.iitb.ac.in/dbms/Data/Courses/CS631/PostgreSQL-Resources/pgsql_demo.txt.
Then click the "Apply" button. Click "Run" to start the program.
You should see following logs in your console:
LOG: database system was shut down at (current date and time) UTC
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
That means, the installation was successful and the server is running.