Re: The problem is related to concurrent resquests

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема Re: The problem is related to concurrent resquests
Дата
Msg-id A737B7A37273E048B164557ADEF4A58B53852F56@ntex2010i.host.magwien.gv.at
обсуждение исходный текст
Ответ на Re: The problem is related to concurrent resquests  (Nguyen Hoai Nam <namptit307@gmail.com>)
Ответы Re: The problem is related to concurrent resquests
Список pgsql-admin
Nguyen Hoai Nam wrote:
> Thank you so much for your time. Let me explain my problem:
> 
> 1. There are some conditions which I must follow it.
> 
> Condition 1: the type of "subnet" is varchar(30),
> Condition 2: currently, I am about to use trigger and function to detect and prevent CIDR overlapping
> (subnet's value)
> 
> 2. What I am doing
> 
> 2.1 Writing a function can detect overlap CIDR (called cidr_overlap).
[...]
> 2.2 Writing a function for trigger and a trigger as follows:
> 
[...]
> - Create trigger:
[...]
> 
> 
> Please don't follow detail syntax. Something like that. Actually, this method is good active in case
> of request sequently. But in case of we have two resquest which insert to DB at the same time (it mean
> there are concurrent request). Have you ever see this problem, could please give me some advices to
> slove it.

A trigger cannot guarantee that the condition will always be satisfied.
At the time that the concurrent triggers run the SELECT, everything is fine.

Do use an SQL contraint to enforce a table constraint.
If you really need to store "subnet" as varchar (why?), define the constraint like this:

EXCLUDE USING gist (subnet::cidr inet_ops WITH &&)

Yours,
Laurenz Albe

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

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: very slow postgresql startup
Следующее
От: zz_11@mail.bg
Дата:
Сообщение: Re: very slow postgresql startup