Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3k2I-00EOZY-As for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Oct 2024 22:41:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3k2G-00EAuM-MS for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Oct 2024 22:41:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3k2G-00EAuC-Cz for pgsql-hackers@lists.postgresql.org; Wed, 23 Oct 2024 22:41:00 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t3k2D-002dUr-UX for pgsql-hackers@lists.postgresql.org; Wed, 23 Oct 2024 22:41:00 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-539fbe22ac0so286417e87.2 for ; Wed, 23 Oct 2024 15:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729723256; x=1730328056; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KUJbOkDwyPTAIBY6OHPcgtPlD2EL1E4iIEUdvCi7rcM=; b=mJFxDA4ieukpzKDmzo6JxBPfpMqoOJqaMlnlbZLpvQjaYoGELY70pZu2+pBHCZ3D5k id2uodALCIqMNF4enJFIsLvufDVSVDlV9n9WYD3+4tr4L+kS0pT/Rb5a9lQco89LqHsP 4U/BwYchXUU/eCu9lux+kgjBNmOKBVHwN3GnhPljum1nrSl7LbksGXHrlHb81NHKLyRT YCz0oWNjl6RFb803wVUe0CM3r2jdYaXJcz1v1WXEKSMjKDVyoXLYtBDj9055FiSJ2lNt 55E/lbOQ/HS62tG15O5jmanM+6JS8lIq3Rn1R7YIJ2g+w7gibhGGsGBSnGGEhRw62Il1 xzoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729723256; x=1730328056; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KUJbOkDwyPTAIBY6OHPcgtPlD2EL1E4iIEUdvCi7rcM=; b=F1BtpkRMe2RYoQJF9XMpgshkieB+G7OlZ12FC4LJD/5FAu+row1ezWMkF2N61+YxUy ITEiEhKw2lDAkbWLY1YXF5i7cZuy9QCc8sIsGm20FEUyGFG1GLCaM2+P8EvDp3KEswDS /FRjXWp7F0X4BKf3lATz6BosdfpgMvUHYm34j5+/30DVOmchhe0n+r2w9jnJAtRJP0mA jyR3NcW1QBmfLFc+2h+QtpTUjkHZsmgc2qF46Ld4P4KZvtRrQ06T+54rT6HqITaqEZqv j/AMtXLWD5Q3BI64G6nLagD69CW2j0P+e25Z7RK9ysWiyrBYgSyzgNjztK4LWpQYfE9c a38w== X-Forwarded-Encrypted: i=1; AJvYcCX6nM8tpIG4I0Fl4kpJBA7AvaGcWBGQ96sE1/bt860Lrtk6qeKlzChfPPwfpmwIPx67h9g8HVkkiMmtIYqW@lists.postgresql.org X-Gm-Message-State: AOJu0YzbIeude31BKhNoRLApNCZxNvFjh7gPgMWC1M4v6zraXSjkOeu+ m4Asn0dr99TJ/US0IcVw1N3ghJ6eH5qssd2LXoH+JMcvXnyL5h44iLab895TpU+9vNzMnWudBpS oCXxPXxo6WtEvGeKrWj8H3jmpE38= X-Google-Smtp-Source: AGHT+IFCIkxD0oTyWG8Y57agaVttpKJCEbfxkhI4WtIib5FhUknB5SNq9EB3ycEp+DLNZW9XudCmbfNfEIP50QMk+CU= X-Received: by 2002:a05:6512:1189:b0:533:3fc8:43ee with SMTP id 2adb3069b0e04-53b1a3030f0mr2526566e87.13.1729723256138; Wed, 23 Oct 2024 15:40:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Wed, 23 Oct 2024 15:40:19 -0700 Message-ID: Subject: Re: Refactor to use common function 'get_publications_str'. To: Peter Smith Cc: Michael Paquier , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 23, 2024 at 3:26=E2=80=AFPM Peter Smith = wrote: > > On Thu, Oct 24, 2024 at 8:26=E2=80=AFAM Masahiko Sawada wrote: > > Thanks for your feedback! > > > > > While the changes look good to me, the comment of GetPublicationsStr() > > seems not match what the function actually does: > > > > +/* > > + * Add publication names from the list to a string. > > + */ > > +void > > +GetPublicationsStr(List *publications, StringInfo dest, bool quote_lit= eral) > > > > It's true that the function adds publication names to the given > > StringInfo, but it seems to me that the function expects the string is > > empty. For example, if we call this function twice with the same > > publication list, say 'pub1' and 'pub2', it would return a string > > 'pub1,pub2pub1,pub2'. > > No, although this function is not designed to be called twice in a > row, there are code examples where this function is being called > passing (non-empty) SQL cmd string. > > e.g. > cmd =3D makeStringInfo(); > appendStringInfoString(cmd, "SELECT t.pubname FROM\n" > " pg_catalog.pg_publication t WHERE\n" > " t.pubname IN ("); > GetPublicationsStr(publications, cmd, true); > appendStringInfoChar(cmd, ')'); Thanks, that makes sense. > > > I think we can improve the description of this > > function to something like "Build a comma-separated string from the > > given list of publication names.". > > > > This is a refactoring patch, so I hadn't intended to touch the > function, but I agree the function comment could be better. > > Now, I've changed the function comment to: > /* > * Add a comma-separated list of publication names to the 'dest' string. > */ Thank you for updating the patch. The patch looks good to me. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com