> On Sep 20, 2016, at 1:06 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> 
> Mark Dilger <hornschnor...@gmail.com> writes:
>> Would patches to not cast away const be considered?
> 
> In general, yes, but I'm not especially in favor of something like this:
> 
>> bool
>> PageIndexTupleOverwrite(Page page, OffsetNumber offnum,
>> -                                               Item newtup, Size newsize)
>> +                                               const char *newtup, Size 
>> newsize)
>> {
> 
> since that seems to be discarding type information in order to add
> "const"; does not seem like a net benefit from here.

The following seems somewhere in between, with ItemPointer
changing to const ItemPointerData *.  I expect you would not care
for this change, but thought I'd check to see where you draw the line:


diff --git a/src/backend/access/gin/ginbulk.c b/src/backend/access/gin/ginbulk.c
index 71c64e4..903b01f 100644
--- a/src/backend/access/gin/ginbulk.c
+++ b/src/backend/access/gin/ginbulk.c
@@ -244,7 +244,7 @@ ginInsertBAEntries(BuildAccumulator *accum,
 static int
 qsortCompareItemPointers(const void *a, const void *b)
 {
-   int         res = ginCompareItemPointers((ItemPointer) a, (ItemPointer) b);
+   int         res = ginCompareItemPointers((const ItemPointerData *) a, 
(const ItemPointerData *) b);

    /* Assert that there are no equal item pointers being sorted */
    Assert(res != 0);
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index bf589ab..2e5a7dff 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -968,7 +968,7 @@ extern ItemPointer ginMergeItemPointers(ItemPointerData *a, 
uint32 na,
  * so we want this to be inlined.
  */
 static inline int
-ginCompareItemPointers(ItemPointer a, ItemPointer b)
+ginCompareItemPointers(const ItemPointerData *a, const ItemPointerData *b)
 {
    uint64      ia = (uint64) a->ip_blkid.bi_hi << 32 | (uint64) 
a->ip_blkid.bi_lo << 16 | a->ip_posid;
    uint64      ib = (uint64) b->ip_blkid.bi_hi << 32 | (uint64) 
b->ip_blkid.bi_lo << 16 | b->ip_posid;




-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to