Re: Use an enum for RELKIND_*?

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Use an enum for RELKIND_*?
Дата
Msg-id CAM-w4HNokh9goZUhuzG-Gi5fHT-AmyKgS-a4p=GqzmJwaD4rmg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Use an enum for RELKIND_*?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Use an enum for RELKIND_*?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Out of curiosity I built with -Wswitch-enum to see if it would be
possible to just enable it. It looks like the main culprits are the
node types and if those were switched to #defines it might be feasible
to do so though it would still be a lot of hassle to add case labels
all over the place.

But I had a second look to see if the output pointed out any actual
bugs. I found one though it's pretty minor:

lockfuncs.c:234:3: warning: enumeration value
‘LOCKTAG_SPECULATIVE_TOKEN’ not handled in switch [-Wswitch-enum]
   switch ((LockTagType) instance->locktag.locktag_type)
   ^~~~~~

It just causes speculative locks to be printed wrong in the
pg_lock_status view. And speculative locks are only held transiently
so unless you're do a bulk load using ON CONFLICT (and also cared
about pg_lock_status, perhaps in some monitoring tool) you wouldn't
even notice this:

 postgres***=# select * from pg_lock_status() where locktype =
'speculative token';

┌───────────────────┬──────────┬──────────┬──────┬───────┬────────────┬───────────────┬─────────┬───────┬──────────┬────────────────────┬───────┬───────────────┬─────────┬──────────┐
│     locktype      │ database │ relation │ page │ tuple │ virtualxid
│ transactionid │ classid │ objid │ objsubid │ virtualtransaction │
pid  │     mode      │ granted │ fastpath │

├───────────────────┼──────────┼──────────┼──────┼───────┼────────────┼───────────────┼─────────┼───────┼──────────┼────────────────────┼───────┼───────────────┼─────────┼──────────┤
│ speculative token │      634 │          │      │       │
│               │       1 │     0 │        0 │ 4/32               │
18652 │ ExclusiveLock │ t       │ f        │

└───────────────────┴──────────┴──────────┴──────┴───────┴────────────┴───────────────┴─────────┴───────┴──────────┴────────────────────┴───────┴───────────────┴─────────┴──────────┘

The speculative lock is actually on a transaction ID and "speculative
lock token" so the "database", "objid", and "objsubid" are bogus here.

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

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: [HACKERS] ArrayLists instead of List (for some things)
Следующее
От: David Fetter
Дата:
Сообщение: Re: Compiling on Termux