Commit 659e5349 authored by Magnus Hagander's avatar Magnus Hagander

Fix union for pgstat message types

The message type for temp files and for checksum failures were missing
from the union. Due to the coding style used there was no compiler error
when this happend. So change the code to actively use the union thereby
producing a compiler error if the same mistake happens again, suggested
by Tom Lane.

Author: Julien Rouhaud
Reported-By: Tomas Vondra
Discussion: https://postgr.es/m/20190430163328.zd4rrlnbvgaqlcdz@development
parent 809c9b48
......@@ -4477,80 +4477,83 @@ PgstatCollectorMain(int argc, char *argv[])
break;
case PGSTAT_MTYPE_INQUIRY:
pgstat_recv_inquiry((PgStat_MsgInquiry *) &msg, len);
pgstat_recv_inquiry(&msg.msg_inquiry, len);
break;
case PGSTAT_MTYPE_TABSTAT:
pgstat_recv_tabstat((PgStat_MsgTabstat *) &msg, len);
pgstat_recv_tabstat(&msg.msg_tabstat, len);
break;
case PGSTAT_MTYPE_TABPURGE:
pgstat_recv_tabpurge((PgStat_MsgTabpurge *) &msg, len);
pgstat_recv_tabpurge(&msg.msg_tabpurge, len);
break;
case PGSTAT_MTYPE_DROPDB:
pgstat_recv_dropdb((PgStat_MsgDropdb *) &msg, len);
pgstat_recv_dropdb(&msg.msg_dropdb, len);
break;
case PGSTAT_MTYPE_RESETCOUNTER:
pgstat_recv_resetcounter((PgStat_MsgResetcounter *) &msg,
len);
pgstat_recv_resetcounter(&msg.msg_resetcounter, len);
break;
case PGSTAT_MTYPE_RESETSHAREDCOUNTER:
pgstat_recv_resetsharedcounter(
(PgStat_MsgResetsharedcounter *) &msg,
&msg.msg_resetsharedcounter,
len);
break;
case PGSTAT_MTYPE_RESETSINGLECOUNTER:
pgstat_recv_resetsinglecounter(
(PgStat_MsgResetsinglecounter *) &msg,
&msg.msg_resetsinglecounter,
len);
break;
case PGSTAT_MTYPE_AUTOVAC_START:
pgstat_recv_autovac((PgStat_MsgAutovacStart *) &msg, len);
pgstat_recv_autovac(&msg.msg_autovacuum_start, len);
break;
case PGSTAT_MTYPE_VACUUM:
pgstat_recv_vacuum((PgStat_MsgVacuum *) &msg, len);
pgstat_recv_vacuum(&msg.msg_vacuum, len);
break;
case PGSTAT_MTYPE_ANALYZE:
pgstat_recv_analyze((PgStat_MsgAnalyze *) &msg, len);
pgstat_recv_analyze(&msg.msg_analyze, len);
break;
case PGSTAT_MTYPE_ARCHIVER:
pgstat_recv_archiver((PgStat_MsgArchiver *) &msg, len);
pgstat_recv_archiver(&msg.msg_archiver, len);
break;
case PGSTAT_MTYPE_BGWRITER:
pgstat_recv_bgwriter((PgStat_MsgBgWriter *) &msg, len);
pgstat_recv_bgwriter(&msg.msg_bgwriter, len);
break;
case PGSTAT_MTYPE_FUNCSTAT:
pgstat_recv_funcstat((PgStat_MsgFuncstat *) &msg, len);
pgstat_recv_funcstat(&msg.msg_funcstat, len);
break;
case PGSTAT_MTYPE_FUNCPURGE:
pgstat_recv_funcpurge((PgStat_MsgFuncpurge *) &msg, len);
pgstat_recv_funcpurge(&msg.msg_funcpurge, len);
break;
case PGSTAT_MTYPE_RECOVERYCONFLICT:
pgstat_recv_recoveryconflict((PgStat_MsgRecoveryConflict *) &msg, len);
pgstat_recv_recoveryconflict(
&msg.msg_recoveryconflict,
len);
break;
case PGSTAT_MTYPE_DEADLOCK:
pgstat_recv_deadlock((PgStat_MsgDeadlock *) &msg, len);
pgstat_recv_deadlock(&msg.msg_deadlock, len);
break;
case PGSTAT_MTYPE_TEMPFILE:
pgstat_recv_tempfile((PgStat_MsgTempFile *) &msg, len);
pgstat_recv_tempfile(&msg.msg_tempfile, len);
break;
case PGSTAT_MTYPE_CHECKSUMFAILURE:
pgstat_recv_checksum_failure((PgStat_MsgChecksumFailure *) &msg, len);
pgstat_recv_checksum_failure(
&msg.msg_checksumfailure,
len);
break;
default:
......
......@@ -560,7 +560,7 @@ typedef union PgStat_Msg
PgStat_MsgResetcounter msg_resetcounter;
PgStat_MsgResetsharedcounter msg_resetsharedcounter;
PgStat_MsgResetsinglecounter msg_resetsinglecounter;
PgStat_MsgAutovacStart msg_autovacuum;
PgStat_MsgAutovacStart msg_autovacuum_start;
PgStat_MsgVacuum msg_vacuum;
PgStat_MsgAnalyze msg_analyze;
PgStat_MsgArchiver msg_archiver;
......@@ -569,6 +569,8 @@ typedef union PgStat_Msg
PgStat_MsgFuncpurge msg_funcpurge;
PgStat_MsgRecoveryConflict msg_recoveryconflict;
PgStat_MsgDeadlock msg_deadlock;
PgStat_MsgTempFile msg_tempfile;
PgStat_MsgChecksumFailure msg_checksumfailure;
} PgStat_Msg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment