PPOOSSTTGGRREESS IINNSSTTAALLLLAATTIIOONN IINNSSTTRRUUCCTTIIOONNSS Release 4.2 DDooccuummeenntt OOvveerrvviieeww Introduction Site Requirements Hardware and Software Distribution Tape Expertise Configuration Programming Environment Disk Requirements Kernel Installing POSTGRES Preparation Finding a Good Place for POSTGRES Creating the POSTGRES Directory Creating the POSTGRES User Loading POSTGRES Loading POSTGRES From Tape Loading POSTGRES From a Tar File Kernel Configuration Kernel Reconfiguration for SPARCs Kernel Reconfiguration for DECs (Ultrix only) Compiler Configuration Setup for Solaris 2 Setup for HP-UX Compiling and Installing POSTGRES Customization Installing "bsdinst" (HP-UX only) Installing "solcc" (Solaris only) Bootstrapping "bmake" Building and installing "libdl" (Ultrix only) Installing "mkldexport" (AIX only) Compile and Install Creating the Initial Database Testing Running POSTGRES The POSTGRES Postmaster The POSTGRES Terminal Monitor The POSTGRES Backend POSTGRES Support Programs Optional Installation Installing LIBPQ, the POSTGRES Frontend Library POSTGRES Header Files Wisconsin Benchmark Database Minimal Installation Documentation Miscellaneous Bug Reports Consulting POSTGRES Mailing List 22 11.. IInnttrroodduuccttiioonn This document gives installation instructions for the POST- GRES database system under development at the University of California, Berkeley. POSTGRES is distributed in source code format and is the property of the Regents of the Uni- versity of California. However, the University will grant unlimited commercialization rights for any derived work on the condition that an educational license to the derived work is obtained. For further information, consult the Berkeley Campus Software Office, 295 Evans Hall, University of California, Berkeley, CA 94720. The University and the POSTGRES development group provide no warranty as to the fitness of the code for any purpose what- soever, and cannot guarantee assistance in fixing problems. This is _u_n_s_u_p_p_o_r_t_e_d software. 22.. SSiittee RReeqquuiirreemmeennttss 22..11.. HHaarrddwwaarree aanndd SSooffttwwaarree POSTGRES currently has been tested by the POSTGRES develop- ment team on the following systems: +o Digital Equipment DECstation 3000 series (Alpha AXP architecture) machines running DEC OSF/1 1.3 and 2.0. +o Digital Equipment DECstation 3100 and 5000 series (MIPS architecture) machines running Ultrix 4.2A and 4.3A. +o Hewlett-Packard H-P 9000 Series 700 and 800 (PA-RISC architecture) machines running HP-UX 9.00, 9.01 and 9.03. +o International Business Machines RS/6000 (POWER architec- ture) machines running AIX 3.2.5. +o Sun Microsystems (SPARC architecture) machines running SunOS 4.1.3, (Solaris 1.0.1), SunOS 4.1.3_U1 and Solaris 2.3. In order to use POSTGRES, your machine should have at least 8 megabytes of memory and you will require at least 45 megabytes of disk space to hold source, binaries, and user databases. If you choose to compile POSTGRES for source- level debugging, you will need roughly twice as much disk space. See the section on compilation for details. 22..22.. DDiissttrriibbuuttiioonn TTaappee These instructions assume you have a POSTGRES Version 4.2 distribution tape (in either SCSI cartridge or DEC TK50 car- tridge format) or a POSTGRES tar file. This release is a source distribution only. The source code is available in tar format over the Internet via anonymous ftp from the site ss22kk--ffttpp..CCSS..BBeerrkkeelleeyy..EEDDUU. Look in the directory ppuubb//ppoossttggrreess//ppoossttggrreess--vv44rr22. The compressed tar file 33 containing the complete source distribution is named ppoosstt-- ggrreess--vv44rr22..ttaarr..ZZ. 22..33.. EExxppeerrttiissee Once a site is properly configured and POSTGRES is installed, very little UNIX expertise is required to main- tain things. However, initially setting things up for your site to run POSTGRES may be difficult and we advise that the person installing POSTGRES be familiar with system adminis- tration procedures. Also note that various steps require superuser privilege on the system, so we recommend that your site's system administrator read this document also. 22..44.. CCoonnffiigguurraattiioonn This section briefly describes the configuration you need to run POSTGRES. Read this to familiarize yourself with the procedure. Detailed instructions for making appropriate modifications to your system are given later in this docu- ment. 22..44..11.. PPrrooggrraammmmiinngg EEnnvviirroonnmmeenntt Some compiler environments must be modified in certain ways. For example, under SunOS 4.x, POSTGRES expects things to be configured for BSD by default. If the default on your site is to use the SunOS 4.x System V compiler and libraries then you may have to make some changes to this procedure before compiling POSTGRES. Under other systems, you may have to apply patches to your compiler. We will describe such modi- fications later. To compile this release from sources requires a new version of mmaakkee which comes from the latest BSD release. A boot- strapping version of the mmaakkee sources is included with this release and additional instructions are provided below. The new mmaakkee program is installed as bbmmaakkee to avoid any conflict with your native mmaakkee. 22..44..22.. DDiisskk RReeqquuiirreemmeennttss POSTGRES requires 50 megabytes of disk space, preferably on a single partition, to compile and install from sources. (As with any program, it may require 2-3 times as much space if you compile the system with optimization turned off and compiler debugging support turned on.) 22..44..33.. KKeerrnneell POSTGRES makes use of the System V inter-process communica- tion (shared memory and semaphore) operations provided by the operating system. Ultrix requires a properly configured 44 kernel which is in general different than the factory- shipped generic kernel. See the section on kernel configu- ration for details. Also, the original release of Ultrix 4.3 has a kernel bug that causes the operating system to hang when running POSTGRES. The bug is in the shared memory module in the kernel, and a patch is available from DEC which fixes the bug. Contact your DEC representative for patch number CLD-CXO09447. (This patch has been included in Ultrix 4.3a.) 33.. IInnssttaalllliinngg PPOOSSTTGGRREESS To install the system you must load the sources into your filesystem and build the system from scratch. To run the compiled programs your kernel may need to be configured to support the shared memory and semaphore operations required by the code. Assuming you have run POSTGRES in the past, your machine may already be properly configured. 33..11.. SStteepp 11 -- PPrreeppaarraattiioonn Some of the tasks involved in this step normally fall in the domain of the site's system administrator and may require superuser privilege. If possible, we advise you to have your system administrator perform these steps. 33..11..11.. FFiinndd aa ggoooodd ppllaaccee ffoorr PPOOSSTTGGRREESS First you should locate a disk partition with at least 50 megabytes of free space available for POSTGRES. For exam- ple: # ddff Filesystem kbytes used avail capacity Mounted on /dev/xy0a 8421 6703 875 88% / /dev/xy0f 10829 6743 3003 69% /pub.MC68020 /dev/xy2h 110811 81181 18548 81% /usr3 /dev/xy2g 221279 167405 31746 84% /b /dev/xy1g 221279 138365 60786 69% /usr/local /dev/xy1a 8179 944 6417 13% /tmp /dev/xy0h 119999 101623 6376 94% /usr.MC68020 /dev/xy0g 156033 135499 4930 96% /usr2 /dev/rf0d 539421 465026 20452 96% /a _/_u_s_r_/_l_o_c_a_l _l_o_o_k_s _l_i_k_e _a _g_o_o_d _p_l_a_c_e _(_i_t _h_a_s _6_0 _m_e_g_s _f_r_e_e_) _s_o _w_e _d_e_c_i_d_e _t_o _c_r_e_a_t_e _t_h_e _P_O_S_T_G_R_E_S _d_i_r_e_c_t_o_r_y _t_h_e_r_e_._._. 55 33..11..22.. CCrreeaattiinngg tthhee PPOOSSTTGGRREESS ddiirreeccttoorryy Once you have decided, create the directory to hold the release if it doesn't already exist. Then ccdd to this direc- tory and type ppwwdd. This is the full path of the directory you will install POSTGRES in. For example: # ccdd //uussrr//llooccaall # mmkkddiirr ppoossttggrreess # ccdd ppoossttggrreess # ppwwdd /usr/local/postgres # 33..22.. CCrreeaattiinngg tthhee PPOOSSTTGGRREESS uusseerr Finally, we need to create a user called "postgres" whose shell is //bbiinn//ccsshh. Though not necessary, it is convenient to make the home directory of the POSTGRES user the pathname where we install the system. This can be done using the "adduser" procedures particular to your platform and site. See your system administration manual for details. The reason we make a "postgres" login is so that when we install the system and create the database directory, every- thing is owned by this "postgres" user. Then, we start the postmaster when logged in as this "postgres" user, and all the backends are also started by the user "postgres" and are able to access the databases. You can make this work with- out creating a "postgres" login but this is highly discour- aged -- all POSTGRES processes run with this user id, and making yourself the POSTGRES user essentially grants all of your database users the ability to become _y_o_u without a password. Note that the restriction about having a "postgres" login with UID 6 was removed in POSTGRES Version 4.0.1. 33..33.. SStteepp 22 -- LLooaaddiinngg PPOOSSTTGGRREESS Now you are ready to load the POSTGRES files onto your sys- tem. To do this, you will need either a distribution tape or a POSTGRES tar file. If you are loading POSTGRES from a tape, follow these instructions; if you are loading from a tar file obtained via FTP, skip to the section "Loading POSTGRES from a Tar File." 33..33..11.. LLooaaddiinngg PPOOSSTTGGRREESS ffrroomm aa TTaappee Login as "postgres" and change directories to the postgres directory that was created. 66 Run ttaarr with the following options % ttaarr xxvvffpp _<_t_a_p_e_-_d_e_v_i_c_e_> where _<_t_a_p_e_-_d_e_v_i_c_e_> is the name for your tape device, i.e., //ddeevv//rrmmtt00, //ddeevv//rrsstt88, etc. The file ppoossttggrreess--vv44rr22..ttaarr..ZZ will appear in your POSTGRES home directory. You may need to re-wind your tape to get it out of your tape drive - see your system administrator for instructions. Proceed to the next section "Loading POSTGRES from a Tar File." 33..33..22.. LLooaaddiinngg PPOOSSTTGGRREESS ffrroomm aa TTaarr FFiillee If you are not logged in as ppoossttggrreess already, do so now. Uncompress the tar file. % uunnccoommpprreessss ppoossttggrreess--vv44rr22..ttaarr..ZZ A larger file should now be in the POSTGRES home directory, and the ".Z" ending should be gone, so it is now named ppoosstt-- ggrreess--vv44rr22..ttaarr. Extract POSTGRES from the tar file using the following com- mand: % ttaarr xxvvffpp ppoossttggrreess--vv44rr22..ttaarr Lots of file names and such should appear on the screen. This step may take several minutes. Now do an llss: % llss The output should look something like: CCOOPPYYRRIIGGHHTT RREEAADDMMEE ddoocc llooccaall ssrrcc IINNIITTIIAALL__SSEETTUUPP bbiinn iinncclluuddee mmaann MMaakkeeffiillee ddaattaa lliibb oobbjj At this point you have loaded the POSTGRES files. Remove the tar file to get back the space. 77 % rrmm ppoossttggrreess--vv44rr22..ttaarr 33..44.. SStteepp 33 -- KKeerrnneell CCoonnffiigguurraattiioonn This step requires familiarity with configuring a UNIX ker- nel. If you are unfamiliar with this procedure, we advise you to read the section on configuring a kernel in the sys- tem administration manual carefully. This task requires superuser privilege and should probably not be done without the assistance of your system administrator. We assume that whoever undergoes this procedure has an understanding of the process and procedures involved. POSTGRES uses shared memory segments which must be compiled into the kernel of the host which will act as the POSTGRES server. If you try to run a POSTGRES backend process on a machine without enough shared memory, the backend will abort with an error message. This is by far the most complicated part of the installation so tthheessee sstteeppss sshhoouulldd bbee ppeerrffoorrmmeedd bbyy ssoommeeoonnee wwiitthh ssyysstteemm aaddmmiinniissttrraattiioonn eexxppeerriieennccee. Again, we advise you to consult the system administration section of your manual before doing this step. For a brief discussion of shared memory, you may want to consult the manual pages for sshhmmggeett((33)), sshhmmoopp((33)), sshhmmccttll((33)), etc. Now proceed to the appropriate section for your machine. 33..44..11.. KKeerrnneell rreeccoonnffiigguurraattiioonn ffoorr SSPPAARRCCss We previously suggested that you reconfigure your kernel under SunOS. However, the parameters in the generic kernel of current releases of SunOS ought to suffice. (We never reconfigure our kernels and have not noticed any problems while running several ppoossttmmaasstteerrs at once.) 33..44..22.. KKeerrnneell rreeccoonnffiigguurraattiioonn ffoorr DDEECCss ((UUllttrriixx oonnllyy)) In order to reconfigure your DECstation 3100 or 5000 Ultrix kernel, you will have to become the superuser and add some lines to //uussrr//ssyyss//ccoonnff//KKEERRNNEELL (your kernel config file). Remember that Ultrix 4.3 has a kernel bug that causes the operating system to hang when running POSTGRES. You should apply the DEC-supplied patch at this point if you have not already. The following lines should be added to //uussrr//ssyyss//ccoonnff//KKEERRNNEELL: 88 ssmmmmaaxx 225566 ssmmsseegg 1122 ssmmbbrrkk 11002244 After adding these lines, run ccoonnffiigg over the configuration file, install the new kernel (saving a copy of the old ker- nel first!) and reboot. 33..55.. SStteepp 44 -- CCoommppiilleerr CCoonnffiigguurraattiioonn 33..55..11.. SSeettuupp ffoorr SSoollaarriiss 22 POSTGRES should build without problems using the SunPro SPARCompiler (we used version 3.0). If you do not have the SunPro compiler, you must use a version of the GNU C com- piler that fully implements the --mmuunnaalliiggnneedd--ddoouubblleess option. You may FTP a suitable set of binaries from ss22kk-- ffttpp..CCSS..BBeerrkkeelleeyy..EEDDUU in the directory ppuubb//ppoossttggrreess//uusseeffuull, or you can rebuild your own copy of the GNU C compiler with the required change. The current version as of this writing is 2.5.8, which must be modified with the following one-line patch: ------ 11,,1199 -------- ++ ****** ccoonnffiigg//ssppaarrcc//ssppaarrcc..cc TThhuu AApprr 77 0099::3300::3300 11999944 ++ ------ ccoonnffiigg//ssppaarrcc//ssppaarrcc..cc..oorriigg TThhuu AApprr 77 0099::3311::3355 11999944 ++ ****************************** ++ ****** 11006677,,11007733 ******** ++ iiss ttrruuee,, iinn wwhhiicchh ccaassee wwee ccaann oonnllyy aassssuummee tthhaatt aann aacccceessss iiss aalliiggnneedd iiff ++ iitt iiss ttoo aann aaggggrreeggaattee,, iitt iiss ttoo aa ccoonnssttaanntt aaddddrreessss,, oorr tthhee aaddddrreessss ++ iinnvvoollvveess aa LLOO__SSUUMM.. **// ++ !! eellssee iiff ((!! TTAARRGGEETT__UUNNAALLIIGGNNEEDD__DDOOUUBBLLEESS //** |||| MMEEMM__IINN__SSTTRRUUCCTT__PP ((mmeemm)) **// ++ |||| CCOONNSSTTAANNTT__PP ((aaddddrr)) |||| GGEETT__CCOODDEE ((aaddddrr)) ==== LLOO__SSUUMM)) ++ rreettuurrnn 11;; ++ ++ ------ 11006677,,11007733 -------- ++ iiss ttrruuee,, iinn wwhhiicchh ccaassee wwee ccaann oonnllyy aassssuummee tthhaatt aann aacccceessss iiss aalliiggnneedd iiff ++ iitt iiss ttoo aann aaggggrreeggaattee,, iitt iiss ttoo aa ccoonnssttaanntt aaddddrreessss,, oorr tthhee aaddddrreessss ++ iinnvvoollvveess aa LLOO__SSUUMM.. **// ++ !! eellssee iiff ((!! TTAARRGGEETT__UUNNAALLIIGGNNEEDD__DDOOUUBBLLEESS |||| MMEEMM__IINN__SSTTRRUUCCTT__PP ((mmeemm)) ++ |||| CCOONNSSTTAANNTT__PP ((aaddddrr)) |||| GGEETT__CCOODDEE ((aaddddrr)) ==== LLOO__SSUUMM)) ++ rreettuurrnn 11;; ++ We have been told that a later version of the GNU C compiler may incorporate this change (this patch has been sent to both Cygnus Support and the FSF). 99 33..55..22.. SSeettuupp ffoorr HHPP--UUXX You cannot build POSTGRES without the unbundled C compiler. Neither the GNU C compiler nor the (crippled) C compiler that comes with stock HP-UX will work, as both are missing critical compiler options. If you are running HP-UX 9.03, you mmuusstt apply patch PHSS_4307 (or a cumulative patch that supercedes this patch) to your system, as the C preprocessor for HP-UX 9.03 has severe problems. We cannot provide you with this patch; you must obtain it from your H-P support representative. Note that POSTGRES should build without problems on 9.01, so you can always build the binaries on a 9.01 system and use them on a 9.03 system. 33..66.. SStteepp 55 -- CCoommppiilliinngg aanndd IInnssttaalllliinngg PPOOSSTTGGRREESS The sources for POSTGRES are all under the directory ssrrcc//. 33..66..11.. BBuuiilldd SStteepp 11:: CCuussttoommiizzaattiioonn CCdd into the ssrrcc// directory and edit the file MMaakkee-- ffiillee..gglloobbaall. You may change the various configuration options here, such as where the POSTGRES executable files are installed and where it looks for the database directory. The configuration switches are fairly self-explanatory, but we will go over some of the more commonly-changed options. The PORTNAME option mmuusstt be set correctly. By default the PORTNAME is uullttrriixx44, but aix alpha hpux sparc sparc_solaris ultrix4 are all valid choices. The top-level directory where POSTGRES binaries, documenta- tion, header files, libraries, and databases are installed is controlled by the variable POSTGRESDIR. This variable defaults to //uussrr//llooccaall//ppoossttggrreess. Whether you change this variable or not, make sure that the directory to which POST- GRESDIR refers exists before proceeding. If you do not want bbmmaakkee installed into //uussrr//llooccaall//bbiinn and //uussrr//llooccaall//lliibb, change the values of TOOLSBINDIR and TOOL- SLIBDIR and make sure that these directories exist before proceeding. 1100 Standards notwithstanding, every system has an iinnssttaallll pro- gram with slightly different options and behavior. Our Makefiles assume that iinnssttaallll accepts BSD (as opposed to System V) options. Where possible, we set the INSTALL vari- able to ensure that the BSD program is called. However, on HP-UX you will have to find a BSD-compatible installation program and set INSTALL to the location of this program. bbssddiinnsstt, which comes with the MIT X Window System distribu- tion (in mmiitt//uuttiill//ssccrriippttss), is widely available (we even include it in the ssrrcc//ttoooollss directory) and works acceptably. The GNU iinnssttaallll program does not. If you are not installing POSTGRES using superuser privi- leges, or you are installing POSTGRES without creating a "postgres" user, you may have to set the values of several variables that control the system ownership. For example, "janeuser" who is a member of group "users" may have to set: BBIINNGGRRPP== uusseerrss BBIINNOOWWNN== jjaanneeuusseerr LLIIBBGGRRPP== uusseerrss LLIIBBOOWWNN== jjaanneeuusseerr MMAANNGGRRPP== uusseerrss MMAANNOOWWNN== jjaanneeuusseerr to prevent the iinnssttaallll program from complaining. If you absolutely insist on having a POSTGRES user other than "postgres", set the variable POSTGRESLOGIN to the name of that user. 33..66..22.. IInnssttaalllliinngg ""bbssddiinnsstt"" ((HHPP--UUXX oonnllyy)) We told you about this above, but in case you missed it, you will have to install bbssddiinnsstt from ssrrcc//ttoooollss//bbssddiinnsstt if you don't have it installed already. You can just copy the shell script bbssddiinnsstt..sshh into some convenient place (probably //uussrr//llooccaall//bbiinn) as bbssddiinnsstt. 33..66..33.. IInnssttaalllliinngg ""ssoollcccc"" ((SSoollaarriiss oonnllyy)) If you are using the GNU C compiler under Solaris 2.3, you must now install the small wrapper in ssrrcc//ttoooollss//ssoollcccc into some convenient place (probably //uussrr//llooccaall//bbiinn). You will have to edit this wrapper, changing the line GCCBINDIR=/opt/gnu/bin to point to the directory where you have your (modified) version of ggcccc installed. If you are using the SunPro SPARCompiler, you do not have to install ssoollcccc. 1111 33..66..44.. BBuuiilldd SStteepp 22:: BBoooottssttrraappppiinngg ""bbmmaakkee"" Because the bbmmaakkee program is normally installed into //uussrr//llooccaall//{{bbiinn,,lliibb}} and that directory is usually only writable by root, it will be necessary to temporarily become root to install bbmmaakkee. If you don't have root privilege you can change where bbmmaakkee is installed by changing the value of the TOOLSBINDIR and TOOLSLIBDIR options in ssrrcc//MMaakkeeffiillee..gglloobbaall, otherwise you will need to ssuu(1) to root. Next make sure that the mmaakkee program in your PATH environment variable is the system-provided mmaakkee (usually //bbiinn//mmaakkee) and NNOOTT GNU mmaakkee (many users have reported prob- lems getting old versions of GNU mmaakkee to work). CCdd into ssrrcc//ttoooollss//bbmmaakkee and type % ..//BBoooottssttrraapp _p_o_r_t_n_a_m_e where _p_o_r_t_n_a_m_e is the value of PORTNAME (ultrix4, sparc, etc). If you are using the GNU C compiler under Solaris 2.3, type % ..//BBoooottssttrraapp _p_o_r_t_n_a_m_e ssoollcccc to specify the correct compiler. This script should compile and install the bbmmaakkee program and its supporting files, including the POSTGRES-related Makefile templates. If all went well you will now be able to use the new program by typing bbmmaakkee, assuming you have //uussrr//llooccaall//bbiinn in your shell path. You may have to type rreehhaasshh if you run ccsshh. 33..66..55.. BBuuiillddiinngg aanndd iinnssttaalllliinngg ""lliibbddll"" ((UUllttrriixx oonnllyy)) This version of POSTGRES uses the ddllooppeenn((33)) interface to implement dynamic function loading. Since there is no such vendor-supplied interface on the Ultrix platform you must build and install a version that we provide. The same previous discussion about being root also holds true here. However, if you cannot become root to install this library, then you will have to change the backend Make- file to look for this library where you have decided to put it using the -L loader flag. To compile and install the library simply ccdd into ssrrcc//ttoooollss//lliibbddll and type % bbmmaakkee aallll iinnssttaallll This will build and install the lliibbddll..aa library into TOOL- SLIBDIR (this is //uussrr//llooccaall//lliibb by default). If your linker/loader doesn't search here by default (it usually does), you may have to rraannlliibb((11)) on it. 1122 33..66..66.. IInnssttaalllliinngg ""mmkkllddeexxppoorrtt"" ((AAIIXX oonnllyy)) CCdd into ssrrcc//ttoooollss//mmkkllddeexxppoorrtt and type % bbmmaakkee aallll iinnssttaallll 33..66..77.. BBuuiilldd SStteepp 33:: CCoommppiillee aanndd IInnssttaallll CCdd back to the ssrrcc// directory (i.e., ccdd ....//....) and type: % bbmmaakkee aallll iinnssttaallll This builds and installs the entire system. The MMaakkeeffiillees contain directives for running all the underlying MMaakkeeffiillees in all the directories, so the whole thing should unfold and compile beautifully and install into the target directory. Should this not be the case, it would be a good idea to save the results of the compile in a file. If you run ccsshh, you could type % bbmmaakkee aallll iinnssttaallll >>&& mmkk..lloogg and if you run kksshh or sshh, type % bbmmaakkee aallll iinnssttaallll >> mmkk..lloogg 22>>&&11 This will save the results in the file mmkk..lloogg so you can inspect it later. This would be an ideal opportunity to get some doughnuts and coffee. 33..77.. SStteepp 55 -- CCrreeaattiinngg tthhee iinniittiiaall ddaattaabbaassee POSTGRES databases are stored in the directory ......//ppoosstt-- ggrreess//ddaattaa. After you have compiled POSTGRES, you will need to create the initial database. If you haven't already put the path to the POSTGRES executable programs in the shell path, do the following (assuming the POSTGRES programs were loaded into //uussrr//llooccaall//ppoossttggrreess//bbiinn). If you run ccsshh, you would put sseett ppaatthh==((//uussrr//llooccaall//ppoossttggrreess//bbiinn $$ppaatthh)) in the ..llooggiinn for the POSTGRES user. If you run sshh or kksshh, put PPAATTHH==//uussrr//llooccaall//ppoossttggrreess//bbiinn::$$PPAATTHH eexxppoorrtt PPAATTHH in your ..pprrooffiillee. Then log back in so the change takes effect. 1133 Now you can create the initial database by running the fol- lowing command: % iinniittddbb If that completes successfully, congratulations. Now, to make the system operational you must run the ppoosstt-- mmaasstteerr. The section after "Testing" discusses this. 33..88.. SStteepp 66 -- TTeessttiinngg We suggest you run the regression tests to make sure the release was installed successfully. Also, you need to have the ppoossttmmaasstteerr running to run the test, so type the follow- ing: % TTZZ==GGMMTT00 % eexxppoorrtt TTZZ % ppoossttmmaasstteerr --SS if you use sshh or kksshh. If you use ccsshh, type % sseetteennvv TTZZ GGMMTT00 % ppoossttmmaasstteerr --SS instead. The bit about "TZ" is just to make sure that your regression output will be comparable to ours; you don't have to do this every time you start the ppoossttmmaasstteerr. Next, cre- ate a new user using the ccrreeaatteeuusseerr command (see the Refer- ence Manual). DDoo nnoott run the regression test script as user "postgres"! Change directories to ssrrcc//rreeggrreessss//rreeggrreessss. % ccdd ssrrcc//rreeggrreessss//rreeggrreessss Make sure that the oobbjj subdirectory is writable by the "postgres" user, as some of the tests involve the "postgres" user copying data into that directory. (We ship it that way, but if you left the "p" flag off of your ttaarr command, it will be set according to your umask.) Type the following command to run the test: % bbmmaakkee cclleeaann aallll rruunntteesstt This will run a whole slew of regression tests and might take a long time to run. When it's done, the output of the test is in the file oobbjj//rreeggrreessss..oouutt. You can compare this to a sample run that we supply in the file ssaamm-- ppllee..rreeggrreessss..oouutt with the following command: 1144 % sshh cchheecckkddiiffff It may take a little while to run as the regression results are quite large. There will be many differences correspond- ing to the timestamp lines and occasional lines where object id numbers (OIDs) are different. The cchheecckkddiiffff program attempts to weed out these innocuous differences. If you see any differences not corresponding to timestamps, OIDs or very small differences between floating-point numbers, there may be a problem. Have your local POSTGRES expert take a look at it. 44.. RRuunnnniinngg PPOOSSTTGGRREESS POSTGRES is designed to be a multiuser system. In practice, POSTGRES consists of three (or more) processes: +o the postmaster, +o a front-end program (often the terminal monitor), and +o the backend server. Users are expected to use the terminal monitor for direct access to the database. The terminal monitor sends commands to the ppoossttmmaasstteerr which forwards commands to a backend. 44..11.. TThhee PPOOSSTTGGRREESS PPoossttmmaasstteerr The ppoossttmmaasstteerr is a process which manages communication between the a front-end program such as the terminal monitor and a POSTGRES backend. Without a running ppoossttmmaasstteerr, the front-end program will not be able to connect to a backend. In general, the ppoossttmmaasstteerr must be running for you (or oth- ers) to run any of the normal POSTGRES commands. Always start the ppoossttmmaasstteerr when logged in as the special "post- gres" user, otherwise the system will not be able to access the database files. To start it, type % ppoossttmmaasstteerr && 44..22.. TThhee PPOOSSTTGGRREESS TTeerrmmiinnaall MMoonniittoorr The POSTGRES terminal monitor is a front-end user interface to the POSTGRES backend. Lets assume _d_a_t_a_b_a_s_e is the name of the database you want to use. It is an error if _d_a_t_a_b_a_s_e does not exist, so to cre- ate the database, you would type 1155 % ccrreeaatteeddbb _d_a_t_a_b_a_s_e Now we will run the monitor: % mmoonniittoorr _d_a_t_a_b_a_s_e WWeellccoommee ttoo tthhee PPOOSSTTGGRREESS tteerrmmiinnaall mmoonniittoorr GGoo ** _T_h_e _`_`_*_'_' _i_s _t_h_e _t_e_r_m_i_n_a_l _m_o_n_i_t_o_r _p_r_o_m_p_t_. _W_e _a_r_e _n_o_w _t_a_l_k_i_n_g _t_o _t_h_e _b_a_c_k_e_n_d_, _s_o _l_e_t_'_s _s_e_n_d _a _s_i_m_p_l_e _t_e_s_t _q_u_e_r_y_: _l_i_s_t _t_h_e _n_a_m_e_s _a_n_d _u_s_e_r _i_d_s _o_f _t_h_e _P_O_S_T_G_R_E_S _u_s_e_r_s_. _W_e _t_e_r_m_i_n_a_t_e _t_h_e _q_u_e_r_y _w_i_t_h _a _\_g _-_- _t_h_e _`_`_g_o_'_' _c_o_m_m_a_n_d _t_o _t_h_e _t_e_r_m_i_n_a_l _m_o_n_i_t_o_r_. ** rreettrriieevvee ((uu..uusseennaammee,, uu..uusseessyyssiidd)) ffrroomm uu iinn ppgg__uusseerr\\gg QQuueerryy sseenntt ttoo bbaacckkeenndd iiss ""rreettrriieevvee ((uu..uusseennaammee,, uu..uusseessyyssiidd)) ffrroomm uu iinn ppgg__uusseerr"" ---------------------------------------------------------- || uusseennaammee || uusseessyyssiidd || ---------------------------------------------------------- || ppoossttggrreess || 66 || ---------------------------------------------------------- || mmiikkee || 779999 || ---------------------------------------------------------- || sspp || 11551111 || ---------------------------------------------------------- || jjhhiinnggrraann || 994433 || ---------------------------------------------------------- || cciimmaarrrroonn || 22335599 || ---------------------------------------------------------- || ggoohh || 11999944 || ---------------------------------------------------------- || oonngg || 22880022 || ---------------------------------------------------------- || hhoonngg || 22446699 || ---------------------------------------------------------- || mmaaoo || 11880066 || ---------------------------------------------------------- || mmaarrcc || 22443355 || ---------------------------------------------------------- || mmaarrggoo || 22669977 || ---------------------------------------------------------- || ssuulllliivvaann || 11551177 || ---------------------------------------------------------- || kkeemmnniittzz || 33449911 || ---------------------------------------------------------- || cchhooii || 33889988 || ---------------------------------------------------------- || mmeerr || 33666655 || 1166 ---------------------------------------------------------- GGoo _O_k_a_y_, _t_h_i_s _w_o_r_k_e_d_, _t_o_o_. _N_o_w _w_e_'_l_l _q_u_i_t_. ** \\qq %% 44..33.. TThhee PPOOSSTTGGRREESS BBaacckkeenndd The POSTGRES backend is the process which does all the "real" work. This process is started by the ppoossttmmaasstteerr when it receives a connection from a terminal monitor, so you should not normally need to start up the backend yourself. Should you wish to start the backend and talk to it directly (without a terminal monitor) you can do this by typing: % ppoossttggrreess _d_a_t_a_b_a_s_e where _d_a_t_a_b_a_s_e is the name of the database you wish to use. If you run a backend in this manner, you will be talking to the backend parser directly. We recommend using the termi- nal monitor; if you are using POSTGRES as a multiuser sys- tem, running the backend can result in locking failures and corrupt databases, as the ppoossttmmaasstteerr handles shared resources such as semaphores and shared memory. In short: never do this if there is a ppoossttmmaasstteerr running. In addi- tion, when using the terminal monitor, returned tuples are displayed more usefully and input is buffered better. The backend should only be used interactively during debugging. 44..44.. PPOOSSTTGGRREESS SSuuppppoorrtt PPrrooggrraammss Included in POSTGRES are a handful of support programs. Most of these are used internally by the system but here is a list of them for your information. initdb - creates the initial template database cleardbdir - totally destroys the data/ directory, allowing a new initdb createdb - creates new POSTGRES databases createuser - add a new user to the POSTGRES system destroydb - destroys POSTGRES databases destroyuser - delete a user from the database system ipcclean - frees up garbage shared memory from failed backends newbki - adjust userid of "postgres" in the database pg_version - make version numbers for createdb pg_id - gets user id's - used by various commands pagedoc - disk page doctor reindexdb - rebuild system catalog indices after disaster shmemdoc - shared memory buffer pool doctor 1177 vacuum - database vacuum cleaner icopy - inversion filesystem file management utility pcat - inversion filesystem cat command pcd - inversion filesystem cd command pls - inversion filesystem ls command pmkdir - inversion filesystem mkdir command pmv - inversion filesystem mv command ppwd - inversion filesystem pwd command prm - inversion filesystem rm command prmdir - inversion filesystem rmdir command 55.. OOppttiioonnaall IInnssttaallllaattiioonn 55..11.. IInnssttaalllliinngg LLIIBBPPQQ,, tthhee PPOOSSTTGGRREESS ffrroonntteenndd lliibbrraarryy The file ......//lliibb//lliibbppqq..aa is created when you install the system. This library contains various routines intended for use by frontend programs. You use this library if you want to execute POSTGRES queries from a C program. If you plan on doing software development, you may wish to copy this file to //uussrr//llooccaall//lliibb or //uussrr//lliibb so that the C compiler can reference it with --llppqq. If you do not, you will have to use the --LL directive to the cccc and lldd commands so that they can find lliibbppqq..aa. 55..22.. PPoossttggrreess HHeeaaddeerr FFiilleess The directory ......//iinncclluuddee contains copies of most of the header files that front-end applications might need. You can compile a frontend program with the --II directive to cccc as illustrated in the following example: % cccc --II//uussrr//llooccaall//ppoossttggrreess//iinncclluuddee --oo _f_o_o _f_o_o_._c --llppqq Occassionally a front-end program source might reference header files from the POSTGRES source that were not copied into the iinncclluuddee directory. If your front-end program com- plains about not being able to find header files, either add the missing header files to the iinncclluuddee// directory and notify us of the problem, or just point the --II compiler directive directly into the source as was done in the past. E.g., % cccc --II//uussrr//llooccaall//ppoossttggrreess//ssrrcc//bbaacckkeenndd --oo _f_o_o _f_o_o_._c --llppqq If you do this, you may need to add the following ##ddeeffiinnees in your source to set the PORTNAME -- add them prior to any ##iinncclluuddees: ##ddeeffiinnee PPOORRTTNNAAMMEE___P_O_R_T_N_A_M_E 1188 For example, if you are running on the ultrix4 port, you would put ##ddeeffiinnee PPOORRTTNNAAMMEE__uullttrriixx44 in your program, or if you're running the sparc port put ##ddeeffiinnee PPOORRTTNNAAMMEE__ssppaarrcc in your program source. 55..33.. WWiissccoonnssiinn BBeenncchhmmaarrkk DDaattaabbaassee In ......//ppoossttggrreess//ssrrcc//rreeggrreessss//bbeenncchh are files which are the queries used in the POSTGRES version of the Wisconsin bench- mark. The Wisconsin benchmark illustrates basic relational performance using B-tree indices on nontrivial amounts of data. To run the benchmark, ccdd to that directory and type % bbmmaakkee rruunntteesstt 55..44.. MMiinniimmaall IInnssttaallllaattiioonn It is the intention that everything below the ssrrcc// directory can be removed. Sometimes however, as stated earlier, the iinncclluuddee// directory may not have all the necessary files to compile all the frontend programs, so you may might get burned if you remove the source. Should you really wish to remove the source to reclaim space you could always copy all the header files from the backend into the include directory (preserving the directory structure of course). 66.. DDooccuummeennttaattiioonn Plain text and PostScript versions of the manual pages and documents are available in the directories mmaann// and ddoocc// at the top level. To recreate these documents, there are cor- responding directories in ssrrcc//{{mmaann,,ddoocc}}. They are currently configured to require ggrrooffff and friends, but you may be able to change the MMaakkeeffiillee to use other facilities if you have them. If you change directories to mmaann// and ddoocc// and type: % bbmmaakkee % bbmmaakkee iinnssttaallll in each, it will format and install the documents into the corresponding destination directories. In general, recreat- ing documents from their source is very difficult due to differences in macro packages and formatting programs (in short, good luck!). 1199 77.. MMiisscceellllaanneeoouuss 77..11.. BBuugg rreeppoorrttss If you find a bug in POSTGRES, please send mail to bbuugg--ppoossttggrreess@@ppoossttggrreess..BBeerrkkeelleeyy..EEDDUU or uuuunneett!!uuccbbvvaaxx!!ppoossttggrreess!!bbuugg--ppoossttggrreess describing as precisely as possible the command that caused the problem, concise instructions on how to repeat the bug, and a script showing the bug. If possible, a stack trace (generated using a debugger such as ddbbxx or ggddbb) should also be provided. (The backend program will leave its core dumps in the directory PGDATA//bbaassee//yyoouurr__ddaattaabbaassee, where "your_database" is the name of your database.) However, see the next section. 77..22.. CCoonnssuullttiinngg This software is unsupported, public domain software. Although we are interested in feedback, it is impossible for us to make any commitment to provide support in a research environment. If you do want to talk directly to the POSTGRES group, elec- tronic mail is the only method. We can be reached via the Internet as ppoosstt__qquueessttiioonnss@@ppoossttggrreess..BBeerrkkeelleeyy..EEDDUU or uuuunneett!!uuccbbvvaaxx!!ppoossttggrreess!!ppoosstt__qquueessttiioonnss Please be aware that this was the last release of POSTGRES from the University of California, and for all practical purposes there is no longer a POSTGRES group. However some of us may still be reading mail for a while and it is likely that some correspondence will occur. 77..33.. PPoossttggrreess MMaaiilliinngg LLiisstt A mailing list for POSTGRES announcements and discussion is available for anyone who is interested. If you wish to sub- scribe to this mailing list, send mail to ppoossttggrreess--rreeqquueesstt@@ppoossttggrreess..BBeerrkkeelleeyy..EEDDUU or 2200 uuuunneett!!uuccbbvvaaxx!!ppoossttggrreess!!ppoossttggrreess--rreeqquueesstt with AADDDD as the subject. Note that mail sent to this address is processed eelleeccttrroonniiccaallllyy. (Deletion requests are handled by sending mail to the same address with subject DDEELL.) The mailing list itself is called ppoossttggrreess@@ppoossttggrreess..BBeerrkkeelleeyy..EEDDUU or uuuunneett!!uuccbbvvaaxx!!ppoossttggrreess!!ppoossttggrreess and all mail sent to this address will be will be routed to the mailing list membership. As of the time of this release, this mailing list was being distributed to over 600 sites around the world, so please do NNOOTT send administrative requests to this address. If you have any problems with the mailing list, send mail to ppoosstt__qquueessttiioonnss. 2211