Fix comments for buf_id field of BufferDesc structure - Mailing list pgsql-hackers

From Daniil Davydov
Subject Fix comments for buf_id field of BufferDesc structure
Date
Msg-id CAJDiXgj6xnpyCfrraiJEVBNUoFVGCNuAEWJtih5wHsQw2xvGww@mail.gmail.com
Whole thread Raw
Responses Re: Fix comments for buf_id field of BufferDesc structure
List pgsql-hackers
Hi,

I noticed that the BufferDesc structure contains the following field
and a comment :

/*
 * Buffer's index number (from 0). The field never changes after
 * initialization, so does not need locking.
 */
int            buf_id;

Actually, the comment is wrong, because we are using negative ids for
local buffers (i.e. "buf_id" field contains values -1, -2, and so on). We
have a comment about it in localbuf.c :

/*
 * negative to indicate local buffer. This is tricky: shared buffers
 * start with 0. We have to start with -2. (Note that the routine
 * BufferDescriptorGetBuffer adds 1 to buf_id so our first buffer id
 * is -1.)
 */

Maybe we should place this note in buf_internals.h? Anyone who
wants to know what this field means will look at the comment in
buf_internals.h and be misled.

I have attached a patch with my suggestion. What do you think?

--
Best regards,
Daniil Davydov

Attachment

pgsql-hackers by date:

Previous
From: "zengman"
Date:
Subject: Re:Some cleanup of pg_stat_statements tests
Next
From: shveta malik
Date:
Subject: Re: pg_upgrade: optimize replication slot caught-up check