Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XqOQD-0008Pn-9e for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Nov 2014 15:40:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XqOQC-0008EZ-Qr for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Nov 2014 15:40:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XqOQB-0008ET-M4 for pgsql-hackers@postgreSQL.org; Mon, 17 Nov 2014 15:40:55 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XqOQ8-00074r-Es for pgsql-hackers@postgreSQL.org; Mon, 17 Nov 2014 15:40:53 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 5673B2822A; Mon, 17 Nov 2014 07:40:48 -0800 (PST) Received: from EX13-CAS-004.vmware.com (EX13-CAS-004.vmware.com [10.113.191.54]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 4FC57B13F4; Mon, 17 Nov 2014 07:40:48 -0800 (PST) Received: from EX13-MBX-024.vmware.com (10.113.191.44) by EX13-MBX-014.vmware.com (10.113.191.34) with Microsoft SMTP Server (TLS) id 15.0.913.22; Mon, 17 Nov 2014 07:40:48 -0800 Received: from [192.168.1.90] (10.113.160.246) by EX13-MBX-024.vmware.com (10.113.191.44) with Microsoft SMTP Server (TLS) id 15.0.913.22; Mon, 17 Nov 2014 07:40:47 -0800 Message-ID: <546A16EF.9070005@vmware.com> Date: Mon, 17 Nov 2014 17:40:31 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Alvaro Herrera CC: PostgreSQL-development Subject: BRIN page type identifier Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.113.160.246] X-ClientProxiedBy: EX13-CAS-013.vmware.com (10.113.191.65) To EX13-MBX-024.vmware.com (10.113.191.44) X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org The "special" area in a BRIN page looks like this: > /* special space on all BRIN pages stores a "type" identifier */ > #define BRIN_PAGETYPE_META 0xF091 > #define BRIN_PAGETYPE_REVMAP 0xF092 > #define BRIN_PAGETYPE_REGULAR 0xF093 >... > typedef struct BrinSpecialSpace > { > uint16 flags; > uint16 type; > } BrinSpecialSpace; I believe this is supposed to follow the usual convention that the last two bytes of a page can be used to identify the page type. SP-GiST uses 0xFF82, while GIN uses values 0x00XX. However, because the special size is MAXALIGNed, the 'type' field are not the last 2 bytes on the page, as intended. I'd suggest just adding "char padding[6]" in BrinSpecialSpace, before 'flags'. That'll waste 4 bytes on 32-bit systems, but that seems acceptable. Also, the comment in GinPageOpaqueData needs updating: > /* > * Page opaque data in an inverted index page. > * > * Note: GIN does not include a page ID word as do the other index types. > * This is OK because the opaque data is only 8 bytes and so can be reliably > * distinguished by size. Revisit this if the size ever increases. > * Further note: as of 9.2, SP-GiST also uses 8-byte special space. This is > * still OK, as long as GIN isn't using all of the high-order bits in its > * flags word, because that way the flags word cannot match the page ID used > * by SP-GiST. > */ BRIN now also uses 8-byte special space. While you're at it, might want to move that comment somewhere else, as it's really about a convention among all page types, not just GIN. - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers