Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cUEbX-0001Gq-4m for pgsql-committers@arkaria.postgresql.org; Thu, 19 Jan 2017 15:26:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cUEbV-0003Xp-Tv for pgsql-committers@arkaria.postgresql.org; Thu, 19 Jan 2017 15:26:21 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cUEbV-0003Xc-BW for pgsql-committers@postgresql.org; Thu, 19 Jan 2017 15:26:21 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cUEbQ-0006g5-TE for pgsql-committers@postgresql.org; Thu, 19 Jan 2017 15:26:20 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 6F86320683; Thu, 19 Jan 2017 10:26:15 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Thu, 19 Jan 2017 10:26:15 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=n/t8zxKAU3eh+B w640I1rFPSqE8=; b=DFVzXc7Ss+X4KFO8pjnlsjDGzJBK40zOkrEIBsRjjtMk8E ZhLtqCreaSEoRRN91dhz1obzppQkQIDeLUeeXogkEN13gcUitQJQkWBDbcNHDeup a3+JQE1qMCZzOowb5JCw4XVpfQLZnawcZ8BrRDLE+tELBEw1/QVymahhj3CEk= X-ME-Sender: X-Sasl-enc: wkGFM5W4BgdaHSubQFGpheXDRfwZYl1M3w2ivMFh6UX2 1484839575 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 3008E7E34D; Thu, 19 Jan 2017 10:26:15 -0500 (EST) Subject: Re: pgsql: Add function to import operating system collations To: Tom Lane , Amit Kapila References: <13753.1484830411@sss.pgh.pa.us> Cc: pgsql-committers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Thu, 19 Jan 2017 10:26:14 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <13753.1484830411@sss.pgh.pa.us> Content-Type: multipart/mixed; boundary="------------11645527F46A8F28C8234906" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org This is a multi-part message in MIME format. --------------11645527F46A8F28C8234906 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 1/19/17 7:53 AM, Tom Lane wrote: > Hm. I see that the patch randomly changed the way that the collation > owner is generated ... looks like it no longer works for mixed-case > usernames. Perhaps follow this model instead: > > if (superuser_password) > PG_CMD_PRINTF2("ALTER USER \"%s\" WITH PASSWORD E'%s';\n\n", > username, escape_quotes(superuser_password)); > > although TBH that doesn't look too darn safe either. I wonder how > initdb has gotten along so far with no quote_ident() function. We could just use the numeric value, like in the attached patch. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------11645527F46A8F28C8234906 Content-Type: text/x-patch; name="initdb-bootstrap-superuser-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="initdb-bootstrap-superuser-fix.patch" diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index eb1be100c8..75d3d6f5f6 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -61,6 +61,7 @@ #endif #include "catalog/catalog.h" +#include "catalog/pg_authid.h" #include "common/file_utils.h" #include "common/restricted_token.h" #include "common/username.h" @@ -1617,7 +1618,7 @@ setup_collation(FILE *cmdfd) PG_CMD_PUTS("SELECT pg_import_system_collations(if_not_exists => false, schema => 'pg_catalog');\n\n"); /* Add an SQL-standard name */ - PG_CMD_PRINTF2("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) VALUES ('ucs_basic', 'pg_catalog'::regnamespace, '%s'::regrole, %d, 'C', 'C');\n\n", escape_quotes(username), PG_UTF8); + PG_CMD_PRINTF2("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) VALUES ('ucs_basic', 'pg_catalog'::regnamespace, %u, %d, 'C', 'C');\n\n", BOOTSTRAP_SUPERUSERID, PG_UTF8); } /* --------------11645527F46A8F28C8234906 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers --------------11645527F46A8F28C8234906--