Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ekGUH-0005Tv-3f for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Feb 2018 21:45:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekGUF-0004q2-Ax for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Feb 2018 21:45:39 +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 1ekGUF-0004ps-0n for pgsql-hackers@lists.postgresql.org; Fri, 09 Feb 2018 21:45:39 +0000 Received: from smtprelay0173.b.hostedemail.com ([64.98.42.173] helo=smtprelay.b.hostedemail.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ekGUB-0007Zt-Eo for pgsql-hackers@postgresql.org; Fri, 09 Feb 2018 21:45:37 +0000 Received: from filter.hostedemail.com (10.5.19.248.rfc1918.com [10.5.19.248]) by smtprelay06.b.hostedemail.com (Postfix) with ESMTP id EF34E8D245; Fri, 9 Feb 2018 21:45:32 +0000 (UTC) X-Session-Marker: 616C76686572726540616C76682E6E6F2D69702E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,alvherre@alvh.no-ip.org,:::,RULES_HIT:41:334:355:368:369:379:599:966:967:968:973:981:988:989:1260:1277:1311:1312:1313:1314:1345:1359:1437:1515:1516:1518:1519:1534:1542:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2525:2560:2563:2682:2685:2693:2828:2859:2915:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3308:3355:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4385:4605:5007:6119:6261:7903:7904:8957:9010:9025:9108:9121:10004:10400:10450:10455:10848:11026:11232:11658:11914:13095:13439:13894:13895:14721:19904:19999:21080:21324:21433:21451:21627:30012:30029:30051:30054:30062:30069:30089,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: cream80_6a948ba042743 X-Filterd-Recvd-Size: 3151 Received: from alvin.alvh.no-ip.org (unknown [179.57.113.18]) (Authenticated sender: alvherre@alvh.no-ip.org) by omf13.b.hostedemail.com (Postfix) with ESMTPA; Fri, 9 Feb 2018 21:45:32 +0000 (UTC) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id ED8EC798; Fri, 9 Feb 2018 18:45:29 -0300 (-03) Date: Fri, 9 Feb 2018 18:45:29 -0300 From: Alvaro Herrera To: Nikolay Shaplov Cc: pgsql-hackers@postgresql.org Subject: Re: [PATCH][PROPOSAL] Add enum releation option type Message-ID: <20180209214529.mbz6iqji7v436xde@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <43332102.S2V5pIjXRx@x200m> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Nikolay Shaplov wrote: > I found out, that all relation options of string type in current postgres, are > actually behaving as "enum" type. If this patch gets in, I wonder if there are any external modules that use actual strings. An hypothetical example would be something like a SSL cipher list; it needs to be somewhat free-form that an enum would not cut it. If there are such modules, then even if we remove all existing in-core use cases we should keep the support code for strings. Maybe we need some in-core user to verify the string case still works. A new module in src/test/modules perhaps? On the other hand, if we can find no use for these string reloptions, maybe we should just remove the support, since as I recall it's messy enough. > [...] But each time this behavior is implemented as validate function > plus strcmp to compare option value against one of the possible > values. > > I think it is not the best practice. It is better to have enum type > where it is technically enum, and keep sting type for further usage > (for example for some kind of index patterns or something like this). Agreed with the goal, for code simplicity and hopefully reducing code duplication. > Possible flaws: > > 1. I've changed error message from 'Valid values are "XXX", "YYY" and "ZZZ".' > to 'Valid values are "XXX", "YYY", "ZZZ".' to make a code a bit simpler. If it > is not acceptable, please let me know, I will add "and" to the string. I don't think we care about this, but is this still the case if you use a stringinfo? > 2. Also about the string with the list of acceptable values: the code that > creates this string is inside parse_one_reloption function now. I think you could save most of that mess by using appendStringInfo and friends. I don't much like the way you've represented the list of possible values for each enum. I think it'd be better to have a struct that represents everything about each value (string name and C symbol. Maybe the numerical value too if that's needed, but is it? I suppose all code should use the C symbol only, so why do we care about the numerical value?). -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services