============================================================
Frequently Asked Questions (FAQ) for PostgreSQL
Sun Solaris specific
To be read in conjunction with the installation instructions.
============================================================
Last updated:        $Date: 2007/09/13 03:34:23 $


Contents:

1) What tools do I need to build and install PostgreSQL on Solaris?
2) Why do I get problems when building with OpenSSL support?
3) Why does configure complain about a failed test program?
4) Why does my 64-bit build sometimes crash?
5) How can I compile for optimum performance?
6) Where I can download prepared Solaris packages?
7) How can I tune PostgreSQL and Solaris for performance?
8) Can I use DTrace for tracing PostgreSQL?


1) What tools do I need to build and install PostgreSQL on Solaris?

You will need

	gzip (for installing the documentation)
	GNU Make
	GNU Readline library (optional)
	Sun Studio CC or GCC

You can download Sun Studio from: 
http://developers.sun.com/prodtech/cc/downloads/index.jsp

Many of GNU tools are integrated into Solaris 10, or they are present
on the Solaris companion CD.

If you like packages for older version of Solaris, you can find these
tools here:

	http://www.sunfreeware.com or http://www.blastwave.org

If you prefer sources, look here:

	http://www.gnu.org/order/ftp.html

You can build with either GCC or Sun's compiler suite.  For better
code optimization, Sun's compiler is strongly recommended on the SPARC
architecture.  We have heard reports of problems when using GCC
2.95.1; gcc 2.95.3 or later is recommended.  If you are using Sun's
compiler, be careful not to select /usr/ucb/cc; use
/opt/SUNWspro/bin/cc.


2) Why do I get problems when building with OpenSSL support?

When you build PostgreSQL with OpenSSL support you might get compilation
errors in the following files:

	src/backend/libpq/crypt.c
	src/backend/libpq/password.c
	src/interfaces/libpq/fe-auth.c
	src/interfaces/libpq/fe-connect.c

This is because of a namespace conflict between the standard
/usr/include/crypt.h header and the header files provided by OpenSSL.

Upgrading your OpenSSL installation to version 0.9.6a fixes this
problem.  Solaris 9 and above has a newer version of OpenSSL.


3) Why does configure complain about a failed test program?

This is probably a case of the run-time linker being unable to find
some library, probably libz, libreadline or some other non-standard
library such as libssl.  To point it to the right location, set the
LDFLAGS environment variable, e.g.,

	LDFLAGS="-R /usr/sfw/lib:/opt/sfw/lib:/usr/local/lib"
	export LDFLAGS

and restart configure. See the ld(1) man page for more
information.


4) Why does my 64-bit build sometimes crash?

On Solaris 7 and older, the 64-bit version of libc has a buggy vsnprintf
routine, which leads to erratic core dumps in PostgreSQL.  The simplest
known workaround is to force PostgreSQL to use its own version of
vsnprintf rather than the library copy.  To do this, after you run
'configure' edit a file produced by configure:

In src/Makefile.global, change the line

    LIBOBJS =

to read

    LIBOBJS = snprintf.o

(There might be other files already listed in this variable.  Order
does not matter.)

Then build as usual.


5) How can I compile for optimal performance?

On the SPARC architecture, Sun Studio is strongly recommended for
compilation.  Try using the -xO5 optimization flag to generate
significantly faster binaries.  Do not use any flags that modify
behavior of floating point operations and errno processing (e.g.,
-fast).  These flags could raise some nonstandard PostgreSQL behavior
for example in the date/time computing.

If you do not have a reason to use 64-bit binaries on SPARC, prefer
the 32-bit version.  The 64-bit operations are slower and 64-bit
binaries are slower than the 32-bit variants.  And on other hand,
32-bit code on the AMD64 CPU family is not native, and that is why
32-bit code is significant slower on this CPU family.


6) Where I can download prepared Solaris packages?

The PostgreSQL is bundled with Solaris 10 (from update 2).  Official
packages are also available on
<http://pgfoundry.org/projects/solarispackages/>.  Packages for older
Solaris version (8, 9) you can be obtained from
<http://www.sunfreeware.com/> or <http://www.blastwave.org/>.


7) How can I tune PostgreSQL and Solaris for performance?

Some tuning tricks can be found here:

	http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp

This article is primary focused on T2000 platform, but many of the
recommendations are also useful on other hardware with Solaris.


8) Can I use DTrace for tracing PostgreSQL?

Yes, see the chapter "Monitoring Database Activity" in the documentation
for further information.

You can also find more information here:

	http://blogs.sun.com/robertlor/entry/user_level_dtrace_probes_in

If you see the linking of the postgres executable abort with an error
message like

	Undefined                       first referenced
	 symbol                             in file
	AbortTransaction                    utils/probes.o
	CommitTransaction                   utils/probes.o
	ld: fatal: Symbol referencing errors. No output written to postgres
	collect2: ld returned 1 exit status
	gmake: *** [postgres] Error 1

your DTrace installation is too old to handle probes in static
functions.  You need Solaris 10u4 or newer. Workaround is remove static
keyword from AbortTransaction and CommitTransaction functions declaration in 
src/backend/access/transam/xact.c.

See http://sunsolve.sun.com/search/document.do?assetkey=1-1-2139224-1
(registration required).
