Adding doubly linked list type which stores the number of items in the list

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Adding doubly linked list type which stores the number of items in the list
Date: 2022-10-27 03:35:26
Message-ID: CAApHDvrtVxr+FXEX0VbViCFKDGxA3tWDgw9oFewNXCJMmwLjLg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)llw5an2aklengrmn(at)alap3(dot)anarazel(dot)de

Attachment Content-Type Size
v1-0001-Add-doubly-linked-count-list-implementation.patch text/plain 26.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2022-10-27 04:26:25 Re: Allow file inclusion in pg_hba and pg_ident files
Previous Message John Naylor 2022-10-27 03:21:40 Re: [PoC] Improve dead tuple storage for lazy vacuum