From 66d947b9d302f1fd6de3d156e6ec61f52e1dc2cb Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 17 Dec 2015 19:34:15 -0500 Subject: Adjust behavior of single-user -j mode for better initdb error reporting. Previously, -j caused the entire input file to be read in and executed as a single command string. That's undesirable, not least because any error causes the entire file to be regurgitated as the "failing query". Some experimentation suggests a better rule: end the command string when we see a semicolon immediately followed by two newlines, ie, an empty line after a query. This serves nicely to break up the existing examples such as information_schema.sql and system_views.sql. A limitation is that it's no longer possible to write such a sequence within a string literal or multiline comment in a file meant to be read with -j; but there are no instances of such a problem within the data currently used by initdb. (If someone does make such a mistake in future, it'll be obvious because they'll get an unterminated-literal or unterminated-comment syntax error.) Other than that, there shouldn't be any negative consequences; you're not forced to end statements that way, it's just a better idea in most cases. In passing, remove src/include/tcop/tcopdebug.h, which is dead code because it's not included anywhere, and hasn't been for more than ten years. One of the debug-support symbols it purported to describe has been unreferenced for at least the same amount of time, and the other is removed by this commit on the grounds that it was useless: forcing -j mode all the time would have broken initdb. The lack of complaints about that, or about the missing inclusion, shows that no one has tried to use TCOP_DONTUSENEWLINE in many years. --- doc/src/sgml/ref/postgres-ref.sgml | 45 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'doc/src/sgml/ref/postgres-ref.sgml') diff --git a/doc/src/sgml/ref/postgres-ref.sgml b/doc/src/sgml/ref/postgres-ref.sgml index e2e99092428..d60d4ffbfcc 100644 --- a/doc/src/sgml/ref/postgres-ref.sgml +++ b/doc/src/sgml/ref/postgres-ref.sgml @@ -529,7 +529,9 @@ PostgreSQL documentation - The following options only apply to the single-user mode. + The following options only apply to the single-user mode + (see ). @@ -558,7 +560,7 @@ PostgreSQL documentation - Echo all commands. + Echo all commands to standard output before executing them. @@ -567,7 +569,8 @@ PostgreSQL documentation - Disables use of newline as a statement delimiter. + Use semicolon followed by two newlines, rather than just newline, + as the command entry terminator. @@ -760,8 +763,8 @@ PostgreSQL documentation - - Usage + + Single-User Mode To start a single-user mode server, use a command like @@ -778,30 +781,40 @@ PostgreSQL documentation entry terminator; there is no intelligence about semicolons, as there is in psql. To continue a command across multiple lines, you must type backslash just before each - newline except the last one. + newline except the last one. The backslash and adjacent newline are + both dropped from the input command. Note that this will happen even + when within a string literal or comment. - But if you use the + + + In either input mode, if you type a semicolon that is not just before or + part of a command entry terminator, it is considered a command separator. + When you do type a command entry terminator, the multiple statements + you've entered will be executed as a single transaction. To quit the session, type EOF (ControlD, usually). - If you've - used Note that the single-user mode server does not provide sophisticated line-editing features (no command history, for example). - Single-User mode also does not do any background processing, like - automatic checkpoints. - + Single-user mode also does not do any background processing, such as + automatic checkpoints or replication. -- cgit v1.2.3