Use Eclipse to chase the source of PostgreSQL

Source: Internet
Author: User
Tags postgresql psql

1, install the compiled PostgreSQL (see Eclipse compiled PostgreSQL 9.2.2).

2. Open the Make Target view (window->show view->other->make->make target) on eclipse. Right-click the project, select New, create a name install.

3. Installation:
1) Double-click Install.

2) Wait a little while to display the PostgreSQL installation complete on the console window and the installation is successful. Shown below:

3) The default path for the installation is the home path configured in Eclipse compile PostgreSQL 9.5.2, where a project folder (containing bin, include, LIB, share four folders) appears in the directory. Inside is the installed PG database.

4, initialize the database.
1) First set up the folder directory where the database will be stored.
Vim/etc/profile
Add the following lines:
Export path=$home/project/bin: $PATH
Export Pgdata=demodir
2) Execute Initdb

5, debugging pg.
1) Back to eclipse, right-click on your own PG project, select Run as->run configurations->c/c++ application->pgsql Default, and configure as follows:


2) When the configuration is complete, click Run and the console will appear as follows:

This indicates that your PG database is already running (initiating 6 postgres processes), monitoring whether there are command inputs, which you can operate from the terminal PG client.

6, Debug PostgreSQL.
1) before debugging, configure the Debug, right-click your own PG project, select Debug as->c/debugconfigurations-> configuration, configuration parameters refer to step 5.

2) Right-click on your own PG project, select Debug as->c/c++ application, select Postgres as shown:

3) Click OK after the project will automatically run and jump to the main function of the entrance, as shown, it is possible to run step-by-step.

7, listen to the client's process (child process), see its execution steps.
1) First open the terminal, start the database server-side process. Go to the Bin directory of the installation database directory and execute the following code:
./postgres-d/home/lzl/pg/postgresql-9.2.2/demodir/
It should be noted that in the environment variables under Linux will not default to the current directory, if necessary, you can configure it, you can also use./Find the executable file in the current directory. You can start the server side of the database when you are done.
It is best to record the start of the 6 postgres process PID, easy to face when the client to listen to the process of choice.
2) Another terminal, or into the installation database directory of the bin directory, the first time the default system comes with three databases, so first to create a database of their own, for example, I create a pgtest database, the execution command is as follows:
./createdb Demodb
Once created, go to this database and execute the command:
./psql Demodb
The results are as follows:

3) Next back to Eclipse, right-click on your own PG project, select Debug As->c/debugconfigurations->c++ Attach to Application->pgsql Default ( Attach) (this name can be named by itself). The configuration is the same as above.
Clicking Debug will pop up a window to select the process, find and postgre related processes, and find the postgres process that just started the client.

Ps:
1. The postgres.c file in the Postgres project is the entry place of the Psql command.
2, in the client to execute the command: \DT, will jump to the location of the breakpoint, the next can be self-chasing source.
3. Error:
1) fatal:lock file "Postmaster.pid" already exists
Solution: Must not delete! Must not DELETE!! Must not be deleted!!! Cat this file, the first line is a PID number, execute "kill-9 pid number" can be
2) Log:could not bind IPv4 socket:address already in use
Solution: listen_addresses all unified; modify some assorted things, such as firewall configuration files, SELinux, pg_conf and so on, all unified into the same
3) UNIX 2 [ACC] STREAM LISTENING 82011/tmp/.s.pgsql.5432.lock
Follow this path to find the file and delete it ... Complete!

Reference documents
1:http://wiki.postgresql.org/wiki/working_with_eclipse
2:http://blog.csdn.net/mgx289106164/article/details/51173302

Use Eclipse to chase the source of PostgreSQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.