Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6I1Q-0002sp-Qu for pgsql-hackers@arkaria.postgresql.org; Fri, 27 May 2016 13:41:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b6I1P-0005Py-Ra for pgsql-hackers@arkaria.postgresql.org; Fri, 27 May 2016 13:41:51 +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_2) (envelope-from ) id 1b6I1O-0005Pi-3I for pgsql-hackers@postgresql.org; Fri, 27 May 2016 13:41:51 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b6I1K-0000ui-EC for pgsql-hackers@postgresql.org; Fri, 27 May 2016 13:41:48 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8750621C88A2 for ; Fri, 27 May 2016 16:41:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru 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 Dm03uH_DS-FR for ; Fri, 27 May 2016 16:41:42 +0300 (MSK) Received: from nataraj-amd64.localnet (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 0C34421C80B8 for ; Fri, 27 May 2016 16:41:41 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1464356502; bh=W9uK7poO3KyssjgplCKMQt800v2U2+hKlDwexFAiobk=; h=From:To:Subject:Date:In-Reply-To:References; b=TOaB2p3D8qGtwBOSgvEFZndYWHvx8Lr9N4Rgowvp+/0nO9N6/kwFLdLPm5xp8eJIC JJoyXWhCJXr9l7BUlnpDo1qVFzTy6cSRdjRIVp5C6JObLG+KzlR0L2YmnGr5THSEgr dx1JYFcRjjs+Gu9k7qDfdNMTCrOJtgZ9ipolX5bY= From: Nikolay Shaplov To: pgsql-hackers@postgresql.org Subject: Re: [PROPOSAL] Move all am-related reloption code into src/backend/access/[am-name] and get rid of relopt_kind Date: Fri, 27 May 2016 16:41:41 +0300 Message-ID: <1544707.j5kAjF95Mp@nataraj-amd64> User-Agent: KMail/4.14.1 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; ) In-Reply-To: <4636505.Bu9AKW1Kzc@nataraj-amd64> References: <4636505.Bu9AKW1Kzc@nataraj-amd64> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Pg-Spam-Score: -3.4 (---) 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 =D0=92 =D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B5 =D0=BE=D1=82 24 =D0=BC=D0=B0=D1= =8F 2016 17:12:16 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0= =B5=D0=BB=D1=8C Nikolay Shaplov =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB: While working on this patch I met some difficulties that makes me to comple= tely=20 rewrite a code that is responsible for interacting reloptions.c with access= =20 methods. Story start from the point that I found out that a.m. can not forbid changi= ng=20 some of it's reloptions with ALTER INDEX command. That was not necessary=20= =20 before, because all reloptions at that existed at that time can be changed = on=20 fly. But now for bloom index it is unacceptable, because for changing bloom= 's=20 reloptions for existing index will lead to index malfunction. I was thinking about adding for_alter flag argument for parseRelOptions fun= tion=20 and pass it all the way from indexcmds.c & tablecmds.c, and add some flag i= n=20 the definition of reloptions to mark those reloptions that should not be us= ed=20 in ALTER INDEX clause.=20 This theoretically this will give us a way to throw error when user tries t= o=20 change an reloption that should not be changed. But unfortunately it turned out that in ATExecSetRelOptions new reloptions = is=20 merged with existing reloptions values using transformRelOptions, and only= =20 after that the result is sent for validation.=20 So on the step of the validation we can not distinguish old options from a = new=20 one.=20 I've been thinking how to work this around, but found out that there is no= =20 simple way. I can pass another array of flags through the whole call stack.= But=20 this make all thing uglier.=20 I can create another function that do pre-validation for new reloptions,=20 before doing final validation of the whole set. But this will make me to ha= ve=20=20 to entities available from the a.m.: the descriptor of reloptions and=20 function for custom validation of the results (i.e. like adjustBloomOptions= =20 for Bloom). But it would be not good if we dedicate two entires of a.m. to reoptions=20 definition. And there can be even more...=20 So I came to a conclusion: gather all the staff that defines the all the=20 behavior of reloption parsing and validation into one structure, both array= of=20 relopt_value, custom validation function, and all the other staff. And this structure is the only thing that a.m. gives to reloptions.c code f= or=20 parsing and validation purposes. And that should be enough. I hope this make code more flexible and more easy to understand. --=20 Nikolay Shaplov Postgres Professional: http://www.postgrespro.com Russian Postgres Company --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers