Hackers,

Is there any reason why HeapTupleSatisfiesUpdate return codes are not an
enum, like they are for HeapTupleSatisfiesVacuum?

I tried and came up with this patch.  If there are no objections, please
apply.

-- 
Alvaro Herrera (<[EMAIL PROTECTED]>)
"El día que dejes de cambiar dejarás de vivir"
Index: src/backend/access/heap/heapam.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/access/heap/heapam.c,v
retrieving revision 1.183
diff -c -r1.183 heapam.c
*** src/backend/access/heap/heapam.c    20 Feb 2005 21:46:47 -0000      1.183
--- src/backend/access/heap/heapam.c    19 Mar 2005 05:36:40 -0000
***************
*** 1265,1271 ****
   * *ctid is set to the ctid link of the target tuple (possibly a later
   * version of the row).
   */
! int
  heap_delete(Relation relation, ItemPointer tid,
                        ItemPointer ctid, CommandId cid,
                        Snapshot crosscheck, bool wait)
--- 1265,1271 ----
   * *ctid is set to the ctid link of the target tuple (possibly a later
   * version of the row).
   */
! HTSU_Result
  heap_delete(Relation relation, ItemPointer tid,
                        ItemPointer ctid, CommandId cid,
                        Snapshot crosscheck, bool wait)
***************
*** 1275,1281 ****
        HeapTupleData tp;
        PageHeader      dp;
        Buffer          buffer;
!       int                     result;
  
        Assert(ItemPointerIsValid(tid));
  
--- 1275,1281 ----
        HeapTupleData tp;
        PageHeader      dp;
        Buffer          buffer;
!       HTSU_Result     result;
  
        Assert(ItemPointerIsValid(tid));
  
