PostGresSql Working with Eclipse
来源:互联网 发布:软件测试技术提高 编辑:程序博客网 时间:2024/04/28 20:02
原文:http://wiki.postgresql.org/wiki/Working_with_Eclipse
Working with Eclipse
Contents
[hide]- 1Developing with Eclipse
- 2Open terminal
- 3Download PostgreSQL source code
- 4Copy with CVS
- 4.1Install CVS
- 4.2Use CVS
- 5Configure source code
- 5.1Install components with Software-Center
- 5.2Configure in the terminal
- 6Download Eclipse
- 6.1Install JDK for Eclipse
- 6.2Download Eclipse
- 6.3Extract and start
- 6.4Set up Workspace
- 6.5The program
- 7Import
- 8Adding make targets
- 8.1Open the Make Target view
- 8.2Add Target
- 9Launch initdb in the terminal
- 10Run Configurations in Eclipse
- 11Debugging PostgreSQL from Eclipse
- 12Debugging with child processes
- 13Create and open Database
- 14Terminate the program
Developing with Eclipse
This page explains how to get quickly started if you want to use Eclipse to develop PostgreSQL.
Used software for this manual:
OS: Ubuntu 8.4
Editor: Eclipse Helios
Versioning: CVS
The manual has been tested on an Ubuntu Live Version to make sure that no required Software is already installed.
!!Important: An internet connection is required
(Remark: If you haven’t installed Ubuntu yet, we recommend the following Link: http://www.ubuntu.com/desktop/get-ubuntu/download )
Open terminal
Through Applications » Accessories » Terminal you can open a new terminal:
Download PostgreSQL source code
Now you can download the latest version of the source code, so you can edit in local in your computer.In our example the CVSROOT ispgrepo (you can choose also an other name), and is located under Home
The command mkdir creates a new folder (pgrepo) and makes a new environment variable that links to this folder:
mkdir pgrepo export CVSROOT=$HOME/pgrepo
The next command downloads with rsync the source code. This can take several minutes:
rsync --progress -avzCH --delete anoncvs.postgresql.org::pgsql-cvs $CVSROOT
Copy with CVS
With CVS (Concurrent Version Control) you can make a versioned copy of the folderpgrepo.
Install CVS
Start Ubuntu Software Center:
Applications » Ubuntu Software Center
To install CVS you should go to the magnifier on the right top side of the application, and enter"cvs". From the results choose "Concurrent Versions System" and click on theInstall button (if CVS is not already installed).
Use CVS
In the previous terminal, if you haven’t closed it (otherwise repeat step 1. Open terminal, and don’t close it until the end of the installation), you can make a copy with the following commands:
mkdir project cd project cvs co pgsql
Warning: Execute these commands one layer above pgrepo, for instance in Home in our example!
You can find more detailed information about setting up your own repository here (Working with CVS).
Configure source code
Install components with Software-Center
You need the following Software, and you can download them through Software Center (Applications » Ubuntu Software Center):
libreadline5-dev
zlib1g-dev
bison (YACC)
flex
You simply have to type the names of the software in the search area, and install them. This is the list of the required Software:
1. libreadline5-dev, 2. zlib1g-dev, 3. bison (YACC), 4.flex
Configure in the terminal
Switch back to the terminal and execute the following commands:
cd pgsql ./configure --prefix=$HOME/project --enable-depend --enable-cassert --enable-debug
Download Eclipse
Install JDK for Eclipse
To see the PostgreSQL source code in an organized manner we will install Eclipse on the computer.
(Remark: You can use any other development tool also, but this manual explains the usage with Eclipse).
First of all you need the "OpenJDK Java 6 Runtime" for Eclipse, which you can also download in the Software-Center.
Start Software Center Center (Applications » Ubuntu Software Center) or switch to the opened window and search for java. Choose"OpenJDK Java 6 Runtime” and click Install.
Download Eclipse
You can download Eclipse from the following link: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliosr
It’s important that you choose a Helios Version, which supports C/C++. Open the Folder in your file browser, where the tar file is. In this example:ubuntu » Downloads.
Extract and start
Right click on the Package and choose "Extract Here" from the menu.
Now enter the extracted Folder and double-click the file "eclipse".
Set up Workspace
You should set up a workspace, where the software stores your projects:
After starting the program you will be prompted to select a folder for your workspace. We will choose the recommended path, but you can change it if you browse for an other folder. If you have chosen your Folder click"OK".
The program
Now you see the welcome-page of Eclipse, where you can choose tutorials, if you are not familiar with Eclipse. To continue the manual choose the arrow on the right to open your Workbench (the defaults layout of the program).
We will import the PostgreSQL code in this workbench.
Import
In this step we will import the project. Select in the left top of the program"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 pgsql folder."Language" is"C" and "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 "pgsql" on the left side of your workbench in the project explorer view.
Adding make targets
Open the Make Target view
If this you can’t find this view, simply click on the Button in the left bottom to add the.
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 "ubuntu/project/pgsql". 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 can’t see it, add it with the button in the left bottom.
In the Project Explorer view right click on the Projektname (pgsql), and select "Run As » Run Configurations".
In this Window you can add a configuration:
Double-click "C/C++ Application" so a subfolder is created with the name"pgsql-Default". Now fill in the form on the right side. At "C/C++ Application:" the path:"src/backend/postgres" and project should be: "pgsql".
Switch to the tab "Arguments". At "Program arguments" type the arguments"-D DemoDir" and 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!
Debugging PostgreSQL from Eclipse
- Make sure gdb is installed on your machine
- Right click on the project in the Project Explorer window and select 'Debug As -> C/C++ Application'
- Select 'postgres' as the binary to execute
- If you don't have PGDATA set in the environment Eclipse is running in, you can tune the command line arguments in Run/Debug Configurations so that Postgres can start properly
Tip: You can do a 'make install' and make your arguments points to that installed directory.
Debugging with child processes
When you start debugging process by using the project default, it can only debug the postmaster process. When clients connect to the database, the postmaster process forks child processes, each of which is actually postgres backend process responsible for the response to the client. You might want gdb to be able to access the forked processes too. Here's how to set that up:
- Debug Perspective => Run => Debug Configuration
- On left side of menu you can see "C/C++ Attach to Application"
- Right click on "C/C++ Attach to Application" and create new debug configuration,
- Set Project, Build Configuration as "Use Active" , C/C++ Application as "postgres" executable path,
- Start postmaster & one instant of postgresql client (for creating one new postgres),
- Click on Debug which will show current process list,
- Select forked "postgres" process you want to debug
- Put breakpoint in your function,
Create and open Database
To see, that the installation is completely working you can do the followings to test the database.
Switch to the terminal, and change to the path "ubuntu/project/pgsql". Execute the command:
psql -l
This will list you all available database.
To create your own database simply type the following:
createdb DemoDB
If you execute the list-database again (psql -l) you can see your database, "DemoDB":
You can login to your database with:
psql DemoDB
Now you can create tables, relationships and much more. You can fully access your database. To exit your database type:
/q
Terminate the program
The server is available until you click on the red rectangle in the console of Eclipse.
If the stop was successful you will see the following log in the console:
LOG: received smart shutdown request
- PostGresSql Working with Eclipse
- Working with Hibernate in Eclipse
- Working with the Eclipse FileSystem
- PLUGINS that HELP YOU WORKING WITH ECLIPSE
- PostgresSQL
- postgressql
- Working with XML nodes
- Working With System Events
- Working with Snort Rules
- Working with XML nodes
- Working with Delegates
- Working with Windows Registry
- Working with EXIF data
- Working with Files
- WORKING WITH SQLite DATABASES
- Working with Kernel Cores
- Working with item renderers
- Working with Querystrings
- 口语语汇单词篇(13)
- 非递归遍历二叉树
- Oracle外键级联更新——延迟约束和触发器实现
- 常用正则表达式大全!(例如:匹配中文、匹配html)
- postgresql8.4+postgis1.5+eclipse CDT3.6 调试环境搭建
- PostGresSql Working with Eclipse
- 没有找到MFC42D.DLL
- volatile: 多线程程序员最好的朋友
- HRESULT返回值说明
- SQLite命令行程序说明
- 楚汉争霸系列地图[zhuan tianya]
- Android 4.0 触摸屏驱动调试记录
- 张孝祥老师,您走好!
- window7装xp