Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j2ceW-0002Db-12 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Feb 2020 15:13:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j2ceU-0006tL-67 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Feb 2020 15:13:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j2ceT-0006tE-Qh for pgsql-hackers@lists.postgresql.org; Fri, 14 Feb 2020 15:13:09 +0000 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j2ceQ-0001XZ-0b for pgsql-hackers@postgresql.org; Fri, 14 Feb 2020 15:13:09 +0000 Received: by mail-qv1-xf43.google.com with SMTP id g6so4420147qvy.5 for ; Fri, 14 Feb 2020 07:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=o/8QOp3dgS2m3LlQs1LYXBGfZ9304GovSa9EUlYtQuM=; b=zRG7c3hZfuG1jDu51uhUB8jAH8d+B0X3L+ZqXnbL5DGFq6vQ8eFyqMXjkimzYQkaYr UZRnY4s1Oh4eWvYehAJTgyV+s2540jRy/QKnG7HEEfTJKi8P57aIca00NgryS5UIcfAl RYWXCrkK18VvJs7/auRKYhAJYzX7glcIjxgSTC59nFroNJZLS6080I/YLhU3PUraePca P52ifLYDx/AhH5neIz4P/MOtFf9Nbv+aJCN2L//a/UyqZlKYKpGDbyTn3AQA/WhZmIJj i+7/8dVVk0UcFzAx+o+UhlZYXX3pxiR9DrbTt8SsBGXq95w3GetWsyyJwb63N8ChOO/9 rSqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=o/8QOp3dgS2m3LlQs1LYXBGfZ9304GovSa9EUlYtQuM=; b=OguWpnavHB12tmZOU38dMjveT6mNPHAE+V0UzOTZkXxucvTmkvqN6ji1ILpovYfPwV Ke6ZgGK4NO68b6pCwXft/hGD1Nxm49a8uz80qUQXU4rKjKkdjoBZKc/622BSvUVKUt1p eUoWaufJVW2Vvuey+qT5pW5qw+zZdp4QvTyz2hxP/zam4F0VDAIYVerpaua1jYjWVfjg RfJTVjhSUZ6zMqxpRK0qtHeAorybecY1cpoM9YpxwRs2tY3t949TGbHwBNdFYI3uMJRN Gk1iymPbg3gSG7piJeJuTQFFSTzKXtVTelN4N4lf53AC+qBg5LmKL1YWyhzsrBeJR2Vw tyKQ== X-Gm-Message-State: APjAAAVBKH+5C+gLa7dYVOnHIIWUen34FPC48Pa/KJod76PDAWuu6grb bvESsQW9EyeVqgbIce47tEQwyA== X-Google-Smtp-Source: APXvYqwAwQyV7f0WoSxGxLXVqWDSiZu5dE4ur6Z1zuLfVHEcz9wcEQPn6q5nlQpbfIS8UChyG1p/AQ== X-Received: by 2002:ad4:4a6e:: with SMTP id cn14mr2573337qvb.21.1581693184463; Fri, 14 Feb 2020 07:13:04 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([201.186.208.119]) by smtp.gmail.com with ESMTPSA id h34sm3545641qtc.62.2020.02.14.07.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Feb 2020 07:13:03 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 97E4430068E; Fri, 14 Feb 2020 12:13:01 -0300 (-03) Date: Fri, 14 Feb 2020 12:13:01 -0300 From: Alvaro Herrera To: Amit Langote Cc: John Naylor , Tom Lane , Justin Pryzby , PostgreSQL-development Subject: Re: assert pg_class.relnatts is consistent Message-ID: <20200214151301.GA6618@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I propose this more concise coding for AddDefaultValues, # Now fill in defaults, and note any columns that remain undefined. foreach my $column (@$schema) { my $attname = $column->{name}; my $atttype = $column->{type}; # Skip if a value already exists next if defined $row->{$attname}; # 'oid' and 'relnatts' are special cases. Ignore. next if $attname eq 'oid'; next if $attname eq 'relnatts'; # This column has a default value. Fill it in. if (defined $column->{default}) { $row->{$attname} = $column->{default}; next; } # Failed to find a value. push @missing_fields, $attname; } -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services