diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml index b3630b4..d90266f 100644 --- a/doc/src/sgml/array.sgml +++ b/doc/src/sgml/array.sgml @@ -601,8 +601,8 @@ SELECT * FROM sal_emp WHERE pay_by_quarter && ARRAY[10000]; - You can also search any value in array using the array_offset - function (It returns a position of first occurrence of value in the array): + You can also search for a value in an array using the array_offset + function. It returns the position of the first occurrence of a value in an array: SELECT array_offset(ARRAY['sun','mon','tue','wen','thu','fri','sat'], 'mon'); diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 48b23ee..311f2fe 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -11606,10 +11606,12 @@ SELECT NULLIF(value, '(none)') ... int - returns a offset of first occurrence of some element in a array. It uses - a IS NOT DISTINCT FROM operator for comparation. Third - optional argument can specify a initial offset when searching starts. - Returns NULL when there are not occurence of value in array. + returns the offset of the first occurrence of a value in an + array. It uses the IS NOT DISTINCT FROM operator for + comparation. The optional third argument specifies an initial offset to + begin the search at. Returns NULL when the value is not found. Note: + multi-dimensional arrays are squashed to one dimension before + searching. array_offset(ARRAY['sun','mon','tue','wen','thu','fri','sat'], 'mon') 2 @@ -11620,9 +11622,11 @@ SELECT NULLIF(value, '(none)') ... int[] - returns a array of offset of all occurrences some element in a array. It uses - a IS NOT DISTINCT FROM operator for comparation. Returns empty array, - when there are no occurence of element in input array. + returns an array of offsets of all occurrences of a value in a array. It uses + the IS NOT DISTINCT FROM operator for comparation. Returns an empty array + when there are no occurences of the value in the array. Note: + multi-dimensional input arrays are squashed to one dimension before + searching. array_offsets(ARRAY['A','A','B','A'], 'A') {1,2,4} diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index 0b53b9a..f7b7932 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -659,9 +659,9 @@ array_agg_array_finalfn(PG_FUNCTION_ARGS) /* - * array_offset - returns a offset of entered element in a array. - * Returns NULL when values is not a element of the array. It allow - * searching a NULL value due using a NOT DISTINCT FROM operator. + * array_offset - returns the offset of a value in an array. + * Returns NULL when value is not found. Uses NOT DISTINCT FROM operator to + * allow searching for NULL. * * Biggest difference against width_array is unsorted input array. */