Header And Logo

PostgreSQL
| The world's most advanced open source database.

Defines | Typedefs | Functions | Variables

pg_operator.h File Reference

#include "catalog/genbki.h"
#include "nodes/pg_list.h"
Include dependency graph for pg_operator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define OperatorRelationId   2617
#define Natts_pg_operator   14
#define Anum_pg_operator_oprname   1
#define Anum_pg_operator_oprnamespace   2
#define Anum_pg_operator_oprowner   3
#define Anum_pg_operator_oprkind   4
#define Anum_pg_operator_oprcanmerge   5
#define Anum_pg_operator_oprcanhash   6
#define Anum_pg_operator_oprleft   7
#define Anum_pg_operator_oprright   8
#define Anum_pg_operator_oprresult   9
#define Anum_pg_operator_oprcom   10
#define Anum_pg_operator_oprnegate   11
#define Anum_pg_operator_oprcode   12
#define Anum_pg_operator_oprrest   13
#define Anum_pg_operator_oprjoin   14
#define BooleanNotEqualOperator   85
#define BooleanEqualOperator   91
#define TextEqualOperator   98
#define TIDEqualOperator   387
#define TIDLessOperator   2799
#define OID_NAME_REGEXEQ_OP   639
#define OID_TEXT_REGEXEQ_OP   641
#define Float8LessOperator   672
#define OID_BPCHAR_REGEXEQ_OP   1055
#define ARRAY_EQ_OP   1070
#define ARRAY_LT_OP   1072
#define ARRAY_GT_OP   1073
#define OID_NAME_LIKE_OP   1207
#define OID_TEXT_LIKE_OP   1209
#define OID_BPCHAR_LIKE_OP   1211
#define OID_NAME_ICREGEXEQ_OP   1226
#define OID_TEXT_ICREGEXEQ_OP   1228
#define OID_BPCHAR_ICREGEXEQ_OP   1234
#define OID_INET_SUB_OP   931
#define OID_INET_SUBEQ_OP   932
#define OID_INET_SUP_OP   933
#define OID_INET_SUPEQ_OP   934
#define OID_NAME_ICLIKE_OP   1625
#define OID_TEXT_ICLIKE_OP   1627
#define OID_BPCHAR_ICLIKE_OP   1629
#define OID_BYTEA_LIKE_OP   2016
#define OID_ARRAY_OVERLAP_OP   2750
#define OID_ARRAY_CONTAINS_OP   2751
#define OID_ARRAY_CONTAINED_OP   2752
#define RECORD_EQ_OP   2988
#define RECORD_LT_OP   2990
#define RECORD_GT_OP   2991
#define OID_RANGE_LESS_OP   3884
#define OID_RANGE_LESS_EQUAL_OP   3885
#define OID_RANGE_GREATER_OP   3886
#define OID_RANGE_GREATER_EQUAL_OP   3887
#define OID_RANGE_OVERLAP_OP   3888
#define OID_RANGE_CONTAINS_ELEM_OP   3889
#define OID_RANGE_CONTAINS_OP   3890
#define OID_RANGE_ELEM_CONTAINED_OP   3891
#define OID_RANGE_CONTAINED_OP   3892
#define OID_RANGE_LEFT_OP   3893
#define OID_RANGE_RIGHT_OP   3894
#define OID_RANGE_OVERLAPS_LEFT_OP   3895
#define OID_RANGE_OVERLAPS_RIGHT_OP   3896

Typedefs

typedef FormData_pg_operatorForm_pg_operator

