Re: change natural column order

Поиск
Список
Период
Сортировка
От Dann Corbit
Тема Re: change natural column order
Дата
Msg-id D425483C2C5C9F49B5B7A41F894415470556C1@postal.corporate.connx.com
обсуждение исходный текст
Ответ на change natural column order  ("Joolz" <joolz@arbodienst-limburg.nl>)
Ответы Re: change natural column order  (Steve Atkins <steve@blighty.com>)
Re: change natural column order  (Greg Stark <gsstark@mit.edu>)
Список pgsql-general
Using "SELECT * FROM <table_name>" from the PSQL prompt or any other interactive tool is perfectly fine.

Putting "SELECT * FROM <table_name>" into a compiled program using libpq or ESQL is a code defect.  Period.

    ALTER TABLE ADD COLUMN /* Most frequent defect maker for SELECT * */

    ALTER TABLE DROP COLUMN /* If you didn't need the column, who cares */

    ALTER TABLE RENAME COLUMN /* This will be a problem either way, but at least you will find out about it.  It also
showswhy renaming columns is almost always a very, very bad idea after any release. */ 

    ALTER TABLE SET WITHOUT OIDS {PG specific} /* One fewer column now, and all the column numbers are now 'off-by-one'
*/

    DROP TABLE/CREATE TABLE /* New version may have the same name and the same number of columns, and they may even
havethe same data types but there is no guarantee that the meaning is the same. */ 

The list goes on and on.

It is a defect of equal magnitude to assume that columns are returned in any particular order unless specified in a
columnlist (again, from a program and not interactively). 

Another typical defect is to assume that columns come backed ordered by the primary key if the table is clustered on
theprimary key column.  You can have a page split with many database systems and so there is no guarantee that data
willbe returned in order without an ORDER BY clause -- clustered or not. 

Any of (ASSMUME NO COLUMN CHANGES/ASSUME COLUMN ORDER/ASSUME CLUSTERED KEY SORT ORDER) would cause me to fail code in a
codereview. 

IMO-YMMV

В списке pgsql-general по дате отправления:

Предыдущее
От: Pierre-Frédéric Caillaud
Дата:
Сообщение: Re: change natural column order
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: Postgres Design