1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00
Files
postgres/doc/src/sgml/ref/create_conversion.sgml
Bruce Momjian be2b660ecd This patch includes a lot of minor cleanups to the SGML documentation,
including:

- replacing all the appropriate usages of <citetitle>PostgreSQL
...</citetitle> with &cite-user;, &cite-admin;, and so on

- fix an omission in the EXECUTE documentation

- add some more text to the EXPLAIN documentation

- improve the PL/PgSQL RETURN NEXT documentation (more work to do here)

- minor markup fixes


Neil Conway
2003-01-19 00:13:31 +00:00

183 lines
4.8 KiB
Plaintext

<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.6 2003/01/19 00:13:29 momjian Exp $ -->
<refentry id="SQL-CREATECONVERSION">
<refmeta>
<refentrytitle id="SQL-CREATECONVERSION-TITLE">CREATE CONVERSION</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>CREATE CONVERSION</refname>
<refpurpose>define a user-defined conversion</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable>
FOR <replaceable>source_encoding</replaceable> TO <replaceable>dest_encoding</replaceable> FROM <replaceable>funcname</replaceable>
</synopsis>
</refsynopsisdiv>
<refsect1 id="sql-createconversion-description">
<title>Description</title>
<para>
<command>CREATE CONVERSION</command> defines a new encoding
conversion. Conversion names may be used in the CONVERT() function
to specify a particular encoding conversion. Also, conversions that
are marked DEFAULT can be used for automatic encoding conversion between
frontend and backend. For this purpose, two conversions, from encoding A to
B AND from encoding B to A, must be defined.
</para>
<para>
To be able to create a conversion, you must have the execute right
on the function and the create right on the destination schema.
</para>
<variablelist>
<title>Parameters</title>
<varlistentry>
<term><literal>DEFAULT</literal></term>
<listitem>
<para>
The <literal>DEFAULT</> clause indicates that this conversion
is the default for this particular source to destination
encoding. There should be only one default encoding in a schema
for the encoding pair.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>conversion_name</replaceable></term>
<listitem>
<para>
The name of the conversion. The conversion name may be
schema-qualified. If it is not, the conversion is defined in the
current schema. The conversion name must be unique within a
schema.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>source_encoding</replaceable></term>
<listitem>
<para>
The source encoding name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>source_encoding</replaceable></term>
<listitem>
<para>
The destination encoding name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>funcname</replaceable></term>
<listitem>
<para>
The function used to perform the conversion. The function name may
be schema-qualified. If it is not, the function will be looked
up in the path.
</para>
<para>
The function must have the following signature:
<programlisting>
conv_proc(
INTEGER, -- source encoding id
INTEGER, -- destination encoding id
CSTRING, -- source string (null terminated C string)
CSTRING, -- destination string (null terminated C string)
INTEGER -- source string length
) returns VOID;
</programlisting>
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="sql-createconversion-notes">
<title>Notes</title>
<para>
Use <command>DROP CONVERSION</command> to remove user-defined conversions.
</para>
<para>
The privileges required to create a conversion may be changed in a future
release.
</para>
</refsect1>
<refsect1 id="sql-createconversion-examples">
<title>Examples</title>
<para>
To create a conversion from encoding UNICODE to LATIN1 using <function>myfunc</>:
<programlisting>
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
</programlisting>
</para>
</refsect1>
<refsect1 id="sql-createconversion-compat">
<title>Compatibility</title>
<para>
<command>CREATE CONVERSION</command>
is a <productname>PostgreSQL</productname> extension.
There is no <command>CREATE CONVERSION</command>
statement in <acronym>SQL99</acronym>.
</para>
</refsect1>
<refsect1 id="sql-createconversion-seealso">
<title>See Also</title>
<para>
<xref linkend="sql-createfunction" endterm="sql-createfunction-title">,
<xref linkend="sql-dropconversion" endterm="sql-dropconversion-title">,
&cite-programmer;
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode:sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:("/usr/lib/sgml/catalog")
sgml-local-ecat-files:nil
End:
-->