~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to doc/src/sgml/ref/create_conversion.sgml

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.14.4.1 2005-05-03 19:18:15 tgl Exp $ -->
 
2
 
 
3
<refentry id="SQL-CREATECONVERSION">
 
4
 <refmeta>
 
5
  <refentrytitle id="SQL-CREATECONVERSION-TITLE">CREATE CONVERSION</refentrytitle>
 
6
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 
7
 </refmeta>
 
8
 
 
9
 <refnamediv>
 
10
  <refname>CREATE CONVERSION</refname>
 
11
  <refpurpose>define a new encoding conversion</refpurpose>
 
12
 </refnamediv>
 
13
 
 
14
 <indexterm zone="sql-createconversion">
 
15
  <primary>CREATE CONVERSION</primary>
 
16
 </indexterm>
 
17
 
 
18
 <refsynopsisdiv>
 
19
<synopsis>
 
20
CREATE [DEFAULT] CONVERSION <replaceable>name</replaceable>
 
21
    FOR <replaceable>source_encoding</replaceable> TO <replaceable>dest_encoding</replaceable> FROM <replaceable>funcname</replaceable>
 
22
</synopsis>
 
23
 </refsynopsisdiv>
 
24
  
 
25
 <refsect1 id="sql-createconversion-description">
 
26
  <title>Description</title>
 
27
 
 
28
  <para>
 
29
   <command>CREATE CONVERSION</command> defines a new conversion between
 
30
   character set encodings.  Conversion names may be used in the
 
31
   <function>convert</function> function
 
32
   to specify a particular encoding conversion.  Also, conversions that
 
33
   are marked <literal>DEFAULT</> can be used for automatic encoding
 
34
   conversion between
 
35
   client and server. For this purpose, two conversions, from encoding A to
 
36
   B <emphasis>and</emphasis> from encoding B to A, must be defined.
 
37
 </para>
 
38
 
 
39
  <para>
 
40
   To be able to create a conversion, you must have <literal>EXECUTE</literal> privilege
 
41
   on the function and <literal>CREATE</literal> privilege on the destination schema.
 
42
  </para>
 
43
 </refsect1>
 
44
 
 
45
 
 
46
 <refsect1>
 
47
  <title>Parameters</title>
 
48
 
 
49
   <variablelist>
 
50
    <varlistentry>
 
51
     <term><literal>DEFAULT</literal></term>
 
52
 
 
53
     <listitem>
 
54
      <para>
 
55
       The <literal>DEFAULT</> clause indicates that this conversion
 
56
       is the default for this particular source to destination
 
57
       encoding. There should be only one default encoding in a schema
 
58
       for the encoding pair.
 
59
      </para>
 
60
     </listitem>
 
61
    </varlistentry>
 
62
 
 
63
    <varlistentry>
 
64
     <term><replaceable>name</replaceable></term>
 
65
 
 
66
     <listitem>
 
67
      <para>
 
68
       The name of the conversion. The conversion name may be
 
69
       schema-qualified. If it is not, the conversion is defined in the
 
70
       current schema. The conversion name must be unique within a
 
71
       schema.
 
72
      </para>
 
73
     </listitem>
 
74
    </varlistentry>
 
75
 
 
76
    <varlistentry>
 
77
     <term><replaceable>source_encoding</replaceable></term>
 
78
 
 
79
     <listitem>
 
80
      <para>
 
81
       The source encoding name.
 
82
      </para>
 
83
     </listitem>
 
84
    </varlistentry>
 
85
 
 
86
    <varlistentry>
 
87
     <term><replaceable>dest_encoding</replaceable></term>
 
88
 
 
89
     <listitem>
 
90
      <para>
 
91
       The destination encoding name.
 
92
      </para>
 
93
     </listitem>
 
94
    </varlistentry>
 
95
 
 
96
    <varlistentry>
 
97
     <term><replaceable>funcname</replaceable></term>
 
98
 
 
99
     <listitem>
 
100
      <para>
 
101
       The function used to perform the conversion.  The function name may
 
102
       be schema-qualified.  If it is not, the function will be looked
 
103
       up in the path.
 
104
      </para>
 
105
 
 
106
      <para>
 
107
       The function must have the following signature:
 
108
 
 
109
<programlisting>
 
110
conv_proc(
 
111
    integer,  -- source encoding ID
 
112
    integer,  -- destination encoding ID
 
113
    cstring,  -- source string (null terminated C string)
 
114
    internal, -- destination (fill with a null terminated C string)
 
115
    integer   -- source string length
 
116
) RETURNS void;
 
117
</programlisting>
 
118
      </para>
 
119
     </listitem>
 
120
    </varlistentry>
 
121
   </variablelist>
 
122
 </refsect1>
 
123
 
 
124
 <refsect1 id="sql-createconversion-notes">
 
125
  <title>Notes</title>
 
126
 
 
127
  <para>
 
128
   Use <command>DROP CONVERSION</command> to remove user-defined conversions.
 
129
  </para>
 
130
 
 
131
  <para>
 
132
   The privileges required to create a conversion may be changed in a future
 
133
   release.
 
134
  </para>
 
135
 </refsect1>
 
136
 
 
137
 <refsect1 id="sql-createconversion-examples">
 
138
  <title>Examples</title>
 
139
 
 
140
  <para>
 
141
   To create a conversion from encoding <literal>UNICODE</literal> to
 
142
   <literal>LATIN1</literal> using <function>myfunc</>:
 
143
<programlisting>
 
144
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
 
145
</programlisting>
 
146
  </para>
 
147
 </refsect1>
 
148
 
 
149
 
 
150
 <refsect1 id="sql-createconversion-compat">
 
151
  <title>Compatibility</title>
 
152
 
 
153
  <para>
 
154
    <command>CREATE CONVERSION</command>
 
155
    is a <productname>PostgreSQL</productname> extension.
 
156
    There is no <command>CREATE CONVERSION</command>
 
157
    statement in the SQL standard.
 
158
  </para>
 
159
 </refsect1>
 
160
 
 
161
 
 
162
 <refsect1 id="sql-createconversion-seealso">
 
163
  <title>See Also</title>
 
164
 
 
165
  <simplelist type="inline">
 
166
   <member><xref linkend="sql-alterconversion" endterm="sql-alterconversion-title"></member>
 
167
   <member><xref linkend="sql-createfunction" endterm="sql-createfunction-title"></member>
 
168
   <member><xref linkend="sql-dropconversion" endterm="sql-dropconversion-title"></member>
 
169
  </simplelist>
 
170
 </refsect1>
 
171
 
 
172
</refentry>
 
173
 
 
174
<!-- Keep this comment at the end of the file
 
175
Local variables:
 
176
mode:sgml
 
177
sgml-omittag:nil
 
178
sgml-shorttag:t
 
179
sgml-minimize-attributes:nil
 
180
sgml-always-quote-attributes:t
 
181
sgml-indent-step:1
 
182
sgml-indent-data:t
 
183
sgml-parent-document:nil
 
184
sgml-default-dtd-file:"../reference.ced"
 
185
sgml-exposed-tags:nil
 
186
sgml-local-catalogs:("/usr/lib/sgml/catalog")
 
187
sgml-local-ecat-files:nil
 
188
End:
 
189
-->