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

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Altering array(composite-types) without breaking code when inserting them and similar questions
Дата
Msg-id 1398015018621-5800848.post@n5.nabble.com
обсуждение исходный текст
Ответ на Altering array(composite-types) without breaking code when inserting them and similar questions  (Dorian Hoxha <dorian.hoxha@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Dorian Hoxha
Дата:
Сообщение: Altering array(composite-types) without breaking code when inserting them and similar questions
Следующее
От: Fede Martinez
Дата:
Сообщение: Re: Altering array(composite-types) without breaking code when inserting them and similar questions