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 1nXjXZ-00025d-HO for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2022 12:59:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nXjXY-0002UO-F8 for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Mar 2022 12:59:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXjXY-0002UE-1i for pgsql-hackers@lists.postgresql.org; Fri, 25 Mar 2022 12:59:40 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nXjXV-0000fq-MX for pgsql-hackers@lists.postgresql.org; Fri, 25 Mar 2022 12:59:39 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 27C2F5C0203; Fri, 25 Mar 2022 08:59:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 25 Mar 2022 08:59:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; bh=56+afOgs8c1pQMZe+wpGFFwF48N4j1xgXLRfnl sbnoc=; b=qAltm21/eoazjytSfLpUC6fY7Bknqro0P095vDue0Vk0ClF9DMznlr 3IdoQoRnSU1KJi6D85UF9e9nXcKrtwthTGZfXdxWk+/eLvMVNOH5LPRtQTzUihfe zVRA1t9jmllomCFK3ntuzygqWf0f13qtux7I4h4Ny+EOjJd+OjV11djkaqzzryzI U0lxpbeI4F5tGTwEze+s1qUdWMSUZuKFcdzdtuYE/vnVTFld52A/FrFc/4byz2jd GdWLMXFYvUcrPDizZQxuO+Stj2mstYxtEcg6uQJ5U+gjnteVAIO9OeXYeE2FqNk8 9/pBwloCyAsHM1Gi8ncXdFsFqRDtXveQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=56+afOgs8c1pQMZe+ wpGFFwF48N4j1xgXLRfnlsbnoc=; b=mdi0YIlRVBVyfAJKN8vOhJwC5ZC3PhPnI K4lB9wh8UPRB4phhkxLiizUuBg7dsFpGlRx5bm88icCIK+A5RvZIrwk1ZI0jK2JU ZfJg11tAPQklLcci5C93rqBiIUnI9MANbRd1UltONh5hZDtgfVpSNI5N943Zd3LC G3lf0IsVu2WBK3pGfUnB6lNHhyqmtuKrOPPcIbIs/CVoUPGWOtX9HZNOj2jJifas Pu0UkBKF/Qs9yJEyqbAB/TOl+auynYTzWBYWDy6K4dI/HigJQqwRap5gRIptD+va dWuSIZSL6DTjC4OgS4SW8smIFw7p8+Du3ggTd80ko2YXspYbNZWgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudehuddggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehmtderredtreejnecuhfhrohhmpeffrghgfhhi nhhnpgfklhhmrghrihgpofgrnhhnshonkhgvrhcuoehilhhmrghrihesihhlmhgrrhhird horhhgqeenucggtffrrghtthgvrhhnpeetveeiheetteelgeelgffhfeekjeehleeltdet tdfgvdekffehffdvkeehueduffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Mar 2022 08:59:36 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Daniel Gustafsson Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Doc patch: replace 'salesmen' with 'salespeople' References: <87o81vqjw0.fsf@wibble.ilmari.org> <7924A395-67D0-4128-8693-D6E2A063092F@yesql.se> Date: Fri, 25 Mar 2022 12:59:35 +0000 In-Reply-To: <7924A395-67D0-4128-8693-D6E2A063092F@yesql.se> (Daniel Gustafsson's message of "Thu, 24 Mar 2022 21:40:11 +0100") Message-ID: <87ils2qjbc.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Daniel Gustafsson writes: >> On 24 Mar 2022, at 19:34, Dagfinn Ilmari Mannsåker wrote: > >> I just spotted an unnecessarily gendered example involving a 'salesmen' >> table in the UPDATE docs. Here's a patch that changes that to >> 'salespeople'. > > No objections to changing that, it's AFAICT the sole such usage in the docs. There's a mention of the travelling salesman problem in the GEQO docs (and one in the code comments), but that's the established name for that problem (although I do note the Wikipedia page says it's "also called the travelling salesperson problem"). >> Update contact names in an accounts table to match the currently assigned >> - salesmen: >> + salespeople: >> >> UPDATE accounts SET (contact_first_name, contact_last_name) = >> - (SELECT first_name, last_name FROM salesmen >> - WHERE salesmen.id = accounts.sales_id); >> + (SELECT first_name, last_name FROM salespeople >> + WHERE salespeople.id = accounts.sales_id); > > This example is a bit confusing to me, it's joining on accounts.sales_id to get > the assigned salesperson, but in the example just above we are finding the > salesperson by joining on accounts.sales_person. Shouldn't this be using the > employees table to keep it consistent? (which also avoids the gendered issue > raised here) The same goes for the second example. Or am I missing something? Yeah, you're right. The second section (added by Tom in commit 8f889b1083f) is inconsistent with the first half in both table and column names. Here's a patch that makes it all consistent, eliminating the salesmen references completely, rather than renaming them. - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-doc-make-UPDATE-FROM-examples-consistent.patch From 5dbbba776d6d53eb3abcbf028f6c94b4e4c0e75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Fri, 25 Mar 2022 12:49:14 +0000 Subject: [PATCH] doc: make UPDATE FROM examples consistent The original first half of the example used an employees table and an accounts.sales_person foreign key column, while the second half (added in commit 8f889b1083f) used a salesmen table and accounts.sales_id for the foreign key. This makes everything use the original names, thus eliminating the unnecessarily gendered salesmen table. --- doc/src/sgml/ref/update.sgml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml index 3a0285df79..2ab24b0523 100644 --- a/doc/src/sgml/ref/update.sgml +++ b/doc/src/sgml/ref/update.sgml @@ -387,23 +387,23 @@ Update contact names in an accounts table to match the currently assigned - salesmen: + salespeople: UPDATE accounts SET (contact_first_name, contact_last_name) = - (SELECT first_name, last_name FROM salesmen - WHERE salesmen.id = accounts.sales_id); + (SELECT first_name, last_name FROM employees + WHERE employees.id = accounts.sales_person); A similar result could be accomplished with a join: UPDATE accounts SET contact_first_name = first_name, contact_last_name = last_name - FROM salesmen WHERE salesmen.id = accounts.sales_id; + FROM employees WHERE employees.id = accounts.sales_person; However, the second query may give unexpected results - if salesmen.id is not a unique key, whereas + if employees.id is not a unique key, whereas the first query is guaranteed to raise an error if there are multiple id matches. Also, if there is no match for a particular - accounts.sales_id entry, the first query + accounts.sales_person entry, the first query will set the corresponding name fields to NULL, whereas the second query will not update that row at all. -- 2.30.2 --=-=-=--