Allow to run pgpool_setup and regression test on Ubuntu box.

Since Ubuntu's bash is in /usr/bin, and others have bash in /bin/, we
need to use env command to make the scripts more portable.
Fix -i option (install directory of pgpool) not working.
Remove unnecessary call to pool_shmem_exit() which removes semaphore when it shouldn't.

exit_handler checks if the process is parent or not. This is
good. However, even if it is a child process, it calls
pool_shmem_exit() which removes semaphore and shmem when it should
not (it should be called only from parent process).

Per bug #102.
Add missing include file sys/wait.h.

Per bug #104.
Fix an infinite loop of error at new active pgpool when virtual IP switching

When active pgpool stops and standby pgpool becomes new active, this brings
virtual IP up and confirm this by ping command. In previous, pgpool handle
exit code of ping wrongly and goes into an infinite loop.

In addition, the old active pgpool also hangs since this waits response
from the new active pgpool, which is in the infinite loop and not able
to respond.

This problem is reported by Qian Peng in [pgpool-hackers: 520].
Disbale statement_timeout while executing online recovery.

Online may take very long time and user may enable statement
timeout. To prevent online recovery canceled by statement timeout,
disable statement timeout in the connection used by online recovery.

See [pgpool-general: 2919] for whole story.
Fix pool_table_name_to_oid in case new to_regclass used which is introduced in PostgreSQL 9.4.

The relcache func used here should return 0 if target table is not
found. However to_regclass returns NULL in this case. To fix the
problem now COALESCE is used.
Fix regression test 057 hung if run against PostgreSQL 9.4 or later.

PostgreSQL 9.4 or later changed libpq behavior: NULL username for
connection string does not cause an error (which is expected in the
test). As a result psql prompts and waits for user's input which
causes regression test hang if executed against PostgreSQL 9.4 or
later. To fix this, "\q" is implicitly provided to psql session.

Now the test (pgpool segafult) is only performed against pre 9.4. 9.4
or later happily passes the test.

Regarding libpq change see:
http://www.postgresql.org/message-id/20140708.111307.408695214582895632.t-ishii@sraoss.co.jp
for more details.
fix coverity issue:1223007 Use after free.

get_insert_command_table_name() function was using the
freed pointer in pool_debug() function call.
Fix SELECT statement used in pool_table_name_to_oid() for to_regclass.

By previous commit it always retruns 0.
Fix pool_handle_query_cache() to not free NULL pointer.
Fix to close pipe when ping command exits with failure

This bug causes pipe open error: Too many open files, which
leads to failure of connecting to trusted servers, and then
pgpool goes to down status.
Fix coverity issue:1223003 Uninitialized scalar variable.
Fix coverity issue:1223002 Uninitialized scalar variable.
Fix coverity issue:1223001 Resource leak.
Fix coverity issue:1223000 Resource leak.
Fix coverity issue:1222999 Resource leak.
Fix coverity issue:1222998 Resource leak.
Change connect() timeout longer (10 seconds) for flaky network.

Change connect() timeout in connect_inet_domain_socket_by_port() from
1 second to 10 seconds for flaky network such as AWS. This should help
reducing frequent failover. Pgpool-II 3.4 will have switch to control
the timeout value, rather than fixed value. However our policy does
not allow to add new feature like that. So I decided to just tweak the
fixed value.
Back porting coverity issues fix patch from master branch.
Fix coverity issue:1111387 Explicit null dereferenced
Fix coverity issue:1111388 Explicit null dereferenced
Fix coverity issue:1111411 Missing break in switch
Fix coverity issue:1111412 Missing break in switch
Fix coverity issue:1111450 Resource leak
Fix coverity issue:1111451 Resource leak
Fix coverity issue:1111472 Dereference before null check
Fix coverity issue:1111473 Dereference before null check
Fix coverity issue:1111474 Dereference before null check
Fix coverity issue:1111475 Wrong sizeof argument
Fix coverity issue:1111495 Use after free
Fix coverity issue:1111496 Use after free
Fix coverity issue:1222989 Bad bit shift operation
Fix coverity issue:1222990 Bad bit shift operation
Fix coverity issue:1222994 Explicit null dereferenced
Fix wrong error message.
Back porting coverity issues fix patch from master branch.

Fix coverity issue:1111380 Logically dead code
Fix coverity issue:1111382 Logically dead code
Fix coverity issue:1111402 Explicit null dereferenced
Fix coverity issue:1111405 Explicit null dereferenced
Fix coverity issue:1111407 Dereference after null check
Fix coverity issue:1111408 Explicit null dereferenced
Fix coverity issue:1111409 Dereference after null check
Fix coverity issue:1111383 Logically dead code
Fix coverity issue:1111492 Structurally dead code
Fix coverity issue:1111417 Nesting level does not match indentation
Fix coverity issue:1111379 Logically dead code
Fix coverity issue:1111406 Explicit null dereferenced
Fix coverity issue:1111396 Explicit null dereferenced
Fix coverity issue:1111397 Explicit null dereferenced
Fix reset query stuck problem.

It is reported that reset query (DISCARD ALL etc.) occasionally does
not finish and pgpool child remain waiting for reply from backend thus
client cannot connect to pgpool (for example
http://www.pgpool.net/mantisbt/view.php?id=107).  The cause of problem
is not identified yet but if client suddenly closes connection to
pgpool in the middle of query processing, backend may not accept the
reset queries because they are not ready for query.

The fix is, if frontend closes connection in unexpected way, query
process loop immediately returns with new state:
POOL_END_WITH_FRONTEND_ERROR and pgpool closes connection to
PostgreSQL then goes back to new connection request waiting loop.
Fix yet another reset query stuck problem.

If client_idle_limit is set and the idle limit reaches,
pool_process_query() returns and tries to execute reset query which
may not be acceptable by backend because it may not be in "ready for
query" state. The fix is, close connections to backend instead.

Per bug#107.
See also: http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=52a3a8c6ab67be3e09db9a7bdfd8e74d81ae3687