Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvZEJ-0002RR-Un for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Sep 2017 01:27:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dvZEI-0001Ku-Jq for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Sep 2017 01:27:38 +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 1dvZEG-0001IC-Bh for pgsql-bugs@postgresql.org; Sat, 23 Sep 2017 01:27:36 +0000 Received: from mail-yw0-x22a.google.com ([2607:f8b0:4002:c05::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dvZEC-0001DR-Uy for pgsql-bugs@postgresql.org; Sat, 23 Sep 2017 01:27:34 +0000 Received: by mail-yw0-x22a.google.com with SMTP id w22so1804483ywa.13 for ; Fri, 22 Sep 2017 18:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=jR4IPmHM7J2sRMDu4qXib/tJiKxuQnspISiu6KtcnJM=; b=QfyhgfJeq7nNslkBV28QGCflslSboAZ+upyjQKIQRA4IKsIQF0F4ssC468Jg4GzgNg FCSnMmWqTKZ6QV3lis8J7s/ROVSaksvVgGnfGGksdOBRh3xtCMTC/ON61LOAJxB4x7zQ ST8R6bYJagO9YQfSnnVhu/7mmPpm4Iz57vCVEqg1yKTm7TG2v/ufYC+Rhu57REmRP3Kd M2dHh5V1u9TNIqaJRggC3lYRPv2sV2TCwuLgxgYLTg04r4Tl6fWMBgN0sHgPC3dwYbEg O8argZGXXs2eFNmqQSi2mSvD4u7YeQJ1hDhgM6Hvy+DAqXn6lqL20izxLlda8xjPYLok xkPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=jR4IPmHM7J2sRMDu4qXib/tJiKxuQnspISiu6KtcnJM=; b=IsTG4zR6GMmlUIwo7xKDiXC9k5nJjy/jaFj7Vl65+zeaunvqUpMW4UAwmtnYeRKUky rF0GdXKxPfW0T3LN/ddMmL8hvzHv6YbTq1M1vgQC+M3XXOeGIhryHyHrKeCQkqvXdAbD E2R+erdCknpfb/3oyYLdq12mcte+2vvobna3N4FjFvwANyQ+Oo8k6QxdaO5iriFdpvg1 2M+I9aDIT/yXLPJalNkQ30yOkcWt2YSpev3rCaepY4vg5Ynw7MnxfjM7n+DRKzpON15J HDhlIthp90IfHxUEx+5IF+0o+39PNweOlsV/+A3nTIbKntSCtxCo75GFnUVLJ+BC1cEy ovYg== X-Gm-Message-State: AHPjjUiGyiifEXxkyc5wgjJqeXBrVLrCyo/7pn0ufLEysb1LoOqdLVQl oOpHAdLmsluIiaaL6a4oPJcp X-Google-Smtp-Source: AOwi7QBQFiC1IWm7zND26i9gA8Q+V8z02UYxixluGJnefF8wuyXtBuOcOlzTD56kDg56TvbhTaMV5Q== X-Received: by 10.37.130.72 with SMTP id d8mr568455ybn.25.1506130051305; Fri, 22 Sep 2017 18:27:31 -0700 (PDT) Received: from [192.168.10.146] ([98.122.175.38]) by smtp.gmail.com with ESMTPSA id y186sm507710ywc.71.2017.09.22.18.27.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 18:27:30 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: BUG #14825: enum type: unsafe use? To: Tom Lane , balazs@obiserver.hu Cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org References: <20170922185904.1448.16585@wrigleys.postgresql.org> <15165.1506116768@sss.pgh.pa.us> Message-ID: <3cece400-af56-7145-2e65-f044de1b0b68@2ndQuadrant.com> Date: Fri, 22 Sep 2017 21:27:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <15165.1506116768@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-MW List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 09/22/2017 05:46 PM, Tom Lane wrote: > balazs@obiserver.hu writes: >> PostgreSQL version: 10beta4 >> testdb=# begin; >> BEGIN >> testdb=# create type enumtype as enum ('v1', 'v2'); >> CREATE TYPE >> testdb=# alter type enumtype owner to testrole; >> ALTER TYPE >> testdb=# create table testtable (enumcolumn enumtype not null default 'v1'); >> ERROR: unsafe use of new value "v1" of enum type enumtype >> HINT: New enum values must be committed before they can be used. > Hmm, that's pretty annoying. It's happening be > cause check_safe_enum_use > insists that the enum's pg_type entry not be updated-in-transaction. > We thought that the new rules instituted by 15bc038f9 would be generally > more convenient to use than the old ones --- but this example shows > that, for example, pg_dump scripts involving enums often could not > be restored inside a single transaction. > > I'm not sure if that qualifies as a stop-ship problem, but it ain't > good, for sure. We need to look at whether we should revert 15bc038f9 > or somehow revise its rules. :-( The only real problem comes from adding a value to an enum that has been created in an earlier transaction and then using that enum value. What we're doing here is essentially a heuristic test for that condition, and we're getting some false positives. I wonder if we wouldn't be better doing this more directly, keeping a per-transaction hash of unsafe enum values (which will almost always be empty). It might even speed up the check. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs