.\" This is -*-nroff-*- .\" XXX standard disclaimer belongs here.... .\" $Header: /usr/local/cvsroot/pgsql/src/man/create_language.l,v 1.2 1998/01/11 22:17:14 momjian Exp $ .\" Translated by Mitsuhiro Maeda (mitsu@cni.co.jp) .TH "CREATE LANGUAGE" SQL 11/05/95 日本語PostgreSQL 日本語PostgreSQL .SH 名称 .\" create language - define a new language for functions create language - 関数のための新しい言語を定義します .SH 形式 .nf \fBcreate\fP [\fBtrusted\fP] \fBprocedural language\fP 'lanname' \fBhandler\fP call_handler \fBlancompiler\fP 'comment' .fi .SH 説明 .\" With this command, a Postgres user can register a new language with .\" Postgres. このコマンドで、Postgres のユーザは Postgres の新しい言語を登録することができます。 .\" Subsequently, functions and trigger procedures can be .\" defined in this new language. その後、関数とトリガ手続きはこの新しい言語で定義できます。 .\" The user must have the Postgres superuser .\" privilege to register a new language. ユーザは新しい言語を登録するには Postgres のスーパーユーザの権限を持っていなくてはなりません。 .PP .\" The lanname is the name of the new procedural language. lanname は新しい手続き言語の名前です。 .\" It is converted .\" to lower case before the new entry in the pg_language system catalog .\" is inserted. システムカタログ pg_language に新しいエントリが挿入される前に 小文字に変換されます。 .\" Note that this case translation is also done on .\" create function(l) and drop language(l). このケースでの変換は create function (l) と drop language (l) でも 行われます。 .\" Thus, the language name .\" is case insensitive. ですから、言語名は大文字小文字を区別しません。 .\" A procedural language cannot override one of the .\" builtin languages of Postgres. 手続き言語は Postgres の組み込み言語を上書きできません。 .PP .\" The argument for \fBhandler\fP .\" is the name of a previously registered function that .\" will be called to execute the PL procedures. 引数の \fBhandler\fP は PL 手続きを実行するのに呼び出される前もって登録してある関数の名前です。 .PP .\" The \fBlancompiler\fP argument is the string that will be inserted .\" in the lancompiler attribute of the new pg_language entry. \fBlancompiler\fP 引数は文字列で、 新しい pg_language のエントリの lancompiler 属性に挿入されます。 .\" Up to now, .\" Postgres doesn't use this attribute in any way. 現在 Postgres はこの属性を何にもつかいません。 .PP .\" The \fBtrusted\fP keyword specifies, that the call handler for the .\" language is safe \fBtrusted\fP キーワードを指定すると、 この言語の呼び出しハンドラは安全とされます。 .\" - i.e. it offers an unprivileged user no functionality .\" to get around access restrictions. - つまり、権限のないユーザにアクセス制御関係の機能を提供しないということです。 .\" If this keyword is omitted when .\" registering the language, only users with the Postgres superuser privilege .\" can use this language to create new functions (like the 'C' language). もしこのキーワードがないと、 言語を登録するときに、Postgres のスーパーユーザ権限のあるユーザのみが 新しい関数を作るのにこの言語を使うことができるようになります。 ('C' 言語のように) .\" .SH "WRITING PL HANDLERS" .SH "PL ハンドラを書く" .\" The call handler for a procedural language must be written in a compiler .\" language such as 'C' and registered with Postgres as a function taking .\" no arguments and returning .\" .IR "opaque" .\" type. 手続き言語の呼び出しハンドラは 'C' のようなコンパイラ言語で書かれなくてはなりません。 また、 .IR "opaque" 型を返す引数を取らない関数として Postgres に登録されます。 .\" This prevents the call handler from beeing called directly as a function .\" from queries. これは呼び出しハンドラが問い合わせから直接呼び出されるのを防ぐためです。 .\" But there are arguments .\" on the actual call when a PL function or trigger procedure in the .\" language offered by the handler is to be executed. しかし、 ハンドラから提供される言語のPL 関数あるいはトリガ手続きが呼び出されるときには、 実際は引数があります。 .PP .\" When called from the trigger manager, the only argument is the object ID from .\" the procedures pg_proc entry. トリガマネージャから呼び出されると、唯一の引数が 手続きの pg_proc エントリのオブジェクトID になります。 .\" All other information from the trigger manager .\" is found in the global CurrentTriggerData pointer. トリガマネージャからの他の情報は グローバルの CurrentTriggerData ポインタに見ることができます。 .PP .\" When called from the function manager, the arguments are the object ID of the .\" procedures pg_proc entry, the number of arguments given to the PL function, .\" the arguments in a FmgrValues structure and a pointer to a boolean where the .\" function tells the caller if the return value is the SQL NULL value. 関数マネージャから呼び出されると、引数は 手続きの pg_proc エントリのオブジェクトID、 PL 関数に与えられる引数の数、 FmgrValues 構造体の引数、 そして関数がその戻り値が SQL の NULL 値であるかどうかを呼び出し元に知らせる boolean へのポインタとなります。 .PP .\" It's up to the call handler to fetch the pg_proc entry .\" and to analyze the argument and return types of the called procedure. pg_proc エントリを取り出し、 引数と呼び出された手続きの戻り値の型を調べるのは呼び出しハンドラによります。 .\" the .\" .IR "as" .\" clause from the create function(l) of the procedure will be found in .\" the prosrc attribute of the pg_proc entry. 手続きの create function(l) からの .IR "as" 句は pg_proc のエントリの prosrc 属性に見ることができます。 .\" This may be the source text .\" in the procedural language itself (like for PL/Tcl), a pathname to a .\" file or anything else that tells the call handler what to do in detail. これは 手続き言語そのもののソーステキスト (PL/Tcl のような)で、 ファイルへのパス、 もしくは呼び出しハンドラが細かく何をするべきかを告げる何らかのものとなります。 .SH 例 .\" Following is a template for a PL handler written in 'C': 次に挙げるのは、'C' で書かれた PL ハンドラの雛型です: .nf #include "executor/spi.h" #include "commands/trigger.h" #include "utils/elog.h" #include "fmgr.h" /* for FmgrValues struct */ #include "access/heapam.h" #include "utils/syscache.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" Datum plsample_call_handler( Oid prooid, int pronargs, FmgrValues *proargs, bool *isNull) { Datum retval; TriggerData *trigdata; if (CurrentTriggerData == NULL) { /* .\" * Called as a function * 関数として呼ばれた */ retval = ... } else { /* .\" * Called as a trigger procedure * トリガ手続きとして呼ばれた */ trigdata = CurrentTriggerData; CurrentTriggerData = NULL; retval = ... } *isNull = false; return retval; } .fi .\" Only a few thousand lines of code have to be added instead of the dots .\" to complete the PL call handler. 完全な PL 呼び出しハンドラには、 ほんの数千行のコードを ... の代わりに加えるだけです。 .\" See create function(l) how to compile .\" it into a loadable module. これをローダブルモジュールにコンパイルする方法は create function(l) を参照してください。 .\" The following commands then register the .\" sample procedural language. 次のコマンドはサンプルの手続き言語を登録します: .nf create function plsample_call_handler () returns opaque as '/usr/local/pgsql/lib/plsample.so' language 'C'; create procedural language 'plsample' handler plsample_call_handler lancompiler 'PL/Sample'; .fi .SH 参照 create function(l), drop language(l). .SH 制限 .\" Since the call handler for a procedural language must be .\" registered with Postgres in the 'C' language, it inherits .\" all the restrictions of 'C' functions. 手続き言語の呼び出しハンドラは 'C' 言語で登録されなくてはならないので、 'C' 関数のすべての制限を受け継ぎます。 .SH バグ .\" Currently, the definitions for a procedural language once .\" created cannot be changed. 現在、手続き言語を一度定義すると、変更することはできません。