11/6/2023 0 Comments Postgresql operator for any![]() Each use is valid, as the operator was overloaded in Example 7-55. Example 7-56 demonstrates three uses of the same operator, with different Once overloaded, PostgreSQL's parser can correctly interpret each defined operator in your As there are twoĬopies of the is_zero() function-one that accepts one argument, and one thatĪccepts two-the !# operator can be safely overloaded to accept both a singleĪrgument (on either the left or right side), as well as to accept parameters from both sides. The same is_zero() function because the function itself was overloaded in Example 7-50 in the Section called Creating C functions," earlier in this chapter. Overloading a user-defined operator booktown=# CREATE OPERATOR !# (PROCEDURE = is_zero,īooktown=# CREATE OPERATOR !# (PROCEDURE = is_zero,Įxample 7-55 overloads the !# operator with The !# operator, which operates on both an argument to the left andĮxample 7-55. The main reason for having operator classes is that for some data types, there could be more than one meaningful index behavior. The second statement creates a third variant of Right of the operator, rather than the left. The same name which operates on an argument of type integer to the Than a LEFTARG clause, resulting in a version of the operator with However, it specifies a RIGHTARG clause rather The firstĬREATE OPERATOR statement creates a similar operator to the one created inĮxample 7-53. Long as a function exists to accept the number and type of arguments implied by the type of operator defined, though, theĮxample 7-53 overloads the !# operator. Same name, although two operators may not share the same name if they accept the same argument definitions. The same name as an existing operator, but affects a different set of defined types. This means that an operator is created with Operators may become overloaded in much the same way as functions. This means that the syntax of value !# will beĮffectively identical to using the functional syntax of is_zero(value). Value to its left to the is_zero() function (defined in Example 7-49). ![]() Furthermore, the function's acceptedĪrgument types should match the relevant operator types defined by CREATE OPERATOR forĮxample 7-53 creates an operator named !#, which passes the RIGHTARG keywords (either one or two arguments). Must accept the appropriate number of arguments as implied by the use of the LEFTARG and That affects values both on the left and right of the operator. Values to its left, while the addition operator ( +) is a good example of an operator The factorial operator ( !) is an example of a built-in operator that affects Specifying both a LEFTARG and RIGHTARG type results inĪn operator that operates on a value to both the left and right. RIGHTARG data type creates an operator that operates only on a value to its right. Value (e.g., a constant or identifier) to its left. Specifying only the LEFTARG data type creates an operator that operates only on a Optional clauses, and further restrictions on the operator name. Note: See the reference entry on CREATE OPERATOR for more information on the remaining ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |