Add item about server-side debugging.
authorBruce Momjian
Sat, 23 Apr 2005 18:57:46 +0000 (18:57 +0000)
committerBruce Momjian
Sat, 23 Apr 2005 18:57:46 +0000 (18:57 +0000)
doc/FAQ_DEV
doc/src/FAQ/FAQ_DEV.html

index 7e0839dbfc538dd4d85946b192862c6dd5d35fcb..b30ff1337c74663ea128f7a398294f9463e85922 100644 (file)
@@ -1,7 +1,7 @@
 
           Developer's Frequently Asked Questions (FAQ) for PostgreSQL
                                        
-   Last updated: Sun Mar 13 22:07:18 EST 2005
+   Last updated: Sat Apr 23 14:57:40 EDT 2005
    
    Current maintainer: Bruce Momjian ([email protected])
    
@@ -42,6 +42,7 @@ Technical Questions
    2.5) Why do we use palloc() and pfree() to allocate memory?
    2.6) What is ereport()?
    2.7) What is CommandCounterIncrement()?
+   2.8) What debugging features are available?
      _________________________________________________________________
    
 General Questions
@@ -762,3 +763,37 @@ typedef struct nameData
    to be broken into pieces so each piece can see rows modified by
    previous pieces. CommandCounterIncrement() increments the Command
    Counter, creating a new part of the transaction.
+   
+  2.8) What debugging features are available?
+  
+   First, try running configure with the --enable-cassert option, many
+   assert()s monitor the progress of the backend and halt the program
+   when something unexpected occurs.
+   
+   The postmaster has a -d option that allows even more detailed
+   information to be reported. The -d option takes a number that
+   specifies the debug level. Be warned that high debug level values
+   generate large log files.
+   
+   If the postmaster is not running, you can actually run the postgres
+   backend from the command line, and type your SQL statement directly.
+   This is recommended only for debugging purposes. If you have compiled
+   with debugging symbols, you can use a debugger to see what is
+   happening. Because the backend was not started from postmaster, it is
+   not running in an identical environment and locking/backend
+   interaction problems may not be duplicated.
+   
+   If the postmaster is running, start psql in one window, then find the
+   PID of the postgres process used by psql using SELECT
+   pg_backend_pid(). Use a debugger to attach to the postgres PID. You
+   can set breakpoints in the debugger and issue queries from psql. If
+   you are debugging postgres startup, you can set PGOPTIONS="-W n", then
+   start psql. This will cause startup to delay for n seconds so you can
+   attach to the process with the debugger, set any breakpoints, and
+   continue through the startup sequence.
+   
+   You can also compile with profiling to see what functions are taking
+   execution time. The backend profile files will be deposited in the
+   pgsql/data/base/dbname directory. The client profile file will be put
+   in the client's current directory. Linux requires a compile with
+   -DLINUX_PROFILE for proper profiling.
index 111fb12a0c850d8bd84609b962121b9224e2b991..a9ef832f29ad4e45abb0205f7700a387132dcaa4 100644 (file)
@@ -13,7 +13,7 @@
     

Developer's Frequently Asked Questions (FAQ) for

     PostgreSQL
 
-    

Last updated: Sun Mar 13 22:07:18 EST 2005

+    

Last updated: Sat Apr 23 14:57:40 EDT 2005

 
     

Current maintainer: Bruce Momjian (

@@ -71,6 +71,8 @@
     pfree() to allocate memory?
      2.6) What is ereport()?
      2.7) What is CommandCounterIncrement()?
+     2.8) What debugging features are available?
+
      
      
     
     modified by previous pieces. CommandCounterIncrement()
     increments the Command Counter, creating a new part of the
     transaction.

+
+    

2.8) What debugging features are

+    available?
+
+    

First, try running configure with the --enable-cassert

+    option, many assert()s monitor the progress of the backend
+    and halt the program when something unexpected occurs.

+
+    

The postmaster has a -d option that allows even more

+    detailed information to be reported. The -d option takes a
+    number that specifies the debug level. Be warned that high debug
+    level values generate large log files.

+
+    

If the postmaster is not running, you can actually run the

+    postgres backend from the command line, and type your
+    SQL statement directly. This is recommended
+    only for debugging purposes. If you have compiled with debugging
+    symbols, you can use a debugger to see what is happening. Because
+    the backend was not started from postmaster, it is not
+    running in an identical environment and locking/backend interaction
+    problems may not be duplicated.

+
+    

If the postmaster is running, start psql in one

+    window, then find the PID of the postgres
+    process used by psql using SELECT pg_backend_pid().
+    Use a debugger to attach to the postgres PID.
+    You can set breakpoints in the debugger and issue queries from
+
+    psql. If you are debugging postgres startup, you can
+    set PGOPTIONS="-W n", then start psql. This will cause startup
+    to delay for n seconds so you can attach to the process with
+    the debugger, set any breakpoints, and continue through the startup
+    sequence.

+
+    

You can also compile with profiling to see what functions are

+    taking execution time. The backend profile files will be deposited
+    in the pgsql/data/base/dbname directory. The client profile
+    file will be put in the client's current directory. Linux requires
+    a compile with -DLINUX_PROFILE for proper profiling.