Re: INSERT INTO arr2(array[1].d, array[2].d)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Jim Nasby <jim(dot)nasby(at)openscg(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INSERT INTO arr2(array[1].d, array[2].d)
Date: 2017-03-11 21:13:23
Message-ID: 20170311211323.hk6fovmcu2qjmchq@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2017-03-11 14:43:55 -0600, Jim Nasby wrote:
> Over in [1], I was very surprised to discover $SUBJECT[2]. I looked in the
> docs, and they clearly indicate that INSERT accepts "column names".

They also say "The column name can be qualified with a subfield name or
array subscript, if needed."

> What's the best way to describe this? "column expression"? "field
> expression"?

field expression is the better of the two, but I'm not really convinced
changing.

For reference:
> 1: https://www.postgresql.org/message-id/20170311005810.kuccp7t5t5jhe736@alap3.anarazel.de

>
> 2:
> CREATE TABLE arr(d int[]);
> CREATE TABLE arr2(arr arr)
> INSERT INTO arr2(arr[1].d, arr[2].d) VALUES(ARRAY[1,2],ARRAY[3,4]) RETURNING
> *
> ┌───────────────────────────────┐
> │ arr │
> ├───────────────────────────────┤
> │ {"(\"{1,2}\")","(\"{3,4}\")"} │
> └───────────────────────────────┘

- Andres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-03-11 21:14:36 Re: How to get the 'ctid' from a record type?
Previous Message Fabien COELHO 2017-03-11 21:04:53 Re: [HACKERS] Small issue in online devel documentation build