public inbox for [email protected]
help / color / mirror / Atom feedRe: table AM option passing
10+ messages / 5 participants
[nested] [flat]
* Re: table AM option passing
@ 2026-03-17 17:31 ` Nathan Bossart <[email protected]>
2026-03-17 20:04 ` Re: table AM option passing Nathan Bossart <[email protected]>
2026-03-18 21:17 ` Re: table AM option passing Nathan Bossart <[email protected]>
1 sibling, 2 replies; 10+ messages in thread
From: Nathan Bossart @ 2026-03-17 17:31 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Pg Hackers <[email protected]>
On Tue, Mar 17, 2026 at 05:50:41PM +0100, Álvaro Herrera wrote:
> We could solve this easily by adding one more boolean to each, but I
> think this is a good time to instead consolidate the API by using a
> bitmask; this also allows us not to have changingPart in the wrong place
> of the heap_delete API.
>
> So here's a patch to do that, which shouldn't change any behavior.
Seems entirely reasonable to me. I read through the patch and nothing
stood out.
> (This change is vaguely similar to b7271aa1d71a, except I used 'int'
> instead of 'bits32', to keep the interface consistent with the existing
> heap_insert() one. Maybe I should make all three take bits64 instead?
> We don't actually have that type at present, so I'd have to add that
> too.)
Why bits64 and not bits32? I must be missing something.
> While at it, I noticed that the table_insert() and heap_insert() uses
> one set of value definitions for each half of the interface; that is, in
> tableam.h we have
>
> /* "options" flag bits for table_tuple_insert */
> /* TABLE_INSERT_SKIP_WAL was 0x0001; RelationNeedsWAL() now governs */
> #define TABLE_INSERT_SKIP_FSM 0x0002
> #define TABLE_INSERT_FROZEN 0x0004
> #define TABLE_INSERT_NO_LOGICAL 0x0008
>
> and in heapam.h we have
> /* "options" flag bits for heap_insert */
> #define HEAP_INSERT_SKIP_FSM TABLE_INSERT_SKIP_FSM
> #define HEAP_INSERT_FROZEN TABLE_INSERT_FROZEN
> #define HEAP_INSERT_NO_LOGICAL TABLE_INSERT_NO_LOGICAL
> #define HEAP_INSERT_SPECULATIVE 0x0010
>
> This seems rather odd to me -- how could heapam.c have a different set
> of behaviors than what table AM uses? I find it even more weird that
> HEAP_INSERT_SPECULATIVE is defined so that as soon as some future patch
> defines the next "free" tableam.h flag value to do something new, we'll
> have a conflict. I think this would be cleaner if we removed from
> heapam.h the flags that correspond to anything in tableam.h, and use
> heapam.c and all its direct callers use the tableam.h flag definitions
> instead; and perhaps move HEAP_INSERT_SPECULATIVE to be at the other end
> of the bitmask (0x1000) -- maybe simply say in tableam.h that the first
> byte of the options int is reserved for internal use.
Probably a good idea.
--
nathan
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-03-17 17:31 ` Re: table AM option passing Nathan Bossart <[email protected]>
@ 2026-03-17 20:04 ` Nathan Bossart <[email protected]>
1 sibling, 0 replies; 10+ messages in thread
From: Nathan Bossart @ 2026-03-17 20:04 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Pg Hackers <[email protected]>
On Tue, Mar 17, 2026 at 08:47:22PM +0100, Álvaro Herrera wrote:
> Does anybody oppose changing table_tuple_insert() to use bits32 instead
> of integer for the 'options' argument?
No objections here.
--
nathan
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-03-17 17:31 ` Re: table AM option passing Nathan Bossart <[email protected]>
@ 2026-03-18 21:17 ` Nathan Bossart <[email protected]>
1 sibling, 0 replies; 10+ messages in thread
From: Nathan Bossart @ 2026-03-18 21:17 UTC (permalink / raw)
To: Andres Freund <[email protected]>; +Cc: Álvaro Herrera <[email protected]>; Pg Hackers <[email protected]>
On Tue, Mar 17, 2026 at 05:09:49PM -0400, Andres Freund wrote:
> Personally I object to the existence of the bits* types, to me they're just
> noise over using the corresponding unsigned integer types. One more thing that
> one has to just know what it means without there being any actual improved
> type checking or such. It's not like using bits* would make it any easier to
> make the underlying type a struct or such (which is different to
> e.g. TransactionId, we could probably replace that with a struct without crazy
> amounts of trouble).
Yeah, I don't see why you'd prefer bits32 over uint32. If anything, uint32
is probably less confusing because most hackers will have used it before.
AFAICT the bits* types are a relic of the 80s, and there used to be other
types like bool8 and word32, all of which were just uint* behind the
scenes. Those were removed in 2004 by commit ca7a1f0c86. I assume bits*
was left behind because it was still in use.
> I think we should just rip the bits* types out and replace them with the
> underlying types.
+1. If there seems to be consensus, I'm happy to write the patch.
--
nathan
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
@ 2026-03-18 20:20 ` Zsolt Parragi <[email protected]>
1 sibling, 0 replies; 10+ messages in thread
From: Zsolt Parragi @ 2026-03-18 20:20 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Pg Hackers <[email protected]>
Hello!
I think there's a change missing in simple_table_tuple_update that
works by accident, as true == 1 == TABLE_UPDATE_WAIT.
Maybe the values could use a different starting value instead of 1 to
surface possible issues?
+ * TABLE_DELETE_WAIT -- set if should wait for any conflicting
+ * update/delete to commit/abort
+ * TABLE_DELETE_CHANGING_PART -- set iff the tuple is being moved to
+ * another partition table due to an update of the partition key.
+ * Otherwise, false.
"Otherwise, false" seems like a leftover from the previous comment version?
tableam.h also have two leftover "wait == false" comments.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
@ 2026-03-31 23:20 ` Zsolt Parragi <[email protected]>
1 sibling, 0 replies; 10+ messages in thread
From: Zsolt Parragi @ 2026-03-31 23:20 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Nathan Bossart <[email protected]>
static inline TM_Result
table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
- Snapshot snapshot, Snapshot crosscheck, bool wait,
- TM_FailureData *tmfd, bool changingPart)
+ uint32 options, Snapshot snapshot, Snapshot crosscheck,
+ bool wait, TM_FailureData *tmfd)
The doc comment still referneces changingPart
Similarly table_tuple_update doesn't document the new options parameter.
@@ -339,7 +341,8 @@ heapam_tuple_update(Relation relation, ItemPointer
otid, TupleTableSlot *slot,
slot->tts_tableOid = RelationGetRelid(relation);
tuple->t_tableOid = slot->tts_tableOid;
- result = heap_update(relation, otid, tuple, cid, crosscheck, wait,
+ result = heap_update(relation, otid, tuple, cid, options,
+ crosscheck, wait,
tmfd, lockmode, update_indexes);
ItemPointerCopy(&tuple->t_self, &slot->tts_tid);
options is marked pg_attribute_unused above, that seems misleading.
Should the annotation be part of the heap_update signature instead?
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
@ 2026-04-01 06:33 ` Chao Li <[email protected]>
2026-04-01 14:27 ` Re: table AM option passing Álvaro Herrera <[email protected]>
1 sibling, 1 reply; 10+ messages in thread
From: Chao Li @ 2026-04-01 06:33 UTC (permalink / raw)
To: Álvaro Herrera <[email protected]>; +Cc: Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Zsolt Parragi <[email protected]>; Nathan Bossart <[email protected]>
> On Apr 1, 2026, at 00:10, Álvaro Herrera <[email protected]> wrote:
>
> Hi,
>
> On 2026-Mar-30, Álvaro Herrera wrote:
>
>> I just pushed the part of 0001 that modifies the API of table_insert and
>> its sibling functions. So here 0001 adds the options bitmask to
>> table_update and table_delete, which is important for REPACK; and 0002
>> is identical as before and makes the interface (IMO) a bit more
>> future-proof.
>
> FWIW I just posted 0001 as part of the repack series here [1]; 0002 is
> inessential, so I didn't; but here's both of them. I have drafted
> commit messages also.
>
> [1] https://postgr.es/m/[email protected]
>
> --
> Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
> "Pensar que el espectro que vemos es ilusorio no lo despoja de espanto,
> sólo le suma el nuevo terror de la locura" (Perelandra, C.S. Lewis)
> <v4-0001-Give-options-parameter-to-table_delete-table_upda.patch><v4-0002-Change-heapam.c-to-obey-tableam.h-option-bits-dir.patch>
Looks like v4-0001/0002 are pure refactoring. A few small comments:
1 - 0001
For table_tuple_delete(), options is added and changingPart is removed, but the header comment should be updated to reflect the change.
2 - 0002
For table_tuple_update(), options is added, the header comment should be updated as well.
3 - 0002
Now TABLE_INSERT_SKIP_FSM, TABLE_INSERT_FROZEN, TABLE_INSERT_NO_LOGICAL belong to the same options word as HEAP_INSERT_SPECULATIVE, but they are still defined as:
```
#define TABLE_INSERT_SKIP_FSM 0x0002
#define TABLE_INSERT_FROZEN 0x0004
#define TABLE_INSERT_NO_LOGICAL 0x0008
```
Could it make sense to change them to the left-shift form?
4 - 0002
In heap_multi_insert(), heap_prepare_insert(), and heap_insert(), options is defined as uint32, but in RelationGetBufferForTuple() and raw_heap_insert() it is still defined as int. Would it make sense to take this opportunity to change all “options" to uint32 for consistency? Otherwise, if this is left for later, a trivial follow-up patch just to change int to uint32 may be harder to get processed.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-04-01 06:33 ` Re: table AM option passing Chao Li <[email protected]>
@ 2026-04-01 14:27 ` Álvaro Herrera <[email protected]>
2026-04-01 15:16 ` Re: table AM option passing Antonin Houska <[email protected]>
0 siblings, 1 reply; 10+ messages in thread
From: Álvaro Herrera @ 2026-04-01 14:27 UTC (permalink / raw)
To: Chao Li <[email protected]>; +Cc: Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Zsolt Parragi <[email protected]>; Nathan Bossart <[email protected]>
On 2026-Apr-01, Chao Li wrote:
> 1 - 0001
> For table_tuple_delete(), options is added and changingPart is
> removed, but the header comment should be updated to reflect the
> change.
True, fixed.
> 2 - 0002
> For table_tuple_update(), options is added, the header comment should
> be updated as well.
Done.
> 3 - 0002
> Now TABLE_INSERT_SKIP_FSM, TABLE_INSERT_FROZEN, TABLE_INSERT_NO_LOGICAL belong to the same options word as HEAP_INSERT_SPECULATIVE, but they are still defined as:
> ```
> #define TABLE_INSERT_SKIP_FSM 0x0002
> #define TABLE_INSERT_FROZEN 0x0004
> #define TABLE_INSERT_NO_LOGICAL 0x0008
> ```
>
> Could it make sense to change them to the left-shift form?
Yeah, I don't know. I don't like this style, but some people like it,
and I don't want to get into an argument about this kind of thing.
> 4 - 0002
> In heap_multi_insert(), heap_prepare_insert(), and heap_insert(),
> options is defined as uint32, but in RelationGetBufferForTuple() and
> raw_heap_insert() it is still defined as int. Would it make sense to
> take this opportunity to change all “options" to uint32 for
> consistency? Otherwise, if this is left for later, a trivial follow-up
> patch just to change int to uint32 may be harder to get processed.
Hmm, this is actually a problem in 1bd6f22f43ac. I added a preliminary
patch that should fix this.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"No renuncies a nada. No te aferres a nada."
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-04-01 06:33 ` Re: table AM option passing Chao Li <[email protected]>
2026-04-01 14:27 ` Re: table AM option passing Álvaro Herrera <[email protected]>
@ 2026-04-01 15:16 ` Antonin Houska <[email protected]>
2026-04-01 18:41 ` Re: table AM option passing Álvaro Herrera <[email protected]>
0 siblings, 1 reply; 10+ messages in thread
From: Antonin Houska @ 2026-04-01 15:16 UTC (permalink / raw)
To: [email protected]; +Cc: Chao Li <[email protected]>; Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Zsolt Parragi <[email protected]>; Nathan Bossart <[email protected]>
Álvaro Herrera <[email protected]> wrote:
> Hmm, this is actually a problem in 1bd6f22f43ac. I added a preliminary
> patch that should fix this.
I've reviewed this patch set too. The only question that occurs to me is
whether INSERT_SKIP_FSM and INSERT_FROZEN shouldn't actually be prefixed with
HEAP_, as these are rather low-level and thus might be considered
AM-specific.
(I like the idea to use the high bits to avoid collisions.)
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-04-01 06:33 ` Re: table AM option passing Chao Li <[email protected]>
2026-04-01 14:27 ` Re: table AM option passing Álvaro Herrera <[email protected]>
2026-04-01 15:16 ` Re: table AM option passing Antonin Houska <[email protected]>
@ 2026-04-01 18:41 ` Álvaro Herrera <[email protected]>
2026-04-02 05:39 ` Re: table AM option passing Antonin Houska <[email protected]>
0 siblings, 1 reply; 10+ messages in thread
From: Álvaro Herrera @ 2026-04-01 18:41 UTC (permalink / raw)
To: Antonin Houska <[email protected]>; +Cc: Chao Li <[email protected]>; Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Zsolt Parragi <[email protected]>; Nathan Bossart <[email protected]>
On 2026-Apr-01, Antonin Houska wrote:
> I've reviewed this patch set too. The only question that occurs to me is
> whether INSERT_SKIP_FSM and INSERT_FROZEN shouldn't actually be prefixed with
> HEAP_, as these are rather low-level and thus might be considered
> AM-specific.
Thanks! I pushed 0001 and 0002 from this patchset, with minimal
cosmetic corrections.
I realized that patch 0003 is doing two different things, and they
should each be their own patch which can be rejected if we don't like
them; so I split it in two. One moves the heapam.h-private bit to the
32th bit. The other removes the duplicity of definitions, so that
heapam.h doesn't have to feel it needs to redefine the tableam.h
interface.
At this point these patches could be considered WIP in the sense that I
wouldn't commit exactly as is (minor corrections might be appropriate,
for example to the nearby comments), but I would like to know opinions
in case we decide to just throw them away.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Las navajas y los monos deben estar siempre distantes" (Germán Poo)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: table AM option passing
2026-04-01 06:33 ` Re: table AM option passing Chao Li <[email protected]>
2026-04-01 14:27 ` Re: table AM option passing Álvaro Herrera <[email protected]>
2026-04-01 15:16 ` Re: table AM option passing Antonin Houska <[email protected]>
2026-04-01 18:41 ` Re: table AM option passing Álvaro Herrera <[email protected]>
@ 2026-04-02 05:39 ` Antonin Houska <[email protected]>
0 siblings, 0 replies; 10+ messages in thread
From: Antonin Houska @ 2026-04-02 05:39 UTC (permalink / raw)
To: [email protected]; +Cc: Chao Li <[email protected]>; Andres Freund <[email protected]>; Pg Hackers <[email protected]>; Zsolt Parragi <[email protected]>; Nathan Bossart <[email protected]>
Álvaro Herrera <[email protected]> wrote:
> On 2026-Apr-01, Antonin Houska wrote:
> I realized that patch 0003 is doing two different things, and they
> should each be their own patch which can be rejected if we don't like
> them; so I split it in two. One moves the heapam.h-private bit to the
> 32th bit.
I'm sorry I haven't recalled yesterday, but this technique resembles the
DSM keys in parallel.c:
/*
* Magic numbers for per-context parallel state sharing. Higher-level code
* should use smaller values, leaving these very large ones for use by this
* module.
*/
#define PARALLEL_KEY_FIXED UINT64CONST(0xFFFFFFFFFFFF0001)
...
What I found inspiring here is that the "core" uses the high bits while users
of the API use the lower ones. Perhaps it'd be appropriate in v6-0001 to
reserve the high bits for the TABLE_ options and leave the lower ones for the
HEAP_ options. If someone implements a new AM (possibly as an extension), it
should be more comfortable for him.
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2026-04-02 05:39 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-17 17:31 ` Nathan Bossart <[email protected]>
2026-03-17 20:04 ` Nathan Bossart <[email protected]>
2026-03-18 21:17 ` Nathan Bossart <[email protected]>
2026-03-18 20:20 ` Zsolt Parragi <[email protected]>
2026-03-31 23:20 ` Zsolt Parragi <[email protected]>
2026-04-01 06:33 ` Chao Li <[email protected]>
2026-04-01 14:27 ` Álvaro Herrera <[email protected]>
2026-04-01 15:16 ` Antonin Houska <[email protected]>
2026-04-01 18:41 ` Álvaro Herrera <[email protected]>
2026-04-02 05:39 ` Antonin Houska <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox