Re: Altering array(composite-types) without breaking code when inserting them and similar questions - Mailing list pgsql-general

From David G Johnston
Subject Re: Altering array(composite-types) without breaking code when inserting them and similar questions
Date
Msg-id 1398015018621-5800848.post@n5.nabble.com
Whole thread Raw
In response to Altering array(composite-types) without breaking code when inserting them and similar questions  (Dorian Hoxha <dorian.hoxha@gmail.com>)
List pgsql-general
Dorian Hoxha wrote
> Hi list,
>
> I have a
> create type thetype(width integer, height integer);
> create table mytable(thetype thetype[]);
>
> How can i make an insert statement so if i later add fields to the
> composite type, the code/query doesn't break ?
> Maybe by specifying the fields of the composite type in the query ?
>
> This can be done for normal inserts(non arrays):
> CREATE TABLE mytable (t thetype);
> INSERT INTO mytable(t.width, t.height) VALUES (11,22);
>
>
> Also how to update an whole element of an array of composites ?
> Also, how to update an attribute in a specific element in an array of
> composites?
>
> (so when i add columns later to the composite, my old code doesn't break)
>
> How much overhead have the composite types beside the values and nulls?
>
> Thanks

You should probably just use a table...

I'm doubtful you can alter the type without breaking code.

You can replace a entire single array element as described in the
documentation.  You cannot update single attributes.

As to the overhead question what are you comparing against and what do you
want to measure?

David J.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Altering-array-composite-types-without-breaking-code-when-inserting-them-and-similar-questions-tp5800847p5800848.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Dorian Hoxha
Date:
Subject: Altering array(composite-types) without breaking code when inserting them and similar questions
Next
From: Fede Martinez
Date:
Subject: Re: Altering array(composite-types) without breaking code when inserting them and similar questions