public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tim Landscheidt <[email protected]>
To: [email protected]
Subject: [PATCH] Explain generate_subscripts() more clearly
Date: Thu, 18 Mar 2010 15:52:31 +0000
Message-ID: <[email protected]> (raw)
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
Attachments:
[text/x-patch] generate-subscripts-doc.patch (1.1K, 2-generate-subscripts-doc.patch)
download | inline diff:
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)
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Explain generate_subscripts() more clearly
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox