[PATCH] Explain generate_subscripts() more clearly
От | Tim Landscheidt |
---|---|
Тема | [PATCH] Explain generate_subscripts() more clearly |
Дата | |
Msg-id | m3d3z1eif4.fsf@passepartout.tim-landscheidt.de обсуждение исходный текст |
Ответы |
Re: [PATCH] Explain generate_subscripts() more clearly
|
Список | pgsql-docs |
Hi, the current documentation on generate_subscripts() uses a "rectangular" example, i. e. where both arrays in question have the same length (that is furthermore equal to the num- ber of arrays, a "square" example so to speak :-)). To point out that generate_subscripts () can be used for more complex cases as well, please find attached patch. Tim diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3419440..2677db9 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -11427,21 +11427,22 @@ select generate_subscripts('{NULL,1,NULL,2}'::int[], 1) as s; -- presenting an array, the subscript and the subscripted -- value requires a subquery select * from arrays; - a --------------------- + a +--------------- {-1,-2} - {100,200} -(2 rows) + {100,200,300} +(2 Zeilen) select a as array, s as subscript, a[s] as value from (select generate_subscripts(a, 1) as s, a from arrays) foo; - array | subscript | value ------------+-----------+------- - {-1,-2} | 1 | -1 - {-1,-2} | 2 | -2 - {100,200} | 1 | 100 - {100,200} | 2 | 200 -(4 rows) + array | subscript | value +---------------+-----------+------- + {-1,-2} | 1 | -1 + {-1,-2} | 2 | -2 + {100,200,300} | 1 | 100 + {100,200,300} | 2 | 200 + {100,200,300} | 3 | 300 +(5 Zeilen) -- unnest a 2D array create or replace function unnest2(anyarray)
В списке pgsql-docs по дате отправления: