[Home] [Download] [Install] [Usage] [Example] [FAQ]

Installation of Pgbash

This page explains about the installation and the confirmation way of Pgbash.

Confirmation of the installation of PostgreSQL
    Before installing Pgbash, PostgreSQL must be installed in advance. Pgbash is on the assumption that PostgreSQL was installed in the "/usr/local/pgsql" directory. Please make the /usr/local/pgsql directory as follows, if PostgreSQL is not in that directory. And please do the symbolic link for 'lib' and 'include'

    cd /usr/local
    mkdir pgsql
    cd pgsql
    ln -s xxxx/pgsql/lib
    ln -s xxxx/pgsql/include

    Here, "xxxx/pgsql" shows the directory in which PostgreSQL exists actually.

Installation of Pgbash
  1. Unpacking the pgbash-2.1 and bash-2.03

    gzip -dc pgbash-2.1.tar.gz | tar xf -
    cd pgbash-2.1
    gzip -dc yyyy/bash-2.03.tar.gz | tar xf -

    Here, "yyyy" shows the directory in which bash-2.03.tar.gz exists actually.

    Unpacking pgbash-2.1 and bash-2.03, the following directorys and files are made in the pgbash-2.1 directory .
    -rw-r--r--   1 pgbash  postgres     7245 Dec 18 19:04 INSTALL
    -rw-r--r--   1 pgbash  postgres     4404 Dec 18 19:04 README
    drwxr-xr-x  10 pgbash  postgres     3584 Dec 21 16:15 bash-2.03/
    drwxr-xr-x   4 pgbash  postgres     1024 Dec 21 16:14 exec_sql/
    drwxr-xr-x   2 pgbash  postgres      512 Dec 21 17:18 patch/
    -rw-r--r--   1 pgbash  postgres     3301 Dec 21 09:28 pgbashrc
    lrwxrwxrwx   1 pgbash  postgres        9 Dec 20 11:05 src@ -> bash-2.03
    drwxr-xr-x   4 pgbash  postgres      512 Dec 19 17:11 test/
    
  2. Apply the bash-2.03 patch

    cd patch
    make

    The result of the patch is recorded for "make.log" file, when make is executed. Please confirm that the patch was normally executed.

  3. Configure

    cd ../bash-2.03
    ./configure

    The bash-2.03 default compilation flag is "-g -O2". In the case of default, Pgbash program size will be about 2.1MB. If the compilation flag is "-O2", its size will be about 620KB. Therefore, pgbash-2.1 patch delete the "-g" option.

  4. make
    After the configure was executed, type 'make' (or gmake). "Pgbash" is made in the bash-2.03 directory. (You must use the GNU make.)

  5. make install
    Type 'su' and type 'make install'. The 'pgbash' is copied to /usr/local/bin directory and the 'pgbashrc' is copied to /etc directory.
    pgbash-2.1/bash-2.03/pgbash  ==> /usr/local/bin/pgbash
    pgbash-2.1/pgbashrc          ==> /etc/pgbashrc
    
    If you can not work in Unix super user, you must copy 'pgbash' and 'pgbashrc' to the appropriate directory.

Environment
    Some environment setting are required when Pgbash is used as a sub shell.

  1. Setting of "~/.bashrc"

    Write a general environment in ~/.bashrc. If you are a postgres supper user then you must describe the following.

    (In the case of postgres supper user)
    # ~/.bashrc
    export POSTGRES_HOME=/usr/local/pgsql
    export PGLIB=$POSTGRES_HOME/lib
    export PGDATA=$POSTGRES_HOME/data
    export LD_LIBRARY_PATH=$PGLIB
    export PATH=/usr/local/bin:/usr/local/pgsql/bin:$PATH
    ...
    

    Only when Pgbash talk to non-MULTIBYTE backend (v6.5), you must define "export PGCLIENTENCODING='SQL_ASCII'". And if database encoding is 'EUC_JP' and client encoding is 'SJIS', you could define "export PGCLIENTENCODING= 'SJIS'". In this case, you could execute "set client_encoding='SJIS';" after connecting to database.

  2. Setting of "~/.pgbashrc"

    Copy /etc/pgbashrc to ~/.pgbashrc.

    #~/.pgbashrc
    function ? {
       echo "  ?       : this help"
       echo "  h  [SQL]: help  syntax or all SQL_commands"
       echo "  o       : help OPTIONs of 'exec_sql' function"
       echo "  v       : print PGBASH VERSION"
       echo "  s       : print STATUS after SQL execution"
       echo "  l       : list all DATABASEs"
       echo "  m       : list all CONNECTIONs"
       ...  
    }
    ...
    

  3. Confirmation of the environment setting

    Confirm the execution of pgbash as a sub shell. Type '/usr/local/bin/pgbash'. It will be displayed as follows.
    Welcome to the PGBASH version 2.1 (bash-2.03)
    
      Type '[time] SQL; [pipeline][redirection][&]' to execute SQL.
      Type 'exec_sql [option] ["SQL"]' to execute SQL with options.
      Type '?' for HELP. (This help is defined with ~/.pgbashrc)
    
    Type 'exit'.

Test of Pgbash.

  1. Add Pgbash user for PostgreSQL

    createuser pgbash
    Is user "pgbash" allowed to create databases (y/n) y
    Is user "pgbash" a superuser? (y/n) n
    
  2. make

    If you want to confirm the operation of pgbash, please type 'make' in the 'test' directory. When you want to test again, you have to type 'make clean' and 'make'.

    Only "./All.bat" is displayed or some "No Differences encountered" are displayed, then pgbash will be rightly operated.

Test in various software environments

  • pgbash-2.1
    • FreeBSD-2.2.7, gcc-2.7.2, PostgreSQL-7.0
    • redhat5.2(Japan) Linux, gcc-2.95.2, PostgreSQL-6.5.3
      SAKAIDA Masaaki(sakaida@psn.co.jp) confirmed it.
    • Solaris 8 for Intel, gcc, PostgreSQL-7.0.2
      IUCHI-sann(iuchi@ml3.yano-el.co.jp) confirmed it, thanks.
      He reported that "CC=gcc" was needed in "pgbash/exec_sql/Makefile".

  • pgbash-2.0.x
    • FreeBSD-2.2.7, gcc-2.7.2, PostgreSQL-6.5.2
    • redhat5.2(Japan) Linux, gcc-2.95.2, PostgreSQL-6.5.1
      SAKAIDA Masaaki(sakaida@psn.co.jp) confirmed it.
    • FreeBSD 3.3 Rel, gcc-2.95.2, PostgreSQL-6.5.3
      ICHIMURA-sann(ichimura@jimu.hokudai.ac.jp) confirmed it, thanks.
    • Unixware7.1.0, gcc-2.95.1, PostgreSQL-6.5.3
      HONDA-sann(fwif0083@mb.infoweb.ne.jp) confirmed it, thanks.
      He reported that he have changed from default patch to GNU patch-2.5.4.
    • RedHat 5.2J for x86, gcc 2.7.2.3, PostgreSQL 6.5.3
      ISHII-sann(t-ishii@sra.co.jp) confirmed it. Thanks.
    • Plamo Linux 2.0 beta1(Kernel-2.2.13), egcs-1.1.2, PostgreSQL-6.5.3
      KUWAMURA-sann(juk@rccm.co.jp) confirm it. Thanks
    • Cygwin
      TANIDA-sann(yutaka@marin.or.jp) made pgbash-2.0.x on cygwin.
      http://www.s34.co.jp/~luster/pgsql/pgbash-2.0.1-cygwinB20.1.tar.gz
      http://www.s34.co.jp/~luster/pgsql/pgbash-2.0-cygwinB20.1.tar.gz

  • pgbash-1.x (exec_sql functions)
    • FreeBSD-2.2.7, gcc-2.7.2, PostgreSQL-6.5.2, bash-2.02
    • FreeBSD-2.2.7, gcc-2.7.2, PostgreSQL-6.5.1, bash-2.02
    • FreeBSD-2.2.7, gcc-2.7.2, PostgreSQL-6.4.2, bash-2.02
    • redhat5.2(Japan) Linux, gcc-2.95.1, PostgreSQL-6.5.1, bash-2.03
      SAKAIDA Masaaki(sakaida@psn.co.jp) confirmed it.
    • UnixWare 7.1.0, gcc-2.95.1, postgres6.5.1, bash-2.0.3
    • Solaris 2.6 x86, gcc-2.8.2, PostgreSQL-6.5, bash-2.03
      HONDA-sann(fwif0083@mb.infoweb.ne.jp) confirmed it. Thanks.
    • Linux Vinec 1.1, gcc-2.7.2.3, PostgreSQL-6.5.0, bash-2.03
      KONDOU-sann(nkon@shonan.ne.jp) confirmed it. Thanks.
    • vine-1.1(CR) linux-2.0.36 gcc-2.7.2.3 PostgreSQL-6.5.2 bash-2.03
      NAKAMURA-sann(waasuke@e-mail.ne.jp) confirm it. Thanks.
    • SunOS 5.7 Intel, pgcc-2.91.66, PostgreSQL-6.5.1, bash-2.03
      AOKI-sann(toshi@saluda.kinotrope.co.jp) confirmed it. Thanks.
    • FreeBSD-3.2, gcc-2.95.1, PostgreSQL-6.5.1, bash-2.03
      ICHIMURA-sann(ichimura@jimu.hokudai.ac.jp) confirmed it. Thanks.
    • Slackware3.6.0(kernel2.0.35), gcc-2.7.2.3, PostgreSQL-6.5.1, bash2.02
      IIDA-sann(webmaster@art-co.com) confirmed it. Thanks.
    • LinuxPPC R4/kernel 2.2.1, egcs-2.90.25, PostgreSQL-6.5.1, bash-2.02
      ISHII-sann(t-ishii@sra.co.jp) confirmed it. Thanks.


[Home] [Download] [Install] [Usage] [Example] [FAQ]

Last Modified at 2000/06/12