***************
*** 1430,1436 ****
  simple_heap_delete(Relation relation, ItemPointer tid)
  {
        ItemPointerData ctid;
!       int                     result;
  
        result = heap_delete(relation, tid,
                                                 &ctid,
--- 1430,1436 ----
  simple_heap_delete(Relation relation, ItemPointer tid)
  {
        ItemPointerData ctid;
!       HTSU_Result             result;
  
        result = heap_delete(relation, tid,
                                                 &ctid,
***************
*** 1480,1486 ****
   * On success, newtup->t_self is set to the TID where the new tuple
   * was inserted.
   */
! int
  heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
                        ItemPointer ctid, CommandId cid,
                        Snapshot crosscheck, bool wait)
--- 1480,1486 ----
   * On success, newtup->t_self is set to the TID where the new tuple
   * was inserted.
   */
! HTSU_Result
  heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
                        ItemPointer ctid, CommandId cid,
                        Snapshot crosscheck, bool wait)
***************
*** 1495,1501 ****
                                already_marked;
        Size            newtupsize,
                                pagefree;
!       int                     result;
  
        Assert(ItemPointerIsValid(otid));
  
--- 1495,1501 ----
                                already_marked;
        Size            newtupsize,
                                pagefree;
!       HTSU_Result     result;
  
        Assert(ItemPointerIsValid(otid));
  
***************
*** 1792,1798 ****
  simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
  {
        ItemPointerData ctid;
!       int                     result;
  
        result = heap_update(relation, otid, tup,
                                                 &ctid,
--- 1792,1798 ----
  simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
  {
        ItemPointerData ctid;
!       HTSU_Result             result;
  
        result = heap_update(relation, otid, tup,
                                                 &ctid,
***************
*** 1822,1828 ****
  /*
   *    heap_mark4update                - mark a tuple for update
   */
! int
  heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
                                 CommandId cid)
  {
--- 1822,1828 ----
  /*
   *    heap_mark4update                - mark a tuple for update
   */
! HTSU_Result
  heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer,
                                 CommandId cid)
  {
***************
*** 1830,1836 ****
        ItemPointer tid = &(tuple->t_self);
        ItemId          lp;
        PageHeader      dp;
!       int                     result;
  
        *buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
        LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
--- 1830,1836 ----
        ItemPointer tid = &(tuple->t_self);
        ItemId          lp;
        PageHeader      dp;
!       HTSU_Result     result;
  
        *buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
        LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE);
Index: src/backend/commands/async.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/commands/async.c,v
retrieving revision 1.119
diff -c -r1.119 async.c
*** src/backend/commands/async.c        27 Jan 2005 23:23:54 -0000      1.119
--- src/backend/commands/async.c        19 Mar 2005 06:00:07 -0000
***************
*** 521,527 ****
                        else if (listener->notification == 0)
                        {
                                ItemPointerData ctid;
!                               int                     result;
  
                                rTuple = heap_modifytuple(lTuple, tdesc,
                                                                                
  value, nulls, repl);
--- 521,527 ----
                        else if (listener->notification == 0)
                        {
                                ItemPointerData ctid;
!                               HTSU_Result             result;
  
                                rTuple = heap_modifytuple(lTuple, tdesc,
                                                                                
  value, nulls, repl);
Index: src/backend/commands/trigger.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/commands/trigger.c,v
retrieving revision 1.177
diff -c -r1.177 trigger.c
*** src/backend/commands/trigger.c      31 Dec 2004 21:59:41 -0000      1.177
--- src/backend/commands/trigger.c      19 Mar 2005 05:52:31 -0000
***************
*** 1566,1572 ****
  
        if (newSlot != NULL)
        {
!               int                     test;
  
                /*
                 * mark tuple for update
--- 1566,1572 ----
  
        if (newSlot != NULL)
        {
!               HTSU_Result     test;
  
                /*
                 * mark tuple for update
Index: src/backend/executor/execMain.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/executor/execMain.c,v
retrieving revision 1.242
diff -c -r1.242 execMain.c
*** src/backend/executor/execMain.c     16 Mar 2005 21:38:06 -0000      1.242
--- src/backend/executor/execMain.c     19 Mar 2005 05:55:13 -0000
***************
*** 1116,1122 ****
                                        Buffer          buffer;
                                        HeapTupleData tuple;
                                        TupleTableSlot *newSlot;
!                                       int                     test;
  
                                        if (!ExecGetJunkAttribute(junkfilter,
                                                                                
          slot,
--- 1116,1122 ----
                                        Buffer          buffer;
                                        HeapTupleData tuple;
                                        TupleTableSlot *newSlot;
!                                       HTSU_Result             test;
  
                                        if (!ExecGetJunkAttribute(junkfilter,
                                                                                
          slot,
***************
*** 1396,1402 ****
        ResultRelInfo *resultRelInfo;
        Relation        resultRelationDesc;
        ItemPointerData ctid;
!       int                     result;
  
        /*
         * get information on the (current) result relation
--- 1396,1402 ----
        ResultRelInfo *resultRelInfo;
        Relation        resultRelationDesc;
        ItemPointerData ctid;
!       HTSU_Result     result;
  
        /*
         * get information on the (current) result relation
***************
*** 1500,1506 ****
        ResultRelInfo *resultRelInfo;
        Relation        resultRelationDesc;
        ItemPointerData ctid;
!       int                     result;
        int                     numIndices;
  
        /*
--- 1500,1506 ----
        ResultRelInfo *resultRelInfo;
        Relation        resultRelationDesc;
        ItemPointerData ctid;
!       HTSU_Result     result;
        int                     numIndices;
  
        /*
Index: src/backend/utils/time/tqual.c
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/backend/utils/time/tqual.c,v
retrieving revision 1.85
diff -c -r1.85 tqual.c
*** src/backend/utils/time/tqual.c      20 Feb 2005 15:01:42 -0000      1.85
--- src/backend/utils/time/tqual.c      19 Mar 2005 05:29:24 -0000
***************
*** 455,461 ****
   *    tuples of my own xact are tested against the passed CommandId not
   *    CurrentCommandId.
   */
! int
  HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid,
                                                 Buffer buffer)
  {
--- 455,461 ----
   *    tuples of my own xact are tested against the passed CommandId not
   *    CurrentCommandId.
   */
! HTSU_Result
  HeapTupleSatisfiesUpdate(HeapTupleHeader tuple, CommandId curcid,
                                                 Buffer buffer)
  {
Index: src/include/access/heapam.h
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/include/access/heapam.h,v
retrieving revision 1.96
diff -c -r1.96 heapam.h
*** src/include/access/heapam.h 16 Mar 2005 21:38:09 -0000      1.96
--- src/include/access/heapam.h 19 Mar 2005 05:45:19 -0000
***************
*** 153,163 ****
  extern void setLastTid(const ItemPointer tid);
  
  extern Oid    heap_insert(Relation relation, HeapTuple tup, CommandId cid);
! extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid,
                        CommandId cid, Snapshot crosscheck, bool wait);
! extern int heap_update(Relation relation, ItemPointer otid, HeapTuple tup,
                ItemPointer ctid, CommandId cid, Snapshot crosscheck, bool 
wait);
! extern int heap_mark4update(Relation relation, HeapTuple tup,
                                 Buffer *userbuf, CommandId cid);
  
  extern Oid    simple_heap_insert(Relation relation, HeapTuple tup);
--- 153,163 ----
  extern void setLastTid(const ItemPointer tid);
  
  extern Oid    heap_insert(Relation relation, HeapTuple tup, CommandId cid);
! extern HTSU_Result heap_delete(Relation relation, ItemPointer tid, 
ItemPointer ctid,
                        CommandId cid, Snapshot crosscheck, bool wait);
! extern HTSU_Result heap_update(Relation relation, ItemPointer otid, HeapTuple 
tup,
                ItemPointer ctid, CommandId cid, Snapshot crosscheck, bool 
wait);
! extern HTSU_Result heap_mark4update(Relation relation, HeapTuple tup,
                                 Buffer *userbuf, CommandId cid);
  
  extern Oid    simple_heap_insert(Relation relation, HeapTuple tup);
Index: src/include/utils/tqual.h
===================================================================
RCS file: /home/alvherre/cvs/pgsql/src/include/utils/tqual.h,v
retrieving revision 1.55
diff -c -r1.55 tqual.h
*** src/include/utils/tqual.h   31 Dec 2004 22:03:46 -0000      1.55
--- src/include/utils/tqual.h   19 Mar 2005 05:28:51 -0000
***************
*** 97,107 ****
  )
  
  /* Result codes for HeapTupleSatisfiesUpdate */
! #define HeapTupleMayBeUpdated         0
! #define HeapTupleInvisible                    1
! #define HeapTupleSelfUpdated          2
! #define HeapTupleUpdated                      3
! #define HeapTupleBeingUpdated         4
  
  /* Result codes for HeapTupleSatisfiesVacuum */
  typedef enum
--- 97,110 ----
  )
  
  /* Result codes for HeapTupleSatisfiesUpdate */
! typedef enum
! {
!       HeapTupleMayBeUpdated,
!       HeapTupleInvisible,
!       HeapTupleSelfUpdated,
!       HeapTupleUpdated,
!       HeapTupleBeingUpdated
! } HTSU_Result;
  
  /* Result codes for HeapTupleSatisfiesVacuum */
  typedef enum
***************
*** 119,125 ****
  extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple, Buffer buffer);
  extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
                                                   Snapshot snapshot, Buffer 
buffer);
! extern int HeapTupleSatisfiesUpdate(HeapTupleHeader tuple,
                                                 CommandId curcid, Buffer 
buffer);
  extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
                                                 TransactionId OldestXmin, 
Buffer buffer);
--- 122,128 ----
  extern bool HeapTupleSatisfiesToast(HeapTupleHeader tuple, Buffer buffer);
  extern bool HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple,
                                                   Snapshot snapshot, Buffer 
buffer);
! extern HTSU_Result HeapTupleSatisfiesUpdate(HeapTupleHeader tuple,
                                                 CommandId curcid, Buffer 
buffer);
  extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
                                                 TransactionId OldestXmin, 
Buffer buffer);
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to