Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aanZy-0007at-BT for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2016 16:55:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aanZx-0002Bt-Fy for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Mar 2016 16:55:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aanZw-00029t-Iu for pgsql-hackers@postgresql.org; Tue, 01 Mar 2016 16:55:20 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aanZs-0007Bz-29 for pgsql-hackers@postgresql.org; Tue, 01 Mar 2016 16:55:19 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id F3B1921C6736 for ; Tue, 1 Mar 2016 19:55:13 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OiaybUdWxQ7J for ; Tue, 1 Mar 2016 19:55:12 +0300 (MSK) Received: from [192.168.27.79] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 51D7821C6734 for ; Tue, 1 Mar 2016 19:55:12 +0300 (MSK) Subject: Re: WIP: Covering + unique indexes. To: pgsql-hackers@postgresql.org References: <56167F09.3090101@postgrespro.ru> <569530FC.2010900@postgrespro.ru> <56965808.7050004@postgrespro.ru> <569E6D77.3080700@postgrespro.ru> <56A24885.7050706@postgrespro.ru> <56A78433.3050303@postgrespro.ru> <56B0A61A.2030808@postgrespro.ru> <56BCBAE0.2080102@postgrespro.ru> <56D46114.9090205@postgrespro.ru> From: Anastasia Lubennikova Message-ID: <56D5C970.6020002@postgrespro.ru> Date: Tue, 1 Mar 2016 19:55:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56D46114.9090205@postgrespro.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.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 29.02.2016 18:17, Anastasia Lubennikova: > 25.02.2016 21:39, Jeff Janes: >>> As promised, here's the new version of the patch >>> "including_columns_4.0". >>> I fixed all issues except some points mentioned below. >> Thanks for the update patch. I get a compiler warning: >> >> genam.c: In function 'BuildIndexValueDescription': >> genam.c:259: warning: unused variable 'tupdesc' > > Thank you for the notice, I'll fix it in the next update. >> Also, I can't create a primary key INCLUDING columns directly: >> >> jjanes=# create table foobar (a int, b int, c int); >> jjanes=# alter table foobar add constraint foobar_pkey primary key >> (a,b) including (c); >> ERROR: syntax error at or near "including" >> >> But I can get there using a circuitous route: >> >> jjanes=# create unique index on foobar (a,b) including (c); >> jjanes=# alter table foobar add constraint foobar_pkey primary key >> using index foobar_a_b_c_idx; >> >> The description of the table's index knows to include the including >> column: >> >> jjanes=# \d foobar >> Table "public.foobar" >> Column | Type | Modifiers >> --------+---------+----------- >> a | integer | not null >> b | integer | not null >> c | integer | >> Indexes: >> "foobar_pkey" PRIMARY KEY, btree (a, b) INCLUDING (c) >> >> >> Since the machinery appears to all be in place to have primary keys >> with INCLUDING columns, it would be nice if the syntax for adding >> primary keys allowed one to implement them directly. >> >> Is this something or future expansion, or could it be added at the >> same time as the main patch? > > Good point. > At quick glance, this looks easy to implement it. The only problem is > that there are too many places in code which must be updated. > I'll try to do it, and if there would be difficulties, it's fine with > me to delay this feature for the future work. > > I found one more thing to do. Pgdump does not handle included columns > now. I will fix it in the next version of the patch. > As promised, fixed patch is in attachments. It allows to perform following statements: create table utbl (a int, b box); alter table utbl add unique (a) including(b); create table ptbl (a int, b box); alter table ptbl add primary key (a) including(b); And now they can be dumped/restored successfully. I used following settings pg_dump --verbose -Fc postgres -f pg.dump pg_restore -d newdb pg.dump It is not the final version, because it breaks pg_dump for previous versions. I need some help from hackers here. pgdump. line 5466 if (fout->remoteVersion >= 90400) What does 'remoteVersion' mean? And what is the right way to change it? Or it changes between releases? I guess that 90400 is for 9.4 and 80200 is for 8.2 but is it really so? That is totally new to me. BTW, While we are on the subject, maybe it's worth to replace these magic numbers with some set of macro? P.S. I'll update documentation for ALTER TABLE in the next patch. -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers