Serial and NULL values
От | Bruce Momjian |
---|---|
Тема | Serial and NULL values |
Дата | |
Msg-id | 199910292129.RAA13358@candle.pha.pa.us обсуждение исходный текст |
Ответы |
Re: [HACKERS] Serial and NULL values
|
Список | pgsql-hackers |
I just received a message from someone complaining about SERIAL/sequence. I think there is a problem:test=> create table test (x int, y serial);NOTICE: CREATE TABLE will create implicit sequence 'test_y_seq'for SERIAL column 'test.y'NOTICE: CREATE TABLE/UNIQUE will create implicit index 'test_y_key' for table 'test'CREATEtest=>insert into test (x) values (100);INSERT 19359 1test=> insert into test (x) values (100);INSERT 19360 1 These work fine, but why does this fail: test=> insert into test values (100, null);ERROR: ExecAppend: Fail to add null value in not null attribute ytest=> insertinto test values (100, 0);INSERT 19363 1test=> insert into test values (100, 0);ERROR: Cannot insert a duplicatekey into a unique index Can't they use zero or null, and have the sequence value be computed? Is there some design decision we made to prevent this? -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
В списке pgsql-hackers по дате отправления: