postgresql/src/backend/utils/mb/conversion_procs
Peter Eisentraut 7798147a76 Expand test coverage support to entire tree
Test coverage support now covers the entire source tree, including
contrib, instead of just src/backend.  In a related but independent
development, the commands make coverage and make coverage-html can be run
in any directory.

This turned out to be much easier than feared.  Besides a few ad hoc fixes
to pass the make target down the tree, change all affected makefiles to
list their directories in the SUBDIRS variable, changed from variants like
DIRS and WANTED_DIRS.  MSVC build fix was attempted as well.
2009-08-07 20:50:22 +00:00
..
ascii_and_mic Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
cyrillic_and_mic 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list 2009-06-11 14:49:15 +00:00
euc_cn_and_mic Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
euc_jis_2004_and_shift_jis_2004 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
euc_jp_and_sjis Fix buffer allocations in encoding conversion routines so that they won't 2009-02-28 18:49:42 +00:00
euc_kr_and_mic Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
euc_tw_and_big5 Fix buffer allocations in encoding conversion routines so that they won't 2009-02-28 18:49:42 +00:00
latin2_and_win1250 Fix buffer allocations in encoding conversion routines so that they won't 2009-02-28 18:49:42 +00:00
latin_and_mic Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_ascii Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_big5 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_cyrillic Support for KOI8U encoding 2009-02-10 19:29:39 +00:00
utf8_and_euc_cn Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_euc_jis_2004 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_euc_jp Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_euc_kr Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_euc_tw Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_gb18030 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_gbk Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_iso8859 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_iso8859_1 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_johab Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_shift_jis_2004 Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_sjis Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_uhc Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
utf8_and_win Replace argument-checking Asserts with regular test-and-elog checks in all 2009-01-29 19:23:42 +00:00
Makefile Expand test coverage support to entire tree 2009-08-07 20:50:22 +00:00
README.euc_jp Fix description how to create conversion function. 2007-04-15 10:49:26 +00:00
proc.mk Implement a few changes to how shared libraries and dynamically loadable 2008-04-07 14:15:58 +00:00
regress_epilogue Refrect the changes to src/test/regress/sql/conversion.sql By Tom. 2002-09-04 02:42:34 +00:00
regress_prolog Rename canonical encodings, per Peter: 2005-03-07 04:30:55 +00:00

README.euc_jp

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

新しいエンコーディング変換関数の追加方法

	2006/04/15 Tatsuo Ishii

はじめに

PostgreSQLにはデータベースとフロントエンドのエンコーディングが異なる
ときに,自動的にエンコーディングの変換を行う機能があります.このディレ
クトリには,そのときに使われる関数が登録されています.これらの関数はユー
ザ定義C関数としてinitdbの中で登録されます具体的には
/usr/local/pgsql/share/conversion_create.sql の中で登録されます(このファ
イルはこのディレクトリでmakeしたときに自動生成されます)

またこれらの関数はconvert()関数からも呼び出されることもあります.

このREADMEではC関数を定義する方法とそれをMakefileなどに追加する方
法を説明します.

o C関数の呼び出し形式

  エンコーディング変換関数の呼び出し形式は次のようになります.

  conv_proc(
	INTEGER,	-- source encoding id
	INTEGER,	-- destination encoding id
	CSTRING,	-- source string (null terminated C string)
	INTERNAL,	-- destination string (null terminated C string)
	INTEGER		-- source string length
  ) returns VOID;

  唯一の出力引数は4番目のdestination stringですユーザ定義関数は必要
  なメモリをpallocしそこに変換結果をNULLターミネートされたC文字列と
  して出力しなければなりません.また,適切な大きさのメモリを確保するの
  はこのC関数の責任ですというのは一般に変換された文字列の長さは
  ソース文字列の長さ(5番目の引数で指定されます単位はNULLターミネート
  を含まないバイト数です)とは一致しないからです.

  エンコーディングIDはinclude/mb/pg_wchar.hのtypedef enum pg_encで定義
  されています.

o 関数の登録とコンパイル

  作ったC関数はサブディレクトリを作りその中に納めますその中に
  Makefileも必要になりますが他のディレクトリにあるMakefileを参考にす
  れば簡単に作成できるでしょう.

  次にメインのMakefile(このファイルが置いてある同じディレクトリにあり
  ます)に関数に関する記述を追加します.

  (1) DIRS=の後にサブディレクトリ名を追加します.

  (2) @set \ で始まる項目に記述を追加します1関数につき1行の追加が必要
    です.

    コンバージョンの名前
    ソースエンコーディング名
    デスティネーションエンコーディング名
    関数名
    オブジェクトファイル名

    を1行の中にスペースで区切って追加します

o テスト

  以上が終わったらこのファイルがあるディレクトリでmakeしすべてがう
  まくいくことを確認します特にcreate_conversion.sqlがちゃんとした
  内容になっているかどうか確認しましょう.良さそうだったら,テスト用に
  新しいデータベースを作り,そこでこのスクリプトを実行します.

  $ psql -e -f create_conversion.sql test

  これも正常だったら最後にregression test suiteにテスト項目を追加し
  てください具体的にはsrc/test/regress/sql/conversion.sqlに追加し
  regression testを行います

o 注意事項

  デフォルトのエンコーディング変換として使用できるためには,ソースエン
  コーディングとデスティネーションエンコーディングの間で双方向の変換が
  できることが必要ですすなわちあるエンコーディングのペアに付き2
  個の関数の作成が必要です.これらの関数は別々のサブディレクトリに登録
  しても良いですが通常は一つのソースファイル中に2個の関数を書くこと
  が多いでしょう.