Server IP : 103.119.228.120 / Your IP : 3.144.8.79 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-9.2.24/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >CREATE OPERATOR CLASS</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 9.2.24 Documentation" HREF="index.html"><LINK REL="UP" TITLE="SQL Commands" HREF="sql-commands.html"><LINK REL="PREVIOUS" TITLE="CREATE OPERATOR" HREF="sql-createoperator.html"><LINK REL="NEXT" TITLE="CREATE OPERATOR FAMILY" HREF="sql-createopfamily.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2017-11-06T22:43:11"></HEAD ><BODY CLASS="REFENTRY" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" ><A HREF="index.html" >PostgreSQL 9.2.24 Documentation</A ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A TITLE="CREATE OPERATOR" HREF="sql-createoperator.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="sql-commands.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="20%" ALIGN="right" VALIGN="top" ><A TITLE="CREATE OPERATOR FAMILY" HREF="sql-createopfamily.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="SQL-CREATEOPCLASS" ></A >CREATE OPERATOR CLASS</H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN69490" ></A ><H2 >Name</H2 >CREATE OPERATOR CLASS -- define a new operator class</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN69495" ></A ><H2 >Synopsis</H2 ><PRE CLASS="SYNOPSIS" >CREATE OPERATOR CLASS <TT CLASS="REPLACEABLE" ><I >name</I ></TT > [ DEFAULT ] FOR TYPE <TT CLASS="REPLACEABLE" ><I >data_type</I ></TT > USING <TT CLASS="REPLACEABLE" ><I >index_method</I ></TT > [ FAMILY <TT CLASS="REPLACEABLE" ><I >family_name</I ></TT > ] AS { OPERATOR <TT CLASS="REPLACEABLE" ><I >strategy_number</I ></TT > <TT CLASS="REPLACEABLE" ><I >operator_name</I ></TT > [ ( <TT CLASS="REPLACEABLE" ><I >op_type</I ></TT >, <TT CLASS="REPLACEABLE" ><I >op_type</I ></TT > ) ] [ FOR SEARCH | FOR ORDER BY <TT CLASS="REPLACEABLE" ><I >sort_family_name</I ></TT > ] | FUNCTION <TT CLASS="REPLACEABLE" ><I >support_number</I ></TT > [ ( <TT CLASS="REPLACEABLE" ><I >op_type</I ></TT > [ , <TT CLASS="REPLACEABLE" ><I >op_type</I ></TT > ] ) ] <TT CLASS="REPLACEABLE" ><I >function_name</I ></TT > ( <TT CLASS="REPLACEABLE" ><I >argument_type</I ></TT > [, ...] ) | STORAGE <TT CLASS="REPLACEABLE" ><I >storage_type</I ></TT > } [, ... ]</PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69512" ></A ><H2 >Description</H2 ><P > <TT CLASS="COMMAND" >CREATE OPERATOR CLASS</TT > creates a new operator class. An operator class defines how a particular data type can be used with an index. The operator class specifies that certain operators will fill particular roles or <SPAN CLASS="QUOTE" >"strategies"</SPAN > for this data type and this index method. The operator class also specifies the support procedures to be used by the index method when the operator class is selected for an index column. All the operators and functions used by an operator class must be defined before the operator class can be created. </P ><P > If a schema name is given then the operator class is created in the specified schema. Otherwise it is created in the current schema. Two operator classes in the same schema can have the same name only if they are for different index methods. </P ><P > The user who defines an operator class becomes its owner. Presently, the creating user must be a superuser. (This restriction is made because an erroneous operator class definition could confuse or even crash the server.) </P ><P > <TT CLASS="COMMAND" >CREATE OPERATOR CLASS</TT > does not presently check whether the operator class definition includes all the operators and functions required by the index method, nor whether the operators and functions form a self-consistent set. It is the user's responsibility to define a valid operator class. </P ><P > Related operator classes can be grouped into <I CLASS="FIRSTTERM" >operator families</I >. To add a new operator class to an existing family, specify the <TT CLASS="LITERAL" >FAMILY</TT > option in <TT CLASS="COMMAND" >CREATE OPERATOR CLASS</TT >. Without this option, the new class is placed into a family named the same as the new class (creating that family if it doesn't already exist). </P ><P > Refer to <A HREF="xindex.html" >Section 35.14</A > for further information. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69527" ></A ><H2 >Parameters</H2 ><P ></P ><DIV CLASS="VARIABLELIST" ><DL ><DT ><TT CLASS="REPLACEABLE" ><I >name</I ></TT ></DT ><DD ><P > The name of the operator class to be created. The name can be schema-qualified. </P ></DD ><DT ><TT CLASS="LITERAL" >DEFAULT</TT ></DT ><DD ><P > If present, the operator class will become the default operator class for its data type. At most one operator class can be the default for a specific data type and index method. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >data_type</I ></TT ></DT ><DD ><P > The column data type that this operator class is for. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >index_method</I ></TT ></DT ><DD ><P > The name of the index method this operator class is for. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >family_name</I ></TT ></DT ><DD ><P > The name of the existing operator family to add this operator class to. If not specified, a family named the same as the operator class is used (creating it, if it doesn't already exist). </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >strategy_number</I ></TT ></DT ><DD ><P > The index method's strategy number for an operator associated with the operator class. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >operator_name</I ></TT ></DT ><DD ><P > The name (optionally schema-qualified) of an operator associated with the operator class. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >op_type</I ></TT ></DT ><DD ><P > In an <TT CLASS="LITERAL" >OPERATOR</TT > clause, the operand data type(s) of the operator, or <TT CLASS="LITERAL" >NONE</TT > to signify a left-unary or right-unary operator. The operand data types can be omitted in the normal case where they are the same as the operator class's data type. </P ><P > In a <TT CLASS="LITERAL" >FUNCTION</TT > clause, the operand data type(s) the function is intended to support, if different from the input data type(s) of the function (for B-tree comparison functions and hash functions) or the class's data type (for B-tree sort support functions and all functions in GiST, SP-GiST and GIN operator classes). These defaults are correct, and so <TT CLASS="REPLACEABLE" ><I >op_type</I ></TT > need not be specified in <TT CLASS="LITERAL" >FUNCTION</TT > clauses, except for the case of a B-tree sort support function that is meant to support cross-data-type comparisons. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >sort_family_name</I ></TT ></DT ><DD ><P > The name (optionally schema-qualified) of an existing <TT CLASS="LITERAL" >btree</TT > operator family that describes the sort ordering associated with an ordering operator. </P ><P > If neither <TT CLASS="LITERAL" >FOR SEARCH</TT > nor <TT CLASS="LITERAL" >FOR ORDER BY</TT > is specified, <TT CLASS="LITERAL" >FOR SEARCH</TT > is the default. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >support_number</I ></TT ></DT ><DD ><P > The index method's support procedure number for a function associated with the operator class. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >function_name</I ></TT ></DT ><DD ><P > The name (optionally schema-qualified) of a function that is an index method support procedure for the operator class. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >argument_type</I ></TT ></DT ><DD ><P > The parameter data type(s) of the function. </P ></DD ><DT ><TT CLASS="REPLACEABLE" ><I >storage_type</I ></TT ></DT ><DD ><P > The data type actually stored in the index. Normally this is the same as the column data type, but some index methods (currently GiST and GIN) allow it to be different. The <TT CLASS="LITERAL" >STORAGE</TT > clause must be omitted unless the index method allows a different type to be used. </P ></DD ></DL ></DIV ><P > The <TT CLASS="LITERAL" >OPERATOR</TT >, <TT CLASS="LITERAL" >FUNCTION</TT >, and <TT CLASS="LITERAL" >STORAGE</TT > clauses can appear in any order. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69611" ></A ><H2 >Notes</H2 ><P > Because the index machinery does not check access permissions on functions before using them, including a function or operator in an operator class is tantamount to granting public execute permission on it. This is usually not an issue for the sorts of functions that are useful in an operator class. </P ><P > The operators should not be defined by SQL functions. A SQL function is likely to be inlined into the calling query, which will prevent the optimizer from recognizing that the query matches an index. </P ><P > Before <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > 8.4, the <TT CLASS="LITERAL" >OPERATOR</TT > clause could include a <TT CLASS="LITERAL" >RECHECK</TT > option. This is no longer supported because whether an index operator is <SPAN CLASS="QUOTE" >"lossy"</SPAN > is now determined on-the-fly at run time. This allows efficient handling of cases where an operator might or might not be lossy. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69620" ></A ><H2 >Examples</H2 ><P > The following example command defines a GiST index operator class for the data type <TT CLASS="LITERAL" >_int4</TT > (array of <TT CLASS="TYPE" >int4</TT >). See the <A HREF="intarray.html" >intarray</A > module for the complete example. </P ><PRE CLASS="PROGRAMLISTING" >CREATE OPERATOR CLASS gist__int_ops DEFAULT FOR TYPE _int4 USING gist AS OPERATOR 3 &&, OPERATOR 6 = (anyarray, anyarray), OPERATOR 7 @>, OPERATOR 8 <@, OPERATOR 20 @@ (_int4, query_int), FUNCTION 1 g_int_consistent (internal, _int4, int, oid, internal), FUNCTION 2 g_int_union (internal, internal), FUNCTION 3 g_int_compress (internal), FUNCTION 4 g_int_decompress (internal), FUNCTION 5 g_int_penalty (internal, internal, internal), FUNCTION 6 g_int_picksplit (internal, internal), FUNCTION 7 g_int_same (_int4, _int4, internal);</PRE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69627" ></A ><H2 >Compatibility</H2 ><P > <TT CLASS="COMMAND" >CREATE OPERATOR CLASS</TT > is a <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > extension. There is no <TT CLASS="COMMAND" >CREATE OPERATOR CLASS</TT > statement in the SQL standard. </P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN69633" ></A ><H2 >See Also</H2 ><A HREF="sql-alteropclass.html" >ALTER OPERATOR CLASS</A >, <A HREF="sql-dropopclass.html" >DROP OPERATOR CLASS</A >, <A HREF="sql-createopfamily.html" >CREATE OPERATOR FAMILY</A >, <A HREF="sql-alteropfamily.html" >ALTER OPERATOR FAMILY</A ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="sql-createoperator.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="sql-createopfamily.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >CREATE OPERATOR</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="sql-commands.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >CREATE OPERATOR FAMILY</TD ></TR ></TABLE ></DIV ></BODY ></HTML >