|
| 1 | +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.1 2002/07/22 08:57:15 ishii 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 user-defined conversion</refpurpose> |
| 12 | + </refnamediv> |
| 13 | + |
| 14 | + <refsynopsisdiv> |
| 15 | +<synopsis> |
| 16 | +CREATE [DEFAULT] CONVERSION <replaceable>conversion_name</replaceable> |
| 17 | + FOR <replaceable>source_encoding</replaceable> |
| 18 | + TO <replaceable>dest_encoding</replaceable> FROM <replaceable>funcname</replaceable> |
| 19 | +</synopsis> |
| 20 | + </refsynopsisdiv> |
| 21 | + |
| 22 | + <refsect1 id="sql-createconversion-description"> |
| 23 | + <title>Description</title> |
| 24 | + |
| 25 | + <para> |
| 26 | + <command>CREATE CONVERSION</command> defines a new encoding |
| 27 | + conversion. There are two kinds of conversions. A default |
| 28 | + conversion is used for an automatic encoding conversion between |
| 29 | + frontend and backend. There should be only one default conversion |
| 30 | + for source/destination encodings pair in a schema. None default |
| 31 | + conversion never be used for the automatic conversion. Instead it |
| 32 | + can be used for CONVERT() function. |
| 33 | + </para> |
| 34 | + |
| 35 | + <para> |
| 36 | + To be able to create a conversion, you must have the execute right |
| 37 | + on the function and the usage right on the schema the function |
| 38 | + belongs to. |
| 39 | + </para> |
| 40 | + |
| 41 | + <variablelist> |
| 42 | + <title>Parameters</title> |
| 43 | + |
| 44 | + <varlistentry> |
| 45 | + <term><literal>DEFAULT</literal></term> |
| 46 | + |
| 47 | + <listitem> |
| 48 | + <para> |
| 49 | + The <literal>DEFAULT</> clause indicates that this conversion |
| 50 | + is the default for this particular source to destination |
| 51 | + encoding. There should be only one default encoding in a schema |
| 52 | + for the encoding pair. A default encoding can be used for not |
| 53 | + only CONVERT() function, but also for the automatic encoding |
| 54 | + conversion between frontend and backend. For this purpose, two |
| 55 | + conversions, from encoding A to B AND encoding B to A, must be |
| 56 | + defined. |
| 57 | + </para> |
| 58 | + </listitem> |
| 59 | + </varlistentry> |
| 60 | + |
| 61 | + <varlistentry> |
| 62 | + <term><replaceable>conversion_name</replaceable></term> |
| 63 | + |
| 64 | + <listitem> |
| 65 | + <para> |
| 66 | + The name of the conversion. The conversion name may be |
| 67 | + schema-qualified. If it is not, a conversion is defined in the |
| 68 | + current schema. The conversion name must be unique with in a |
| 69 | + schema. |
| 70 | + </para> |
| 71 | + </listitem> |
| 72 | + </varlistentry> |
| 73 | + |
| 74 | + <varlistentry> |
| 75 | + <term><replaceable>source_encoding</replaceable></term> |
| 76 | + |
| 77 | + <listitem> |
| 78 | + <para> |
| 79 | + The source encoding name. |
| 80 | + </para> |
| 81 | + </listitem> |
| 82 | + </varlistentry> |
| 83 | + |
| 84 | + <varlistentry> |
| 85 | + <term><replaceable>source_encoding</replaceable></term> |
| 86 | + |
| 87 | + <listitem> |
| 88 | + <para> |
| 89 | + The destination encoding name. |
| 90 | + </para> |
| 91 | + </listitem> |
| 92 | + </varlistentry> |
| 93 | + |
| 94 | + <varlistentry> |
| 95 | + <term><replaceable>funcname</replaceable></term> |
| 96 | + |
| 97 | + <listitem> |
| 98 | + <para> |
| 99 | + The function used to perform the conversion. The function name may |
| 100 | + be schema-qualified. If it is not, the function will be looked |
| 101 | + up in the path. |
| 102 | + </para> |
| 103 | + |
| 104 | + <para> |
| 105 | + The function must have following signature: |
| 106 | + |
| 107 | + <programlisting> |
| 108 | + conv_proc( |
| 109 | + INTEGER, -- source encoding id |
| 110 | + INTEGER, -- destination encoding id |
| 111 | + OPAQUE, -- source string (null terminated C string) |
| 112 | + OPAQUE, -- destination string (null terminated C string) |
| 113 | + INTEGER -- source string length |
| 114 | + ) returns INTEGER; -- dummy. returns nothing, actually. |
| 115 | + </programlisting> |
| 116 | + </para> |
| 117 | + </listitem> |
| 118 | + </varlistentry> |
| 119 | + </variablelist> |
| 120 | + |
| 121 | + </refsect1> |
| 122 | + |
| 123 | + <refsect1 id="sql-createconversion-notes"> |
| 124 | + <title>Notes</title> |
| 125 | + |
| 126 | + <para> |
| 127 | + Use <command>DROP CONVERSION</command> to remove user-defined conversions. |
| 128 | + </para> |
| 129 | + |
| 130 | + <para> |
| 131 | + The privileges required to create a conversion may be changed in a future |
| 132 | + release. |
| 133 | + </para> |
| 134 | + |
| 135 | + </refsect1> |
| 136 | + |
| 137 | + |
| 138 | + <refsect1 id="sql-createconversion-examples"> |
| 139 | + <title>Examples</title> |
| 140 | + |
| 141 | + <para> |
| 142 | + To create a conversion from encoding UNICODE to LATIN1 using 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 OPERATOR</command> |
| 157 | + statement in <acronym>SQL99</acronym>. |
| 158 | + </para> |
| 159 | + </refsect1> |
| 160 | + |
| 161 | + |
| 162 | + <refsect1 id="sql-createconversion-seealso"> |
| 163 | + <title>See Also</title> |
| 164 | + |
| 165 | + <para> |
| 166 | + <xref linkend="sql-createfunction" endterm="sql-createfunction-title">, |
| 167 | + <xref linkend="sql-dropconversion" endterm="sql-dropconversion-title">, |
| 168 | + <citetitle>PostgreSQL Programmer's Guide</citetitle> |
| 169 | + </para> |
| 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 | +--> |
0 commit comments