Re: ON CONFLICT DO SELECT (take 3)

Поиск
Список
Период
Сортировка
От jian he
Тема Re: ON CONFLICT DO SELECT (take 3)
Дата
Msg-id CACJufxGaSLpweeQfmFyxTAAOQqe-z_RWzMKWiPmH+GTn-u=cVQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: ON CONFLICT DO SELECT (take 3)  (Viktor Holmberg <v@viktorh.net>)
Ответы Re: ON CONFLICT DO SELECT (take 3)
Re: ON CONFLICT DO SELECT (take 3)
Список pgsql-hackers
On Mon, Nov 24, 2025 at 11:23 PM Viktor Holmberg <v@viktorh.net> wrote:
>
> It did not. But this will.
> For some reason, in this bit:
>
> ‘''
> LockTupleMode lockmode;
> ….
> case LCS_FORUPDATE:
>  lockmode = LockTupleExclusive;
>  break;
>  case LCS_NONE:
>  elog(ERROR, "unexpected lock strength %d", lockStrength);
>  }
>
>  if (!ExecOnConflictLockRow(context, existing, conflictTid,
>  resultRelInfo->ri_RelationDesc, lockmode, false))
>  return false;
> ‘''
>
> GCC gives warning "error: ‘lockmode’ may be used uninitialized”. But if I switch the final exhaustive “case" to a
“default”the warning goes away. Strange, if anyone know how to fix let me know. But also I don’t think it’s a big deal. 

hi.
you can search ``/* keep compiler quiet */`` within the codebase.

after
``elog(ERROR, "unexpected lock strength %d", lockStrength);``
you can add
``
lockmode = LockTupleExclusive;
break;
``

in doc/src/sgml/mvcc.sgml:
   <para>
    <command>INSERT</command> with an <literal>ON CONFLICT DO
    NOTHING</literal> clause may have insertion not proceed for a row due to
    the outcome of another transaction whose effects are not visible
    to the <command>INSERT</command> snapshot.  Again, this is only
    the case in Read Committed mode.
   </para>
I think we need to add something after the above quoted paragraph.

doc/src/sgml/ref/create_view.sgml, some places also need to be updated, I think.
see text ON CONFLICT UPDATE in there.

I added some dummy tests on src/test/regress/sql/triggers.sql.
also did some minor doc changes.

please check the attached v16.
v16-0001: rebase and combine v15-0001, v15-0002, v15-0003, v15-0004 together.
v16-0002: using INJECTION_POINT to test the case when
ExecOnConflictSelect->ExecOnConflictLockRow returns false.

v16-0002, I use
```
        if (!ExecOnConflictLockRow(context, existing, conflictTid,
                                   resultRelInfo->ri_RelationDesc,
lockmode, false))
        {
            INJECTION_POINT("exec-onconflictselect-after-lockrow", NULL);
            elog(INFO, "this part is reached");
            return false;
        }
```
to demomate that ExecOnConflictLockRow is reachable.
obviously, ``elog(INFO, "this part is reached");`` needs to be removed later.


--
jian
https://www.enterprisedb.com/

Вложения

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