Functions

 CATALOG (pg_operator, 2617)
 DATA (insert OID=15("="PGNSP PGUID b t t 23 20 16 416 36 int48eq eqsel eqjoinsel))
 DESCR ("equal")
 DESCR ("not equal")
 DESCR ("less than")
 DESCR ("greater than")
 DESCR ("less than or equal")
 DESCR ("greater than or equal")
 DESCR ("append element onto end of array")
 DESCR ("prepend element onto front of array")
 DESCR ("concatenate")
 DESCR ("factorial")
 DESCR ("deprecated, use ! instead")
 DESCR ("modulus")
 DESCR ("absolute value")
 DESCR ("negate")
 DESCR ("is left of")
 DESCR ("overlaps or is left of")
 DESCR ("overlaps or is right of")
 DESCR ("is right of")
 DESCR ("is contained by")
 DESCR ("contains")
 DESCR ("same as")
 DESCR ("overlaps")
 DESCR ("greater than or equal by area")
 DESCR ("greater than by area")
 DESCR ("equal by area")
 DESCR ("less than by area")
 DESCR ("less than or equal by area")
 DESCR ("is above")
 DESCR ("is below")
 DESCR ("point inside box")
 DESCR ("point within closed path, or point on open path")
 DESCR ("center of")
 DESCR ("multiply")
 DESCR ("distance between")
 DESCR ("divide")
 DESCR ("add")
 DESCR ("subtract")
 DESCR ("equal by length")
 DESCR ("not equal by length")
 DESCR ("less than by length")
 DESCR ("greater than by length")
 DESCR ("less than or equal by length")
 DESCR ("greater than or equal by length")
 DESCR ("square root")
 DESCR ("cube root")
 DESCR ("start of interval")
 DESCR ("convert to tinterval")
 DESCR ("matches regular expression, case-sensitive")
 DESCR ("does not match regular expression, case-sensitive")
 DESCR ("add points (translate)")
 DESCR ("subtract points (translate)")
 DESCR ("multiply points (scale/rotate)")
 DESCR ("divide points (scale/rotate)")
 DESCR ("add (translate path)")
 DESCR ("subtract (translate path)")
 DESCR ("multiply (rotate/scale path)")
 DESCR ("divide (rotate/scale path)")
 DESCR ("number of points")
 DESCR ("intersect")
 DESCR ("sum of path segment lengths")
 DESCR ("is above (allows touching)")
 DESCR ("is below (allows touching)")
 DESCR ("deprecated, use && instead")
 DESCR ("box intersection")
 DESCR ("add point to box (translate)")
 DESCR ("subtract point from box (translate)")
 DESCR ("multiply box by point (scale)")
 DESCR ("divide box by point (scale)")
 DESCR ("horizontally aligned")
 DESCR ("vertically aligned")
 DESCR ("exponentiation")
 DESCR ("add/update ACL item")
 DESCR ("remove ACL item")
 DESCR ("matches LIKE expression")
 DESCR ("does not match LIKE expression")
 DESCR ("matches regular expression, case-insensitive")
 DESCR ("does not match regular expression, case-insensitive")
 DESCR ("convert date and time to timestamp")
 DESCR ("convert date and time with time zone to timestamp with time zone")
 DESCR ("convert time and date to timestamp")
 DESCR ("convert time with time zone and date to timestamp with time zone")
 DESCR ("not equal by area")
 DESCR ("parallel")
 DESCR ("perpendicular")
 DESCR ("horizontal")
 DESCR ("vertical")
 DESCR ("intersection point")
 DESCR ("point on line")
 DESCR ("lseg on line")
 DESCR ("closest point to A on B")
 DESCR ("distance between endpoints")
 DESCR ("bitwise not")
 DESCR ("bitwise and")
 DESCR ("bitwise or")
 DESCR ("is subnet")
 DESCR ("is subnet or equal")
 DESCR ("is supernet")
 DESCR ("is supernet or equal")
 DESCR ("matches LIKE expression, case-insensitive")
 DESCR ("does not match LIKE expression, case-insensitive")
 DESCR ("bitwise exclusive or")
 DESCR ("bitwise shift left")
 DESCR ("bitwise shift right")
 DESCR ("unary plus")
 DESCR ("overlaps or is below")
 DESCR ("overlaps or is above")
 DESCR ("deprecated, use <@ instead")
 DESCR ("deprecated, use @> instead")
 DESCR ("text search match")
 DESCR ("deprecated, use @@ instead")
 DESCR ("AND-concatenate")
 DESCR ("OR-concatenate")
 DESCR ("NOT tsquery")
 DESCR ("is adjacent to")
 DESCR ("range union")
 DESCR ("range difference")
 DESCR ("range intersection")
 DESCR ("get json object field")
 DESCR ("get json object field as text")
 DESCR ("get json array element")
 DESCR ("get json array element as text")
 DESCR ("get value from json with path elements")
 DESCR ("get value from json as text with path elements")
Oid OperatorCreate (const char *operatorName, Oid operatorNamespace, Oid leftTypeId, Oid rightTypeId, Oid procedureId, List *commutatorName, List *negatorName, Oid restrictionId, Oid joinId, bool canMerge, bool canHash)

Variables

 FormData_pg_operator

Define Documentation

#define Anum_pg_operator_oprcanhash   6

Definition at line 71 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprcanmerge   5

Definition at line 70 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprcode   12

Definition at line 77 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprcom   10

Definition at line 75 of file pg_operator.h.

Referenced by OperatorCreate(), OperatorShellMake(), and OperatorUpd().

#define Anum_pg_operator_oprjoin   14

Definition at line 79 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprkind   4

Definition at line 69 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprleft   7

Definition at line 72 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprname   1

Definition at line 66 of file pg_operator.h.

Referenced by OperatorCreate(), OperatorShellMake(), and regoperin().

#define Anum_pg_operator_oprnamespace   2

Definition at line 67 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprnegate   11

Definition at line 76 of file pg_operator.h.

Referenced by OperatorCreate(), OperatorShellMake(), and OperatorUpd().

#define Anum_pg_operator_oprowner   3

Definition at line 68 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprrest   13

Definition at line 78 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprresult   9

Definition at line 74 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define Anum_pg_operator_oprright   8

Definition at line 73 of file pg_operator.h.

Referenced by OperatorCreate(), and OperatorShellMake().

#define ARRAY_EQ_OP   1070
#define ARRAY_GT_OP   1073

Definition at line 774 of file pg_operator.h.

Referenced by lookup_type_cache().

#define ARRAY_LT_OP   1072

Definition at line 771 of file pg_operator.h.

Referenced by lookup_type_cache().

#define BooleanEqualOperator   91
#define BooleanNotEqualOperator   85

Definition at line 112 of file pg_operator.h.

Referenced by eval_const_expressions_mutator().

#define Float8LessOperator   672

Definition at line 530 of file pg_operator.h.

#define Natts_pg_operator   14

Definition at line 65 of file pg_operator.h.

#define OID_ARRAY_CONTAINED_OP   2752
#define OID_ARRAY_CONTAINS_OP   2751
#define OID_ARRAY_OVERLAP_OP   2750

Definition at line 1526 of file pg_operator.h.

Referenced by mcelem_array_selec().

#define OID_BPCHAR_ICLIKE_OP   1629

Definition at line 1181 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_BPCHAR_ICREGEXEQ_OP   1234

Definition at line 907 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_BPCHAR_LIKE_OP   1211

Definition at line 890 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_BPCHAR_REGEXEQ_OP   1055

Definition at line 749 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_BYTEA_LIKE_OP   2016

Definition at line 1361 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_INET_SUB_OP   931
#define OID_INET_SUBEQ_OP   932
#define OID_INET_SUP_OP   933

Definition at line 1148 of file pg_operator.h.

#define OID_INET_SUPEQ_OP   934

Definition at line 1151 of file pg_operator.h.

#define OID_NAME_ICLIKE_OP   1625

Definition at line 1171 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_NAME_ICREGEXEQ_OP   1226

Definition at line 897 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_NAME_LIKE_OP   1207

Definition at line 880 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_NAME_REGEXEQ_OP   639

Definition at line 494 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_RANGE_CONTAINED_OP   3892

Definition at line 1706 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_CONTAINS_ELEM_OP   3889
#define OID_RANGE_CONTAINS_OP   3890

Definition at line 1700 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_ELEM_CONTAINED_OP   3891

Definition at line 1703 of file pg_operator.h.

#define OID_RANGE_GREATER_EQUAL_OP   3887

Definition at line 1691 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_GREATER_OP   3886

Definition at line 1688 of file pg_operator.h.

Referenced by calc_hist_selectivity(), and default_range_selectivity().

#define OID_RANGE_LEFT_OP   3893

Definition at line 1709 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_LESS_EQUAL_OP   3885

Definition at line 1685 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_LESS_OP   3884

Definition at line 1682 of file pg_operator.h.

Referenced by calc_hist_selectivity(), and default_range_selectivity().

#define OID_RANGE_OVERLAP_OP   3888

Definition at line 1694 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_RANGE_OVERLAPS_LEFT_OP   3895

Definition at line 1715 of file pg_operator.h.

Referenced by calc_hist_selectivity(), and calc_rangesel().

#define OID_RANGE_OVERLAPS_RIGHT_OP   3896

Definition at line 1718 of file pg_operator.h.

Referenced by calc_hist_selectivity(), and calc_rangesel().

#define OID_RANGE_RIGHT_OP   3894

Definition at line 1712 of file pg_operator.h.

