]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix vicinity of tuple_insert to use uint32, not int, for options
authorÁlvaro Herrera <alvherre@kurilemu.de>
Wed, 1 Apr 2026 16:14:51 +0000 (18:14 +0200)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Wed, 1 Apr 2026 16:14:51 +0000 (18:14 +0200)
Oversight in commit 1bd6f22f43ac: I was way too optimistic about the
compiler letting me know what variables needed to be updated, and missed
a few of them.  Clean it up.

Author: Álvaro Herrera <alvherre@kurilemu.de>
Reported-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/40E570EE-5A60-49D8-B8F7-2F8F2B7C8DFA@gmail.com

13 files changed:
src/backend/access/common/toast_internals.c
src/backend/access/heap/heaptoast.c
src/backend/access/heap/hio.c
src/backend/access/heap/rewriteheap.c
src/backend/access/table/toast_helper.c
src/backend/commands/copyfrom.c
src/backend/commands/createas.c
src/backend/commands/matview.c
src/backend/commands/tablecmds.c
src/include/access/heaptoast.h
src/include/access/hio.h
src/include/access/toast_helper.h
src/include/access/toast_internals.h

index 4d0da07135e8f4041a0e63fab08d6ae674000eea..77d42e7ed65af2951e1bb8a49a0bec21dcc2abf0 100644 (file)
@@ -117,7 +117,7 @@ toast_compress_datum(Datum value, char cmethod)
  */
 Datum
 toast_save_datum(Relation rel, Datum value,
-                                varlena *oldexternal, int options)
+                                varlena *oldexternal, uint32 options)
 {
        Relation        toastrel;
        Relation   *toastidxs;
index ba541bd60c9d6a670680fca11e4e283269f52ce5..03f885a25b0751159ca28aca15b4188e1204d6b0 100644 (file)
@@ -94,7 +94,7 @@ heap_toast_delete(Relation rel, HeapTuple oldtup, bool is_speculative)
  */
 HeapTuple
 heap_toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup,
-                                                       int options)
+                                                       uint32 options)
 {
        HeapTuple       result_tuple;
        TupleDesc       tupleDesc;
index 1097f44a74efe786434d9b84a951370c0eabc4ea..e96e0f77d9264996ea9eb7670aaefb2a8a9f99b3 100644 (file)
@@ -498,7 +498,7 @@ RelationAddBlocks(Relation relation, BulkInsertState bistate,
  */
 Buffer
 RelationGetBufferForTuple(Relation relation, Size len,
-                                                 Buffer otherBuffer, int options,
+                                                 Buffer otherBuffer, uint32 options,
                                                  BulkInsertState bistate,
                                                  Buffer *vmbuffer, Buffer *vmbuffer_other,
                                                  int num_pages)
index 6b19ac3030d671eee2a0198c51ec90597a2155a2..f707b102c7234323bc83f6674e94a12d7e2f2117 100644 (file)
@@ -618,7 +618,7 @@ raw_heap_insert(RewriteState state, HeapTuple tup)
        }
        else if (HeapTupleHasExternal(tup) || tup->t_len > TOAST_TUPLE_THRESHOLD)
        {
-               int                     options = HEAP_INSERT_SKIP_FSM;
+               uint32          options = HEAP_INSERT_SKIP_FSM;
 
                /*
                 * While rewriting the heap for VACUUM FULL / CLUSTER, make sure data
index 0d792a60ca0f71a6aa9dac4eed6e79ea9f6c9dd8..2f2022d99510a44c4e07eea9daf771cc7f4032fa 100644 (file)
@@ -253,7 +253,7 @@ toast_tuple_try_compression(ToastTupleContext *ttc, int attribute)
  * Move an attribute to external storage.
  */
 void
-toast_tuple_externalize(ToastTupleContext *ttc, int attribute, int options)
+toast_tuple_externalize(ToastTupleContext *ttc, int attribute, uint32 options)
 {
        Datum      *value = &ttc->ttc_values[attribute];
        Datum           old_value = *value;
index aa253b587aabc93bddfca107d10d1a83805cc502..64ac3063c61a9a8af00c285981999fbf0344939f 100644 (file)
@@ -101,7 +101,7 @@ typedef struct CopyMultiInsertInfo
        CopyFromState cstate;           /* Copy state for this CopyMultiInsertInfo */
        EState     *estate;                     /* Executor state used for COPY */
        CommandId       mycid;                  /* Command Id used for COPY */
-       int                     ti_options;             /* table insert options */
+       uint32          ti_options;             /* table insert options */
 } CopyMultiInsertInfo;
 
 
@@ -401,7 +401,7 @@ CopyMultiInsertInfoSetupBuffer(CopyMultiInsertInfo *miinfo,
 static void
 CopyMultiInsertInfoInit(CopyMultiInsertInfo *miinfo, ResultRelInfo *rri,
                                                CopyFromState cstate, EState *estate, CommandId mycid,
-                                               int ti_options)
+                                               uint32 ti_options)
 {
        miinfo->multiInsertBuffers = NIL;
        miinfo->bufferedTuples = 0;
@@ -535,7 +535,7 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo,
        else
        {
                CommandId       mycid = miinfo->mycid;
-               int                     ti_options = miinfo->ti_options;
+               uint32          ti_options = miinfo->ti_options;
                bool            line_buf_valid = cstate->line_buf_valid;
                uint64          save_cur_lineno = cstate->cur_lineno;
                MemoryContext oldcontext;
@@ -792,7 +792,7 @@ CopyFrom(CopyFromState cstate)
        PartitionTupleRouting *proute = NULL;
        ErrorContextCallback errcallback;
        CommandId       mycid = GetCurrentCommandId(true);
-       int                     ti_options = 0; /* start with default options for insert */
+       uint32          ti_options = 0; /* start with default options for insert */
        BulkInsertState bistate = NULL;
        CopyInsertMethod insertMethod;
        CopyMultiInsertInfo multiInsertInfo = {0};      /* pacify compiler */
index 270e9bf31105697790514eabe43baf44e8b6d19d..6dbb831ca890dfbde82b2e18a685463ffbf146ee 100644 (file)
@@ -56,7 +56,7 @@ typedef struct
        Relation        rel;                    /* relation to write to */
        ObjectAddress reladdr;          /* address of rel, for ExecCreateTableAs */
        CommandId       output_cid;             /* cmin to insert in output tuples */
-       int                     ti_options;             /* table_tuple_insert performance options */
+       uint32          ti_options;             /* table_tuple_insert performance options */
        BulkInsertState bistate;        /* bulk insert state */
 } DR_intorel;
 
index 81a55a33ef2aa5f764feac81f82f062d2ac9117a..d3be8939011be951adf1475f68a43f5dbfd6f2fe 100644 (file)
@@ -49,7 +49,7 @@ typedef struct
        /* These fields are filled by transientrel_startup: */
        Relation        transientrel;   /* relation to write to */
        CommandId       output_cid;             /* cmin to insert in output tuples */
-       int                     ti_options;             /* table_tuple_insert performance options */
+       uint32          ti_options;             /* table_tuple_insert performance options */
        BulkInsertState bistate;        /* bulk insert state */
 } DR_transientrel;
 
index 8b4ebc6f226a6e32a5795f29deb3026a03c1cd04..0ce2e81f9c2f2c26f20f01ad72ad9b8b0f55f93a 100644 (file)
@@ -6195,7 +6195,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
        EState     *estate;
        CommandId       mycid;
        BulkInsertState bistate;
-       int                     ti_options;
+       uint32          ti_options;
        ExprState  *partqualstate = NULL;
 
        /*
@@ -22835,7 +22835,7 @@ MergePartitionsMoveRows(List **wqueue, List *mergingPartitions, Relation newPart
        ListCell   *ltab;
 
        /* The FSM is empty, so don't bother using it. */
-       int                     ti_options = TABLE_INSERT_SKIP_FSM;
+       uint32          ti_options = TABLE_INSERT_SKIP_FSM;
        BulkInsertState bistate;        /* state of bulk inserts for partition */
        TupleTableSlot *dstslot;
 
@@ -23226,7 +23226,7 @@ createSplitPartitionContext(Relation partRel)
  * deleteSplitPartitionContext: delete context for partition
  */
 static void
-deleteSplitPartitionContext(SplitPartitionContext *pc, List **wqueue, int ti_options)
+deleteSplitPartitionContext(SplitPartitionContext *pc, List **wqueue, uint32 ti_options)
 {
        ListCell   *ltab;
 
@@ -23268,7 +23268,7 @@ SplitPartitionMoveRows(List **wqueue, Relation rel, Relation splitRel,
                                           List *partlist, List *newPartRels)
 {
        /* The FSM is empty, so don't bother using it. */
-       int                     ti_options = TABLE_INSERT_SKIP_FSM;
+       uint32          ti_options = TABLE_INSERT_SKIP_FSM;
        CommandId       mycid;
        EState     *estate;
        ListCell   *listptr,
index 725c0ce75544da0b20259f4dd41d0231a8f43269..631cb1836b962cfac36a112d2be62fa12cd2f319 100644 (file)
@@ -95,7 +95,7 @@
  * ----------
  */
 extern HeapTuple heap_toast_insert_or_update(Relation rel, HeapTuple newtup,
-                                                                                        HeapTuple oldtup, int options);
+                                                                                        HeapTuple oldtup, uint32 options);
 
 /* ----------
  * heap_toast_delete -
index d8e63a54ea5e7c153870b5d74de50e1e9915ff7e..60cfc375fd5233189d358d89f1c2e19e2477b37a 100644 (file)
@@ -54,7 +54,7 @@ typedef struct BulkInsertStateData
 extern void RelationPutHeapTuple(Relation relation, Buffer buffer,
                                                                 HeapTuple tuple, bool token);
 extern Buffer RelationGetBufferForTuple(Relation relation, Size len,
-                                                                               Buffer otherBuffer, int options,
+                                                                               Buffer otherBuffer, uint32 options,
                                                                                BulkInsertStateData *bistate,
                                                                                Buffer *vmbuffer, Buffer *vmbuffer_other,
                                                                                int num_pages);
index e8ecb995cb32a3091f5e1f1d670de3a166913a03..2ec92397f2676f0f7ee1848ed1c3b3dfd9081c5d 100644 (file)
@@ -107,7 +107,7 @@ extern int  toast_tuple_find_biggest_attribute(ToastTupleContext *ttc,
                                                                                           bool check_main);
 extern void toast_tuple_try_compression(ToastTupleContext *ttc, int attribute);
 extern void toast_tuple_externalize(ToastTupleContext *ttc, int attribute,
-                                                                       int options);
+                                                                       uint32 options);
 extern void toast_tuple_cleanup(ToastTupleContext *ttc);
 
 extern void toast_delete_external(Relation rel, const Datum *values, const bool *isnull,
index d382db342620f93be7462a7569e92385e0f4294f..bf45889a6428071bb92bb227387aaa152f3ca8fe 100644 (file)
@@ -50,7 +50,7 @@ extern Oid    toast_get_valid_index(Oid toastoid, LOCKMODE lock);
 
 extern void toast_delete_datum(Relation rel, Datum value, bool is_speculative);
 extern Datum toast_save_datum(Relation rel, Datum value,
-                                                         varlena *oldexternal, int options);
+                                                         varlena *oldexternal, uint32 options);
 
 extern int     toast_open_indexes(Relation toastrel,
                                                           LOCKMODE lock,