diff --git a/contrib/citext/citext.cpp b/contrib/citext/citext.cpp index 3f318c50a..96894063e 100644 --- a/contrib/citext/citext.cpp +++ b/contrib/citext/citext.cpp @@ -240,26 +240,38 @@ Datum citext_ge(PG_FUNCTION_ARGS) * =================== */ -PG_FUNCTION_INFO_V1(citext_smaller); - -Datum citext_smaller(PG_FUNCTION_ARGS) -{ - text* left = PG_GETARG_TEXT_PP(0); - text* right = PG_GETARG_TEXT_PP(1); - text* result = NULL; - - result = (citextcmp(left, right, PG_GET_COLLATION()) < 0) ? left : right; - PG_RETURN_TEXT_P(result); -} - -PG_FUNCTION_INFO_V1(citext_larger); - -Datum citext_larger(PG_FUNCTION_ARGS) -{ - text* left = PG_GETARG_TEXT_PP(0); - text* right = PG_GETARG_TEXT_PP(1); - text* result = NULL; - - result = (citextcmp(left, right, PG_GET_COLLATION()) > 0) ? left : right; - PG_RETURN_TEXT_P(result); -} +// Declare a function named citext_smaller, which is an internal function of PostgreSQL, used to compare whether the first citext value is smaller than the second. +PG_FUNCTION_INFO_V1(citext_smaller); + +// Implement the citext_smaller function. This function takes two parameters (two text* pointers) and returns a text* value. +Datum citext_smaller(PG_FUNCTION_ARGS) +{ + // Get the first and second text* pointers from the function parameters and assign them to left and right respectively. + text* left = PG_GETARG_TEXT_PP(0); + text* right = PG_GETARG_TEXT_PP(1); + // Initialize a text* variable result, which will store the result of the comparison. + text* result = NULL; + + // Use the citextcmp function to compare left and right. If left is smaller than right, assign left to result; otherwise, assign right to result. + result = (citextcmp(left, right, PG_GET_COLLATION()) < 0) ? left : right; + // Return the result of the comparison. + PG_RETURN_TEXT_P(result); +} + +// Declare a function named citext_larger, which is an internal function of PostgreSQL, used to compare whether the first citext value is larger than the second. +PG_FUNCTION_INFO_V1(citext_larger); + +// Implement the citext_larger function. This function takes two parameters (two text* pointers) and returns a text* value. +Datum citext_larger(PG_FUNCTION_ARGS) +{ + // Get the first and second text* pointers from the function parameters and assign them to left and right respectively. + text* left = PG_GETARG_TEXT_PP(0); + text* right = PG_GETARG_TEXT_PP(1); + // Initialize a text* variable result, which will store the result of the comparison. + text* result = NULL; + + // Use the citextcmp function to compare left and right. If left is larger than right, assign left to result; otherwise, assign right to result. + result = (citextcmp(left, right, PG_GET_COLLATION()) > 0) ? left : right; + // Return the result of the comparison. + PG_RETURN_TEXT_P(result); +} \ No newline at end of file