RE: Syntax checking DO blocks and ALTER TABLE statements?

Поиск
Список
Период
Сортировка
От Kevin Brannen
Тема RE: Syntax checking DO blocks and ALTER TABLE statements?
Дата
Msg-id SN6PR19MB235186CCE9C40E5D0D0F5BD7A4849@SN6PR19MB2351.namprd19.prod.outlook.com
обсуждение исходный текст
Ответ на Syntax checking DO blocks and ALTER TABLE statements?  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: Syntax checking DO blocks and ALTER TABLE statements?  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
>From: Ron <ronljohnsonjr@gmail.com>
>
>How does one go about syntax checking this?
>
>do $$
>begin if exists (select 1 from information_schema.table_constraints
>        where constraint_name = 'error_to_web_service_error') then
>             raise notice 'EXISTS error_to_web_service_error';
>     else
>         ALTER TABLE web_service_error
>            ADD CONSTRAINT error_to_web_service_error FOREIGN KEY (error_id)
>            REFERENCES error_code(error_id)
>            ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE;
>     end if
>end $$
>
>(There are 222 ALTER TABLE ADD FOREIGN KEY statements that I'm wrapping in similar DO blocks, and want to make sure
thestatements are clean.)
 


I've always wondered why Pg doesn't have something like that built in, but I suppose the obvious answer is that no one
hasfelt like scratching that itch.
 

Have you checked out:  https://github.com/okbob/plpgsql_check

I don't know if it'll do everything you want, but maybe it'd help at least some. It's on my to-do list to check out one
daywhen I have time. :)
 

HTH,
Kevin
This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain confidential
information.If you are not the intended recipient, or a person responsible for delivering it to the intended recipient,
youare hereby notified that any disclosure, distribution, review, copy or use of any of the information contained in or
attachedto this message is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately
notifyus by reply e-mail, and destroy the original transmission and its attachments without reading them or saving them
todisk. Thank you.
 

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Error with pg_dump (of data), with --role
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Syntax checking DO blocks and ALTER TABLE statements?