Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
19a20e04
Commit
19a20e04
authored
22 years ago
by
Tatsuo Ishii
Browse files
Options
Downloads
Patches
Plain Diff
Add Japanese README explaining how to add new conversion.
English README will come soon...
parent
88b74dcd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/utils/mb/conversion_procs/README.euc_jp
+83
-0
83 additions, 0 deletions
src/backend/utils/mb/conversion_procs/README.euc_jp
with
83 additions
and
0 deletions
src/backend/utils/mb/conversion_procs/README.euc_jp
0 → 100644
+
83
−
0
View file @
19a20e04
新しいエンコーディング変換関数の追加方法
2002/07/24 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
OPAQUE, -- source string (null terminated C string)
OPAQUE, -- destination string (null terminated C string)
INTEGER -- source string length
) returns INTEGER; -- dummy. returns nothing, actually.
唯一の出力引数は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個の関数を書くことが
多いでしょう.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment