From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: initdb / bootstrap design |
Date: | 2022-02-20 00:31:52 |
Message-ID: | 20220220003152.qdnjp3skpkw42tof@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2022-02-19 18:35:18 -0500, Tom Lane wrote:
> Here's an initial patch that gets rid of the need for initdb to
> change the contents of postgres.bki before feeding it to the
> bootstrap backend. After this, we could look at having the
> backend read the file directly.
Cool!
> I don't really detect any speed change from getting rid of initdb's
> string manipulations, but TBH I was not expecting any. On my machine,
> that was lost in the noise already, according to perf(1).
Yea, I'd not expect much either. The slowdown around the string stuff that I
did see was on windows.
I would however expect some, but not huge, speedup by getting rid of the
line-by-line reading/writing of postgres.bki, even without moving the handling
to the backend.
A quick way to prototype the moving the handlign to the backend would be to
just call postgres with input redirection from postgres.bki...
> + /*
> + * Ideally we'd change the superuser name with ALTER USER, but the backend
> + * will reject that with "session user cannot be renamed", so we must
> + * cheat. (In any case, we'd need a function to escape an identifier, not
> + * a string literal.) Likewise, we can't change template1's
> + * locale/encoding without cheating.
> + */
> + static char *final_details[] = {
> + "UPDATE pg_authid SET rolname = E'SUPERUSER_NAME' WHERE rolname = 'POSTGRES';\n\n",
> + "UPDATE pg_database SET encoding = E'ENCODING', datcollate = E'LC_COLLATE', datctype = E'LC_CTYPE';\n\n",
> + NULL
> + };
> +
> + detail_lines = replace_token(final_details, "SUPERUSER_NAME",
> + escape_quotes(username));
> + detail_lines = replace_token(detail_lines, "ENCODING",
> + encodingid_to_string(encodingid));
> + detail_lines = replace_token(detail_lines, "LC_COLLATE",
> + escape_quotes(lc_collate));
> + detail_lines = replace_token(detail_lines, "LC_CTYPE",
> + escape_quotes(lc_ctype));
Hm, wouldn't it be less code to just use printf?
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-02-20 00:39:38 | Re: initdb / bootstrap design |
Previous Message | Peter Geoghegan | 2022-02-20 00:22:23 | Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations |