.\" This is -*-nroff-*- .\" XXX standard disclaimer belongs here.... .\" $Header: /usr/local/cvsroot/pgsql/src/man/create_operator.l,v 1.4 1998/01/11 22:17:15 momjian Exp $ .\" Translated by Mitsuhiro Maeda (mitsu@cni.co.jp) .TH "CREATE OPERATOR" SQL 11/05/95 日本語PostgreSQL 日本語PostgreSQL .SH 名称 .\" create operator - define a new user operator create operator - 新しいユーザ演算子を定義します .SH 形式 .nf \fBcreate operator\fR operator_name \fB(\fR[ \fBleftarg\fR \fB=\fR type-1 ] [ \fB,\fR \fBrightarg\fR \fB=\fR type-2 ] , \fBprocedure =\fR func_name [\fB, commutator =\fR com_op ] [\fB, negator =\fR neg_op ] [\fB, restrict =\fR res_proc ] [\fB, hashes\fR] [\fB, join =\fR join_proc ] [\fB, sort =\fR sor_op1 {\fB,\fR sor_op2 } ] \fB)\fR .\" \fB"arg is (" .\" type [ .\" \fB, .\" type ] .\" \fB) .fi .SH 説明 .\" This command defines a new user operator, .\" .IR "operator_name" . このコマンドは新しいユーザ演算子 .IR "operator_name" を定義します。 .\" The user who defines an operator becomes its owner. 演算子を定義したユーザがその所有者になります。 .PP .\" The .\" .IR "operator_name" .\" is a sequence of up to sixteen punctuation characters. .IR "operator_name" は連続して16文字までの句読点文字です。 .\" The following .\" characters are valid for single-character operator names: 次の文字が1文字の演算子の名前として有効です: .nf .ce 1 ~ ! @ # % ^ & ` ? .fi .\" If the operator name is more than one character long, it may consist .\" of any combination of the above characters or the following additional .\" characters: もし演算子の名前が 1文字よりも長いならば、 上の文字の、または次の文字のどのような組合せでも可能です。 .nf .ce 1 | $ : + - * / < > = .fi .\" The operator "!=" is mapped to "<>" on input, and they are .\" therefore equivalent. 演算子 "!=" は入力時に "<>" にマップされるので、 同じ意味となります。 .PP .\" At least one of .\" .IR leftarg .\" and .\" .IR rightarg .\" must be defined. 少なくとも .IR leftarg と .IR rightarg のどちらかが定義されなくてはなりません。 .\" For binary operators, both should be defined. バイナリの演算子は両方が定義されるべきです。 .\" For .\" right unary operators, only .\" .IR arg1 .\" should be defined, while for left unary operators only .\" .IR arg2 .\" should be defined. 右項演算子は、 .IR arg1 だけが定義され、 左項演算子は .IR arg2 だけが定義されるでしょう。 .PP .\" The name of the operator, .\" .IR operator_name , .\" can be composed of symbols only. 演算子の名前 .IR operator_name は記号のみから成り立つことができます。 .\" Also, the .\" .IR func_name .\" procedure must have been previously defined using .\" .IR "create function" (l) .\" and must have one or two arguments. また、 .IR func_name 手続きは前もって .IR "create function" (l) で定義されていて、1つまたは2つの引数を取らなくてはなりません。 .PP .\" .\" that multiple instances of the .\" .\" operator must be be evaluated .\" .\" For example, consider the area-intersection operator, .\" .\" .q A, .\" .\" and the following expression: .\" .\" .(l .\" .\" MYBOXES2.description A \*(lq0,0,1,1\*(rq A MYBOXES.description .\" .\" .)l .\" .\" .in .5i .\" .\" The associativity flag indicates that .\" .\" .(l .\" .\" (MYBOXES2.description A \*(lq0,0,1,1\*(rq) A MYBOXES.description .\" .\" .)l .\" .\" .in .5i .\" .\" is the same as .\" .\" .(l .\" .\" MYBOXES2.description A (\*(lq0,0,1,1\*(rq A MYBOXES.description). .\" .\" .)l .\" The commutator operator is present so that Postgres can reverse the order .\" of the operands if it wishes. 転換演算子(commutator)があることで、 Postgres がオペランドの順番を逆にすることができます。 .\" For example, the operator .\" area-less-than, >>>, would have a commutator operator, .\" area-greater-than, <<<. Suppose that an operator, area-equal, ===, .\" exists, as well as an area not equal, !==. Hence, the query optimizer .\" could freely convert: 例えば、演算子の "エリアがより小さい" >>> には 転換演算子 "エリアがより大きい" <<<があるでしょう。 演算子 "エリアが等しい" === と、"エリアが等しくない" !== があったとしましょう。 ここで、問い合わせ最適化機構は自由に変換をすることができます: .nf .ce 1 "0,0,1,1"::box >>> MYBOXES.description .fi を .nf .ce 1 MYBOXES.description <<< "0,0,1,1"::box .fi にできるのです。 .\" This allows the execution code to always use the latter representation .\" and simplifies the query optimizer somewhat. これは実行コードをいつも後者の表現を使うようにでき、 若干問い合わせ最適化を単純にできます。 .PP .\" The negator operator allows the query optimizer to convert 否定(negator)演算子は問い合わせ最適化機構に以下の変換を許します。 .nf .ce 1 NOT MYBOXES.description === "0,0,1,1"::box .fi を .nf .ce 1 MYBOXES.description !== "0,0,1,1"::box .fi にします。 .\" If a commutator operator name is supplied, Postgres searches for it in .\" the catalog. もし転換(commutator)演算子の名前が与えられると、 Postgres はカタログを探します。 .\" If it is found and it does not yet have a commutator .\" itself, then the commutator's entry is updated to have the current .\" (new) operator as its commutator. もし見つかって、しかもそれが転換(commutator)演算子を自身に持っていなければ、 その転換演算子のエントリは現在の(新規)演算子がそれ自身の転換演算子として 更新されます。 .\" This applies to the negator, as .\" well. これは否定(negator)にもあてはまります。 .PP .\" This is to allow the definition of two operators that are the .\" commutators or the negators of each other. これで互いに転換(commutator)あるいは否定(negator)の関係にある 2つの演算子を定義できます。 .\" The first operator should .\" be defined without a commutator or negator (as appropriate). 最初の演算子は転換(commutator)あるいは否定(negator)なしで(適切に) 定義します。 .\" When the .\" second operator is defined, name the first as the commutator or .\" negator. そして 2番目の演算子を定義する時に 最初の演算子を転換(commutator)あるいは否定(negator)とします。 .\" The first will be updated as a side effect. 最初の演算子はその副作用として更新されることになります。 .PP .\" The next two specifications are present to support the query optimizer .\" in performing joins. 次の 2つの記述があると問い合わせ最適化機構は結合を実行することをサポートします。 .\" Postgres can always evaluate a join (i.e., .\" processing a clause with two tuple variables separated by an operator .\" that returns a boolean) by iterative substitution [WONG76]. Postgres は常に結合を評価するのに(つまり、 2つのタプル変数が boolean を返す演算子によって 分けられている句を処理することです)反復代用を使います[WONG76]。 .\" In .\" addition, Postgres is planning on implementing a hash-join algorithm .\" along the lines of [SHAP86]; however, it must know whether this .\" strategy is applicable. 加えて、Postgres は [SHAP86] の行に従って ハッシュ結合のアルゴリズムをインプリメントするプランをしますが、 しかし、この手順が適用できるかどうかを知らなくてはなりません。 .\" For example, a hash-join algorithm is usable .\" for a clause of the form: 例えば、ハッシュ結合のアルゴリズムは 次のようなフォームの句: .nf .ce 1 MYBOXES.description === MYBOXES2.description .fi には使えますが、次のようなフォームの句: .\" but not for a clause of the form: .nf .ce 1 MYBOXES.description <<< MYBOXES2.description. .fi には使えません。 .\" The .\" .BR hashes .\" flag gives the needed information to the query optimizer concerning .\" whether a hash join strategy is usable for the operator in question. .BR ハッシュ フラッグは質問の演算子にハッシュ結合の手段が使えるかどうかを心配する 問い合わせ最適化機構に必要な情報を与えます。 .PP .\" Similarly, the two sort operators indicate to the query optimizer .\" whether merge-sort is a usable join strategy and what operators should .\" be used to sort the two operand classes. 同様に、2つの並べ変え演算子は、 問い合わせ最適化機構にマージソートが結合手順が使えるかどうかと 2つのオペランドクラスを並べ変えるのにどの演算子を使うべきかを示します。 .\" For the === clause above, .\" the optimizer must sort both relations using the operator, <<<. 上記の === 句には、 最適化機構は両リレーションを演算子 <<< を使って並べ変えます。 .\" On .\" the other hand, merge-sort is not usable with the clause: 一方で、マージソートは次の句では使えません: .nf .ce 1 MYBOXES.description <<< MYBOXES2.description .fi .\" If other join strategies are found to be practical, Postgres will change .\" the optimizer and run-time system to use them and will require .\" additional specification when an operator is defined. もし違う結合手順が現実的であると見つけたら、 Postgres は最適化機構と実行システムを変更してそれらを使うようにし、 演算子が定義されると付加的な記述を要求します。 .\" Fortunately, .\" the research community invents new join strategies infrequently, and .\" the added generality of user-defined join strategies was not felt to .\" be worth the complexity involved. 幸い、 まれに研究団体が新しい結合手順を発明するので、 ユーザ定義の結合手順で加えられた普遍性が 複雑さを伴うだけの価値があると思えません。 .PP .\" The last two pieces of the specification are present so the query .\" optimizer can estimate result sizes. 最後の 2つの記述があると、 問い合わせ最適化機構は結果のサイズを評価します。 .\" If a clause of the form: 次のようなフォームの句: .nf .ce 1 MYBOXES.description <<< "0,0,1,1"::box .fi .\" is present in the qualification, then Postgres may have to estimate the .\" fraction of the instances in MYBOXES that satisfy the clause. が制約句にあると、Postgres はMYBOXES のインスタンスの断片が その句を満たすかどうかを評価しなくてはならないでしょう。 .\" The .\" function res_proc must be a registered function (meaning it is already .\" defined using .\" .IR "define function" (l)) .\" which accepts one argument of the correct data type and returns a .\" floating point number. 正しいデータ型の 1つの引数を取り、小数を返す関数 res_proc は 登録された関数でなくてはなりません。 (これは既に .IR "define function" (l) で定義されているということを意味します。) .\" The query optimizer simply calls this .\" function, passing the parameter "0,0,1,1" .\" and multiplies the result by the relation size to get the desired .\" expected number of instances. 問い合わせ最適化機構はパラメータ "0,0,1,1" を渡して単にこの関数を呼び出し、 その結果をリレーションのサイズに掛け合わせて 望ましいインスタンスの数を得ます。 .PP .\" Similarly, when the operands of the operator both contain instance .\" variables, the query optimizer must estimate the size of the resulting .\" join. 同様に、演算子のオペランドが両方ともインスタンス変数を含んでいる時、 問い合わせ最適化機構は結合の結果のサイズを評価しなくてはなりません。 .\" The function join_proc will return another floating point .\" number which will be multiplied by the cardinalities of the two .\" classes involved to compute the desired expected result size. 関数 join_proc は 望ましい結果のサイズを計算する 2つのクラスの重要性を掛け合わせられる 小数を返します。 .PP .\" The difference between the function 関数 .nf .ce 1 my_procedure_1 (MYBOXES.description, "0,0,1,1"::box) .fi と演算子 .\" and the operator .nf .ce 1 MYBOXES.description === "0,0,1,1"::box .fi .\" is that Postgres attempts to optimize operators and can decide to use an .\" index to restrict the search space when operators are involved. との違いは、 Postgres が演算子を最適化しようと試み、 演算子が関係する検索スペースを制限するインデックスを使おうとすることです。 .\" However, there is no attempt to optimize functions, and they are .\" performed by brute force. しかし、関数を最適化することは試されず、 力ずくで処理されます。 .\" Moreover, functions can have any number of .\" arguments while operators are restricted to one or two. さらに、関数はどんな数の引数も取れますが、 演算子は1つか2つに制限されています。 .SH 例 .nf -- .\" --The following command defines a new operator, .\" --area-equality, for the BOX data type. -- 次のコマンドは BOX データ型のための -- 新しい演算子 area_equal_procedure を定義します。 -- create operator === ( leftarg = box, rightarg = box, procedure = area_equal_procedure, commutator = ===, negator = !==, restrict = area_restriction_procedure, hashes, join = area-join-procedure, sort = <<<, <<<) .\" arg is (box, box) .fi .SH 参照 create function(l), drop operator(l). .SH バグ .\" Operator names cannot be composed of alphabetic characters in .\" Postgres. Postgres では演算子の名前にアルファベットを含めることができません。 .PP .\" If an operator is defined before its commuting operator has been defined .\" (a case specifically warned against above), a dummy operator with invalid .\" fields will be placed in the system catalogs. 演算子が、その転換演算子が定義される前に定義されると(特に上に対して警告されたケース)、 無効なフィールドのダミーの演算子がシステムカタログに置かれます。 .\" This may interfere with .\" the definition of later operators. これは後の演算子の定義を妨げることがあります。