Re: Privilege required for IF EXISTS event if the object already exists

Поиск
Список
Период
Сортировка
От Shay Rojansky
Тема Re: Privilege required for IF EXISTS event if the object already exists
Дата
Msg-id CADT4RqCY=wHsgDw6pws49Xp1p=Vnbu7z5NzOAeoGQKuesjb+WA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Privilege required for IF EXISTS event if the object already exists  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Privilege required for IF EXISTS event if the object already exists  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
>> Now, before creating tables, the ORM generates CREATE SCHEMA IF NOT EXISTS, to ensure that the schema exists before CREATE TABLE; that's reasonable general-purpose behavior.
>
If the user hasn’t specified they want the schema created it’s arguable that executing create schema anyway is reasonable.  The orm user should know whether they are expected/able to create the schema as part of their responsibilities and instruct the orm accordingly and expect it to only create what it has been explicitly directed to create.

I think the point being missed here, is that the user isn't interacting directly with PostgreSQL - they're doing so via an ORM which isn't necessarily aware of everything. Yes, a switch could be added to the ORM where the user instructs it to not ensure that the schema exists, but that's placing unnecessary burden on the user - having the "ensure" operation silently no-op (instead of throwing) if the schema already exists just makes everything smoother.

Put another way, let's say I introduce a user-facing flag in my ORM to opt out of CREATE SCHEMA IF NOT EXISTS. If the user forget to pre-create the schema, they would still get an error when trying to create the tables (since the schema doesn't exist). So failure to properly set up would generate an error in any case, either when trying to create the schema (if no flag is added), or when trying to create the table (if the flag is added). This makes the flag pretty useless and an unnecesary extra burden on the user, when the database could simply be ignoring CREATE SCHEMA IF NOT EXISTS for the case where the schema already exists.

Is there any specific reason you think this shouldn't be done?

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

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Unnecessary delay in streaming replication due to replay lag
Следующее
От: Ronan Dunklau
Дата:
Сообщение: Re: Use generation context to speed up tuplesorts