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

Installation of Pgbash

The installation method of Pgbash is explained. When the version number of Pgbash is changed, please transpose the version number in the following explanation to a new number.

  1. Installation of PostgreSQL
  2. Installation of Pgbash
  3. Settings of environment
  4. Test of Pgbash(option)



Installation of PostgreSQL
    When installing Pgbash from a source file, the include file of PostgreSQL is needed. Moreover, the libpq library of PostgreSQL is needed at the time of execution of Pgbash. Therefore, in order to use Pgbash, you have to install PostgreSQL beforehand.



Installation of Pgbash
  1. Unpacking pgbash-7.3 and bash-2.05a

    tar xfz pgbash-7.3.tar.gz (or gzip -dc pgbash-7.3.tar.gz | tar xf -)

    cd pgbash-7.3/src
    tar xfz xxx/bash-2.05a.tar.gz

    Here, 'xxx' is the directory bash-2.05a.tar.gz is actually placed.

    By unpacking Pgbash-7.3 and bash-2.05a, the following files and directories are created.
    ChangeLog    ........... Change Logs 
    INSTALL      ........... Explanation of installation
    README       ........... Explanation of Pgbash
    rc/          ........... Pgbashrc file directory
    src/
        bash-2.05a/  ....... bash-2.05a source file directory
        bash-2.05a-patch/ .. bash-2.05a patch file directory
        exec_sql/    ....... Pgbash source directory
    test/        ........... Pgbash test directory
    

    (The case of PostgreSQL 7.0/7.1, Symbolic link is needed)
    PostgreSQL-7.2 has changed 'config.h' into 'pg_config.h' in the PostrgeSQL 'include' directory(e.g. /usr/local/pgsql/include). So, Pgbash has changed the header file into 'pg_config.h'. Therefore, If you are using PostgreSQL-7.0/7.1, then you must link the 'pg_config.h' into the 'config.h' as follows.
    cd exec_sql
    ln -s /usr/local/pgsql/include/config.h pg_config.h

  2. Apply the patch to the bash

    cd src/bash-2.05a-patch
    make

  3. Configure

    cd src/bash-2.05a

    CFLAGS='-O2' ./configure     <---- without a debug option
    or
    ./configure     < ---- with a debug option(CFLAGS='-g -O2')

    If PostgreSQL has not been installed to /usr/local/pgsql directory, you can specify --pginc-prefix, --pglib-prefix option.

    (Option)
    --pginc-prefix : Path of PostrgeSQL include file
    --pglib-prefix : Path of PostgreSQL library file

    (By default)
    --pginc-prefix=/usr/local/pgsql/include
    --pglib-prefix=/usr/local/pgsql/lib

    (example)
    CFLAGS='-O2' ./configure --pginc-prefix=/usr/include/pgsql   \
                             --pglib-prefix=/usr/lib
    

  4. Make (You must use GNU make)

    make

    If GNU make has not been installed like FreeBSD, you must specify 'gmake'.

  5. Make install

    make install

    Please execute 'make install' as a postgres super user. 'make install' copies Pgbash to /usr/local/bin directory and copies Pgbashrc to /etc directory.
    pgbash-7.3/src/bash-2.05a/pgbash ==> /usr/local/bin/pgbash
    pgbash-7.3/rc/pgbashrc           ==> /etc/pgbashrc
    
    If you can not work as a postgres super user, please copy Pgbash to a suitable directory directory and copy Pgbash to the home directory.
    cp pgbash-7.3/src/bash-2.05a/pgbash ~/pgbash
    cp pgbash-7.3/rc/pgbashrc           ~/.pgbashrc
    



Settings of environment
    Pgbash can be used as a login shell and a sub shell. Here, settings of environment in the case of using Pgbash as a sub shell is explained. In the following explanation, Pgbash is assumed to be copied to /usr/local/bin directory, and Pgbashrc is assumed to be copied to /etc directory.

    Pgbash reads ~/.bashrc asnd ~/.pgbashrc ( or /etc/pgbashrc) when it starts.

  1. Settings of ~/.bashrc

    You must describe a path of libpq library in ~/.bashrc because Pgbash links libpq library when Pgbash starts.

    # ~/.bashrc
    export PGLIB=/usr/local/pgsql/lib
    export LD_LIBRARY_PATH=$PGLIB
    export PATH=/usr/local/bin:$PATH
    (snip)
    

  2. Settings of ~/.pgbashrc

    Pgbash reads /etc/pgbashrc if ~/.pgbashrc does not exist. If you want to specify the users original environment, you must copy /etc/pgbashrc to your home directory as ~/.pgbashrc, and edit it. ~/.pgbashrc is not necessarily required for pgbash-7.3 although it is surely required until pgbash-2.2.

  3. Check of operation

    Please input /usr/local/bin/pgbash, and '?'. The messages are displayed as follows.
    prompt> /usr/local/bin/pgbash
    Welcome to Pgbash version 7.3 ( bash-2.05a.-release )
    
      Type '?' for HELP. 
      Type 'connect to DB;' before executing SQL.
      Type 'SQL;' to execute SQL.
      Type 'exit' or 'Ctrl+D' to terminate Pgbash.
    
    pgbash> ?
      ?         : this help
      ??        : help pgbash usage
      ??h [SQL] : help SQL(or "SQL") syntax or all SQL reserved words
      ??e       : help SQLCODE (sql ERROR code)
      ??f       : help 'pgbashrc' FUNCTIONs for using a shell script
      ??o       : help 'exec_sql' options
      ?m        : show CONNECTION NAMEs
      ....
    
    Now, installation of pgbash was completed. After checking a little operation, please input 'exit' to finish Pgbash.




Test of Pgbash

    In order to test all the functionality of Pgbash, the script for a test can be performed. However, this test is not indispensable.

  1. Create a pgbash user

    It is assumed that a user name is 'pgbash'. When a pgbash user is not being created, please become a postgres super user and create it using createuser command. For example, it is performed as follows.
    createuser pgbash
    Is user "pgbash" allowed to create databases (y/n) y
    Is user "pgbash" a superuser? (y/n) n
    
  2. Confirmation of operation

    cd test
    make <PostgreSQL_VERSION No.>

    Please execute 'make' in the 'src/test' directory. In the case of PostgreSQL-7.3, you must specify 'make 7.3'

    If the followings were displayed, Pgbash would operate correctly. Please refer to the "test/README" file before testing.
    # Start tests:
    # connect test : begin .... end.
    # sql test : begin .... end.
    # fetch test : begin .... end.
    # command test : begin .... end.
    # cgi test : begin .... end.
    # copy test : begin .... end.
    # Check the results ....
    # End.
    


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