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.96) (envelope-from ) id 1vhENo-00BXeg-1L for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Jan 2026 22:03:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vhENm-009gy6-0J for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Jan 2026 22:02:58 +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.96) (envelope-from ) id 1vhENl-009gxy-1J for pgsql-hackers@lists.postgresql.org; Sat, 17 Jan 2026 22:02:58 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vhENh-0013ZI-2i for pgsql-hackers@lists.postgresql.org; Sat, 17 Jan 2026 22:02:56 +0000 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.stl.internal (Postfix) with ESMTP id B38BC1D002B2; Sat, 17 Jan 2026 17:02:49 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Sat, 17 Jan 2026 17:02:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1768687369; x=1768773769; bh=j lPMABEqci4Lnh9lsCWjeYcO6Af7bwDUccsRdfR4kas=; b=VcAzoiskac3EmLxaz YSErxzPP4hsofxfAfgkKI1RpfDh3RTMszC8WzTSTtpl2wIE9ypHSHhQd9LmDBx6b 2JgKxKbPoeHyGh8qDHboi+AQWqf+Q0AUwm5oJDEfcIsfBpgA4cgQY90s+YQ6ppzc sCtNZo6pHDlCf9SSQlNWvKsJLXxWst1MvJghJxCTqDxvI7f6g129TYOCHK6HSjUq som4Kb2be5u6/8SfnA1vRha9MGPUT64Mbvv7VVgWjPjlUnhAvXw8gE7Q3C9FpPMG BrRFMRS9ggujFG5VGW1jt+MJn+8XE8tECqfCHAI+LucxvaHoGzLZZjv4lXINMy2L ZYqHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddufedvleeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqne cuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeekfffg udffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgv rhhrvgesrghlvhhhrdhnohdqihhprdhorhhgpdhnsggprhgtphhtthhopeehpdhmohguvg epshhmthhpohhuthdprhgtphhtthhopegrnhgurhgvshesrghnrghrrgiivghlrdguvgdp rhgtphhtthhopegvuhhlvghrsegvuhhlvghrthhordgtohhmpdhrtghpthhtoheplhhird gvvhgrnhdrtghhrghosehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhgrphhinhhlihes hhhothhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlih hsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 17 Jan 2026 17:02:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1768687367; bh=h59mjamNkNQz5AKFlvbly7Mp8AwBID6lNNPIfpMVeQs=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=OvqIQeibFKjQnSwDfgq62fv+PSv/X+7/741W4ggBhAkXTAhpJtbVasIm7hUKqnJSu KTgj7HR+ZGRbZ3N0GxilylFDreM8SrpcQ19iEPoBrWUMkn+mTkp1GZVS5jLOEBQIsD hq9XFyLV9Y7WAkCtH0TPwQJoVQVFFbmjpJu0HJpJn6VCYGeVTWtuA6qoCYgPOuXBV2 Lqv1HT+TO9StWIaAXfhznYX5Xofv1yya5Hj+xMTyEiaEQWpWQX5ZSAsAxXDpvu2FwE M3wY5BsHNODVKQ/UjnwK579ID6hgfJpz0dzzcTJtNsqdH+EerFLtRUKVWBDa1PrhFr Xv5CDzQOuEGIQ== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id 67FD478; Sat, 17 Jan 2026 23:02:47 +0100 (CET) Date: Sat, 17 Jan 2026 23:02:47 +0100 From: Alvaro Herrera To: Euler Taveira Cc: japin , Andres Freund , pgsql-hackers@lists.postgresql.org, Chao Li Subject: Re: log_min_messages per backend type Message-ID: <202601172159.zlzebobtb7kq@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Jan-15, Euler Taveira wrote: > + /* > + * Use a stable representation of log_min_messages. The generic level is > + * always the first element and the other elements (type:level) are sorted > + * by process type. > + */ > + list_sort(elemlist, string_cmp); > + foreach(l, elemlist) > + { > + char *tok = (char *) lfirst(l); > + > + if (strchr(tok, ':') == NULL) > + { > + elemlist = list_delete(elemlist, tok); > + elemlist = lcons(tok, elemlist); > + break; > + } > + } > +static int > +string_cmp(const ListCell *a, const ListCell *b) > +{ > + const char *s = lfirst(a); > + const char *t = lfirst(b); > + > + return strcmp(s, t); > +} I'm not opposed to this idea, but I think it should be implemented not by sorting and then moving the first element to the top of the list, but instead by modifying the cmp function so that the desired order is achieved directly. So the cmp() should return -1 if element a has no colon, or 1 if element b has no colon, otherwise return per strcmp. That way you can remove the foreach() block above, which is icky. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "Computing is too important to be left to men." (Karen Spärck Jones)