Re: Regression tests and NOTICE statements
От | Tom Lane |
---|---|
Тема | Re: Regression tests and NOTICE statements |
Дата | |
Msg-id | 19091.1020952775@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Regression tests and NOTICE statements ("Rod Taylor" <rbt@zort.ca>) |
Список | pgsql-hackers |
"Rod Taylor" <rbt@zort.ca> writes: > Ok, I need something guarenteed unique, system generated, and I really > didn't like the way CHECK constraints test a name, increment a > counter, test the new name, increment a counter, test yet another > name, increament a counter, ..... > So.. Is there a good way to do this? Or was the above CHECK > constraint method of testing ~10 different names with each creation > good enough. It seems like a perfectly fine way to me. I like it because it gives predictable results (ie, same table schema will always be assigned the same numbers), which the OID approach doesn't. Also, if you want something *guaranteed* unique then you must do this even with OIDs; there's nothing stopping the user from declaring a constraint with a name "foo_nnnnnnn" that happens to match the OID-based name you invent for its unnamed sibling. I suppose with lots and lots of constraints the O(N^2) time behavior might start to be a problem, but there are probably ways around that too --- say, keep a counter in analyze.c that starts at 1 for each new CREATE TABLE, and is incremented each time you need to invent a constraint name. You still have to check-and-retry, but the expected time is O(N) not O(N^2). regards, tom lane
В списке pgsql-hackers по дате отправления: