1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>CREATE CONVERSION</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="sql-commands.html" title="SQL Commands">
<link rel="prev" href="sql-createconstraint.html" title="CREATE CONSTRAINT TRIGGER">
<link rel="next" href="sql-createdatabase.html" title="CREATE DATABASE">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
<a name="sql-createconversion"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>CREATE CONVERSION — define a new encoding conversion</p>
</div>
<a name="id753888"></a><div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">CREATE [DEFAULT] CONVERSION <em class="replaceable"><code>name</code></em>
FOR <em class="replaceable"><code>source_encoding</code></em> TO <em class="replaceable"><code>dest_encoding</code></em> FROM <em class="replaceable"><code>funcname</code></em></pre>
</div>
<div class="refsect1" lang="en">
<a name="sql-createconversion-description"></a><h2>Description</h2>
<p> <code class="command">CREATE CONVERSION</code> defines a new conversion between
character set encodings. Conversion names may be used in the
<code class="function">convert</code> function
to specify a particular encoding conversion. Also, conversions that
are marked <code class="literal">DEFAULT</code> can be used for automatic encoding
conversion between
client and server. For this purpose, two conversions, from encoding A to
B <span class="emphasis"><em>and</em></span> from encoding B to A, must be defined.
</p>
<p> To be able to create a conversion, you must have <code class="literal">EXECUTE</code> privilege
on the function and <code class="literal">CREATE</code> privilege on the destination schema.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id753981"></a><h2>Parameters</h2>
<div class="variablelist"><dl>
<dt><span class="term"><code class="literal">DEFAULT</code></span></dt>
<dd><p> The <code class="literal">DEFAULT</code> 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.
</p></dd>
<dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt>
<dd><p> 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.
</p></dd>
<dt><span class="term"><em class="replaceable"><code>source_encoding</code></em></span></dt>
<dd><p> The source encoding name.
</p></dd>
<dt><span class="term"><em class="replaceable"><code>dest_encoding</code></em></span></dt>
<dd><p> The destination encoding name.
</p></dd>
<dt><span class="term"><em class="replaceable"><code>funcname</code></em></span></dt>
<dd>
<p> 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.
</p>
<p> The function must have the following signature:
</p>
<pre class="programlisting">conv_proc(
integer, -- source encoding ID
integer, -- destination encoding ID
cstring, -- source string (null terminated C string)
internal, -- destination (fill with a null terminated C string)
integer -- source string length
) RETURNS void;</pre>
<p>
</p>
</dd>
</dl></div>
</div>
<div class="refsect1" lang="en">
<a name="sql-createconversion-notes"></a><h2>Notes</h2>
<p> Use <code class="command">DROP CONVERSION</code> to remove user-defined conversions.
</p>
<p> The privileges required to create a conversion may be changed in a future
release.
</p>
</div>
<div class="refsect1" lang="en">
<a name="sql-createconversion-examples"></a><h2>Examples</h2>
<p> To create a conversion from encoding <code class="literal">UTF8</code> to
<code class="literal">LATIN1</code> using <code class="function">myfunc</code>:
</p>
<pre class="programlisting">CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;</pre>
<p>
</p>
</div>
<div class="refsect1" lang="en">
<a name="sql-createconversion-compat"></a><h2>Compatibility</h2>
<p> <code class="command">CREATE CONVERSION</code>
is a <span class="productname">PostgreSQL</span> extension.
There is no <code class="command">CREATE CONVERSION</code>
statement in the SQL standard.
</p>
</div>
<div class="refsect1" lang="en">
<a name="sql-createconversion-seealso"></a><h2>See Also</h2>
<span class="simplelist"><a href="sql-alterconversion.html">ALTER CONVERSION</a>, <a href="sql-createfunction.html">CREATE FUNCTION</a>, <a href="sql-dropconversion.html">DROP CONVERSION</a></span>
</div>
</div></body>
</html>
|