Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jimlg-00072z-Qb for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2020 22:30:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jimlf-0005lt-15 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jun 2020 22:30:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jimle-0005lm-LI for pgsql-hackers@lists.postgresql.org; Tue, 09 Jun 2020 22:30:50 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jimlb-0000Ga-Qh for pgsql-hackers@postgresql.org; Tue, 09 Jun 2020 22:30:50 +0000 Received: by mail-io1-xd2f.google.com with SMTP id t9so2860242ioj.13 for ; Tue, 09 Jun 2020 15:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=shpVZ4pOVwewpc6ae4fN/2nudvQ8BPK8L8rdyUvbo4Y=; b=NsD9duX7KD2BIOH63Cur9tPq4FDy3XLs2q1wMvcEkwfGfB1yy3yUL6yka2pHMB2H9R t1rdPv4IYq0fuwJypOiFLs0gCBJRkuH9NLvkh+bbqHcXiKb36QdcElTj8Gb8OAM6N4+1 TGI10fPAs/F11gqYgWGwSPkHvbWmfJg+tYsgisdIRSNvDhQ/PYXxaKTr4ZHcbelVp+R6 Qf4TeqsiBDSv6LG1q07eUHYNy7N6C4Q/5lH5wdDdQLY9gMC/1eP2Ei4RidmgwPGsy3Cf 3Nl+ngnX7ia9vWcABmk5vDLaZKOc6wn6Ukjcx34aOmuK+CeJcPyNsaIGZXYgt9mkcK7X wxxw== 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=shpVZ4pOVwewpc6ae4fN/2nudvQ8BPK8L8rdyUvbo4Y=; b=GbRILcOdCJ1UUHqpxlq5SWNHI79rQbtsIbMlMQdNP20SaZ8jlZcwl9jDaiAior5OxD BmuyyYooTX33kfY3q1dPLnCpAVcHOtsv0sEyCslAke3awII5MBMNVjTSNb5OtfVGTkN2 7Op+uBR6IetS2Z19PZoYKSREv4q+o3n1unOCs+QCrccV613KSu9ACfnx/LgC2PNlLDwj rufwoPnD41xDmUZj9dzC6mVHMlTln8HR69FFb6VrmVeYJm6WEmds/pvXruo3V0oIU+Jn uFnBI5umPCtze3UdH5KrOyw7QLSfD2OU4ygraYRLXbujL5WkEMs7acAg6bGL630/cUw7 MUdw== X-Gm-Message-State: AOAM532oZAiw3aDoqywcbN5YAEwY2D25Ntp1iPvT9BWaR+IuThcCgxEZ 71Gl8OIg/Ol4wGcLj4xLSDVCtw== X-Google-Smtp-Source: ABdhPJxQV4s7AgHaVF70BEEEJFgJlT7MGNatFhkttwxUr+OQQDD+Vv2QyqP8ln3SX/2l6T4Z/dIOiw== X-Received: by 2002:a02:a19d:: with SMTP id n29mr368247jah.85.1591741845241; Tue, 09 Jun 2020 15:30:45 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x63sm10109077ilk.66.2020.06.09.15.30.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jun 2020 15:30:44 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 69FB7800271; Tue, 9 Jun 2020 17:30:42 -0500 (CDT) Date: Tue, 9 Jun 2020 17:30:42 -0500 From: Justin Pryzby To: Pavel Stehule Cc: pgsql-hackers@postgresql.org Subject: Re: proposal: possibility to read dumped table's name from file Message-ID: <20200609223042.GF26811@telsasoft.com> References: <20200529182514.GL17850@telsasoft.com> <20200608212957.GB22473@telsasoft.com> 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.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jun 09, 2020 at 11:46:24AM +0200, Pavel Stehule wrote: > po 8. 6. 2020 v 23:30 odesílatel Justin Pryzby napsal: > I still wonder if a better syntax would use a unified --filter option, whose > > argument would allow including/excluding any type of object: > I tried to implement simple format "[+-][tndf] objectname" Thanks. > + /* ignore empty rows */ > + if (*line != '\0') Maybe: if line=='\0': continue We should also support comments. > + bool include_filter = false; > + bool exclude_filter = false; I think we only need one bool. You could call it: bool is_exclude = false > + > + if (chars < 4) > + invalid_filter_format(optarg, line, lineno); I think that check is too lax. I think it's ok if we require the first char to be [-+] and the 2nd char to be [dntf] > + objecttype = line[1]; ... but I think this is inadequately "liberal in what it accepts"; I think it should skip spaces. In my proposed scheme, someone might reasonably write: > + > + objectname = &line[3]; > + > + /* skip initial spaces */ > + while (*objectname == ' ') > + objectname++; I suggest to use isspace() I think we should check that *objectname != '\0', rather than chars>=4, above. > + if (include_filter) > + { > + simple_string_list_append(&table_include_patterns, objectname); > + dopt.include_everything = false; > + } > + else if (exclude_filter) > + simple_string_list_append(&table_exclude_patterns, objectname); If you use bool is_exclude, then this becomes "else" and you don't need to think about checking if (!include && !exclude). > + else if (objecttype == 'f') > + { > + if (include_filter) > + simple_string_list_append(&foreign_servers_include_patterns, objectname); > + else if (exclude_filter) > + invalid_filter_format(optarg, line, lineno); > + } I would handle invalid object types as "else: invalid_filter_format()" here, rather than duplicating above as: !=ALL('d','n','t','f') > + > + if (ferror(f)) > + fatal("could not read from file \"%s\": %s", > + f == stdin ? "stdin" : optarg, > + strerror(errno)); I think we're allowed to use %m here ? > + printf(_(" --filter=FILENAME read object names from file\n")); Object name filter expression, or something.. > + * getline is originaly GNU function, and should not be everywhere still. originally > + * Use own reduced implementation. Did you "reduce" this from another implementation? Where? What is its license ? Maybe a line-reader already exists in the frontend (?) .. or maybe it should. -- Justin