mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
Fix unportable, non-spec-compliant use of offsetof() with a nonconstant
member offset.
This commit is contained in:
parent
b7ca9a9403
commit
8e75b36aeb
@ -16,7 +16,7 @@
|
||||
*
|
||||
* Copyright (c) 2001, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.14 2001/10/25 05:49:40 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.15 2001/11/26 22:31:08 tgl Exp $
|
||||
* ----------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
@ -464,7 +464,8 @@ pgstat_report_tabstat(void)
|
||||
for (i = 0; i < pgStatTabstatUsed; i++)
|
||||
{
|
||||
n = pgStatTabstatMessages[i]->m_nentries;
|
||||
len = offsetof(PgStat_MsgTabstat, m_entry[n]);
|
||||
len = offsetof(PgStat_MsgTabstat, m_entry[0]) +
|
||||
n * sizeof(PgStat_TableEntry);
|
||||
|
||||
pgStatTabstatMessages[i]->m_xact_commit = pgStatXactCommit;
|
||||
pgStatTabstatMessages[i]->m_xact_rollback = pgStatXactRollback;
|
||||
@ -573,7 +574,8 @@ pgstat_vacuum_tabstat(void)
|
||||
*/
|
||||
if (msg.m_nentries >= PGSTAT_NUM_TABPURGE)
|
||||
{
|
||||
len = offsetof(PgStat_MsgTabpurge, m_tableid[msg.m_nentries]);
|
||||
len = offsetof(PgStat_MsgTabpurge, m_tableid[0])
|
||||
+ msg.m_nentries * sizeof(Oid);
|
||||
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
|
||||
pgstat_send(&msg, len);
|
||||
@ -587,7 +589,8 @@ pgstat_vacuum_tabstat(void)
|
||||
*/
|
||||
if (msg.m_nentries > 0)
|
||||
{
|
||||
len = offsetof(PgStat_MsgTabpurge, m_tableid[msg.m_nentries]);
|
||||
len = offsetof(PgStat_MsgTabpurge, m_tableid[0])
|
||||
+ msg.m_nentries * sizeof(Oid);
|
||||
|
||||
pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
|
||||
pgstat_send(&msg, len);
|
||||
|
Loading…
Reference in New Issue
Block a user