PostgreSQL 9.0 textsearch-ja 9.0.0

FreeBSD 8.2

http://textsearch-ja.projects.postgresql.org/textsearch_ja.html#install

postgresql インストール

# portinstall databases/postgresql90-server

# vi /etc/rc.conf
====
postgresql_enable="YES"
====
# /usr/local/etc/rc.d/postgresql initdb
# /usr/local/etc/rc.d/postgresql start

mecab インストール

# cd /usr/ports/japanese/mecab
# make WITH_CHARSET=utf-8 install
# cd /usr/ports/japanese/mecab-ipadic
# make WITH_CHARSET=utf-8 install clean

textsearch-ja インストール

$ cd /usr/loacl/src
$ wget http://pgfoundry.org/frs/download.php/2943/textsearch_ja-9.0.0.tar.gz
$ tar xvzf textsearch_ja-9.0.0.tar.gz
$ cd textsearch_ja-9.0.0
$ vi Makefile
====
SHLIB_LINK = -lmecab

SHLIB_LINK = -lmecab -pthread
==== ★1

(先頭のBOMを除去)
$ vi encoding_eucjp.c
$ vi textsearch_ja.c
$ vi encoding_utf8.c


$ gmake USE_PGXS=1
# gmake USE_PGXS=1 install

確認

$ createdb -U pgsql -E UTF8 -T template0 test
(データベースに関数を登録)
$ psql -U pgsql -f /usr/local/share/postgresql/contrib/textsearch_ja.sql test
(テスト)
$ psql -U pgsql -f /usr/local/src/textsearch_ja-9.0.0/sql/textsearch_ja.sql test

★1 -pthread がないとインストールで以下のエラー

$ psql -U pgsql -f /usr/local/share/postgresql/contrib/textsearch_ja.sql test
SET
BEGIN
psql:textsearch_ja.sql:12: ERROR: could not load library "/usr/local/pgsql/lib/textsearch_ja.so": dlopen (/usr/local/pgsql/lib/textsearch_ja.so) failed: /usr/local/lib/libmecab.so.1: Undefined symbol "pthread_create"

9.2 以降は /usr/local/share/postgresql/contrib/textsearch_ja.sql
の LANGUAGE 'C' を LANGUAGE Cに置換が必要

http://lists.pgfoundry.org/pipermail/pgmemcache-general/2012-December/000000.html

-lpthread と -pthread の違い

(→ 調べる)

テスト、確認

SELECT furigana('漢字の読みをカタカナで返します。');
               furigana               
--------------------------------------
カンジノヨミヲカタカナデカエシマス。
(1 row)

textsearch_jaを使う: telblog 2009

(データベースに) textsearch_ja 再インストール

psql -U postgres -f /usr/local/pgsql/share/contrib/uninstall_textsearch_ja.sql test
psql -U postgres -f /usr/local/pgsql/share/contrib/textsearch_ja.sql test