Adding doubly linked list type which stores the number of items in the list - Mailing list pgsql-hackers

From David Rowley
Subject Adding doubly linked list type which stores the number of items in the list
Date
Msg-id CAApHDvrtVxr+FXEX0VbViCFKDGxA3tWDgw9oFewNXCJMmwLjLg@mail.gmail.com
Whole thread Raw
Responses Re: Adding doubly linked list type which stores the number of items in the list  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-hackers
As part of the AIO work [1], there are quite a number of dlist_heads
which a counter is used to keep track on how many items are in the
list.  We also have a few places in master which do the same thing.

In order to tidy this up and to help ensure that the count variable
does not get out of sync with the items which are stored in the list,
how about we introduce "dclist" which maintains the count for us?

I've attached a patch which does this.  The majority of the functions
for the new type are just wrappers around the equivalent dlist
function.

dclist provides all of the functionality that dlist does except
there's no dclist_delete() function.  dlist_delete() can be done by
just knowing the element to delete and not the list that the element
belongs to.  With dclist, that's not possible as we must also subtract
1 from the count variable and obviously we need the dclist_head for
that.

I'll add this to the November commitfest.

David

[1] https://www.postgresql.org/message-id/flat/20210223100344.llw5an2aklengrmn@alap3.anarazel.de

Attachment

pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: [PoC] Improve dead tuple storage for lazy vacuum
Next
From: Julien Rouhaud
Date:
Subject: Re: Allow file inclusion in pg_hba and pg_ident files