Commit 8e75b36a authored by Tom Lane's avatar Tom Lane

Fix unportable, non-spec-compliant use of offsetof() with a nonconstant

member offset.
parent b7ca9a94
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* Copyright (c) 2001, PostgreSQL Global Development Group * 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" #include "postgres.h"
...@@ -464,7 +464,8 @@ pgstat_report_tabstat(void) ...@@ -464,7 +464,8 @@ pgstat_report_tabstat(void)
for (i = 0; i < pgStatTabstatUsed; i++) for (i = 0; i < pgStatTabstatUsed; i++)
{ {
n = pgStatTabstatMessages[i]->m_nentries; 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_commit = pgStatXactCommit;
pgStatTabstatMessages[i]->m_xact_rollback = pgStatXactRollback; pgStatTabstatMessages[i]->m_xact_rollback = pgStatXactRollback;
...@@ -573,7 +574,8 @@ pgstat_vacuum_tabstat(void) ...@@ -573,7 +574,8 @@ pgstat_vacuum_tabstat(void)
*/ */
if (msg.m_nentries >= PGSTAT_NUM_TABPURGE) 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_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
pgstat_send(&msg, len); pgstat_send(&msg, len);
...@@ -587,7 +589,8 @@ pgstat_vacuum_tabstat(void) ...@@ -587,7 +589,8 @@ pgstat_vacuum_tabstat(void)
*/ */
if (msg.m_nentries > 0) 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_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE);
pgstat_send(&msg, len); pgstat_send(&msg, len);
......
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