Referenced by calc_hist_selectivity(), calc_rangesel(), and default_range_selectivity().

#define OID_TEXT_ICLIKE_OP   1627

Definition at line 1176 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_TEXT_ICREGEXEQ_OP   1228

Definition at line 902 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_TEXT_LIKE_OP   1209

Definition at line 885 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OID_TEXT_REGEXEQ_OP   641

Definition at line 499 of file pg_operator.h.

Referenced by expand_indexqual_opclause(), and match_special_index_operator().

#define OperatorRelationId   2617
#define RECORD_EQ_OP   2988

Definition at line 1661 of file pg_operator.h.

Referenced by lookup_type_cache(), and op_mergejoinable().

#define RECORD_GT_OP   2991

Definition at line 1669 of file pg_operator.h.

Referenced by lookup_type_cache().

#define RECORD_LT_OP   2990

Definition at line 1666 of file pg_operator.h.

Referenced by lookup_type_cache().

#define TextEqualOperator   98

Definition at line 135 of file pg_operator.h.

#define TIDEqualOperator   387

Definition at line 159 of file pg_operator.h.

Referenced by IsTidEqualAnyClause(), and IsTidEqualClause().

#define TIDLessOperator   2799

Definition at line 164 of file pg_operator.h.

Referenced by validate_index().


Typedef Documentation

Definition at line 58 of file pg_operator.h.


Function Documentation

CATALOG ( pg_operator  ,
2617   
)

Definition at line 35 of file pg_operator.h.

{
    NameData    oprname;        /* name of operator */
    Oid         oprnamespace;   /* OID of namespace containing this oper */
    Oid         oprowner;       /* operator owner */
    char        oprkind;        /* 'l', 'r', or 'b' */
    bool        oprcanmerge;    /* can be used in merge join? */
    bool        oprcanhash;     /* can be used in hash join? */
    Oid         oprleft;        /* left arg type, or 0 if 'l' oprkind */
    Oid         oprright;       /* right arg type, or 0 if 'r' oprkind */
    Oid         oprresult;      /* result datatype */
    Oid         oprcom;         /* OID of commutator oper, or 0 if none */
    Oid         oprnegate;      /* OID of negator oper, or 0 if none */
    regproc     oprcode;        /* OID of underlying function */
    regproc     oprrest;        /* OID of restriction estimator, or 0 */
    regproc     oprjoin;        /* OID of join estimator, or 0 */
} FormData_pg_operator;

