summaryrefslogtreecommitdiff
path: root/src/bin/psql/prompt.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2014-09-02 13:05:48 +0200
committerAndres Freund <andres@anarazel.de>2014-09-02 13:06:11 +0200
commit51bb79569f934ad2135c2ff859c61b9ab8d51750 (patch)
tree3dc8d93438ee68238f1229ed16e37f4f5198ba3a /src/bin/psql/prompt.c
parentbd3b7a9eef6fd8d71ad9aa5eaf1f90e904e96f0b (diff)
Add psql PROMPT variable showing which line of a statement is being edited.
The new %l substitution shows the line number inside a (potentially multi-line) statement starting from one. Author: Sawada Masahiko, heavily editorialized by me. Reviewed-By: Jeevan Chalke, Alvaro Herrera
Diffstat (limited to 'src/bin/psql/prompt.c')
-rw-r--r--src/bin/psql/prompt.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 26fca04756d..f2db9a97bc5 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -44,6 +44,7 @@
* in prompt2 -, *, ', or ";
* in prompt3 nothing
* %x - transaction status: empty, *, !, ? (unknown or no connection)
+ * %l - The line number inside the current statement, starting from 1.
* %? - the error code of the last query (not yet implemented)
* %% - a percent sign
*
@@ -229,6 +230,10 @@ get_prompt(promptStatus_t status)
}
break;
+ case 'l':
+ snprintf(buf, sizeof(buf), UINT64_FORMAT, pset.stmt_lineno);
+ break;
+
case '?':
/* not here yet */
break;