Array function

Started by David Fetterover 21 years ago13 messagesdocs
Jump to latest
#1David Fetter
david@fetter.org

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!

Attachments:

array_func.difftext/plain; charset=us-asciiDownload+14-0
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#1)
Re: Array function

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

#3David Fetter
david@fetter.org
In reply to: Tom Lane (#2)
Re: Array function

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!

Attachments:

array.difftext/plain; charset=us-asciiDownload+10-0
#4Peter Eisentraut
peter_e@gmx.net
In reply to: David Fetter (#3)
Re: Array function

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/

#5Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: David Fetter (#1)
Re: Array function

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?"

#6David Fetter
david@fetter.org
In reply to: Peter Eisentraut (#4)
Re: Array function

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!

Attachments:

array.difftext/plain; charset=us-asciiDownload+12-0
#7David Fetter
david@fetter.org
In reply to: Jim Nasby (#5)
Re: Array function

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!

#8Peter Eisentraut
peter_e@gmx.net
In reply to: David Fetter (#7)
Re: Array function

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/

#9Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Peter Eisentraut (#8)
Re: Array function

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?"

#10Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Jim Nasby (#9)
Re: Array function

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?"

#11Bruce Momjian
bruce@momjian.us
In reply to: David Fetter (#6)
Re: Array function

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
#12Bruce Momjian
bruce@momjian.us
In reply to: David Fetter (#7)
Re: Array function

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
#13Bruce Momjian
bruce@momjian.us
In reply to: David Fetter (#6)
Re: Array function

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