DATA ( insert  OID = 15("="PGNSP PGUID b t t 23 20 16 416 36 int48eq eqsel eqjoinsel)  ) 
DESCR ( "get value from json as text with path elements"   ) 
DESCR ( "get value from json with path elements"   ) 
DESCR ( "get json array element as text  ) 
DESCR ( "get json array element"   ) 
DESCR ( "get json object field as text  ) 
DESCR ( "get json object field"   ) 
DESCR ( "range intersection"   ) 
DESCR ( "range difference"   ) 
DESCR ( "range union"   ) 
DESCR ( "is adjacent to"   ) 
DESCR ( "NOT tsquery"   ) 
DESCR ( "OR-concatenate"   ) 
DESCR ( "AND-concatenate"   ) 
DESCR ( deprecated,
use @@instead"   
)
DESCR ( "text search match"   ) 
DESCR ( deprecated,
use @  ,
instead"   
)
DESCR ( deprecated  ) 
DESCR ( "overlaps or is above"   ) 
DESCR ( "overlaps or is below"   ) 
DESCR ( "unary plus"   ) 
DESCR ( "bitwise shift right"   ) 
DESCR ( "bitwise shift left"   ) 
DESCR ( "bitwise exclusive or"   ) 
DESCR ( "does not match LIKE   expression,
case-insensitive"   
)
DESCR ( "matches LIKE   expression,
case-insensitive"   
)
DESCR ( "is supernet or equal"   ) 
DESCR ( "is supernet"   ) 
DESCR ( "is subnet or equal"   ) 
DESCR ( "is subnet"   ) 
DESCR ( "bitwise or"   ) 
DESCR ( "bitwise and"   ) 
DESCR ( "bitwise not"   ) 
DESCR ( "distance between endpoints"   ) 
DESCR ( "closest point to A on B"   ) 
DESCR ( "lseg on line"   ) 
DESCR ( "point on line"   ) 
DESCR ( "intersection point"   ) 
DESCR ( "vertical"   ) 
DESCR ( "horizontal"   ) 
DESCR ( "perpendicular"   ) 
DESCR ( "parallel"   ) 
DESCR ( "not equal by area"   ) 
DESCR ( "convert time with time zone and date to timestamp with time zone  ) 
DESCR ( "convert time and date to timestamp  ) 
DESCR ( "convert date and time with time zone to timestamp with time zone  ) 
DESCR ( "convert date and time to timestamp  ) 
DESCR ( "does not match regular   expression,
case-insensitive"   
)
DESCR ( "matches regular   expression,
case-insensitive"   
)
DESCR ( "does not match LIKE expression"   ) 
DESCR ( "matches LIKE expression"   ) 
DESCR ( "remove ACL item"   ) 
DESCR ( "add/update ACL item"   ) 
DESCR ( "exponentiation"   ) 
DESCR ( "vertically aligned"   ) 
DESCR ( "horizontally aligned"   ) 
DESCR ( "divide box by point (scale)"   ) 
DESCR ( "multiply box by point (scale)"   ) 
DESCR ( "subtract point from box (translate)"   ) 
DESCR ( "add point to box (translate)"   ) 
DESCR ( "box intersection"   ) 
DESCR ( deprecated,
use &&instead"   
)
DESCR ( "not equal"   ) 
DESCR ( "is above (allows touching)"   ) 
DESCR ( "sum of path segment lengths"   ) 
DESCR ( "intersect"   ) 
DESCR ( "number of points"   ) 
DESCR ( "divide (rotate/scale path)"   ) 
DESCR ( "multiply (rotate/scale path)"   ) 
DESCR ( "subtract (translate path)"   ) 
DESCR ( "add (translate path)"   ) 
DESCR ( "divide points (scale/rotate)"   ) 
DESCR ( "multiply points (scale/rotate)"   ) 
DESCR ( "subtract points (translate)"   ) 
DESCR ( "add points (translate)"   ) 
DESCR ( "does not match regular   expression,
case-sensitive"   
)
DESCR ( "matches regular   expression,
case-sensitive"   
)
DESCR ( "convert to tinterval"   ) 
DESCR ( "start of interval  ) 
DESCR ( "cube root"   ) 
DESCR ( "square root"   ) 
DESCR ( "greater than or equal by length"   ) 
DESCR ( "less than or equal by length"   ) 
DESCR ( "greater than by length"   ) 
DESCR ( "less than by length"   ) 
DESCR ( "not equal by length"   ) 
DESCR ( "equal by length"   ) 
DESCR ( "subtract"   ) 
DESCR ( "add"   ) 
DESCR ( "divide"   ) 
DESCR ( "distance between"   ) 
DESCR ( "multiply"   ) 
DESCR ( "center of"   ) 
DESCR ( "point within closed   path,
or point on open path"   
)
DESCR ( "greater than or equal"   ) 
DESCR ( "is below"   ) 
DESCR ( "is above"   ) 
DESCR ( "less than or equal by area"   ) 
DESCR ( "less than by area"   ) 
DESCR ( "equal by area"   ) 
DESCR ( "greater than by area"   ) 
DESCR ( "greater than or equal by area"   ) 
DESCR ( "overlaps"   ) 
DESCR ( "same as"   ) 
DESCR ( "contains"   ) 
DESCR ( "is contained by"   ) 
DESCR ( "is right of"   ) 
DESCR ( "overlaps or is right of"   ) 
DESCR ( "overlaps or is left of"   ) 
DESCR ( "is left of"   ) 
DESCR ( "negate"   ) 
DESCR ( "absolute value  ) 
DESCR ( "modulus"   ) 
DESCR ( deprecated,
use!instead"   
)
DESCR ( "factorial"   ) 
DESCR ( "concatenate"   ) 
DESCR ( "prepend element onto front of array"   ) 
DESCR ( "append element onto end of array"   ) 
DESCR ( "point inside box"   ) 
DESCR ( "less than or equal"   ) 
DESCR ( "greater than"   ) 
DESCR ( "less than"   ) 
DESCR ( "is below (allows touching)"   ) 
DESCR ( "equal"   ) 
Oid OperatorCreate ( const char *  operatorName,
Oid  operatorNamespace,
Oid  leftTypeId,
Oid  rightTypeId,
Oid  procedureId,
List commutatorName,
List negatorName,
Oid  restrictionId,
Oid  joinId,
bool  canMerge,
bool  canHash 
)

Definition at line 329 of file pg_operator.c.

References ACL_KIND_OPER, aclcheck_error(), ACLCHECK_NOT_OWNER, Anum_pg_operator_oprcanhash, Anum_pg_operator_oprcanmerge, Anum_pg_operator_oprcode, Anum_pg_operator_oprcom, Anum_pg_operator_oprjoin, Anum_pg_operator_oprkind, Anum_pg_operator_oprleft, Anum_pg_operator_oprname, Anum_pg_operator_oprnamespace, Anum_pg_operator_oprnegate, Anum_pg_operator_oprowner, Anum_pg_operator_oprrest, Anum_pg_operator_oprresult, Anum_pg_operator_oprright, BoolGetDatum, BOOLOID, CatalogUpdateIndexes(), CharGetDatum, elog, ereport, errcode(), errmsg(), ERROR, get_func_rettype(), get_other_operator(), GetUserId(), heap_close, heap_form_tuple(), heap_modify_tuple(), heap_open(), HeapTupleIsValid, i, InvokeObjectPostCreateHook, makeOperatorDependencies(), NameGetDatum, NameListToString(), namestrcpy(), NULL, ObjectIdGetDatum, OidIsValid, OperatorRelationId, OperatorUpd(), OPEROID, pg_oper_ownercheck(), RelationData::rd_att, RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy1, simple_heap_update(), HeapTupleData::t_self, validOperatorName(), and values.

Referenced by DefineOperator().

{
    Relation    pg_operator_desc;
    HeapTuple   tup;
    bool        nulls[Natts_pg_operator];
    bool        replaces[Natts_pg_operator];
    Datum       values[Natts_pg_operator];
    Oid         operatorObjectId;
    bool        operatorAlreadyDefined;
    Oid         operResultType;
    Oid         commutatorId,
                negatorId;
    bool        selfCommutator = false;
    NameData    oname;
    TupleDesc   tupDesc;
    int         i;

    /*
     * Sanity checks
     */
    if (!validOperatorName(operatorName))
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_NAME),
                 errmsg("\"%s\" is not a valid operator name",
                        operatorName)));

    if (!(OidIsValid(leftTypeId) && OidIsValid(rightTypeId)))
    {
        /* If it's not a binary op, these things mustn't be set: */
        if (commutatorName)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only binary operators can have commutators")));
        if (OidIsValid(joinId))
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                 errmsg("only binary operators can have join selectivity")));
        if (canMerge)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only binary operators can merge join")));
        if (canHash)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only binary operators can hash")));
    }

    operResultType = get_func_rettype(procedureId);

    if (operResultType != BOOLOID)
    {
        /* If it's not a boolean op, these things mustn't be set: */
        if (negatorName)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only boolean operators can have negators")));
        if (OidIsValid(restrictionId))
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only boolean operators can have restriction selectivity")));
        if (OidIsValid(joinId))
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                errmsg("only boolean operators can have join selectivity")));
        if (canMerge)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only boolean operators can merge join")));
        if (canHash)
            ereport(ERROR,
                    (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
                     errmsg("only boolean operators can hash")));
    }

    operatorObjectId = OperatorGet(operatorName,
                                   operatorNamespace,
                                   leftTypeId,
                                   rightTypeId,
                                   &operatorAlreadyDefined);

    if (operatorAlreadyDefined)
        ereport(ERROR,
                (errcode(ERRCODE_DUPLICATE_FUNCTION),
                 errmsg("operator %s already exists",
                        operatorName)));

    /*
     * At this point, if operatorObjectId is not InvalidOid then we are
     * filling in a previously-created shell.  Insist that the user own any
     * such shell.
     */
    if (OidIsValid(operatorObjectId) &&
        !pg_oper_ownercheck(operatorObjectId, GetUserId()))
        aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
                       operatorName);

    /*
     * Set up the other operators.  If they do not currently exist, create
     * shells in order to get ObjectId's.
     */

    if (commutatorName)
    {
        /* commutator has reversed arg types */
        commutatorId = get_other_operator(commutatorName,
                                          rightTypeId, leftTypeId,
                                          operatorName, operatorNamespace,
                                          leftTypeId, rightTypeId,
                                          true);

        /* Permission check: must own other operator */
        if (OidIsValid(commutatorId) &&
            !pg_oper_ownercheck(commutatorId, GetUserId()))
            aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
                           NameListToString(commutatorName));

        /*
         * self-linkage to this operator; will fix below. Note that only
         * self-linkage for commutation makes sense.
         */
        if (!OidIsValid(commutatorId))
            selfCommutator = true;
    }
    else
        commutatorId = InvalidOid;

    if (negatorName)
    {
        /* negator has same arg types */
        negatorId = get_other_operator(negatorName,
                                       leftTypeId, rightTypeId,
                                       operatorName, operatorNamespace,
                                       leftTypeId, rightTypeId,
                                       false);

        /* Permission check: must own other operator */
        if (OidIsValid(negatorId) &&
            !pg_oper_ownercheck(negatorId, GetUserId()))
            aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
                           NameListToString(negatorName));
    }
    else
        negatorId = InvalidOid;

    /*
     * set up values in the operator tuple
     */

    for (i = 0; i < Natts_pg_operator; ++i)
    {
        values[i] = (Datum) NULL;
        replaces[i] = true;
        nulls[i] = false;
    }

    namestrcpy(&oname, operatorName);
    values[Anum_pg_operator_oprname - 1] = NameGetDatum(&oname);
    values[Anum_pg_operator_oprnamespace - 1] = ObjectIdGetDatum(operatorNamespace);
    values[Anum_pg_operator_oprowner - 1] = ObjectIdGetDatum(GetUserId());
    values[Anum_pg_operator_oprkind - 1] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l');
    values[Anum_pg_operator_oprcanmerge - 1] = BoolGetDatum(canMerge);
    values[Anum_pg_operator_oprcanhash - 1] = BoolGetDatum(canHash);
    values[Anum_pg_operator_oprleft - 1] = ObjectIdGetDatum(leftTypeId);
    values[Anum_pg_operator_oprright - 1] = ObjectIdGetDatum(rightTypeId);
    values[Anum_pg_operator_oprresult - 1] = ObjectIdGetDatum(operResultType);
    values[Anum_pg_operator_oprcom - 1] = ObjectIdGetDatum(commutatorId);
    values[Anum_pg_operator_oprnegate - 1] = ObjectIdGetDatum(negatorId);
    values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(procedureId);
    values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(restrictionId);
    values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(joinId);

    pg_operator_desc = heap_open(OperatorRelationId, RowExclusiveLock);

    /*
     * If we are replacing an operator shell, update; else insert
     */
    if (operatorObjectId)
    {
        tup = SearchSysCacheCopy1(OPEROID,
                                  ObjectIdGetDatum(operatorObjectId));
        if (!HeapTupleIsValid(tup))
            elog(ERROR, "cache lookup failed for operator %u",
                 operatorObjectId);

        tup = heap_modify_tuple(tup,
                                RelationGetDescr(pg_operator_desc),
                                values,
                                nulls,
                                replaces);

        simple_heap_update(pg_operator_desc, &tup->t_self, tup);
    }
    else
    {
        tupDesc = pg_operator_desc->rd_att;
        tup = heap_form_tuple(tupDesc, values, nulls);

        operatorObjectId = simple_heap_insert(pg_operator_desc, tup);
    }

    /* Must update the indexes in either case */
    CatalogUpdateIndexes(pg_operator_desc, tup);

    /* Add dependencies for the entry */
    makeOperatorDependencies(tup);

    /* Post creation hook for new operator */
    InvokeObjectPostCreateHook(OperatorRelationId, operatorObjectId, 0);

    heap_close(pg_operator_desc, RowExclusiveLock);

    /*
     * If a commutator and/or negator link is provided, update the other
     * operator(s) to point at this one, if they don't already have a link.
     * This supports an alternative style of operator definition wherein the
     * user first defines one operator without giving negator or commutator,
     * then defines the other operator of the pair with the proper commutator
     * or negator attribute.  That style doesn't require creation of a shell,
     * and it's the only style that worked right before Postgres version 6.5.
     * This code also takes care of the situation where the new operator is
     * its own commutator.
     */
    if (selfCommutator)
        commutatorId = operatorObjectId;

    if (OidIsValid(commutatorId) || OidIsValid(negatorId))
        OperatorUpd(operatorObjectId, commutatorId, negatorId);

    return operatorObjectId;
}


Variable Documentation

Definition at line 51 of file pg_operator.h.