Thread: Array function
Folks, Here's a little addition to the array functions & operators section of the manual. It adds a function array() to the list. Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
Attachment
David Fetter <david@fetter.org> writes: > Here's a little addition to the array functions & operators section of > the manual. It adds a function array() to the list. The ARRAY() construct isn't really a function; it is a special syntax documented in Array Constructors, http://developer.postgresql.org/docs/postgres/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS The addition you propose is misleading, because it would lead people to expect to find array() in the output of \df, for example. It might be reasonable to put in some kind of "see also" cross-reference in the array functions section, but we shouldn't list array() as though it were just like every other function in the section. regards, tom lane
On Sun, Oct 31, 2004 at 10:40:47PM -0500, Tom Lane wrote: > David Fetter <david@fetter.org> writes: > > Here's a little addition to the array functions & operators section of > > the manual. It adds a function array() to the list. > > The ARRAY() construct isn't really a function; it is a special > syntax documented in Array Constructors, > http://developer.postgresql.org/docs/postgres/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS > > The addition you propose is misleading, because it would lead people > to expect to find array() in the output of \df, for example. It > might be reasonable to put in some kind of "see also" > cross-reference in the array functions section, but we shouldn't > list array() as though it were just like every other function in the > section. Good point. Please find attached a different diff :) Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
Attachment
David Fetter wrote: > Please find attached a different diff :) If you want to write a note, use the <note> element. -- Peter Eisentraut http://developer.postgresql.org/~petere/
BTW, it seems it would be useful to dedicate a chapter to array handling, since it's something that's not very common amongst databases. On Sun, Oct 31, 2004 at 04:36:14PM -0800, David Fetter wrote: > Folks, > > Here's a little addition to the array functions & operators section of > the manual. It adds a function array() to the list. > > Cheers, > D -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"
On Mon, Nov 01, 2004 at 08:47:05PM +0100, Peter Eisentraut wrote: > David Fetter wrote: > > Please find attached a different diff :) > > If you want to write a note, use the <note> element. Thanks for the tip :) Fixed, attaching a diff against CVS HEAD. Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
Attachment
On Mon, Nov 01, 2004 at 01:59:13PM -0600, Jim C. Nasby wrote: > On Sun, Oct 31, 2004 at 04:36:14PM -0800, David Fetter wrote: > > Folks, > > > > Here's a little addition to the array functions & operators > > section of the manual. It adds a function array() to the list. > > > > Cheers, D > > BTW, it seems it would be useful to dedicate a chapter to array > handling, since it's something that's not very common amongst > databases. I guess it depends what you mean. Oracle has "subtables," and other things have stuff like that. Also, it's in the SQL standard... Anyhow, where do you think it should go? Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
David Fetter wrote: > Anyhow, where do you think it should go? In the chapter on data types -- where it already is. -- Peter Eisentraut http://developer.postgresql.org/~petere/
The datatypes chapter mentions nothing about ARRAY(), for starters. I'm not suggesting that the reference is incomplete, but I think a chapter explaining some about arrays, how to use them, and what you can do with them would be useful. On Mon, Nov 01, 2004 at 11:11:31PM +0100, Peter Eisentraut wrote: > David Fetter wrote: > > Anyhow, where do you think it should go? > > In the chapter on data types -- where it already is. > > -- > Peter Eisentraut > http://developer.postgresql.org/~petere/ > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"
Here's an example I just thought of that would be great to document: I have an array of integers. I'd like to also associate some names with them. I can't do this in the same array, but I can do it in a different array. But how do I ensure that when I build that array using name=ARRAY(SELECT name FROM table WHERE id = ANY(id_array) ) that name[1] actually corresponds to id_array[1]? On Tue, Nov 02, 2004 at 02:43:42PM -0600, Jim C. Nasby wrote: > The datatypes chapter mentions nothing about ARRAY(), for starters. I'm > not suggesting that the reference is incomplete, but I think a chapter > explaining some about arrays, how to use them, and what you can do with > them would be useful. > > On Mon, Nov 01, 2004 at 11:11:31PM +0100, Peter Eisentraut wrote: > > David Fetter wrote: > > > Anyhow, where do you think it should go? > > > > In the chapter on data types -- where it already is. > > > > -- > > Peter Eisentraut > > http://developer.postgresql.org/~petere/ > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > -- > Jim C. Nasby, Database Consultant decibel@decibel.org > Give your computer some brain candy! www.distributed.net Team #1828 > > Windows: "Where do you want to go today?" > Linux: "Where do you want to go tomorrow?" > FreeBSD: "Are you guys coming, or what?" > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -- Jim C. Nasby, Database Consultant decibel@decibel.org Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?"
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. --------------------------------------------------------------------------- David Fetter wrote: > On Mon, Nov 01, 2004 at 08:47:05PM +0100, Peter Eisentraut wrote: > > David Fetter wrote: > > > Please find attached a different diff :) > > > > If you want to write a note, use the <note> element. > > Thanks for the tip :) > > Fixed, attaching a diff against CVS HEAD. > > Cheers, > D > -- > David Fetter david@fetter.org http://fetter.org/ > phone: +1 510 893 6100 mobile: +1 415 235 3778 > > Remember to vote! [ Attachment, skipping... ] > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
FYI, this discussion about adding a separate array section to the docs (which we already have, as Peter pointed out) is independent of the ARRAY() documentation addition I just put in the patch queue. --------------------------------------------------------------------------- David Fetter wrote: > On Mon, Nov 01, 2004 at 01:59:13PM -0600, Jim C. Nasby wrote: > > On Sun, Oct 31, 2004 at 04:36:14PM -0800, David Fetter wrote: > > > Folks, > > > > > > Here's a little addition to the array functions & operators > > > section of the manual. It adds a function array() to the list. > > > > > > Cheers, D > > > > BTW, it seems it would be useful to dedicate a chapter to array > > handling, since it's something that's not very common amongst > > databases. > > I guess it depends what you mean. Oracle has "subtables," and other > things have stuff like that. Also, it's in the SQL standard... > > Anyhow, where do you think it should go? > > Cheers, > D > -- > David Fetter david@fetter.org http://fetter.org/ > phone: +1 510 893 6100 mobile: +1 415 235 3778 > > Remember to vote! > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Patch applied. Thanks. --------------------------------------------------------------------------- David Fetter wrote: > On Mon, Nov 01, 2004 at 08:47:05PM +0100, Peter Eisentraut wrote: > > David Fetter wrote: > > > Please find attached a different diff :) > > > > If you want to write a note, use the <note> element. > > Thanks for the tip :) > > Fixed, attaching a diff against CVS HEAD. > > Cheers, > D > -- > David Fetter david@fetter.org http://fetter.org/ > phone: +1 510 893 6100 mobile: +1 415 235 3778 > > Remember to vote! [ Attachment, skipping... ] > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073