Re: table lock when where clause uses unique constraing instead of primary key.

Поиск
Список
Период
Сортировка
От Jeff Amiel
Тема Re: table lock when where clause uses unique constraing instead of primary key.
Дата
Msg-id 1383597847.53321.YahooMailNeo@web161402.mail.bf1.yahoo.com
обсуждение исходный текст
Ответ на Re: table lock when where clause uses unique constraing instead of primary key.  (Adrian Klaver <adrian.klaver@gmail.com>)
Ответы Re: table lock when where clause uses unique constraing instead of primary key.  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-general




On Monday, November 4, 2013 2:25 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

>
> I grepped the schema (just to be sure) - no foreign keys on columns or table at all.
> I do have an audit trigger on the table for updates - inserts into an audit table when changes are made and it DOES
doa separate select from user_profile for other reasons - but not "for update" or anything - no explicit locking. 
>

>Would it be possible to see that audit function?

it's kind of long (really just a lot of compares of old/new values.
The relevant portion (that selects from user_profile) looks like this:

BEGIN
            SELECT user_id, user_ip INTO my_user_id, my_user_ip FROM audit_metadata WHERE pg_pid = getpid();
            IF ((NOT FOUND) OR (my_user_id = -1)) THEN
                SELECT user_id INTO my_user_id FROM user_profile WHERE username = 'db-'||CURRENT_USER and
user_type='DBASE';
                IF (NOT FOUND) THEN
                     RAISE EXCEPTION 'USERNAME NOT FOUND IN USER_PROFILE: % ',CURRENT_USER;
                END IF;
                my_user_ip := inet_client_addr();
            END IF;

            INSERT INTO audit .....
       
        END;



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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: table lock when where clause uses unique constraing instead of primary key.
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: table lock when where clause uses unique constraing instead of primary key.