CREATE CONVERSION 中文man頁面
NAME
CREATE CONVERSION - 定義一個用戶定義的碼制轉換
SYNOPSIS
CREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTION 描述
CREATE CONVERSION 定義一種新的編碼轉換。 轉換的名字可以用在 convert 函數內部聲明特定的編碼轉換。 同樣,標記為 DEFAULT 的轉換可以用于在前端和后端之間的自動編碼轉換。 出于這個原因,我們必須定義兩種轉換,從編碼 A 到 B 以及從編碼 B 到 A。
為了可以創建轉換,你必須在函數上有EXECUTE權限并且有在目標模式上的CREATE權限。
PARAMETERS 參數
- DEFAULT
- DEFAULT 子句表示這種轉換對于從這種源編碼到目的編碼的情況是缺省的。在一個模式里每個編碼對應該只有一個缺省編碼。
- name
轉換的名字。轉換名可以用模式修飾。如果沒有,那么轉換就在當前模式中定義。轉換名在一個模式里必須***。- source_encoding
源編碼名。- dest_encoding
目的編碼名。- funcname
用于執行轉換的函數。這個函數名可以用模式名修飾。 如果沒有,那么將從路徑中找出這個函數。
此函數必須有如下的樣子:conv_proc( integer, -- 源編碼 ID integer, -- 目的編碼 ID cstring, -- 源字串(空結尾的 C 字串) cstring, -- 目的字串(空結尾的 C 字串) integer -- 源字串長度 ) RETURNS void;
NOTES 注意
使用 DROP CONVERSION 刪除用戶定義的轉換。
創建轉換所需要的權限可能在未來的版本中改變。
EXAMPLES 例子
用 myfunc 創建一個從編碼 UNICODE 到 LATIN1 的轉換:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITY 兼容性
CREATE CONVERSION 是 PostgreSQL 的擴展。 在 SQL 標準里沒有CREATE CONVERSION 語句。
SEE ALSO 參見
ALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]
#p#
NAME
CREATE CONVERSION - define a new conversion
SYNOPSIS
CREATE [DEFAULT] CONVERSION name FOR source_encoding TO dest_encoding FROM funcname
DESCRIPTION
CREATE CONVERSION 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 client and server. For this purpose, two conversions, from encoding A to B and from encoding B to A, must be defined.
To be able to create a conversion, you must have EXECUTE privilege on the function and CREATE privilege on the destination schema.
PARAMETERS
- DEFAULT
- The 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.
- name
- 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.
- source_encoding
- The source encoding name.
- dest_encoding
- The destination encoding name.
- funcname
- 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.
The function must have the following signature:
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;
NOTES
Use DROP CONVERSION to remove user-defined conversions.
The privileges required to create a conversion may be changed in a future release.
EXAMPLES
To create a conversion from encoding UNICODE to LATIN1 using myfunc:
CREATE CONVERSION myconv FOR 'UNICODE' TO 'LATIN1' FROM myfunc;
COMPATIBILITY
CREATE CONVERSION is a PostgreSQL extension. There is no CREATE CONVERSION statement in the SQL standard.
SEE ALSO
ALTER CONVERSION [alter_conversion(7)], CREATE FUNCTION [create_function(l)], DROP CONVERSION [drop_conversion(l)]