ページ更新: 2004-08-28 (土) (5442日前)

関連:

2004-08-28

cygwin ML の、
「Any working PL./Perl instance of - Postgres 7.4.5-1,perl-5.8.5 - on -XP home or Win 2000?」について追試した。

http://cygwin.com/ml/cygwin/2004-08/threads.html#01096

$ createdb test
CREATE DATABASE

$ createlang plperl test

$ createlang --list test
Procedural Languages
  Name  | Trusted?
--------+----------
 plperl | yes
$ psql test
Welcome to psql 7.4.5, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

                                        version

--------------------------------------------------------------------------------
-------
 PostgreSQL 7.4.5 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.3.1 (cygming sp
ecial)
(1 row)

SJIS
test=#
test=# CREATE TABLE employee (
test(#      name text,
test(#      basesalary integer,
test(#      bonus integer
test(# );
CREATE TABLE
test=# CREATE FUNCTION empcomp(employee) RETURNS integer AS '
test'#      my ($emp) = @_;
test'#      return $emp->{''basesalary''} +
test'#             $emp->{''bonus''};
test'# ' LANGUAGE plperl;
CREATE FUNCTION
test=# insert into employee values('Sir Postgre',40,5);
INSERT 130092 1

select で plperl で作った empcomp 関数を使うと、失敗する。

test=# SELECT name, empcomp(employee) FROM employee;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!>

このとき、postgres.exe (postmaster) は(異常終了することなく)動作しつづけている。

$ ps -W | grep post
     4048       0       0       4048    ?    0 00:01:16 C:\cygwin\bin\postgres.e
xe
      960    1872    1872        960    ? 1014 00:01:16 /usr/bin/postgres
      496     960    1872        496    ? 1014 00:01:16 /usr/bin/postgres

このときのログは次のようになっている。 (postmaster.conf にて「log_statement = true」を設定しているため、 投入されたSQLも記録されている)

  • ログを見ると、PID 1720 のプロセスが終了して、リカバリされてる。
LOG:  statement: CREATE DATABASE test;
	
LOG:  statement: SELECT oid FROM pg_language WHERE lanname = 'plperl';
LOG:  statement: SELECT oid FROM pg_proc WHERE proname = 'plperl_call_handler' A
ND prorettype = (SELECT oid FROM pg_type WHERE typname = 'language_handler') AND
 pronargs = 0;
LOG:  statement: CREATE FUNCTION "plperl_call_handler" () RETURNS language_handl
er AS '$libdir/plperl' LANGUAGE C;
	CREATE TRUSTED LANGUAGE "plperl" HANDLER "plperl_call_handler";
	
LOG:  statement: select version();
LOG:  statement: set client_encoding to 'SJIS'
LOG:  statement: CREATE TABLE employee (
	     name text,
	     basesalary integer,
	     bonus integer
	);
LOG:  statement: CREATE FUNCTION empcomp(employee) RETURNS integer AS '
	     my ($emp) = @_;
	     return $emp->{''basesalary''} +
	            $emp->{''bonus''};
	' LANGUAGE plperl;
LOG:  statement: insert into employee values('Sir Postgre',40,5);
LOG:  statement: SELECT name, empcomp(employee) FROM employee;
LOG:  server process (PID 1720) exited with exit code 128   ★
LOG:  terminating any other active server processes
LOG:  all server processes terminated; reinitializing
LOG:  database system was interrupted at 2004-08-28 00:52:22    
LOG:  checkpoint record is at 0/40819F8
LOG:  redo record is at 0/40819F8; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 6057; next OID: 130083
LOG:  database system was not properly shut down; automatic recovery in progress
FATAL:  the database system is starting up
LOG:  redo starts at 0/4081A38
LOG:  record with zero length at 0/40C5558
LOG:  redo done at 0/40C5530
LOG:  database system is ready