pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Dilger <hornschnorter@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: gratuitous casting away const
Date: Tue, 20 Sep 2016 14:33:17 -0700
Message-ID: <96DBB26C-34FF-4090-98A8-6DDA5136AC73@gmail.com> (raw)
In-Reply-To: <20919.1474402019@sss.pgh.pa.us>
References: <ACF3A030-E3D5-4E68-B744-184E11DE68F3@gmail.com>
	<20919.1474402019@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>


> On Sep 20, 2016, at 1:06 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 
> Mark Dilger <hornschnorter@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



view thread (6+ messages)  latest in thread

Message-ID: <96DBB26C-34FF-4090-98A8-6DDA5136AC73@gmail.com>
Permalink:  ../96DBB26C-34FF-4090-98A8-6DDA5136AC73@gmail.com/
Also on:    postgresql.org/message-id/96DBB26C-34FF-4090-98A8-6DDA5136AC73@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: hornschnorter@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: gratuitous casting away const
  In-Reply-To: <96DBB26C-34FF-4090-98A8-6DDA5136AC73@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox