*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 3298,3303 **** testdb=> INSERT INTO my_table VALUES (:'content');
--- 3298,3308 ----
+ %l
+ The current line number
+
+
+
%digits
*** a/src/bin/psql/prompt.c
--- b/src/bin/psql/prompt.c
***************
*** 17,22 ****
--- 17,24 ----
#include
#endif
+ #include
+
#include "common.h"
#include "input.h"
#include "prompt.h"
***************
*** 44,49 ****
--- 46,52 ----
* in prompt2 -, *, ', or ";
* in prompt3 nothing
* %x - transaction status: empty, *, !, ? (unknown or no connection)
+ * %l - the line number
* %? - the error code of the last query (not yet implemented)
* %% - a percent sign
*
***************
*** 72,82 **** get_prompt(promptStatus_t status)
--- 75,92 ----
bool esc = false;
const char *p;
const char *prompt_string = "? ";
+ static int cur_line = 1;
+
+ if (++cur_line >= INT_MAX)
+ {
+ cur_line = 1;
+ }
switch (status)
{
case PROMPT_READY:
prompt_string = pset.prompt1;
+ cur_line = 1;
break;
case PROMPT_CONTINUE:
***************
*** 229,234 **** get_prompt(promptStatus_t status)
--- 239,247 ----
}
break;
+ case 'l':
+ sprintf(buf, "%d", cur_line);
+ break;
case '?':
/* not here yet */
break;