バージョンごとのドキュメント一覧

第42章 手続き言語

目次

42.1. 手続き言語のインストール
<title>Procedural Languages</title>

<productname>PostgreSQL</productname> allows user-defined functions to be written in other languages besides SQL and C. These other languages are generically called <firstterm>procedural languages</firstterm> (<acronym>PL</acronym>s). For a function written in a procedural language, the database server has no built-in knowledge about how to interpret the function's source text. Instead, the task is passed to a special handler that knows the details of the language. The handler could either do all the work of parsing, syntax analysis, execution, etc. itself, or it could serve as <quote>glue</quote> between <productname>PostgreSQL</productname> and an existing implementation of a programming language. The handler itself is a C language function compiled into a shared object and loaded on demand, just like any other C function. PostgreSQLでは、SQLやC言語以外の言語でユーザ定義の関数を作成することができます。 これらの他の言語は一般に手続き言語PL)と呼ばれます。 手続き言語で関数が記述されていた場合、データベースサーバにはその関数のソースをどのように解釈すればよいかについての知識が組み込まれていません。 代わりに、その処理はその言語を解釈する特別なハンドラに引き渡されます。 そのハンドラは解析、構文分析、実行などすべてのことを行うこともできますし、PostgreSQLと存在するプログラミング言語の実装との橋渡しともなり得ます。 ハンドラそのものはC言語関数で、他のC言語関数と同様に、共有オブジェクトにコンパイルされ、要求に応じてロードされます。

There are currently four procedural languages available in the standard <productname>PostgreSQL</productname> distribution: <application>PL/pgSQL</application> (<xref linkend="plpgsql"/>), <application>PL/Tcl</application> (<xref linkend="pltcl"/>), <application>PL/Perl</application> (<xref linkend="plperl"/>), and <application>PL/Python</application> (<xref linkend="plpython"/>). There are additional procedural languages available that are not included in the core distribution. <xref linkend="external-projects"/> has information about finding them. In addition other languages can be defined by users; the basics of developing a new procedural language are covered in <xref linkend="plhandler"/>. 現在PostgreSQLの標準配布物では、PL/pgSQL第43章)、PL/Tcl第44章)、PL/Perl第45章)、PL/Python第46章)という4つの手続き言語があります。 さらに、コア配布物には含まれない手続き言語があります。 付録Hでその見つけ方を説明します。 ユーザは他の言語を定義することもできます。 新しい手続き言語の開発について、その基礎を第58章で説明します。