Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f1e864

Browse files
committed
Add item about server-side debugging.
1 parentc34ea74 commit9f1e864

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

‎doc/FAQ_DEV

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Developer's Frequently Asked Questions (FAQ) for PostgreSQL
33

4-
Last updated:Sun Mar 13 22:07:18 EST 2005
4+
Last updated:Sat Apr 23 14:57:40 EDT 2005
55

66
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
77

@@ -42,6 +42,7 @@ Technical Questions
4242
2.5) Why do we use palloc() and pfree() to allocate memory?
4343
2.6) What is ereport()?
4444
2.7) What is CommandCounterIncrement()?
45+
2.8) What debugging features are available?
4546
_________________________________________________________________
4647

4748
General Questions
@@ -762,3 +763,37 @@ typedef struct nameData
762763
to be broken into pieces so each piece can see rows modified by
763764
previous pieces. CommandCounterIncrement() increments the Command
764765
Counter, creating a new part of the transaction.
766+
767+
2.8) What debugging features are available?
768+
769+
First, try running configure with the --enable-cassert option, many
770+
assert()s monitor the progress of the backend and halt the program
771+
when something unexpected occurs.
772+
773+
The postmaster has a -d option that allows even more detailed
774+
information to be reported. The -d option takes a number that
775+
specifies the debug level. Be warned that high debug level values
776+
generate large log files.
777+
778+
If the postmaster is not running, you can actually run the postgres
779+
backend from the command line, and type your SQL statement directly.
780+
This is recommended only for debugging purposes. If you have compiled
781+
with debugging symbols, you can use a debugger to see what is
782+
happening. Because the backend was not started from postmaster, it is
783+
not running in an identical environment and locking/backend
784+
interaction problems may not be duplicated.
785+
786+
If the postmaster is running, start psql in one window, then find the
787+
PID of the postgres process used by psql using SELECT
788+
pg_backend_pid(). Use a debugger to attach to the postgres PID. You
789+
can set breakpoints in the debugger and issue queries from psql. If
790+
you are debugging postgres startup, you can set PGOPTIONS="-W n", then
791+
start psql. This will cause startup to delay for n seconds so you can
792+
attach to the process with the debugger, set any breakpoints, and
793+
continue through the startup sequence.
794+
795+
You can also compile with profiling to see what functions are taking
796+
execution time. The backend profile files will be deposited in the
797+
pgsql/data/base/dbname directory. The client profile file will be put
798+
in the client's current directory. Linux requires a compile with
799+
-DLINUX_PROFILE for proper profiling.

‎doc/src/FAQ/FAQ_DEV.html

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<H1>Developer's Frequently Asked Questions (FAQ) for
1414
PostgreSQL</H1>
1515

16-
<P>Last updated:Sun Mar 13 22:07:18 EST 2005</P>
16+
<P>Last updated:Sat Apr 23 14:57:40 EDT 2005</P>
1717

1818
<P>Current maintainer: Bruce Momjian (<Ahref=
1919
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)<BR>
@@ -71,6 +71,8 @@ <H2>Technical Questions</H2>
7171
<I>pfree</I>() to allocate memory?<BR>
7272
<Ahref="#2.6">2.6</A>) What is ereport()?<BR>
7373
<Ahref="#2.7">2.7</A>) What is CommandCounterIncrement()?<BR>
74+
<Ahref="#2.8">2.8</A>) What debugging features are available?<BR>
75+
7476
<BR>
7577

7678
<HR>
@@ -941,6 +943,45 @@ <H3><A name="2.7">2.7</A>) What is CommandCounterIncrement()?</H3>
941943
modified by previous pieces.<I>CommandCounterIncrement()</I>
942944
increments the Command Counter, creating a new part of the
943945
transaction.</P>
946+
947+
<H3><Aname="2.8">2.8</A>) What debugging features are
948+
available?</H3>
949+
950+
<P>First, try running<I>configure</I> with the --enable-cassert
951+
option, many<I>assert()</I>s monitor the progress of the backend
952+
and halt the program when something unexpected occurs.</P>
953+
954+
<P>The<I>postmaster</I> has a<I>-d</I> option that allows even more
955+
detailed information to be reported. The<I>-d</I> option takes a
956+
number that specifies the debug level. Be warned that high debug
957+
level values generate large log files.</P>
958+
959+
<P>If the<I>postmaster</I> is not running, you can actually run the
960+
<I>postgres</I> backend from the command line, and type your
961+
<SMALL>SQL</SMALL> statement directly. This is recommended
962+
<B>only</B> for debugging purposes. If you have compiled with debugging
963+
symbols, you can use a debugger to see what is happening. Because
964+
the backend was not started from<I>postmaster</I>, it is not
965+
running in an identical environment and locking/backend interaction
966+
problems may not be duplicated.</P>
967+
968+
<P>If the<I>postmaster</I> is running, start<I>psql</I> in one
969+
window, then find the<SMALL>PID</SMALL> of the<I>postgres</I>
970+
process used by<I>psql</I> using<CODE>SELECT pg_backend_pid()</CODE>.
971+
Use a debugger to attach to the<I>postgres</I><SMALL>PID</SMALL>.
972+
You can set breakpoints in the debugger and issue queries from
973+
974+
<I>psql</I>. If you are debugging<I>postgres</I> startup, you can
975+
set PGOPTIONS="-W n", then start<I>psql</I>. This will cause startup
976+
to delay for<I>n</I> seconds so you can attach to the process with
977+
the debugger, set any breakpoints, and continue through the startup
978+
sequence.</P>
979+
980+
<P>You can also compile with profiling to see what functions are
981+
taking execution time. The backend profile files will be deposited
982+
in the<I>pgsql/data/base/dbname</I> directory. The client profile
983+
file will be put in the client's current directory. Linux requires
984+
a compile with<I>-DLINUX_PROFILE</I> for proper profiling.</P>
944985
</BODY>
945986
</HTML>
946987

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp