Other formats in pset like markdown, rst, mediawiki
Have a nice day
I`m using \pset format html for generating tables for some documentation,
training, reports, blogs... Mainly sample of data for SQL queries, or
explaining structure etc.
But in some software like sphinx, wiki on redmine, or markdown on github
issues I`m not able to insert table in html into text. Using some
converters or sed script is little bit tricky if I need to create reports
from bash scripts, for example by jenkins.
Is there posibility, that support for some others formats will be added in
the future? Or id posible to create some of this formats by manipulating
with pset? Or I need use xml for export and use some xslt templates, or
lxml etc. to create format that I will be able to copy on wiki page or in
github issue.
Thanks Je;
--
Jelen
Starší čeledín datovýho chlíva
On Thu, Feb 23, 2017 at 7:29 PM, Jan Michálek <godzilalalala@gmail.com> wrote:
Is there possibility, that support for some others formats will be added in
the future? Or is it possible to create some of this formats by manipulating
with pset?
Addition of new formats is definitely possible, the latest one added
was asciidoc from two years back that I spent some time playing with:
- thread: /messages/by-id/CAFjNrYsppN=GbBuFw0kmk10uZczdqeax0vr3L6wOinmvEDibsg@mail.gmail.com
- commit: http://git.postgresql.org/pg/commitdiff/9d9991c84e64c0c5f568b3cdaf46bb91a1368b5a
If you want to submit patches in this area you can get inspiration
from this example, such changes are rather mechanical.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Jan Mich�lek wrote:
Is there posibility, that support for some others formats will be added in
the future? Or id posible to create some of this formats by manipulating
with pset? Or I need use xml for export and use some xslt templates, or
lxml etc. to create format that I will be able to copy on wiki page or in
github issue.
I would love to have something that generates Markdown tables. One of
the goals of psql is to make common tasks easy, and IMO generating
tables in formats commonly used in documents is one such task.
I think we discussed the idea of Markdown awhile ago, and eventually
found out that you absolutely need to align things following some crazy
rules, or the markdown processor just gives up on them. (It works fine
for simple table contents, but if you have to escape a character
somewhere, then the alignment needs to subtract the escaping character,
or something like that)
The pandoc document http://pandoc.org/MANUAL.html#tables appears to
suggest we could use "pipe tables" to get rid of the alignment
requirement, but then the result is ugly. It's a pity that multiline
rows don't work in that mode, also.
If you come up with code to generate good pandoc Markdown tables, I am
happy to help.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Leknín Řepánek wrote:
I was mainly using tables in rst, i think, that this format is very
similar to "grid tables" in markdown. And it is really similar to default borders used
in psql with border 2.
Great. So are you writing the code now? :-)
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Import Notes
Reply to msg id not found: 20170223185622.GG675@gmail.com | Resolved by subject fallback
I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.
2017-02-23 18:03 GMT+01:00 Alvaro Herrera <alvherre@2ndquadrant.com>:
Leknín Řepánek wrote:
I was mainly using tables in rst, i think, that this format is very
similar to "grid tables" in markdown. And it is really similar todefault borders used
in psql with border 2.
Great. So are you writing the code now? :-)
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Jelen
Starší čeledín datovýho chlíva
I was mainly using tables in rst, i think, that this format is very
similar to "grid tables" in markdown. And it is really similar to default borders used
in psql with border 2.
On Thu, Feb 23, 2017 at 12:06:36PM -0300, Alvaro Herrera wrote:
Jan Mich�lek wrote:
Is there posibility, that support for some others formats will be added in
the future? Or id posible to create some of this formats by manipulating
with pset? Or I need use xml for export and use some xslt templates, or
lxml etc. to create format that I will be able to copy on wiki page or in
github issue.I would love to have something that generates Markdown tables. One of
the goals of psql is to make common tasks easy, and IMO generating
tables in formats commonly used in documents is one such task.I think we discussed the idea of Markdown awhile ago, and eventually
found out that you absolutely need to align things following some crazy
rules, or the markdown processor just gives up on them. (It works fine
for simple table contents, but if you have to escape a character
somewhere, then the alignment needs to subtract the escaping character,
or something like that)The pandoc document http://pandoc.org/MANUAL.html#tables appears to
suggest we could use "pipe tables" to get rid of the alignment
requirement, but then the result is ugly. It's a pity that multiline
rows don't work in that mode, also.If you come up with code to generate good pandoc Markdown tables, I am
happy to help.--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-02-23 19:09 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.
It is not a problem, there is lot of iteration for code cleaning
Regards
Pavel
Show quoted text
2017-02-23 18:03 GMT+01:00 Alvaro Herrera <alvherre@2ndquadrant.com>:
Leknín Řepánek wrote:
I was mainly using tables in rst, i think, that this format is very
similar to "grid tables" in markdown. And it is really similar todefault borders used
in psql with border 2.
Great. So are you writing the code now? :-)
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalalala@gmail.com> wrote:
I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.
If you want to have something available in Postgres 10, you had better
be quick. The last commit fest of the development cycle of Postgres 10
begins on the 1st of March, you need to to register your patch here:
https://commitfest.postgresql.org/13/
Here are also some rough guidelines about submitting a patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I will add this
thing following structure of asciidoc commit.
Output is tested using retext, rst is OK, md have problem with cells with
newline (i must find out, how it is possible create table with this in
markdown).
[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.
jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g
| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |
(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+
(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalalala@gmail.com>
wrote:I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.If you want to have something available in Postgres 10, you had better
be quick. The last commit fest of the development cycle of Postgres 10
begins on the 1st of March, you need to to register your patch here:
https://commitfest.postgresql.org/13/
Here are also some rough guidelines about submitting a patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
--
Michael
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
patch_markdown_rst.txttext/plain; charset=US-ASCII; name=patch_markdown_rst.txtDownload
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/command.c 2017-02-28 01:07:26.000000000 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = &pg_asciiformat_old;
else if (pg_strncasecmp("unicode", value, vallen) == 0)
popt->topt.line_style = &pg_utf8format;
+ /* format markdown
+ */
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.line_style = &pg_markdown;
+ /* format rst
+ */
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.line_style = &pg_rst;
else
{
- psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode\n");
+ psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode, markdown\n");
return false;
}
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/fe_utils/print.c 2017-02-28 13:34:11.000000000 +0100
@@ -57,6 +57,48 @@
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+const printTextFormat pg_markdown =
+{
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
+const printTextFormat pg_rst =
+{
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ "+",
+ ".",
+ ".",
+ true
+};
+
const printTextFormat pg_asciiformat =
{
"ascii",
@@ -623,6 +665,12 @@
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
@@ -1124,13 +1172,20 @@
fputc('\n', fout);
} while (more_lines);
+
+ /* add line after every record */
+ if (opt_border == 2 && format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
- if (opt_border == 2 && !cancel_pressed)
+ /* dont add line after last row, because line is added after every row
+ **/
+ if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
@@ -1138,6 +1193,9 @@
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*add newline after table because rst needs empty line after table
+ */
+ fprintf(fout, "\n");
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
diff -ru a/src/include/fe_utils/print.h b/src/include/fe_utils/print.h
--- a/src/include/fe_utils/print.h 2017-02-06 22:45:25.000000000 +0100
+++ b/src/include/fe_utils/print.h 2017-02-28 01:04:05.000000000 +0100
@@ -176,6 +176,8 @@
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_markdown; /*format pro markdown*/
+extern const printTextFormat pg_rst; /*format pro rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
There it is, what i have.
I need i small help with psql.out, because \pset format wrapped. I don`t
know, how to have it in fixed width.
2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I will add this
thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem with cells with
newline (i must find out, how it is possible create table with this in
markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalalala@gmail.com>
wrote:I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.If you want to have something available in Postgres 10, you had better
be quick. The last commit fest of the development cycle of Postgres 10
begins on the 1st of March, you need to to register your patch here:
https://commitfest.postgresql.org/13/
Here are also some rough guidelines about submitting a patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
--
Michael--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
patch_markdown_rst.difftext/plain; charset=US-ASCII; name=patch_markdown_rst.diffDownload
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml 2017-02-06 22:45:25.000000000 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml 2017-03-01 00:37:19.000000000 +0100
@@ -2373,6 +2373,7 @@
<para>
Sets the border line drawing style to one
of <literal>ascii</literal>, <literal>old-ascii</literal>,
+ , <literal>rst</literal>, <literal>markdown</literal>
or <literal>unicode</literal>.
Unique abbreviations are allowed. (That would mean one
letter is enough.)
@@ -2408,6 +2409,12 @@
again in the left-hand margin of the following line.
</para>
+ <para><literal>rst</literal> and <literal>markdown</literal> format
+ tables for use restructured text on markdown documents. Both of them
+ works well only with format <literal>aligned</literal> and border
+ <literal>2</literal>.
+ </para>
+
<para>
When the <literal>border</> setting is greater than zero,
the <literal>linestyle</literal> option also determines the
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/command.c 2017-03-01 01:12:17.000000000 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = &pg_asciiformat_old;
else if (pg_strncasecmp("unicode", value, vallen) == 0)
popt->topt.line_style = &pg_utf8format;
+ /* format markdown
+ */
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.line_style = &pg_markdown;
+ /* format rst
+ */
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.line_style = &pg_rst;
else
{
- psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode\n");
+ psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode, markdown, rst\n");
return false;
}
diff -ru a/src/bin/psql/help.c b/src/bin/psql/help.c
--- a/src/bin/psql/help.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/help.c 2017-03-01 00:59:07.000000000 +0100
@@ -374,7 +374,7 @@
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
- fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
+ fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode, rst, markdown]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
" groups of digits [on, off]\n"));
diff -ru a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
--- a/src/bin/psql/tab-complete.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/tab-complete.c 2017-03-01 02:44:26.000000000 +0100
@@ -3075,7 +3075,7 @@
COMPLETE_WITH_LIST_CS(my_list);
}
else if (TailMatchesCS1("linestyle"))
- COMPLETE_WITH_LIST_CS3("ascii", "old-ascii", "unicode");
+ COMPLETE_WITH_LIST_CS5("ascii", "old-ascii", "unicode", "rst", "markdown");
else if (TailMatchesCS1("unicode_border_linestyle|"
"unicode_column_linestyle|"
"unicode_header_linestyle"))
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/fe_utils/print.c 2017-03-01 01:29:20.000000000 +0100
@@ -57,6 +57,48 @@
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+const printTextFormat pg_markdown =
+{
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
+const printTextFormat pg_rst =
+{
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
const printTextFormat pg_asciiformat =
{
"ascii",
@@ -623,6 +665,12 @@
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
@@ -1124,13 +1172,20 @@
fputc('\n', fout);
} while (more_lines);
+
+ /* add line after every record */
+ if (opt_border == 2 && format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
- if (opt_border == 2 && !cancel_pressed)
+ /* dont add line after last row, because line is added after every row
+ **/
+ if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
@@ -1138,6 +1193,9 @@
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*add newline after table because rst needs empty line after table
+ */
+ fprintf(fout, "\n");
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
diff -ru a/src/include/fe_utils/print.h b/src/include/fe_utils/print.h
--- a/src/include/fe_utils/print.h 2017-02-06 22:45:25.000000000 +0100
+++ b/src/include/fe_utils/print.h 2017-02-28 01:04:05.000000000 +0100
@@ -176,6 +176,8 @@
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_markdown; /*format pro markdown*/
+extern const printTextFormat pg_rst; /*format pro rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff -ru a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
--- a/src/test/regress/expected/psql.out 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/expected/psql.out 2017-03-01 03:10:54.000000000 +0100
@@ -2714,3 +2714,87 @@
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121, (279./278.)::text, 0.1111, repeat('Hello ', 50))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111, repeat('cigar from nicaragua ', 20))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator, pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11, repeat('camfire ', 20));
+\pset format aligned
+\pset linestyle rst
+execute q;
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+======================================================================================================================================================================================================================================================================================================================================================================================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset linestyle markdown
+execute q;
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+\pset format wrapped
+\pset linestyle rst
+execute q;
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+======================================================================================================================================================================================================================================================================================================================================================================================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset linestyle markdown
+execute q;
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+deallocate q;
diff -ru a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
--- a/src/test/regress/sql/psql.sql 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/sql/psql.sql 2017-03-01 02:50:50.000000000 +0100
@@ -379,3 +379,19 @@
raise notice 'foo';
raise exception 'bar';
end $$;
+
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121, (279./278.)::text, 0.1111, repeat('Hello ', 50))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111, repeat('cigar from nicaragua ', 20))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator, pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11, repeat('camfire ', 20));
+
+\pset format aligned
+\pset linestyle rst
+execute q;
+\pset linestyle markdown
+execute q;
+\pset format wrapped
+\pset linestyle rst
+execute q;
+\pset linestyle markdown
+execute q;
+deallocate q;
Sorry, I have some errors in my diff, i had copy something from bad folder.
I will fix it.
2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
There it is, what i have.
I need i small help with psql.out, because \pset format wrapped. I don`t
know, how to have it in fixed width.2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I will add this
thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem with cells with
newline (i must find out, how it is possible create table with this in
markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalalala@gmail.com>
wrote:I can try it, doesn`t look dificult, but I`m worry, that I`m not able
to
write clean, pretty code.
If you want to have something available in Postgres 10, you had better
be quick. The last commit fest of the development cycle of Postgres 10
begins on the 1st of March, you need to to register your patch here:
https://commitfest.postgresql.org/13/
Here are also some rough guidelines about submitting a patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
Sorry, I have some errors in my diff, i had copy something from bad
folder. I will fix it.2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
There it is, what i have.
I need i small help with psql.out, because \pset format wrapped. I don`t
know, how to have it in fixed width.2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I will add
this thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem with cells
with newline (i must find out, how it is possible create table with this in
markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký kobyly'),
('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek <godzilalalala@gmail.com>
wrote:I can try it, doesn`t look dificult, but I`m worry, that I`m not able
to
write clean, pretty code.
If you want to have something available in Postgres 10, you had better
be quick. The last commit fest of the development cycle of Postgres 10
begins on the 1st of March, you need to to register your patch here:
https://commitfest.postgresql.org/13/
Here are also some rough guidelines about submitting a patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
patch_markdown_rst.difftext/plain; charset=US-ASCII; name=patch_markdown_rst.diffDownload
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml 2017-02-06 22:45:25.000000000 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml 2017-03-01 00:37:19.000000000 +0100
@@ -2373,6 +2373,7 @@
<para>
Sets the border line drawing style to one
of <literal>ascii</literal>, <literal>old-ascii</literal>,
+ , <literal>rst</literal>, <literal>markdown</literal>
or <literal>unicode</literal>.
Unique abbreviations are allowed. (That would mean one
letter is enough.)
@@ -2408,6 +2409,12 @@
again in the left-hand margin of the following line.
</para>
+ <para><literal>rst</literal> and <literal>markdown</literal> format
+ tables for use restructured text on markdown documents. Both of them
+ works well only with format <literal>aligned</literal> and border
+ <literal>2</literal>.
+ </para>
+
<para>
When the <literal>border</> setting is greater than zero,
the <literal>linestyle</literal> option also determines the
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/command.c 2017-03-01 01:12:17.000000000 +0100
@@ -2584,9 +2584,17 @@
popt->topt.line_style = &pg_asciiformat_old;
else if (pg_strncasecmp("unicode", value, vallen) == 0)
popt->topt.line_style = &pg_utf8format;
+ /* format markdown
+ */
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.line_style = &pg_markdown;
+ /* format rst
+ */
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.line_style = &pg_rst;
else
{
- psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode\n");
+ psql_error("\\pset: allowed line styles are ascii, old-ascii, unicode, markdown, rst\n");
return false;
}
diff -ru a/src/bin/psql/help.c b/src/bin/psql/help.c
--- a/src/bin/psql/help.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/help.c 2017-03-01 00:59:07.000000000 +0100
@@ -374,7 +374,7 @@
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
- fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
+ fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode, rst, markdown]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
" groups of digits [on, off]\n"));
diff -ru a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
--- a/src/bin/psql/tab-complete.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/tab-complete.c 2017-03-01 02:44:26.000000000 +0100
@@ -3075,7 +3075,7 @@
COMPLETE_WITH_LIST_CS(my_list);
}
else if (TailMatchesCS1("linestyle"))
- COMPLETE_WITH_LIST_CS3("ascii", "old-ascii", "unicode");
+ COMPLETE_WITH_LIST_CS5("ascii", "old-ascii", "unicode", "rst", "markdown");
else if (TailMatchesCS1("unicode_border_linestyle|"
"unicode_column_linestyle|"
"unicode_header_linestyle"))
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/fe_utils/print.c 2017-03-01 14:53:37.000000000 +0100
@@ -57,6 +57,48 @@
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+const printTextFormat pg_markdown =
+{
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
+const printTextFormat pg_rst =
+{
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
const printTextFormat pg_asciiformat =
{
"ascii",
@@ -623,6 +665,12 @@
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
@@ -1124,13 +1172,20 @@
fputc('\n', fout);
} while (more_lines);
+
+ /* add line after every record */
+ if (opt_border == 2 && format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
- if (opt_border == 2 && !cancel_pressed)
+ /* dont add line after last row, because line is added after every row
+ **/
+ if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
@@ -1138,6 +1193,12 @@
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
diff -ru a/src/include/fe_utils/print.h b/src/include/fe_utils/print.h
--- a/src/include/fe_utils/print.h 2017-02-06 22:45:25.000000000 +0100
+++ b/src/include/fe_utils/print.h 2017-02-28 01:04:05.000000000 +0100
@@ -176,6 +176,8 @@
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_markdown; /*format pro markdown*/
+extern const printTextFormat pg_rst; /*format pro rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff -ru a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
--- a/src/test/regress/expected/psql.out 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/expected/psql.out 2017-03-01 15:02:08.000000000 +0100
@@ -2714,3 +2714,89 @@
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121, (279./278.)::text, 0.1111, repeat('Hello ', 50))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111, repeat('cigar from nicaragua ', 20))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator, pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11, repeat('camfire ', 20));
+\pset format aligned
+\pset linestyle rst
+execute q;
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+======================================================================================================================================================================================================================================================================================================================================================================================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset linestyle markdown
+execute q;
+
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+\pset format wrapped
+\pset linestyle rst
+execute q;
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+======================================================================================================================================================================================================================================================================================================================================================================================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset linestyle markdown
+execute q;
+
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua cigar from nicaragua |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire camfire |
+| eagle, whale, | | | | |
+| aligator, pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+deallocate q;
diff -ru a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
--- a/src/test/regress/sql/psql.sql 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/sql/psql.sql 2017-03-01 02:50:50.000000000 +0100
@@ -379,3 +379,19 @@
raise notice 'foo';
raise exception 'bar';
end $$;
+
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121, (279./278.)::text, 0.1111, repeat('Hello ', 50))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111, repeat('cigar from nicaragua ', 20))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator, pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11, repeat('camfire ', 20));
+
+\pset format aligned
+\pset linestyle rst
+execute q;
+\pset linestyle markdown
+execute q;
+\pset format wrapped
+\pset linestyle rst
+execute q;
+\pset linestyle markdown
+execute q;
+deallocate q;
If you want to implement a new table format, you should be looking at
\pset format, not \pset linestyle. \pset format sets different table
formats, such as html, latex, and asciidoc. \pset linestyle just
chooses between different styles for the plain-text table format.
On 3/1/17 06:31, Jan Michálek wrote:
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Sorry, I have some errors in my diff, i had copy something from bad
folder. I will fix it.2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:There it is, what i have.
I need i small help with psql.out, because \pset format wrapped.
I don`t know, how to have it in fixed width.2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I
will add this thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem
with cells with newline (i must find out, how it is possible
create table with this in markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier
<michael.paquier@gmail.com <mailto:michael.paquier@gmail.com>>:On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek
<godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>> wrote:I can try it, doesn`t look dificult, but I`m worry, that I`m not able to
write clean, pretty code.If you want to have something available in Postgres 10,
you had better
be quick. The last commit fest of the development cycle
of Postgres 10
begins on the 1st of March, you need to to register your
patch here:
https://commitfest.postgresql.org/13/
<https://commitfest.postgresql.org/13/>
Here are also some rough guidelines about submitting a
patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
<https://wiki.postgresql.org/wiki/Submitting_a_Patch>
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.
Je;
jelen=# \pset linestyle rst
Line style is rst.
jelen=# \pset format wrapped
Output format is wrapped.
jelen=# SELECT repeat('Goodnight Irene ', 30);
+-----------------------------------------------------------------------------+
|
repeat |
+=============================================================================+
| Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
I.|
|.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodni.|
|.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
G.|
|.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
Ir.|
|.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodnig.|
|.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Go.|
|.odnight Irene Goodnight
Irene |
+-----------------------------------------------------------------------------+
(1 row)
jelen=#
2017-03-01 15:00 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:
If you want to implement a new table format, you should be looking at
\pset format, not \pset linestyle. \pset format sets different table
formats, such as html, latex, and asciidoc. \pset linestyle just
chooses between different styles for the plain-text table format.On 3/1/17 06:31, Jan Michálek wrote:
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Sorry, I have some errors in my diff, i had copy something from bad
folder. I will fix it.2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:There it is, what i have.
I need i small help with psql.out, because \pset format wrapped.
I don`t know, how to have it in fixed width.2017-02-28 14:23 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I
will add this thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem
with cells with newline (i must find out, how it is possible
create table with this in markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier
<michael.paquier@gmail.com <mailto:michael.paquier@gmail.com:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek
<godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>> wrote:I can try it, doesn`t look dificult, but I`m worry,
that I`m not able to
write clean, pretty code.
If you want to have something available in Postgres 10,
you had better
be quick. The last commit fest of the development cycle
of Postgres 10
begins on the 1st of March, you need to to register your
patch here:
https://commitfest.postgresql.org/13/
<https://commitfest.postgresql.org/13/>
Here are also some rough guidelines about submitting a
patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
<https://wiki.postgresql.org/wiki/Submitting_a_Patch>
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Jelen
Starší čeledín datovýho chlíva
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.
Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.
Not sure if wrapped or aligned behave is correct for markdown - it is task
for markdown processing, not for psql.
Regards
Pavel
Show quoted text
Je;
jelen=# \pset linestyle rst Line style is rst. jelen=# \pset format wrapped Output format is wrapped. jelen=# SELECT repeat('Goodnight Irene ', 30); +----------------------------------------------------------- ------------------+ | repeat | +=========================================================== ==================+ | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight I.| |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodni.| |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene G.| |.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Ir.| |.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnig.| |.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Go.| |.odnight Irene Goodnight Irene | +----------------------------------------------------------- ------------------+(1 row)
jelen=#
2017-03-01 15:00 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:If you want to implement a new table format, you should be looking at
\pset format, not \pset linestyle. \pset format sets different table
formats, such as html, latex, and asciidoc. \pset linestyle just
chooses between different styles for the plain-text table format.On 3/1/17 06:31, Jan Michálek wrote:
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Sorry, I have some errors in my diff, i had copy something from bad
folder. I will fix it.2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:There it is, what i have.
I need i small help with psql.out, because \pset format wrapped.
I don`t know, how to have it in fixed width.2017-02-28 14:23 GMT+01:00 Jan Michálek <
godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I
will add this thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem
with cells with newline (i must find out, how it is possible
create table with this in markdown).[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier
<michael.paquier@gmail.com <mailto:michael.paquier@gmail.com>>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek
<godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>> wrote:I can try it, doesn`t look dificult, but I`m worry,
that I`m not able to
write clean, pretty code.
If you want to have something available in Postgres 10,
you had better
be quick. The last commit fest of the development cycle
of Postgres 10
begins on the 1st of March, you need to to register your
patch here:
https://commitfest.postgresql.org/13/
<https://commitfest.postgresql.org/13/>
Here are also some rough guidelines about submitting a
patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
<https://wiki.postgresql.org/wiki/Submitting_a_Patch>
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
It is question if it is really new format, because formating is the same as
aligned/wrapped format, changed is only style of lines.
2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.Not sure if wrapped or aligned behave is correct for markdown - it is task
for markdown processing, not for psql.Regards
Pavel
Je;
jelen=# \pset linestyle rst Line style is rst. jelen=# \pset format wrapped Output format is wrapped. jelen=# SELECT repeat('Goodnight Irene ', 30); +----------------------------------------------------------- ------------------+ | repeat | +=========================================================== ==================+ | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight I.| |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodni.| |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene G.| |.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Ir.| |.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnig.| |.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Go.| |.odnight Irene Goodnight Irene | +----------------------------------------------------------- ------------------+(1 row)
jelen=#
2017-03-01 15:00 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:If you want to implement a new table format, you should be looking at
\pset format, not \pset linestyle. \pset format sets different table
formats, such as html, latex, and asciidoc. \pset linestyle just
chooses between different styles for the plain-text table format.On 3/1/17 06:31, Jan Michálek wrote:
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Sorry, I have some errors in my diff, i had copy something from bad
folder. I will fix it.2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:There it is, what i have.
I need i small help with psql.out, because \pset formatwrapped.
I don`t know, how to have it in fixed width.
2017-02-28 14:23 GMT+01:00 Jan Michálek <
godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc., I
will add this thing following structure of asciidoc commit.Output is tested using retext, rst is OK, md have problem
with cells with newline (i must find out, how it ispossible
create table with this in markdown).
[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier
<michael.paquier@gmail.com <mailto:michael.paquier@gmail.com>>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek
<godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>> wrote:I can try it, doesn`t look dificult, but I`m worry,
that I`m not able to
write clean, pretty code.
If you want to have something available in Postgres 10,
you had better
be quick. The last commit fest of the development cycle
of Postgres 10
begins on the 1st of March, you need to to registeryour
patch here:
https://commitfest.postgresql.org/13/
<https://commitfest.postgresql.org/13/>
Here are also some rough guidelines about submitting a
patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
<https://wiki.postgresql.org/wiki/Submitting_a_Patch>
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
It is question if it is really new format, because formating is the same
as aligned/wrapped format, changed is only style of lines.
Please, don't do top posting
https://en.wikipedia.org/wiki/Posting_style#Top-posting
2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.Not sure if wrapped or aligned behave is correct for markdown - it is
task for markdown processing, not for psql.
In this case I am inclined to prefer setting via format setting - you can
set a linestyle and border in one step, and then is easy to return back to
previous format. I don't see a big benefit in enhancing set of ascii
linestyles. The collecting new features in formatting is more intuitive
(for me).
Regards
Pavel
Show quoted text
Regards
Pavel
Je;
jelen=# \pset linestyle rst Line style is rst. jelen=# \pset format wrapped Output format is wrapped. jelen=# SELECT repeat('Goodnight Irene ', 30); +----------------------------------------------------------- ------------------+ | repeat | +=========================================================== ==================+ | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight I.| |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodni.| |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene G.| |.oodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Ir.| |.ene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnig.| |.ht Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Go.| |.odnight Irene Goodnight Irene | +----------------------------------------------------------- ------------------+(1 row)
jelen=#
2017-03-01 15:00 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:If you want to implement a new table format, you should be looking at
\pset format, not \pset linestyle. \pset format sets different table
formats, such as html, latex, and asciidoc. \pset linestyle just
chooses between different styles for the plain-text table format.On 3/1/17 06:31, Jan Michálek wrote:
Regression test corrected.
2017-03-01 11:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:Sorry, I have some errors in my diff, i had copy something from
bad
folder. I will fix it.
2017-03-01 0:27 GMT+01:00 Jan Michálek <godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:There it is, what i have.
I need i small help with psql.out, because \pset formatwrapped.
I don`t know, how to have it in fixed width.
2017-02-28 14:23 GMT+01:00 Jan Michálek <
godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>>:
Current state is something like this (diff is attached).
I currently haven`t regression test, tab completion etc.,I
will add this thing following structure of asciidoc
commit.
Output is tested using retext, rst is OK, md have problem
with cells with newline (i must find out, how it ispossible
create table with this in markdown).
[jelen@laptak patch_postgre_rst]$
[jelen@laptak psql]$ ./psql
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle markdown
Line style is markdown.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g | xclip
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g| column1 | column2 |
|---------------|------------------|
| nasral Franta | Žluťoučký kobyly |
| na trabanta | |
| ' | a b |(2 rows)
jelen=# \pset linestyle rst
Line style is rst.
jelen=# values(E'nasral Franta\nna trabanta','Žluťoučký
kobyly'), ('''',E'a\tb') \g
+---------------+------------------+
| column1 | column2 |
+===============+==================+
| nasral Franta+| Žluťoučký kobyly |
| na trabanta | |
+---------------+------------------+
| ' | a b |
+---------------+------------------+(2 rows)
jelen=#
2017-02-24 0:46 GMT+01:00 Michael Paquier
<michael.paquier@gmail.com <mailto:michael.paquier@gmail.com>>:
On Fri, Feb 24, 2017 at 3:09 AM, Jan Michálek
<godzilalalala@gmail.com
<mailto:godzilalalala@gmail.com>> wrote:I can try it, doesn`t look dificult, but I`m worry,
that I`m not able to
write clean, pretty code.
If you want to have something available in Postgres
10,
you had better
be quick. The last commit fest of the developmentcycle
of Postgres 10
begins on the 1st of March, you need to to registeryour
patch here:
https://commitfest.postgresql.org/13/
<https://commitfest.postgresql.org/13/>
Here are also some rough guidelines about submitting a
patch:
https://wiki.postgresql.org/wiki/Submitting_a_Patch
<https://wiki.postgresql.org/wiki/Submitting_a_Patch>
--
Michael--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva
2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
It is question if it is really new format, because formating is the same
as aligned/wrapped format, changed is only style of lines.Please, don't do top posting https://en.wikipedia.org/wiki/
Posting_style#Top-posting2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning ascii
linestyle and few lines in print_aligned_text. Both works with "aligned"
and "wrapped" format. In rst is wrapped format useful, in my opinion, in
markdown i can`t find how I can get newline in record (maybe it is not
posiible in main markdown types). So it is why i add markdown and rst as
new linestyles. But it is not problem to change it in command to use "\pset
format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.Not sure if wrapped or aligned behave is correct for markdown - it is
task for markdown processing, not for psql.In this case I am inclined to prefer setting via format setting - you can
set a linestyle and border in one step, and then is easy to return back to
previous format. I don't see a big benefit in enhancing set of ascii
linestyles. The collecting new features in formatting is more intuitive
(for me).
This can be discussed what we prefer, and what we would to implement?
1. Nice formatted markdown tables
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
or 2. enough formatting
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
Pavel
2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
It is question if it is really new format, because formating is the same
as aligned/wrapped format, changed is only style of lines.Please, don't do top posting https://en.wikipedia.org/wiki/
Posting_style#Top-posting2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning
ascii linestyle and few lines in print_aligned_text. Both works with
"aligned" and "wrapped" format. In rst is wrapped format useful, in my
opinion, in markdown i can`t find how I can get newline in record (maybe it
is not posiible in main markdown types). So it is why i add markdown and
rst as new linestyles. But it is not problem to change it in command to use
"\pset format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.Not sure if wrapped or aligned behave is correct for markdown - it is
task for markdown processing, not for psql.In this case I am inclined to prefer setting via format setting - you can
set a linestyle and border in one step, and then is easy to return back to
previous format. I don't see a big benefit in enhancing set of ascii
linestyles. The collecting new features in formatting is more intuitive
(for me).This can be discussed what we prefer, and what we would to implement?
1. Nice formatted markdown tables
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |or 2. enough formatting
Markdown | Less | Pretty --- | --- | --- *Still* | `renders` | **nicely** 1 | 2 | 3I personally prefer nice formated table, because more comfortable reading
source of document and easier editing with blocks (deleting whole columns
etc.).
I will change \pset to format.
I find, when adding <\br> for newline works in retext. I will try to add it
to patch.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centere<br/>d | $12 |
| zebra stripes | are neat | $1 |
Jan
Pavel
--
Jelen
Starší čeledín datovýho chlíva
2017-03-05 14:02 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
It is question if it is really new format, because formating is the
same as aligned/wrapped format, changed is only style of lines.Please, don't do top posting https://en.wikipedia.org/wiki/
Posting_style#Top-posting2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning
ascii linestyle and few lines in print_aligned_text. Both works with
"aligned" and "wrapped" format. In rst is wrapped format useful, in my
opinion, in markdown i can`t find how I can get newline in record (maybe it
is not posiible in main markdown types). So it is why i add markdown and
rst as new linestyles. But it is not problem to change it in command to use
"\pset format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But new
format should be switched with \pset format command.
changed
Not sure if wrapped or aligned behave is correct for markdown - it is
task for markdown processing, not for psql.In this case I am inclined to prefer setting via format setting - you
can set a linestyle and border in one step, and then is easy to return back
to previous format. I don't see a big benefit in enhancing set of ascii
linestyles. The collecting new features in formatting is more intuitive
(for me).This can be discussed what we prefer, and what we would to implement?
1. Nice formatted markdown tables
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |or 2. enough formatting
Markdown | Less | Pretty --- | --- | --- *Still* | `renders` | **nicely** 1 | 2 | 3I personally prefer nice formated table, because more comfortable reading
source of document and easier editing with blocks (deleting whole columns
etc.).
I will change \pset to format.
I find, when adding <\br> for newline works in retext. I will try to add
it to patch.| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centere<br/>d | $12 |
| zebra stripes | are neat | $1 |
Jan
Pavel
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
patch_markdown_rst.difftext/plain; charset=US-ASCII; name=patch_markdown_rst.diffDownload
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml 2017-02-06 22:45:25.000000000 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml 2017-03-06 01:35:46.000000000 +0100
@@ -2326,7 +2326,8 @@
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
- <literal>latex-longtable</literal>, or
+ <literal>latex-longtable</literal>,
+ <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
@@ -2354,7 +2355,8 @@
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
- <literal>latex-longtable</literal>, and <literal>troff-ms</>
+ <literal>latex-longtable</literal>, <literal>troff-ms</>,
+ and <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/command.c 2017-03-06 03:27:07.000000000 +0100
@@ -2494,6 +2494,12 @@
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
@@ -2565,9 +2571,13 @@
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0) /*markdown*/
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0) /*rst*/
+ popt->topt.format = PRINT_RST;
else
{
- psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
+ psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
diff -ru a/src/bin/psql/help.c b/src/bin/psql/help.c
--- a/src/bin/psql/help.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/help.c 2017-03-06 01:46:41.000000000 +0100
@@ -373,7 +373,7 @@
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
- fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
+ fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff -ru a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
--- a/src/bin/psql/tab-complete.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/tab-complete.c 2017-03-06 00:57:11.000000000 +0100
@@ -3070,7 +3070,7 @@
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
- "latex", "latex-longtable", "troff-ms", NULL};
+ "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/fe_utils/print.c 2017-03-06 00:39:40.000000000 +0100
@@ -57,6 +57,48 @@
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+const printTextFormat pg_markdown =
+{
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
+const printTextFormat pg_rst =
+{
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
const printTextFormat pg_asciiformat =
{
"ascii",
@@ -623,6 +665,12 @@
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
@@ -1124,13 +1172,20 @@
fputc('\n', fout);
} while (more_lines);
+
+ /* add line after every record */
+ if (opt_border == 2 && format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
- if (opt_border == 2 && !cancel_pressed)
+ /* dont add line after last row, because line is added after every row
+ **/
+ if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
@@ -1138,6 +1193,12 @@
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
@@ -3263,6 +3324,15 @@
else
print_troff_ms_text(cont, fout);
break;
+
+ case PRINT_RST:
+ print_aligned_text(cont, fout, false);
+ break;
+
+ case PRINT_MARKDOWN:
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
@@ -3417,8 +3487,12 @@
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
- if (opt->line_style != NULL)
- return opt->line_style;
+ if (opt->format == PRINT_RST)
+ return &pg_rst;
+ else if (opt->format == PRINT_MARKDOWN)
+ return &pg_markdown;
+ else if (opt->line_style != NULL)
+ return opt->line_style;
else
return &pg_asciiformat;
}
diff -ru a/src/include/fe_utils/print.h b/src/include/fe_utils/print.h
--- a/src/include/fe_utils/print.h 2017-02-06 22:45:25.000000000 +0100
+++ b/src/include/fe_utils/print.h 2017-03-05 18:28:04.000000000 +0100
@@ -33,7 +33,9 @@
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
- PRINT_TROFF_MS
+ PRINT_TROFF_MS,
+ PRINT_MARKDOWN,
+ PRINT_RST
/* add your favourite output format here ... */
};
@@ -176,6 +178,8 @@
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_markdown; /*linestyle markdown*/
+extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff -ru a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
--- a/src/test/regress/expected/psql.out 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/expected/psql.out 2017-03-06 02:58:18.000000000 +0100
@@ -2714,3 +2714,53 @@
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+(279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+\pset format rst
+execute q;
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+========================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+| eagle, whale, | | | | |
+| aligator, | | | | |
+| pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset format markdown
+execute q;
+
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+| eagle, whale, | | | | |
+| aligator, | | | | |
+| pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+deallocate q;
diff -ru a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
--- a/src/test/regress/sql/psql.sql 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/sql/psql.sql 2017-03-06 02:15:15.000000000 +0100
@@ -379,3 +379,17 @@
raise notice 'foo';
raise exception 'bar';
end $$;
+
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+(279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+\pset format rst
+execute q;
+\pset format markdown
+execute q;
+deallocate q;
2017-03-06 16:25 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-06 16:17 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-06 15:19 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-06 0:26 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-05 14:02 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-05 13:39 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:22 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 13:08 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
It is question if it is really new format, because formating is the
same as aligned/wrapped format, changed is only style of lines.Please, don't do top posting https://en.wikipedia.org/wiki/
Posting_style#Top-posting2017-03-05 12:36 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-05 11:40 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
I know, but, both new linestyles are created literally by cloning
ascii linestyle and few lines in print_aligned_text. Both works with
"aligned" and "wrapped" format. In rst is wrapped format useful, in my
opinion, in markdown i can`t find how I can get newline in record (maybe it
is not posiible in main markdown types). So it is why i add markdown and
rst as new linestyles. But it is not problem to change it in command to use
"\pset format", but i mean, that this is cleaner.Using a special linestyle for new format is possible probably. But
new format should be switched with \pset format command.changed
quick test shows it is working.
Just idea - can you specify aligning? right aligning for numbers, left
for others?I used "aligned" format as it is and I don`t know, if I`m able to do this
with current solution based only on change linestyle internally.you can try to test result in some markdown processors? I will not be
surprised if these processor ignore aligning in input data.
I tested markdown only in retext and retext aligns columns set by -----:|
well.
Refards
Pavel
Regards
Pavel
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Import Notes
Reply to msg id not found: CAFj8pRAih6ujDMkstN330hVOEqWMfJdybFgiEJY-sckwADRb3Q@mail.gmail.com
On 3/5/17 05:40, Jan Michálek wrote:
jelen=# \pset linestyle rst Line style is rst. jelen=# \pset format wrapped Output format is wrapped. jelen=# SELECT repeat('Goodnight Irene ', 30); +-----------------------------------------------------------------------------+ | repeat | +=============================================================================+ | Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight I.| |.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodni.| |.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene G.|
I doubt that this kind of line breaking style is actually proper rst.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-03-06 19:45 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:
On 3/5/17 05:40, Jan Michálek wrote:
jelen=# \pset linestyle rst
Line style is rst.
jelen=# \pset format wrapped
Output format is wrapped.
jelen=# SELECT repeat('Goodnight Irene ', 30);
+-----------------------------------------------------------------------------+
|
repeat |
+=============================================================================+
| Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodnight I.|
|.rene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight Irene
Goodni.|
|.ght Irene Goodnight Irene Goodnight Irene Goodnight Irene Goodnight
Irene G.|I doubt that this kind of line breaking style is actually proper rst.
If you mean wrapped lines, it is wrapped by email client (in sent messages
it looks as a table).
But really, this rst (original version from sent messages) doesn`t work (I
actually test it) and don`t know why, but problem is probably related with
linebreaks.
In last wersion of diff is pset changed from linestyle to format and using
"wrapped" format is not possible.
Regards
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Jelen
Starší čeledín datovýho chlíva
This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.
- Does not support \x
- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.
- Broken output in tuples_only (\t) mode. (rst and markdown)
- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directive
- markdown: Extra blank line between table and footer.
- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)
- markdown: Table title needs to be after the table, like
Table: title
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:
This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.
Thanks, original code is very synoptical and and well prepared for adding
new formats.
- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.
- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.
I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.
- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directive
OK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.
- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)
I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.
- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.
This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.
Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Jelen
Starší čeledín datovýho chlíva
I find, there is problem in tab indent in rst, it looks that lines should
be aligned to left in some cases.
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.
I prepared something like this (i have no prepared diff, i need do some
another changes)
There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.
Bigger problem is with tab indent, rst processor doesn`t work with this in
this case.
jelen=# execute q \g | xclip
+---------+------------------------------------------------------------------------+
| **RECORD
1** |
+---------+------------------------------------------------------------------------+
| column1 | Elephant,
kangaroo, |
| | squirrel,
gorilla |
+---------+------------------------------------------------------------------------+
| column2 |
121 |
+---------+------------------------------------------------------------------------+
| column3 |
1.0035971223021583 |
+---------+------------------------------------------------------------------------+
| column4 |
0.1111 |
+---------+------------------------------------------------------------------------+
| column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello
Hello |
+---------+------------------------------------------------------------------------+
| **RECORD
2** |
+---------+------------------------------------------------------------------------+
| column1 | goat,
rhinoceros, |
| | monkey,
ape |
+---------+------------------------------------------------------------------------+
| column2 |
11121 |
+---------+------------------------------------------------------------------------+
| column3 |
1.0007824726134585 |
+---------+------------------------------------------------------------------------+
| column4 |
5.1111 |
+---------+------------------------------------------------------------------------+
| column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx
xxxxxx |
+---------+------------------------------------------------------------------------+
| **RECORD
3** |
+---------+------------------------------------------------------------------------+
| column1 | donkey, cow, horse,
tit, |
| | eagle,
whale, |
| |
aligator, |
| |
pelican, |
| |
grasshoper |
| |
pig |
| |
bat |
+---------+------------------------------------------------------------------------+
| column2 |
14351 |
+---------+------------------------------------------------------------------------+
| column3 |
50.3877551020408163 |
+---------+------------------------------------------------------------------------+
| column4 |
345.11 |
+---------+------------------------------------------------------------------------+
| column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy
yyyyyy |
+---------+------------------------------------------------------------------------+
- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.I prepared something like this (i have no prepared diff, i need do some
another changes)
There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.
Bigger problem is with tab indent, rst processor doesn`t work with this in
this case.
In new diff is added \x for rst and skipping leading spaces in rst in both.
make check passed
Jan
jelen=# execute q \g | xclip +---------+------------------------------------------------- -----------------------+ | **RECORD 1** | +---------+------------------------------------------------- -----------------------+ | column1 | Elephant, kangaroo, | | | squirrel, gorilla | +---------+------------------------------------------------- -----------------------+ | column2 | 121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0035971223021583 | +---------+------------------------------------------------- -----------------------+ | column4 | 0.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello | +---------+------------------------------------------------- -----------------------+ | **RECORD 2** | +---------+------------------------------------------------- -----------------------+ | column1 | goat, rhinoceros, | | | monkey, ape | +---------+------------------------------------------------- -----------------------+ | column2 | 11121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0007824726134585 | +---------+------------------------------------------------- -----------------------+ | column4 | 5.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx | +---------+------------------------------------------------- -----------------------+ | **RECORD 3** | +---------+------------------------------------------------- -----------------------+ | column1 | donkey, cow, horse, tit, | | | eagle, whale, | | | aligator, | | | pelican, | | | grasshoper | | | pig | | | bat | +---------+------------------------------------------------- -----------------------+ | column2 | 14351 | +---------+------------------------------------------------- -----------------------+ | column3 | 50.3877551020408163 | +---------+------------------------------------------------- -----------------------+ | column4 | 345.11 | +---------+------------------------------------------------- -----------------------+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy | +---------+------------------------------------------------- -----------------------+- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
patch_markdown_rst.difftext/plain; charset=US-ASCII; name=patch_markdown_rst.diffDownload
diff -ru a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
--- a/doc/src/sgml/ref/psql-ref.sgml 2017-02-06 22:45:25.000000000 +0100
+++ b/doc/src/sgml/ref/psql-ref.sgml 2017-03-06 01:35:46.000000000 +0100
@@ -2326,7 +2326,8 @@
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
- <literal>latex-longtable</literal>, or
+ <literal>latex-longtable</literal>,
+ <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
@@ -2354,7 +2355,8 @@
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
- <literal>latex-longtable</literal>, and <literal>troff-ms</>
+ <literal>latex-longtable</literal>, <literal>troff-ms</>,
+ and <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff -ru a/src/bin/psql/command.c b/src/bin/psql/command.c
--- a/src/bin/psql/command.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/command.c 2017-03-06 03:27:07.000000000 +0100
@@ -2494,6 +2494,12 @@
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
@@ -2565,9 +2571,13 @@
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0) /*markdown*/
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0) /*rst*/
+ popt->topt.format = PRINT_RST;
else
{
- psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
+ psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
diff -ru a/src/bin/psql/help.c b/src/bin/psql/help.c
--- a/src/bin/psql/help.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/help.c 2017-03-06 01:46:41.000000000 +0100
@@ -373,7 +373,7 @@
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
- fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
+ fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff -ru a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
--- a/src/bin/psql/tab-complete.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/bin/psql/tab-complete.c 2017-03-06 00:57:11.000000000 +0100
@@ -3070,7 +3070,7 @@
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
- "latex", "latex-longtable", "troff-ms", NULL};
+ "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff -ru a/src/fe_utils/print.c b/src/fe_utils/print.c
--- a/src/fe_utils/print.c 2017-02-06 22:45:25.000000000 +0100
+++ b/src/fe_utils/print.c 2017-03-18 22:15:18.000000000 +0100
@@ -57,6 +57,48 @@
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+const printTextFormat pg_markdown =
+{
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
+const printTextFormat pg_rst =
+{
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+};
+
const printTextFormat pg_asciiformat =
{
"ascii",
@@ -206,6 +248,7 @@
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+static void skip_leading_spaces_print(const char *in, FILE *fout);
/* Count number of digits in integral part of number */
static int
@@ -575,6 +618,40 @@
fputc('\n', fout);
}
+/*
+ * skip leading spaces
+ */
+static void
+skip_leading_spaces_print(const char *in, FILE *fout)
+{
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++; /*fputs(".", fout);*/
+ else
+ fputc(*p, fout);
+
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+
+}
+
/*
* Print pretty boxes around cells.
@@ -623,6 +700,12 @@
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
@@ -1053,9 +1136,13 @@
else /* Left aligned cell */
{
/* spaces second */
- fputnbytes(fout,
- (char *) (this_line->ptr + bytes_output[j]),
- bytes_to_output);
+ if (format != &pg_rst)
+ fputnbytes(fout,
+ (char *) (this_line->ptr + bytes_output[j]),
+ bytes_to_output);
+
+ else
+ skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
@@ -1124,13 +1211,20 @@
fputc('\n', fout);
} while (more_lines);
+
+ /* add line after every record */
+ if (opt_border == 2 && format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
- if (opt_border == 2 && !cancel_pressed)
+ /* dont add line after last row, because line is added after every row
+ **/
+ if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_BOTTOM, format, fout);
@@ -1138,6 +1232,12 @@
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
@@ -1193,6 +1293,8 @@
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
@@ -1258,6 +1360,10 @@
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_RST) /*rst works only with border 2*/
+ opt_border = 2;
+
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
@@ -1307,6 +1413,9 @@
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4; /*this broke print RECORD without pipe */
+
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
{
@@ -1504,7 +1613,7 @@
if (cancel_pressed)
break;
- if (i == 0)
+ if (i == 0 || cont->opt->format == PRINT_RST)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
@@ -1519,9 +1628,19 @@
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
- if (!opt_tuples_only)
+ if (!opt_tuples_only && cont->opt->format != PRINT_RST)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
+ else if (!opt_tuples_only && format == &pg_rst)
+ {
+ if (i ==0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ print_aligned_vertical_line(format, opt_border, record++,
+ 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ }
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
@@ -1565,9 +1684,18 @@
/*
* Header text
*/
- strlen_max_width(hlineptr[hline].ptr, &target_width,
- encoding);
- fprintf(fout, "%-s", hlineptr[hline].ptr);
+
+ if (format != &pg_rst)
+ strlen_max_width(hlineptr[hline].ptr, &target_width,
+ encoding);
+ else
+ strlen_max_width(hlineptr[hline].ptr, &target_width - 4,
+ encoding);
+
+ if (format != &pg_rst)
+ fprintf(fout, "%-s", hlineptr[hline].ptr);
+ else
+ fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
@@ -1641,8 +1769,12 @@
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
- fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
- bytes_to_output);
+
+ if (format != &pg_rst)
+ fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
+ bytes_to_output);
+ else
+ skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
@@ -1704,12 +1836,18 @@
else
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
- }
+ /*if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout); */
+ }
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
- if (opt_border == 2 && !cancel_pressed)
+ if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
@@ -3263,6 +3401,18 @@
else
print_troff_ms_text(cont, fout);
break;
+
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
+ case PRINT_MARKDOWN:
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
@@ -3417,8 +3567,12 @@
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
- if (opt->line_style != NULL)
- return opt->line_style;
+ if (opt->format == PRINT_RST)
+ return &pg_rst;
+ else if (opt->format == PRINT_MARKDOWN)
+ return &pg_markdown;
+ else if (opt->line_style != NULL)
+ return opt->line_style;
else
return &pg_asciiformat;
}
diff -ru a/src/include/fe_utils/print.h b/src/include/fe_utils/print.h
--- a/src/include/fe_utils/print.h 2017-02-06 22:45:25.000000000 +0100
+++ b/src/include/fe_utils/print.h 2017-03-05 18:28:04.000000000 +0100
@@ -33,7 +33,9 @@
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
- PRINT_TROFF_MS
+ PRINT_TROFF_MS,
+ PRINT_MARKDOWN,
+ PRINT_RST
/* add your favourite output format here ... */
};
@@ -176,6 +178,8 @@
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+extern const printTextFormat pg_markdown; /*linestyle markdown*/
+extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff -ru a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
--- a/src/test/regress/expected/psql.out 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/expected/psql.out 2017-03-18 22:24:40.000000000 +0100
@@ -2714,3 +2714,102 @@
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+(279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+\pset format rst
+execute q;
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| column1 | column2 | column3 | column4 | column5 |
++==========================+=========+=====================+=========+========================================================================+
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+| monkey, ape | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+| eagle, whale, | | | | |
+| aligator, | | | | |
+| pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
++--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+(3 rows)
+
+\pset format markdown
+execute q;
+
+| column1 | column2 | column3 | column4 | column5 |
+|--------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+| Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+| squirrel, gorilla | | | | |
+| goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+| monkey, ape | | | | |
+| donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+| eagle, whale, | | | | |
+| aligator, | | | | |
+| pelican, | | | | |
+| grasshoper | | | | |
+| pig | | | | |
+| bat | | | | |
+
+
+(3 rows)
+
+\pset format rst
+\x
+execute q;
++-------------+------------------------------------------------------------------------+
+| **RECORD 1** |
++-------------+------------------------------------------------------------------------+
+| **column1** | Elephant, kangaroo, |
+| | squirrel, gorilla |
++-------------+------------------------------------------------------------------------+
+| **column2** | 121 |
++-------------+------------------------------------------------------------------------+
+| **column3** | 1.0035971223021583 |
++-------------+------------------------------------------------------------------------+
+| **column4** | 0.1111 |
++-------------+------------------------------------------------------------------------+
+| **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
++-------------+------------------------------------------------------------------------+
+| **RECORD 2** |
++-------------+------------------------------------------------------------------------+
+| **column1** | goat, rhinoceros, |
+| | monkey, ape |
++-------------+------------------------------------------------------------------------+
+| **column2** | 11121 |
++-------------+------------------------------------------------------------------------+
+| **column3** | 1.0007824726134585 |
++-------------+------------------------------------------------------------------------+
+| **column4** | 5.1111 |
++-------------+------------------------------------------------------------------------+
+| **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
++-------------+------------------------------------------------------------------------+
+| **RECORD 3** |
++-------------+------------------------------------------------------------------------+
+| **column1** | donkey, cow, horse, tit, |
+| | eagle, whale, |
+| | aligator, |
+| | pelican, |
+| | grasshoper |
+| | pig |
+| | bat |
++-------------+------------------------------------------------------------------------+
+| **column2** | 14351 |
++-------------+------------------------------------------------------------------------+
+| **column3** | 50.3877551020408163 |
++-------------+------------------------------------------------------------------------+
+| **column4** | 345.11 |
++-------------+------------------------------------------------------------------------+
+| **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
++-------------+------------------------------------------------------------------------+
+
+deallocate q;
diff -ru a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
--- a/src/test/regress/sql/psql.sql 2017-02-06 22:45:25.000000000 +0100
+++ b/src/test/regress/sql/psql.sql 2017-03-18 22:21:54.000000000 +0100
@@ -379,3 +379,20 @@
raise notice 'foo';
raise exception 'bar';
end $$;
+
+prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+(279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+\pset format rst
+execute q;
+\pset format markdown
+execute q;
+\pset format rst
+\x
+execute q;
+deallocate q;
Hi,
I like your suggestion and took a look at your patch though I’m not the expert about psql.
I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly developing pset format things.
But I'm thinking two comments below needs change to something about not focusing only linestyle.
That's because they really take care of both '\pset linestyle and \pset format' and it may lead to misunderstanding to readers.
---
/* Line style control structures */
const printTextFormat pg_markdown =
/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
The rest things are about code style convention.
- there are some indents with white spaces around skip_leading_spaces_print()
but Postgresql conventions says indents should be with 4 column tab.
https://www.postgresql.org/docs/devel/static/source-format.html
- On the other hand, in docs there are some tab indent
but white space indenet is preferable. Looking around sgml files, white space is used.
- some multi-line comment style also needs fix according to the above documentation (link)
- And I also found patch cannot be applied to current master.
Regards,
Ideriha, Takeshi
From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Jan Michalek
Sent: Sunday, March 19, 2017 5:10 AM
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Pavel Stehule <pavel.stehule@gmail.com>; PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] Other formats in pset like markdown, rst, mediawiki
2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com<mailto:godzilalalala@gmail.com>>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com<mailto:godzilalalala@gmail.com>>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.com<mailto:peter.eisentraut@2ndquadrant.com>>:
This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.
Thanks, original code is very synoptical and and well prepared for adding new formats.
- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it is done in other formats like html. I think, that it should work in sense, that table generated to rst should give similar output after processing like output of html format.
I prepared something like this (i have no prepared diff, i need do some another changes)
There a few things I need to do. First problem is bold column names, i should do it in sme fashin as "RECORD", but i need to do some research about length of column.
Bigger problem is with tab indent, rst processor doesn`t work with this in this case.
In new diff is added \x for rst and skipping leading spaces in rst in both. make check passed
Jan
jelen=# execute q \g | xclip
+---------+------------------------------------------------------------------------+
| **RECORD 1** |
+---------+------------------------------------------------------------------------+
| column1 | Elephant, kangaroo, |
| | squirrel, gorilla |
+---------+------------------------------------------------------------------------+
| column2 | 121 |
+---------+------------------------------------------------------------------------+
| column3 | 1.0035971223021583 |
+---------+------------------------------------------------------------------------+
| column4 | 0.1111 |
+---------+------------------------------------------------------------------------+
| column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+---------+------------------------------------------------------------------------+
| **RECORD 2** |
+---------+------------------------------------------------------------------------+
| column1 | goat, rhinoceros, |
| | monkey, ape |
+---------+------------------------------------------------------------------------+
| column2 | 11121 |
+---------+------------------------------------------------------------------------+
| column3 | 1.0007824726134585 |
+---------+------------------------------------------------------------------------+
| column4 | 5.1111 |
+---------+------------------------------------------------------------------------+
| column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+---------+------------------------------------------------------------------------+
| **RECORD 3** |
+---------+------------------------------------------------------------------------+
| column1 | donkey, cow, horse, tit, |
| | eagle, whale, |
| | aligator, |
| | pelican, |
| | grasshoper |
| | pig |
| | bat |
+---------+------------------------------------------------------------------------+
| column2 | 14351 |
+---------+------------------------------------------------------------------------+
| column3 | 50.3877551020408163 |
+---------+------------------------------------------------------------------------+
| column4 | 345.11 |
+---------+------------------------------------------------------------------------+
| column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+---------+------------------------------------------------------------------------+
- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.
I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what returns html format. Or i can use it in markdown for nice vs expanded format.
- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directive
OK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count presented.
- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)
I use format that was similar to aligned format and ascii linestyle, because it allows me to use existing features. I should look over more table styles in markdown.
- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.
This can be problem because of aligning, i will look on this, this same problem as replace newline with </br> for markdown.
Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>:
Hi,
I like your suggestion and took a look at your patch though I’m not the
expert about psql.I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly
developing pset format things.
But I'm thinking two comments below needs change to something about not
focusing only linestyle.That's because they really take care of both '\pset linestyle and \pset
format' and it may lead to misunderstanding to readers.
I am not sure if linestyle is enough - the markdown aligning is not visual.
regards
Pavel
Show quoted text
---
/* Line style control structures */
const printTextFormat pg_markdown =
/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
The rest things are about code style convention.
- there are some indents with white spaces around
skip_leading_spaces_print()but Postgresql conventions says indents should be with 4 column tab.
https://www.postgresql.org/docs/devel/static/source-format.html
- On the other hand, in docs there are some tab indent
but white space indenet is preferable. Looking around sgml files, white
space is used.- some multi-line comment style also needs fix according to the above
documentation (link)- And I also found patch cannot be applied to current master.
Regards,
Ideriha, Takeshi
*From:* pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@
postgresql.org] *On Behalf Of *Jan Michalek
*Sent:* Sunday, March 19, 2017 5:10 AM
*To:* Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
*Cc:* Pavel Stehule <pavel.stehule@gmail.com>; PostgreSQL mailing lists <
pgsql-hackers@postgresql.org>
*Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
mediawiki2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.I prepared something like this (i have no prepared diff, i need do some
another changes)There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.Bigger problem is with tab indent, rst processor doesn`t work with this in
this case.In new diff is added \x for rst and skipping leading spaces in rst in
both. make check passedJan
jelen=# execute q \g | xclip +---------+------------------------------------------------- -----------------------+ | **RECORD 1** | +---------+------------------------------------------------- -----------------------+ | column1 | Elephant, kangaroo, | | | squirrel, gorilla | +---------+------------------------------------------------- -----------------------+ | column2 | 121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0035971223021583 | +---------+------------------------------------------------- -----------------------+ | column4 | 0.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello | +---------+------------------------------------------------- -----------------------+ | **RECORD 2** | +---------+------------------------------------------------- -----------------------+ | column1 | goat, rhinoceros, | | | monkey, ape | +---------+------------------------------------------------- -----------------------+ | column2 | 11121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0007824726134585 | +---------+------------------------------------------------- -----------------------+ | column4 | 5.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx | +---------+------------------------------------------------- -----------------------+ | **RECORD 3** | +---------+------------------------------------------------- -----------------------+ | column1 | donkey, cow, horse, tit, | | | eagle, whale, | | | aligator, | | | pelican, | | | grasshoper | | | pig | | | bat | +---------+------------------------------------------------- -----------------------+ | column2 | 14351 | +---------+------------------------------------------------- -----------------------+ | column3 | 50.3877551020408163 | +---------+------------------------------------------------- -----------------------+ | column4 | 345.11 | +---------+------------------------------------------------- -----------------------+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy | +---------+------------------------------------------------- -----------------------+- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com>:
Hi,
I like your suggestion and took a look at your patch though I’m not the
expert about psql.I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly
developing pset format things.But I'm thinking two comments below needs change to something about not
focusing only linestyle.That's because they really take care of both '\pset linestyle and \pset
format' and it may lead to misunderstanding to readers.---
/* Line style control structures */
const printTextFormat pg_markdown =
/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
It is in command.c?
I have it done that \pset format changes linestyle
psql (9.6.2, server 9.6.1)
Type "help" for help.
jelen=# \pset linestyle ascii
Line style is ascii.
jelen=# \pset format rst
Output format is rst.
jelen=# \pset linestyle
Line style is rst.
jelen=#
Peter wrote that this is not right, but i don`t know how it should like,
because most of this is done on linestyle, format is used only for switch
from console.
The rest things are about code style convention.
- there are some indents with white spaces around
skip_leading_spaces_print()but Postgresql conventions says indents should be with 4 column tab.
https://www.postgresql.org/docs/devel/static/source-format.html
Thanks, i often using 4 whitespaces (i have it in vim) but in other code i
found mostly used 8 whitespaces.
I will look on this. I use code from another functions (fputnbytes,
print_html_escaped) as template.
- On the other hand, in docs there are some tab indent
but white space indenet is preferable. Looking around sgml files, white
space is used.- some multi-line comment style also needs fix according to the above
documentation (link)
I will look on the comments, this is only work version, coding style issues
will be corrected (i have some comments only my orientation in code).
- And I also found patch cannot be applied to current master.
I have 9.6.2 source code. It is not correct? Where i find source code i
should use?
Have nice day
Jan
Regards,
Ideriha, Takeshi
*From:* pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@
postgresql.org] *On Behalf Of *Jan Michalek
*Sent:* Sunday, March 19, 2017 5:10 AM
*To:* Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
*Cc:* Pavel Stehule <pavel.stehule@gmail.com>; PostgreSQL mailing lists <
pgsql-hackers@postgresql.org>
*Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
mediawiki2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <peter.eisentraut@2ndquadrant.
com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.I prepared something like this (i have no prepared diff, i need do some
another changes)There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.Bigger problem is with tab indent, rst processor doesn`t work with this in
this case.In new diff is added \x for rst and skipping leading spaces in rst in
both. make check passedJan
jelen=# execute q \g | xclip +---------+------------------------------------------------- -----------------------+ | **RECORD 1** | +---------+------------------------------------------------- -----------------------+ | column1 | Elephant, kangaroo, | | | squirrel, gorilla | +---------+------------------------------------------------- -----------------------+ | column2 | 121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0035971223021583 | +---------+------------------------------------------------- -----------------------+ | column4 | 0.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello | +---------+------------------------------------------------- -----------------------+ | **RECORD 2** | +---------+------------------------------------------------- -----------------------+ | column1 | goat, rhinoceros, | | | monkey, ape | +---------+------------------------------------------------- -----------------------+ | column2 | 11121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0007824726134585 | +---------+------------------------------------------------- -----------------------+ | column4 | 5.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx | +---------+------------------------------------------------- -----------------------+ | **RECORD 3** | +---------+------------------------------------------------- -----------------------+ | column1 | donkey, cow, horse, tit, | | | eagle, whale, | | | aligator, | | | pelican, | | | grasshoper | | | pig | | | bat | +---------+------------------------------------------------- -----------------------+ | column2 | 14351 | +---------+------------------------------------------------- -----------------------+ | column3 | 50.3877551020408163 | +---------+------------------------------------------------- -----------------------+ | column4 | 345.11 | +---------+------------------------------------------------- -----------------------+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy | +---------+------------------------------------------------- -----------------------+- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-21 10:59 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.com
:
Hi,
I like your suggestion and took a look at your patch though I’m not the
expert about psql.I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly
developing pset format things.But I'm thinking two comments below needs change to something about not
focusing only linestyle.That's because they really take care of both '\pset linestyle and \pset
format' and it may lead to misunderstanding to readers.---
/* Line style control structures */
const printTextFormat pg_markdown =
/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
It is in command.c?
I have it done that \pset format changes linestyle
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle ascii
Line style is ascii.
jelen=# \pset format rst
Output format is rst.
jelen=# \pset linestyle
Line style is rst.
jelen=#Peter wrote that this is not right, but i don`t know how it should like,
because most of this is done on linestyle, format is used only for switch
from console.The rest things are about code style convention.
- there are some indents with white spaces around
skip_leading_spaces_print()but Postgresql conventions says indents should be with 4 column tab.
https://www.postgresql.org/docs/devel/static/source-format.html
Thanks, i often using 4 whitespaces (i have it in vim) but in other code i
found mostly used 8 whitespaces.
I will look on this. I use code from another functions (fputnbytes,
print_html_escaped) as template.- On the other hand, in docs there are some tab indent
but white space indenet is preferable. Looking around sgml files, white
space is used.- some multi-line comment style also needs fix according to the above
documentation (link)I will look on the comments, this is only work version, coding style
issues will be corrected (i have some comments only my orientation in code).- And I also found patch cannot be applied to current master.
I have 9.6.2 source code. It is not correct? Where i find source code i
should use?
Please use git master https://wiki.postgresql.org/wiki/Working_with_Git
Regards
Pavel
Show quoted text
Have nice day
JanRegards,
Ideriha, Takeshi
*From:* pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@po
stgresql.org] *On Behalf Of *Jan Michalek
*Sent:* Sunday, March 19, 2017 5:10 AM
*To:* Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
*Cc:* Pavel Stehule <pavel.stehule@gmail.com>; PostgreSQL mailing lists <
pgsql-hackers@postgresql.org>
*Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
mediawiki2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for adding
new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how it
is done in other formats like html. I think, that it should work in sense,
that table generated to rst should give similar output after processing
like output of html format.I prepared something like this (i have no prepared diff, i need do some
another changes)There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.Bigger problem is with tab indent, rst processor doesn`t work with this
in this case.In new diff is added \x for rst and skipping leading spaces in rst in
both. make check passedJan
jelen=# execute q \g | xclip +---------+------------------------------------------------- -----------------------+ | **RECORD 1** | +---------+------------------------------------------------- -----------------------+ | column1 | Elephant, kangaroo, | | | squirrel, gorilla | +---------+------------------------------------------------- -----------------------+ | column2 | 121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0035971223021583 | +---------+------------------------------------------------- -----------------------+ | column4 | 0.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello | +---------+------------------------------------------------- -----------------------+ | **RECORD 2** | +---------+------------------------------------------------- -----------------------+ | column1 | goat, rhinoceros, | | | monkey, ape | +---------+------------------------------------------------- -----------------------+ | column2 | 11121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0007824726134585 | +---------+------------------------------------------------- -----------------------+ | column4 | 5.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx | +---------+------------------------------------------------- -----------------------+ | **RECORD 3** | +---------+------------------------------------------------- -----------------------+ | column1 | donkey, cow, horse, tit, | | | eagle, whale, | | | aligator, | | | pelican, | | | grasshoper | | | pig | | | bat | +---------+------------------------------------------------- -----------------------+ | column2 | 14351 | +---------+------------------------------------------------- -----------------------+ | column3 | 50.3877551020408163 | +---------+------------------------------------------------- -----------------------+ | column4 | 345.11 | +---------+------------------------------------------------- -----------------------+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy | +---------+------------------------------------------------- -----------------------+- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
2017-03-21 11:01 GMT+01:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-21 10:59 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-21 9:59 GMT+01:00 Ideriha, Takeshi <ideriha.takeshi@jp.fujitsu.co
m>:Hi,
I like your suggestion and took a look at your patch though I’m not the
expert about psql.I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly
developing pset format things.But I'm thinking two comments below needs change to something about not
focusing only linestyle.That's because they really take care of both '\pset linestyle and \pset
format' and it may lead to misunderstanding to readers.---
/* Line style control structures */
const printTextFormat pg_markdown =
/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
It is in command.c?
I have it done that \pset format changes linestyle
psql (9.6.2, server 9.6.1)
Type "help" for help.jelen=# \pset linestyle ascii
Line style is ascii.
jelen=# \pset format rst
Output format is rst.
jelen=# \pset linestyle
Line style is rst.
jelen=#Peter wrote that this is not right, but i don`t know how it should like,
because most of this is done on linestyle, format is used only for switch
from console.The rest things are about code style convention.
- there are some indents with white spaces around
skip_leading_spaces_print()but Postgresql conventions says indents should be with 4 column tab.
https://www.postgresql.org/docs/devel/static/source-format.html
Thanks, i often using 4 whitespaces (i have it in vim) but in other code
i found mostly used 8 whitespaces.
I will look on this. I use code from another functions (fputnbytes,
print_html_escaped) as template.- On the other hand, in docs there are some tab indent
but white space indenet is preferable. Looking around sgml files,
white space is used.- some multi-line comment style also needs fix according to the above
documentation (link)I will look on the comments, this is only work version, coding style
issues will be corrected (i have some comments only my orientation in code).- And I also found patch cannot be applied to current master.
I have 9.6.2 source code. It is not correct? Where i find source code i
should use?Please use git master https://wiki.postgresql.org/wiki/Working_with_Git
Thanks, i will look on this on weekend.
Regards
Pavel
Have nice day
JanRegards,
Ideriha, Takeshi
*From:* pgsql-hackers-owner@postgresql.org [mailto:
pgsql-hackers-owner@postgresql.org] *On Behalf Of *Jan Michalek
*Sent:* Sunday, March 19, 2017 5:10 AM
*To:* Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
*Cc:* Pavel Stehule <pavel.stehule@gmail.com>; PostgreSQL mailing lists
<pgsql-hackers@postgresql.org>
*Subject:* Re: [HACKERS] Other formats in pset like markdown, rst,
mediawiki2017-03-12 19:21 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-10 9:43 GMT+01:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-09 20:10 GMT+01:00 Peter Eisentraut <
peter.eisentraut@2ndquadrant.com>:This is looking pretty neat. I played around with it a bit. There are
a couple of edge cases that you need to address, I think.Thanks, original code is very synoptical and and well prepared for
adding new formats.- Does not support \x
I know, i dnot`t know, if \x make sense in this case. I will look, how
it is done in other formats like html. I think, that it should work in
sense, that table generated to rst should give similar output after
processing like output of html format.I prepared something like this (i have no prepared diff, i need do some
another changes)There a few things I need to do. First problem is bold column names, i
should do it in sme fashin as "RECORD", but i need to do some research
about length of column.Bigger problem is with tab indent, rst processor doesn`t work with this
in this case.In new diff is added \x for rst and skipping leading spaces in rst in
both. make check passedJan
jelen=# execute q \g | xclip +---------+------------------------------------------------- -----------------------+ | **RECORD 1** | +---------+------------------------------------------------- -----------------------+ | column1 | Elephant, kangaroo, | | | squirrel, gorilla | +---------+------------------------------------------------- -----------------------+ | column2 | 121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0035971223021583 | +---------+------------------------------------------------- -----------------------+ | column4 | 0.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello | +---------+------------------------------------------------- -----------------------+ | **RECORD 2** | +---------+------------------------------------------------- -----------------------+ | column1 | goat, rhinoceros, | | | monkey, ape | +---------+------------------------------------------------- -----------------------+ | column2 | 11121 | +---------+------------------------------------------------- -----------------------+ | column3 | 1.0007824726134585 | +---------+------------------------------------------------- -----------------------+ | column4 | 5.1111 | +---------+------------------------------------------------- -----------------------+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx | +---------+------------------------------------------------- -----------------------+ | **RECORD 3** | +---------+------------------------------------------------- -----------------------+ | column1 | donkey, cow, horse, tit, | | | eagle, whale, | | | aligator, | | | pelican, | | | grasshoper | | | pig | | | bat | +---------+------------------------------------------------- -----------------------+ | column2 | 14351 | +---------+------------------------------------------------- -----------------------+ | column3 | 50.3877551020408163 | +---------+------------------------------------------------- -----------------------+ | column4 | 345.11 | +---------+------------------------------------------------- -----------------------+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy | +---------+------------------------------------------------- -----------------------+- When \pset format is rst, then \pset linestyle also shows up as
"rst". That is wrong. Same for markdown.I will look on this.
- Broken output in tuples_only (\t) mode. (rst and markdown)
Similar to \x, im not certain, what it should return. I will look, what
returns html format. Or i can use it in markdown for nice vs expanded
format.- rst: Do something about \pset title; the way it currently shows up
appears to be invalid; could use ".. table:: title" directiveOK, it shouldn`t be problem alter this.
- markdown: Extra blank line between table and footer.
It is because markdown needs empty line after table, if is row count
presented.- markdown: We should document or comment somewhere exactly which of the
various markdown table formats this is supposed to produce. (Pandoc
pipe_tables?)I use format that was similar to aligned format and ascii linestyle,
because it allows me to use existing features. I should look over more
table styles in markdown.- markdown: Table title needs to be after the table, like
Table: title
I will change this.
- markdown: Needs to escape | characters in cell contents. (Not
needed for rst.) More escaping might be needed.This can be problem because of aligning, i will look on this, this same
problem as replace newline with </br> for markdown.Have Nice day
Jan
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
I like the idea taking advantage of linestyle utilities
to implement rst and markdown format efficiently instead of newly developing pset format things.
But I'm thinking two comments below needs change to something about not focusing only linestyle.
That's because they really take care of both '\pset linestyle and \pset format' and it may lead to misunderstanding to readers.---
/* Line style control structures */
const printTextFormat pg_markdown =/* get selected or default line style */
const printTextFormat *
get_line_style(const printTableOpt *opt)
---
It is in command.c?
I have it done that \pset format changes linestyle
psql (9.6.2, server 9.6.1)
Type "help" for help.
jelen=# \pset linestyle ascii
Line style is ascii.
jelen=# \pset format rst
Output format is rst.
jelen=# \pset linestyle
Line style is rst.
jelen=#
Peter wrote that this is not right, but i don`t know how it should like, because most of this is done on linestyle, format is used only for switch from console.
Thank you for explanation!
That's about print.c, but my explanation was poor...
My point was a slight thing about comments in source code.
I've just wanted to say comments needs change to match actual code.
These comments says about line style but the corresponding codes are about both line style and format.
But these points should be considered after how to implement the new formats are decided.
So please don't care.
(I've just thought implementing the new formats using linestyle code came into consensus.)
Regards,
Ideriha Takeshi
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passed
Hi
This is my first review (Magnus said in his presentation in PGDay Paris that volunteers should just come and help, so here I am), so please notify me for any mistake I do when using the review tools...
The feature seems to work as expected, but I don't claim to be a markdown and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between space based and tab based indentation) and a few trailing spaces in code
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown and rst formats" ==> duplicated and
- "Sets the output format to one of unaligned, aligned, wrapped, html, asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between "cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see any obvious reason for that
- the documentation doesn't mention (but ok, it's kind of obvious) that the linestyle option will not work with rst and markdown
Thanks !
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a markdown
and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between
space based and tab based indentation) and a few trailing spaces in code
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated and
- "Sets the output format to one of unaligned, aligned, wrapped, html,
asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after
every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for that
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdownThanks !
Thanks
I will work on it this weekend. I need to adapt it to current master and i
will do some indentation issues with this.
I need to add \x to markdown format and some things about title from older
posts there.
Nice Day Je;
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Jelen
Starší čeledín datovýho chlíva
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a markdown
and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between
space based and tab based indentation) and a few trailing spaces in code
corrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated and
corrected
- "Sets the output format to one of unaligned, aligned, wrapped, html,
asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after
every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for that
corrected
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdown
In this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).
Have nice day
Jan
Thanks !
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 2a9c412020..ee0c8fbea6 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2366,2372 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2366,2373 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2394,2400 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2395,2402 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 4f4a0aa9bd..97f4f37923 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 2518,2523 **** _align2string(enum printFormat in)
--- 2518,2529 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 2589,2597 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 2595,2607 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ba14df0344..d9dc5e10d9 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 375,381 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 375,381 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index f7494065de..ea14ec3d28 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3422,3428 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3422,3428 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/print.c index 9180b90004..322fa12b24 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {"", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,709 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1134,1145 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1208,1241 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1291,1298 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1358,1366 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_rst) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1409,1416 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1609,1615 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1526 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
--- 1624,1642 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && cont->opt->format != PRINT_RST)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
+ else if (!opt_tuples_only && format == &pg_rst)
+ {
+ if (i ==0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ print_aligned_vertical_line(format, opt_border, record++,
+ 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ }
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
***************
*** 1564,1572 **** print_aligned_vertical(const printTableContent *cont,
/*
* Header text
*/
! strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
--- 1680,1695 ----
/*
* Header text
*/
! if (format != &pg_rst)
! strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! else
! strlen_max_width(hlineptr[hline].ptr, &target_width - 4,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1763,1774 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1831,1844 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3392,3407 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
***************
*** 3416,3422 **** get_line_style(const printTableOpt *opt)
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
--- 3556,3566 ----
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->format == PRINT_RST)
! return &pg_rst;
! else if (opt->format == PRINT_MARKDOWN)
! return &pg_markdown;
! else if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
diff --git a/src/include/feindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex eb7f197b12..ab79a52d67 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2763,2765 **** NOTICE: foo
--- 2763,2864 ----
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |--------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+
+
+ (3 rows)
+
+ \pset format rst
+ \x
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex 8f8e17a87c..a87578b8b6 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 404,406 **** begin
--- 404,423 ----
raise notice 'foo';
raise exception 'bar';
end $$;
+
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \pset format rst
+ \x
+ execute q;
+ deallocate q;
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a markdown
and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between
space based and tab based indentation) and a few trailing spaces in codecorrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated andcorrected
- "Sets the output format to one of unaligned, aligned, wrapped, html,
asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after
every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for thatcorrected
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdownIn this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).
Added \x option form markdown
In markdown works multiline cels (newline replaced by </br>)
regre tests passed
Jan
Have nice day
Jan
Thanks !
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 2a9c412020..ee0c8fbea6 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2366,2372 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2366,2373 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2394,2400 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2395,2402 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 4f4a0aa9bd..97f4f37923 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 2518,2523 **** _align2string(enum printFormat in)
--- 2518,2529 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 2589,2597 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 2595,2607 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ba14df0344..d9dc5e10d9 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 375,381 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 375,381 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index f7494065de..ea14ec3d28 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3422,3428 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3422,3428 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/mbprint.index d186fc4c91..a2b030e2f7 100644
*** a/src/fe_utils/mbprint.c
--- b/src/fe_utils/mbprint.c
***************
*** 285,290 **** pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
--- 285,368 ----
}
/*
+ * version of pg_wcssize for markdown
+ * replace newline with </br>
+ */
+ void
+ pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *result_width, int *result_height, int *result_format_size)
+ {
+ int w,
+ chlen = 0,
+ linewidth = 0;
+ int width = 0;
+ int height = 1;
+ int format_size = 0;
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ linewidth += 5;
+ format_size += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ linewidth++;
+ format_size++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ format_size += 1;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ linewidth += 6; /* \u0000 */
+ format_size += 6;
+ }
+ else /* All other chars */
+ {
+ linewidth += w;
+ format_size += chlen;
+ }
+ len -= chlen;
+ }
+ if (linewidth > width)
+ width = linewidth;
+ format_size += 1; /* For NUL char */
+
+ /* Set results */
+ if (result_width)
+ *result_width = width;
+ if (result_height)
+ *result_height = height;
+ if (result_format_size)
+ *result_format_size = format_size;
+ }
+
+ /*
* Format a string into one or more "struct lineptr" lines.
* lines[i].ptr == NULL indicates the end of the array.
*
***************
*** 382,387 **** pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 460,555 ----
(lines + 1)->ptr = NULL; /* terminate line array */
}
+ /*
+ * version of pg_wcsformat for markdown
+ * replace newline with </br>
+ */
+
+ void
+ pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count)
+ {
+ int w,
+ chlen = 0;
+ int linewidth = 0;
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ strcpy((char *) ptr, "</br>");
+ linewidth += 5;
+ ptr += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ strcpy((char *) ptr, "\\r");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ *ptr++ = ' ';
+ linewidth++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
+ linewidth += 4;
+ ptr += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ *ptr++ = *pwcs;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ if (encoding == PG_UTF8)
+ sprintf((char *) ptr, "\\u%04X", utf8_to_unicode(pwcs));
+ else
+ {
+ /*
+ * This case cannot happen in the current code because only
+ * UTF-8 signals multibyte control characters. But we may need
+ * to support it at some stage
+ */
+ sprintf((char *) ptr, "\\u????");
+ }
+ ptr += 6;
+ linewidth += 6;
+ }
+ else /* All other chars */
+ {
+ int i;
+
+ for (i = 0; i < chlen; i++)
+ *ptr++ = pwcs[i];
+ linewidth += w;
+ }
+ len -= chlen;
+ }
+ lines->width = linewidth;
+ *ptr++ = '\0'; /* Terminate formatted string */
+
+ if (count <= 0)
+ exit(1); /* Screwup */
+
+ (lines + 1)->ptr = NULL; /* terminate line array */
+ }
+
/*
* Encoding validation: delete any unvalidatable characters from the string
diff --git a/src/fe_utils/priindex 9180b90004..735d3973ce 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,709 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 661,668 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
--- 743,754 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
***************
*** 685,692 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
--- 771,782 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
***************
*** 846,853 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
--- 936,947 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
***************
*** 885,892 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
int width,
height;
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
--- 979,990 ----
int width,
height;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
! else
! pg_wcssize_newline((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
***************
*** 907,915 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
--- 1005,1018 ----
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
! else
! pg_wcsformat_newline((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
***************
*** 978,985 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
*/
for (j = 0; j < col_count; j++)
{
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
--- 1081,1092 ----
*/
for (j = 0; j < col_count; j++)
{
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
! else
! pg_wcsformat_newline((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1159,1170 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1233,1266 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1316,1325 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
+ else if (format == &pg_markdown)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1385,1393 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_rst || format == &pg_markdown) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1293,1300 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
if (width > hwidth)
hwidth = width;
if (height > hheight)
--- 1424,1436 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
!
if (width > hwidth)
hwidth = width;
if (height > hheight)
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1441,1453 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
+
+ /* if hwidth < reclen fromheader */
+ if (format == &pg_markdown)
+ if (hwidth < floor (log10 (abs (cont->nrows))) + 12)
+ hwidth = floor (log10 (abs (cont->nrows))) + 12;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1313,1320 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
if (width > dwidth)
dwidth = width;
if (height > dheight)
--- 1456,1468 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
!
if (width > dwidth)
dwidth = width;
if (height > dheight)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1651,1657 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1538 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
/*
* Loop through header and data in parallel dealing with newlines and
--- 1666,1717 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && (format != &pg_rst && format != &pg_markdown))
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
+ else if (!opt_tuples_only && format == &pg_rst)
+ {
+ if (i ==0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ print_aligned_vertical_line(format, opt_border, record++,
+ 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ }
+ else if (!opt_tuples_only && format == &pg_markdown)
+ {
+ print_aligned_vertical_line(format, opt_border, record++,
+ lhwidth, dwidth, PRINT_RULE_DATA, fout);
+ if (i == 0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, PRINT_RULE_MIDDLE, fout);
+ }
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! if (format != &pg_markdown)
! {
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
! else
! {
! /* Format the header */
! pg_wcsformat_newline((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
/*
* Loop through header and data in parallel dealing with newlines and
***************
*** 1564,1572 **** print_aligned_vertical(const printTableContent *cont,
/*
* Header text
*/
! strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
--- 1743,1758 ----
/*
* Header text
*/
! if (format != &pg_rst)
! strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! else
! strlen_max_width(hlineptr[hline].ptr, &target_width - 4,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1826,1837 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1894,1907 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3455,3473 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
***************
*** 3416,3422 **** get_line_style(const printTableOpt *opt)
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
--- 3622,3632 ----
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->format == PRINT_RST)
! return &pg_rst;
! else if (opt->format == PRINT_MARKDOWN)
! return &pg_markdown;
! else if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
diff --git a/src/include/feindex 56626f631b..70684155b5 100644
*** a/src/include/fe_utils/mbprint.h
--- b/src/include/fe_utils/mbprint.h
***************
*** 25,29 **** extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 25,33 ----
struct lineptr * lines, int count);
extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
int *width, int *height, int *format_size);
+ extern void pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count);
+ extern void pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *width, int *height, int *format_size);
#endif /* MBPRINT_H */
diff --git a/src/include/fe_utils/priindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex eb7f197b12..adaac27fc3 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2763,2765 **** NOTICE: foo
--- 2763,2879 ----
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |-------------------------------------------------------------------------------------------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo,</br>squirrel, gorilla | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | goat, rhinoceros,</br>monkey, ape | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ (3 rows)
+
+ \x
+ \pset format rst
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ \pset format markdown
+ execute q;
+ | **RECORD 1** | |
+ |--------------|-------------------------------------------------------------------------------------------------------------|
+ | column1 | Elephant, kangaroo,</br>squirrel, gorilla |
+ | column2 | 121 |
+ | column3 | 1.0035971223021583 |
+ | column4 | 0.1111 |
+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | **RECORD 2** | |
+ | column1 | goat, rhinoceros,</br>monkey, ape |
+ | column2 | 11121 |
+ | column3 | 1.0007824726134585 |
+ | column4 | 5.1111 |
+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | **RECORD 3** | |
+ | column1 | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat |
+ | column2 | 14351 |
+ | column3 | 50.3877551020408163 |
+ | column4 | 345.11 |
+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex 8f8e17a87c..8e3aea7c6b 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 404,406 **** begin
--- 404,425 ----
raise notice 'foo';
raise exception 'bar';
end $$;
+
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \x
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ deallocate q;
2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a
markdown and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix
between space based and tab based indentation) and a few trailing spaces in
codecorrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated andcorrected
- "Sets the output format to one of unaligned, aligned, wrapped, html,
asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added
after every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for thatcorrected
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdownIn this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).Added \x option form markdown
In markdown works multiline cels (newline replaced by </br>)
regre tests passed
\pset format rst
\x
select 10
crash on segfault
Program received signal SIGSEGV, Segmentation fault.
0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
(gdb) bt
#0 0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
#1 0x00007f77673b1574 in fprintf () from /lib64/libc.so.6
#2 0x0000000000437bc5 in print_aligned_vertical (cont=0x7fffade43da0,
fout=<optimized out>,
is_pager=<optimized out>) at print.c:1755
#3 0x000000000043a70d in printTable (cont=cont@entry=0x7fffade43da0,
fout=<optimized out>,
fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager=<optimized out>,
is_pager@entry=0 '\000',
flog=flog@entry=0x0) at print.c:3466
#4 0x000000000043c37f in printQuery (result=result@entry=0x9c4b60,
opt=opt@entry=0x7fffade43f00,
fout=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager=is_pager@entry=0
'\000', flog=0x0) at print.c:3551
#5 0x000000000040da6d in PrintQueryTuples (results=0x9c4b60) at
common.c:808
#6 PrintQueryResults (results=0x9c4b60) at common.c:1140
#7 SendQuery (query=0x9c1700 "select 10;") at common.c:1317
#8 0x000000000041c3d4 in MainLoop (source=0x7f77677248a0 <_IO_2_1_stdin_>)
at mainloop.c:319
#9 0x0000000000405d5d in main (argc=<optimized out>, argv=<optimized out>)
at startup.c:396
Regards
Pavel
Show quoted text
Jan
Have nice day
Jan
Thanks !
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-03-30 21:53 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a
markdown and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix
between space based and tab based indentation) and a few trailing spaces in
codecorrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated andcorrected
- "Sets the output format to one of unaligned, aligned, wrapped,
html, asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added
after every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for thatcorrected
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdownIn this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).Added \x option form markdown
In markdown works multiline cels (newline replaced by </br>)
regre tests passed\pset format rst
\x
select 10
crash on segfaultProgram received signal SIGSEGV, Segmentation fault.
0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
(gdb) bt
#0 0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
#1 0x00007f77673b1574 in fprintf () from /lib64/libc.so.6
#2 0x0000000000437bc5 in print_aligned_vertical (cont=0x7fffade43da0,
fout=<optimized out>,
is_pager=<optimized out>) at print.c:1755
#3 0x000000000043a70d in printTable (cont=cont@entry=0x7fffade43da0,
fout=<optimized out>,
fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager=<optimized
out>, is_pager@entry=0 '\000',
flog=flog@entry=0x0) at print.c:3466
#4 0x000000000043c37f in printQuery (result=result@entry=0x9c4b60,
opt=opt@entry=0x7fffade43f00,
fout=0x7f77677255e0 <_IO_2_1_stdout_>, is_pager=is_pager@entry=0
'\000', flog=0x0) at print.c:3551
#5 0x000000000040da6d in PrintQueryTuples (results=0x9c4b60) at
common.c:808
#6 PrintQueryResults (results=0x9c4b60) at common.c:1140
#7 SendQuery (query=0x9c1700 "select 10;") at common.c:1317
#8 0x000000000041c3d4 in MainLoop (source=0x7f77677248a0
<_IO_2_1_stdin_>) at mainloop.c:319
#9 0x0000000000405d5d in main (argc=<optimized out>, argv=<optimized
out>) at startup.c:396Regards
On source from monday it works (last commit on master I have is from 27.3
14:30). Or, maybe I didn`t generate diff well, or some gitt issue.
psql (10devel, server 9.6.1)
Type "help" for help.
jelen=# \x
Expanded display is on.
jelen=# \pset format rst
Output format is rst.
jelen=# select 10;
+--------------+----+
| **RECORD 1** |
+--------------+----+
| **?column?** | 10 |
+--------------+----+
jelen=#
Pavel
Jan
Have nice day
Jan
Thanks !
The new status of this patch is: Waiting on Author
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers--
Jelen
Starší čeledín datovýho chlíva--
Jelen
Starší čeledín datovýho chlíva--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Jelen
Starší čeledín datovýho chlíva
On Friday, March 31, 2017 7:17:08 AM CEST, Jan Michálek wrote:
2017-03-30 21:53 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in
PGDay Paris that volunteers should just come and help, so here I
am), so please notify me for any mistake I do when using the
review tools...The feature seems to work as expected, but I don't claim to be
a markdown and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with
mix between space based and tab based indentation) and a few
trailing spaces in codecorrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and
markdown and rst formats" ==> duplicated andcorrected
- "Sets the output format to one of unaligned, aligned,
wrapped, html, asciidoc, latex (uses tabular), latex-longtable,
rst, markdown, or troff-ms." ==> extra comma at the end of the
list
- the comment " dont add line after last row, because line is
added after every row" is misleading, it should warn that it's
only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix
between "cont->opt->format == PRINT_RST" and "format == &pg_rst"
and I don't see any obvious reason for that
corrected
- the documentation doesn't mention (but ok, it's kind of
obvious) that the linestyle option will not work with rst and
markdownIn this patch are corrected (i hope, i had correct changes in
vimrc) indentation issues. Plese, look at this if it is OK (i
men indentats) and some minor errors. And it should work on
current master (probably).Added \x option form markdown
In markdown works multiline cels (newline replaced by </br>)
regre tests passed\pset format rst
\x
select 10
crash on segfaultProgram received signal SIGSEGV, Segmentation fault.
0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
(gdb) bt
#0 0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
#1 0x00007f77673b1574 in fprintf () from /lib64/libc.so.6
#2 0x0000000000437bc5 in print_aligned_vertical
(cont=0x7fffade43da0, fout=<optimized out>,
is_pager=<optimized out>) at print.c:1755
#3 0x000000000043a70d in printTable
(cont=cont@entry=0x7fffade43da0, fout=<optimized out>,
fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>,
is_pager=<optimized out>, is_pager@entry=0 '\000',
flog=flog@entry=0x0) at print.c:3466
#4 0x000000000043c37f in printQuery
(result=result@entry=0x9c4b60, opt=opt@entry=0x7fffade43f00,
fout=0x7f77677255e0 <_IO_2_1_stdout_>,
is_pager=is_pager@entry=0 '\000', flog=0x0) at print.c:3551
#5 0x000000000040da6d in PrintQueryTuples (results=0x9c4b60)
at common.c:808
#6 PrintQueryResults (results=0x9c4b60) at common.c:1140
#7 SendQuery (query=0x9c1700 "select 10;") at common.c:1317
#8 0x000000000041c3d4 in MainLoop (source=0x7f77677248a0
<_IO_2_1_stdin_>) at mainloop.c:319
#9 0x0000000000405d5d in main (argc=<optimized out>,
argv=<optimized out>) at startup.c:396Regards
On source from monday it works (last commit on master I have is
from 27.3 14:30). Or, maybe I didn`t generate diff well, or some
gitt issue.
I agree with Pavel, there is a segfault when you do these with your current
patch. The current patch does not pass make check-world.
How did you generate the diff ? Basically, the simplest way to generate a
patch serie is through git format-patch.
For instance, say you have a rstFormat branch freshly rebased upon
origin/master, just do git format-patch origin/master..rstFormat and you
will
have one patch file per commit.
And don't forget to commit everything :)
I hope this helps, I don't have enough time to go through the patch and
find
out what is causing the segfault right now.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-03-31 12:01 GMT+02:00 Pierre Ducroquet <p.sql@pinaraf.info>:
On Friday, March 31, 2017 7:17:08 AM CEST, Jan Michálek wrote:
2017-03-30 21:53 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
2017-03-29 20:11 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-27 19:41 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a markdown
and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between
space based and tab based indentation) and a few trailing spaces in codecorrected
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated andcorrected - "Sets the output format to one of unaligned, aligned,
wrapped, html, asciidoc, latex (uses tabular), latex-longtable, rst,
markdown, or troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after
every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for that
corrected - the documentation doesn't mention (but ok, it's kind of
obvious) that the linestyle option will not work with rst and markdownIn this patch are corrected (i hope, i had correct changes in vimrc)
indentation issues. Plese, look at this if it is OK (i men indentats) and
some minor errors. And it should work on current master (probably).Added \x option form markdown
In markdown works multiline cels (newline replaced by </br>)
regre tests passed\pset format rst
\x
select 10
crash on segfaultProgram received signal SIGSEGV, Segmentation fault.
0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
(gdb) bt
#0 0x00007f77673a866c in vfprintf () from /lib64/libc.so.6
#1 0x00007f77673b1574 in fprintf () from /lib64/libc.so.6
#2 0x0000000000437bc5 in print_aligned_vertical (cont=0x7fffade43da0,
fout=<optimized out>, is_pager=<optimized out>) at print.c:1755
#3 0x000000000043a70d in printTable (cont=cont@entry=0x7fffade43da0,
fout=<optimized out>, fout@entry=0x7f77677255e0 <_IO_2_1_stdout_>,
is_pager=<optimized out>, is_pager@entry=0 '\000', flog=flog@entry=0x0)
at print.c:3466
#4 0x000000000043c37f in printQuery (result=result@entry=0x9c4b60,
opt=opt@entry=0x7fffade43f00, fout=0x7f77677255e0 <_IO_2_1_stdout_>,
is_pager=is_pager@entry=0 '\000', flog=0x0) at print.c:3551
#5 0x000000000040da6d in PrintQueryTuples (results=0x9c4b60) at
common.c:808
#6 PrintQueryResults (results=0x9c4b60) at common.c:1140
#7 SendQuery (query=0x9c1700 "select 10;") at common.c:1317
#8 0x000000000041c3d4 in MainLoop (source=0x7f77677248a0
<_IO_2_1_stdin_>) at mainloop.c:319
#9 0x0000000000405d5d in main (argc=<optimized out>, argv=<optimized
out>) at startup.c:396Regards
On source from monday it works (last commit on master I have is from 27.3
14:30). Or, maybe I didn`t generate diff well, or some gitt issue.I agree with Pavel, there is a segfault when you do these with your
current patch. The current patch does not pass make check-world.
How did you generate the diff ? Basically, the simplest way to generate a
patch serie is through git format-patch.
For instance, say you have a rstFormat branch freshly rebased upon
origin/master, just do git format-patch origin/master..rstFormat and you
will have one patch file per commit.
And don't forget to commit everything :)I hope this helps, I don't have enough time to go through the patch and
find out what is causing the segfault right now.
There was error in code (I don`t know why it works on my computer). Pavel
found this error and there is corrected patch.
Thanks
Jan
P.S.: There are few things i should change (linestyle comment, few things
in documentation, table annotation etc), so I didn`t change state of patch.
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index b51b11baa3..7e9dca5523 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2455,2461 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2455,2462 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2483,2489 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2484,2491 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 94a3cfce90..9b5c4c9eec 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 3684,3689 **** _align2string(enum printFormat in)
--- 3684,3695 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 3755,3763 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 3761,3773 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ac435220e6..13f2e44add 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 382,388 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 382,388 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index dc2794d48a..7b0fbaf98f 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3422,3428 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3422,3428 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/mbprint.index d186fc4c91..a2b030e2f7 100644
*** a/src/fe_utils/mbprint.c
--- b/src/fe_utils/mbprint.c
***************
*** 285,290 **** pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
--- 285,368 ----
}
/*
+ * version of pg_wcssize for markdown
+ * replace newline with </br>
+ */
+ void
+ pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *result_width, int *result_height, int *result_format_size)
+ {
+ int w,
+ chlen = 0,
+ linewidth = 0;
+ int width = 0;
+ int height = 1;
+ int format_size = 0;
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ linewidth += 5;
+ format_size += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ linewidth++;
+ format_size++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ format_size += 1;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ linewidth += 6; /* \u0000 */
+ format_size += 6;
+ }
+ else /* All other chars */
+ {
+ linewidth += w;
+ format_size += chlen;
+ }
+ len -= chlen;
+ }
+ if (linewidth > width)
+ width = linewidth;
+ format_size += 1; /* For NUL char */
+
+ /* Set results */
+ if (result_width)
+ *result_width = width;
+ if (result_height)
+ *result_height = height;
+ if (result_format_size)
+ *result_format_size = format_size;
+ }
+
+ /*
* Format a string into one or more "struct lineptr" lines.
* lines[i].ptr == NULL indicates the end of the array.
*
***************
*** 382,387 **** pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 460,555 ----
(lines + 1)->ptr = NULL; /* terminate line array */
}
+ /*
+ * version of pg_wcsformat for markdown
+ * replace newline with </br>
+ */
+
+ void
+ pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count)
+ {
+ int w,
+ chlen = 0;
+ int linewidth = 0;
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ strcpy((char *) ptr, "</br>");
+ linewidth += 5;
+ ptr += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ strcpy((char *) ptr, "\\r");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ *ptr++ = ' ';
+ linewidth++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
+ linewidth += 4;
+ ptr += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ *ptr++ = *pwcs;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ if (encoding == PG_UTF8)
+ sprintf((char *) ptr, "\\u%04X", utf8_to_unicode(pwcs));
+ else
+ {
+ /*
+ * This case cannot happen in the current code because only
+ * UTF-8 signals multibyte control characters. But we may need
+ * to support it at some stage
+ */
+ sprintf((char *) ptr, "\\u????");
+ }
+ ptr += 6;
+ linewidth += 6;
+ }
+ else /* All other chars */
+ {
+ int i;
+
+ for (i = 0; i < chlen; i++)
+ *ptr++ = pwcs[i];
+ linewidth += w;
+ }
+ len -= chlen;
+ }
+ lines->width = linewidth;
+ *ptr++ = '\0'; /* Terminate formatted string */
+
+ if (count <= 0)
+ exit(1); /* Screwup */
+
+ (lines + 1)->ptr = NULL; /* terminate line array */
+ }
+
/*
* Encoding validation: delete any unvalidatable characters from the string
diff --git a/src/fe_utils/priindex 9180b90004..17fc63497a 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,709 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 661,668 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
--- 743,754 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
***************
*** 685,692 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
--- 771,782 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
***************
*** 846,853 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
--- 936,947 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
***************
*** 885,892 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
int width,
height;
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
--- 979,990 ----
int width,
height;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
! else
! pg_wcssize_newline((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
***************
*** 907,915 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
--- 1005,1018 ----
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
! else
! pg_wcsformat_newline((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
***************
*** 978,985 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
*/
for (j = 0; j < col_count; j++)
{
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
--- 1081,1092 ----
*/
for (j = 0; j < col_count; j++)
{
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
! else
! pg_wcsformat_newline((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1159,1170 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1233,1266 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1316,1325 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
+ else if (format == &pg_markdown)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1385,1393 ----
if (opt_border > 2)
opt_border = 2;
+ if (format == &pg_rst || format == &pg_markdown) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1293,1300 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
if (width > hwidth)
hwidth = width;
if (height > hheight)
--- 1424,1436 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
!
if (width > hwidth)
hwidth = width;
if (height > hheight)
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1441,1453 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
+
+ /* if hwidth < reclen fromheader */
+ if (format == &pg_markdown)
+ if (hwidth < floor (log10 (abs (cont->nrows))) + 12)
+ hwidth = floor (log10 (abs (cont->nrows))) + 12;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1313,1320 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
if (width > dwidth)
dwidth = width;
if (height > dheight)
--- 1456,1468 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
!
if (width > dwidth)
dwidth = width;
if (height > dheight)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1651,1657 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1538 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
/*
* Loop through header and data in parallel dealing with newlines and
--- 1666,1717 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && (format != &pg_rst && format != &pg_markdown))
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
+ else if (!opt_tuples_only && format == &pg_rst)
+ {
+ if (i ==0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ print_aligned_vertical_line(format, opt_border, record++,
+ 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, pos, fout);
+ }
+ else if (!opt_tuples_only && format == &pg_markdown)
+ {
+ print_aligned_vertical_line(format, opt_border, record++,
+ lhwidth, dwidth, PRINT_RULE_DATA, fout);
+ if (i == 0)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, PRINT_RULE_MIDDLE, fout);
+ }
else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! if (format != &pg_markdown)
! {
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
! else
! {
! /* Format the header */
! pg_wcsformat_newline((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
/*
* Loop through header and data in parallel dealing with newlines and
***************
*** 1565,1577 **** print_aligned_vertical(const printTableContent *cont,
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
*/
! swidth -= target_width;
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
--- 1744,1763 ----
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
*/
! if (format == &pg_rst)
! swidth -= target_width + 4;
! else
! swidth -= target_width;
!
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1826,1837 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1894,1907 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3455,3473 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
***************
*** 3416,3422 **** get_line_style(const printTableOpt *opt)
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
--- 3622,3632 ----
* printTableOpt struct can be initialized to zeroes to get default
* behavior.
*/
! if (opt->format == PRINT_RST)
! return &pg_rst;
! else if (opt->format == PRINT_MARKDOWN)
! return &pg_markdown;
! else if (opt->line_style != NULL)
return opt->line_style;
else
return &pg_asciiformat;
diff --git a/src/include/feindex 56626f631b..70684155b5 100644
*** a/src/include/fe_utils/mbprint.h
--- b/src/include/fe_utils/mbprint.h
***************
*** 25,29 **** extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 25,33 ----
struct lineptr * lines, int count);
extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
int *width, int *height, int *format_size);
+ extern void pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count);
+ extern void pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *width, int *height, int *format_size);
#endif /* MBPRINT_H */
diff --git a/src/include/fe_utils/priindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex 8aa914fa95..bd7cb36385 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2932,2934 **** NOTICE: foo
--- 2932,3048 ----
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |-------------------------------------------------------------------------------------------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo,</br>squirrel, gorilla | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | goat, rhinoceros,</br>monkey, ape | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ (3 rows)
+
+ \x
+ \pset format rst
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ \pset format markdown
+ execute q;
+ | **RECORD 1** | |
+ |--------------|-------------------------------------------------------------------------------------------------------------|
+ | column1 | Elephant, kangaroo,</br>squirrel, gorilla |
+ | column2 | 121 |
+ | column3 | 1.0035971223021583 |
+ | column4 | 0.1111 |
+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | **RECORD 2** | |
+ | column1 | goat, rhinoceros,</br>monkey, ape |
+ | column2 | 11121 |
+ | column3 | 1.0007824726134585 |
+ | column4 | 5.1111 |
+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | **RECORD 3** | |
+ | column1 | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat |
+ | column2 | 14351 |
+ | column3 | 50.3877551020408163 |
+ | column4 | 345.11 |
+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex 0ae4dd84ea..0ca94d2fa6 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 548,550 **** begin
--- 548,569 ----
raise notice 'foo';
raise exception 'bar';
end $$;
+
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \x
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ deallocate q;
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: tested, passed
Spec compliant: tested, passed
Documentation: tested, passedHi
This is my first review (Magnus said in his presentation in PGDay Paris
that volunteers should just come and help, so here I am), so please notify
me for any mistake I do when using the review tools...The feature seems to work as expected, but I don't claim to be a markdown
and rst expert.
Some minor issues with the code itself :
- some indentation issues (documentation and code itself with mix between
space based and tab based indentation) and a few trailing spaces in code
- typographic issues in the documentation :
- "The html, asciidoc, latex, latex-longtable, troff-ms, and markdown
and rst formats" ==> duplicated and
- "Sets the output format to one of unaligned, aligned, wrapped, html,
asciidoc, latex (uses tabular), latex-longtable, rst, markdown, or
troff-ms." ==> extra comma at the end of the list
- the comment " dont add line after last row, because line is added after
every row" is misleading, it should warn that it's only for rst
- there is a block of commented out code left
- in the print_aligned_vertical function, there is a mix between
"cont->opt->format == PRINT_RST" and "format == &pg_rst" and I don't see
any obvious reason for that
- the documentation doesn't mention (but ok, it's kind of obvious) that
the linestyle option will not work with rst and markdownThanks !
The new status of this patch is: Waiting on Author
Corrected problem with \pset linestyle when format is set to markdown, or
rst.
Corrected tuples only for markdown and rst (normal and expanded)
Jan
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index ad463e71c1..b513aa703b 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2470,2476 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2470,2477 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2498,2504 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2499,2506 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 94a3cfce90..9b5c4c9eec 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 3684,3689 **** _align2string(enum printFormat in)
--- 3684,3695 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 3755,3763 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 3761,3773 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ac435220e6..13f2e44add 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 382,388 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 382,388 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index dc2794d48a..7b0fbaf98f 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3422,3428 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3422,3428 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/mbprint.index d186fc4c91..a2b030e2f7 100644
*** a/src/fe_utils/mbprint.c
--- b/src/fe_utils/mbprint.c
***************
*** 285,290 **** pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
--- 285,368 ----
}
/*
+ * version of pg_wcssize for markdown
+ * replace newline with </br>
+ */
+ void
+ pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *result_width, int *result_height, int *result_format_size)
+ {
+ int w,
+ chlen = 0,
+ linewidth = 0;
+ int width = 0;
+ int height = 1;
+ int format_size = 0;
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ linewidth += 5;
+ format_size += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ linewidth++;
+ format_size++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ format_size += 1;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ linewidth += 6; /* \u0000 */
+ format_size += 6;
+ }
+ else /* All other chars */
+ {
+ linewidth += w;
+ format_size += chlen;
+ }
+ len -= chlen;
+ }
+ if (linewidth > width)
+ width = linewidth;
+ format_size += 1; /* For NUL char */
+
+ /* Set results */
+ if (result_width)
+ *result_width = width;
+ if (result_height)
+ *result_height = height;
+ if (result_format_size)
+ *result_format_size = format_size;
+ }
+
+ /*
* Format a string into one or more "struct lineptr" lines.
* lines[i].ptr == NULL indicates the end of the array.
*
***************
*** 382,387 **** pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 460,555 ----
(lines + 1)->ptr = NULL; /* terminate line array */
}
+ /*
+ * version of pg_wcsformat for markdown
+ * replace newline with </br>
+ */
+
+ void
+ pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count)
+ {
+ int w,
+ chlen = 0;
+ int linewidth = 0;
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ strcpy((char *) ptr, "</br>");
+ linewidth += 5;
+ ptr += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ strcpy((char *) ptr, "\\r");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ *ptr++ = ' ';
+ linewidth++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
+ linewidth += 4;
+ ptr += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ *ptr++ = *pwcs;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ if (encoding == PG_UTF8)
+ sprintf((char *) ptr, "\\u%04X", utf8_to_unicode(pwcs));
+ else
+ {
+ /*
+ * This case cannot happen in the current code because only
+ * UTF-8 signals multibyte control characters. But we may need
+ * to support it at some stage
+ */
+ sprintf((char *) ptr, "\\u????");
+ }
+ ptr += 6;
+ linewidth += 6;
+ }
+ else /* All other chars */
+ {
+ int i;
+
+ for (i = 0; i < chlen; i++)
+ *ptr++ = pwcs[i];
+ linewidth += w;
+ }
+ len -= chlen;
+ }
+ lines->width = linewidth;
+ *ptr++ = '\0'; /* Terminate formatted string */
+
+ if (count <= 0)
+ exit(1); /* Screwup */
+
+ (lines + 1)->ptr = NULL; /* terminate line array */
+ }
+
/*
* Encoding validation: delete any unvalidatable characters from the string
diff --git a/src/fe_utils/priindex 9180b90004..526a40a5d4 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,714 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ format = &pg_markdown;
+ else if (cont->opt->format == PRINT_RST)
+ format = &pg_rst;
+
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 661,668 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
--- 748,759 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
***************
*** 685,692 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
--- 776,787 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
***************
*** 846,853 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
--- 941,952 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
***************
*** 885,892 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
int width,
height;
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
--- 984,995 ----
int width,
height;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
! else
! pg_wcssize_newline((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
***************
*** 907,915 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
--- 1010,1023 ----
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
! else
! pg_wcsformat_newline((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
***************
*** 963,968 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 1071,1079 ----
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_MIDDLE, format, fout);
}
+ else if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_TOP, format, fout);
}
/* print cells, one loop per row */
***************
*** 974,985 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
break;
/*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
--- 1085,1108 ----
break;
/*
+ * line after first row for markdown with only tuples option
+ */
+ if(opt_tuples_only && format == &pg_markdown && i == col_count)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_MIDDLE, format, fout);
+
+
+ /*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
! else
! pg_wcsformat_newline((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1175,1186 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1249,1282 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1332,1341 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
+ else if (format == &pg_markdown)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1401,1414 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ format = &pg_markdown;
+ else if (cont->opt->format == PRINT_RST)
+ format = &pg_rst;
+
+ if (format == &pg_rst || format == &pg_markdown) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1293,1300 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
if (width > hwidth)
hwidth = width;
if (height > hheight)
--- 1445,1457 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
!
if (width > hwidth)
hwidth = width;
if (height > hheight)
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1462,1474 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
+
+ /* if hwidth < reclen fromheader */
+ if (format == &pg_markdown && !opt_tuples_only)
+ if (hwidth < floor (log10 (abs (cont->nrows))) + 12)
+ hwidth = floor (log10 (abs (cont->nrows))) + 12;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1313,1320 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
if (width > dwidth)
dwidth = width;
if (height > dheight)
--- 1477,1489 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
!
if (width > dwidth)
dwidth = width;
if (height > dheight)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1672,1678 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1538 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
/*
* Loop through header and data in parallel dealing with newlines and
--- 1687,1745 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && (format != &pg_rst && format != &pg_markdown))
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (!opt_tuples_only && format == &pg_rst)
! {
! if (i ==0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! print_aligned_vertical_line(format, opt_border, record++,
! 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! }
! else if (!opt_tuples_only && format == &pg_markdown)
! {
! print_aligned_vertical_line(format, opt_border, record++,
! lhwidth, dwidth, PRINT_RULE_DATA, fout);
! if (i == 0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, PRINT_RULE_MIDDLE, fout);
! }
! else if ((i != 0 || !cont->opt->start_table || opt_border == 2) && format != &pg_markdown)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
+ else if (i != 0 && format == &pg_markdown)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, PRINT_RULE_DATA, fout);
}
! if (i == 1 && format == &pg_markdown && opt_tuples_only)
! print_aligned_vertical_line(format, opt_border, 0, hwidth,
! dwidth, pos, fout);
!
! if (format != &pg_markdown)
! {
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
! else
! {
! /* Format the header */
! pg_wcsformat_newline((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
/*
* Loop through header and data in parallel dealing with newlines and
***************
*** 1565,1577 **** print_aligned_vertical(const printTableContent *cont,
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
*/
! swidth -= target_width;
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
--- 1772,1791 ----
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
*/
! if (format == &pg_rst)
! swidth -= target_width + 4;
! else
! swidth -= target_width;
!
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1854,1865 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1922,1935 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3483,3501 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
diff --git a/src/include/feindex 56626f631b..70684155b5 100644
*** a/src/include/fe_utils/mbprint.h
--- b/src/include/fe_utils/mbprint.h
***************
*** 25,29 **** extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 25,33 ----
struct lineptr * lines, int count);
extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
int *width, int *height, int *format_size);
+ extern void pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count);
+ extern void pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *width, int *height, int *format_size);
#endif /* MBPRINT_H */
diff --git a/src/include/fe_utils/priindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex 8aa914fa95..bd7cb36385 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2932,2934 **** NOTICE: foo
--- 2932,3048 ----
CONTEXT: PL/pgSQL function inline_code_block line 3 at RAISE
ERROR: bar
CONTEXT: PL/pgSQL function inline_code_block line 4 at RAISE
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |-------------------------------------------------------------------------------------------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo,</br>squirrel, gorilla | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | goat, rhinoceros,</br>monkey, ape | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ (3 rows)
+
+ \x
+ \pset format rst
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ \pset format markdown
+ execute q;
+ | **RECORD 1** | |
+ |--------------|-------------------------------------------------------------------------------------------------------------|
+ | column1 | Elephant, kangaroo,</br>squirrel, gorilla |
+ | column2 | 121 |
+ | column3 | 1.0035971223021583 |
+ | column4 | 0.1111 |
+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | **RECORD 2** | |
+ | column1 | goat, rhinoceros,</br>monkey, ape |
+ | column2 | 11121 |
+ | column3 | 1.0007824726134585 |
+ | column4 | 5.1111 |
+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | **RECORD 3** | |
+ | column1 | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat |
+ | column2 | 14351 |
+ | column3 | 50.3877551020408163 |
+ | column4 | 345.11 |
+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex 0ae4dd84ea..0ca94d2fa6 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 548,550 **** begin
--- 548,569 ----
raise notice 'foo';
raise exception 'bar';
end $$;
+
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \x
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ deallocate q;
Hi,
On 2017-04-02 22:28:40 +0200, Jan Mich�lek wrote:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The new status of this patch is: Waiting on Author
Corrected problem with \pset linestyle when format is set to markdown, or
rst.Corrected tuples only for markdown and rst (normal and expanded)
This patch still is undergoing development and review, and the code
freeze is closing in rapidly. As this patch has been submitted just
before the last commitfest in the v10 cycle and has received plenty
feedback, I think it's fair to move this to the next commitfest.
Regards,
Andres
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-04-06 0:55 GMT+02:00 Andres Freund <andres@anarazel.de>:
Hi,
On 2017-04-02 22:28:40 +0200, Jan Michálek wrote:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The new status of this patch is: Waiting on Author
Corrected problem with \pset linestyle when format is set to markdown, or
rst.Corrected tuples only for markdown and rst (normal and expanded)
This patch still is undergoing development and review, and the code
freeze is closing in rapidly. As this patch has been submitted just
before the last commitfest in the v10 cycle and has received plenty
feedback, I think it's fair to move this to the next commitfest.Regards,
Andres
There is only few last things to complete (align by |:- in markdown and
pset title, and few words about pabdoc pipe tables in documentation).
I hope, I`m able to do this on sunday, or monday.
Jan
--
Jelen
Starší čeledín datovýho chlíva
On April 5, 2017 11:19:04 PM PDT, "Jan Michálek" <godzilalalala@gmail.com> wrote:
2017-04-06 0:55 GMT+02:00 Andres Freund <andres@anarazel.de>:
Hi,
On 2017-04-02 22:28:40 +0200, Jan Michálek wrote:
2017-03-23 17:26 GMT+01:00 Pierre Ducroquet <p.psql@pinaraf.info>:
The new status of this patch is: Waiting on Author
Corrected problem with \pset linestyle when format is set to
markdown, or
rst.
Corrected tuples only for markdown and rst (normal and expanded)
This patch still is undergoing development and review, and the code
freeze is closing in rapidly. As this patch has been submitted just
before the last commitfest in the v10 cycle and has received plenty
feedback, I think it's fair to move this to the next commitfest.Regards,
Andres
There is only few last things to complete (align by |:- in markdown and
pset title, and few words about pabdoc pipe tables in documentation).
I hope, I`m able to do this on sunday, or monday.
Code freeze is on Friday. As this patch is still in active development, I don't think it's realistic to get this into v10.
Andres
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Hello Jan,
Corrected problem with \pset linestyle when format is set to markdown, or
rst.Corrected tuples only for markdown and rst (normal and expanded)
It seems that the patch does not apply anymore on head due to changes in
psql non regression tests. Could you rebase?
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-04-18 2:27 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
Hello Jan,
Corrected problem with \pset linestyle when format is set to markdown, or
rst.
Corrected tuples only for markdown and rst (normal and expanded)
It seems that the patch does not apply anymore on head due to changes in
psql non regression tests. Could you rebase?
Hi
This patch willl not be in 10, because i haven`t it already completed on
commit freeze.
Should I update it to current master? Im afraid, that some changes will be
in conflict with this.
Je;
--
Fabien.
--
Jelen
Starší čeledín datovýho chlíva
2017-04-18 2:27 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
Hello Jan,
Corrected problem with \pset linestyle when format is set to markdown, or
rst.
Corrected tuples only for markdown and rst (normal and expanded)
It seems that the patch does not apply anymore on head due to changes in
psql non regression tests. Could you rebase?
This should work on current master (all test passed).
Je;
--
Fabien.
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 3b86612862..97d8612359 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2536,2542 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2536,2543 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2564,2570 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2565,2572 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 859ded71f6..5bca425d22 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 3693,3698 **** _align2string(enum printFormat in)
--- 3693,3704 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 3764,3772 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 3770,3782 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ac435220e6..13f2e44add 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 382,388 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 382,388 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index e2a3351210..96b0067919 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3444,3450 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3444,3450 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/mbprint.index d186fc4c91..a2b030e2f7 100644
*** a/src/fe_utils/mbprint.c
--- b/src/fe_utils/mbprint.c
***************
*** 285,290 **** pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
--- 285,368 ----
}
/*
+ * version of pg_wcssize for markdown
+ * replace newline with </br>
+ */
+ void
+ pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *result_width, int *result_height, int *result_format_size)
+ {
+ int w,
+ chlen = 0,
+ linewidth = 0;
+ int width = 0;
+ int height = 1;
+ int format_size = 0;
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ linewidth += 5;
+ format_size += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ linewidth++;
+ format_size++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ format_size += 1;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ linewidth += 6; /* \u0000 */
+ format_size += 6;
+ }
+ else /* All other chars */
+ {
+ linewidth += w;
+ format_size += chlen;
+ }
+ len -= chlen;
+ }
+ if (linewidth > width)
+ width = linewidth;
+ format_size += 1; /* For NUL char */
+
+ /* Set results */
+ if (result_width)
+ *result_width = width;
+ if (result_height)
+ *result_height = height;
+ if (result_format_size)
+ *result_format_size = format_size;
+ }
+
+ /*
* Format a string into one or more "struct lineptr" lines.
* lines[i].ptr == NULL indicates the end of the array.
*
***************
*** 382,387 **** pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 460,555 ----
(lines + 1)->ptr = NULL; /* terminate line array */
}
+ /*
+ * version of pg_wcsformat for markdown
+ * replace newline with </br>
+ */
+
+ void
+ pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count)
+ {
+ int w,
+ chlen = 0;
+ int linewidth = 0;
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ strcpy((char *) ptr, "</br>");
+ linewidth += 5;
+ ptr += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ strcpy((char *) ptr, "\\r");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ *ptr++ = ' ';
+ linewidth++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (w < 0) /* Other control char */
+ {
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
+ linewidth += 4;
+ ptr += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ *ptr++ = *pwcs;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ if (encoding == PG_UTF8)
+ sprintf((char *) ptr, "\\u%04X", utf8_to_unicode(pwcs));
+ else
+ {
+ /*
+ * This case cannot happen in the current code because only
+ * UTF-8 signals multibyte control characters. But we may need
+ * to support it at some stage
+ */
+ sprintf((char *) ptr, "\\u????");
+ }
+ ptr += 6;
+ linewidth += 6;
+ }
+ else /* All other chars */
+ {
+ int i;
+
+ for (i = 0; i < chlen; i++)
+ *ptr++ = pwcs[i];
+ linewidth += w;
+ }
+ len -= chlen;
+ }
+ lines->width = linewidth;
+ *ptr++ = '\0'; /* Terminate formatted string */
+
+ if (count <= 0)
+ exit(1); /* Screwup */
+
+ (lines + 1)->ptr = NULL; /* terminate line array */
+ }
+
/*
* Encoding validation: delete any unvalidatable characters from the string
diff --git a/src/fe_utils/priindex 9180b90004..526a40a5d4 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,714 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ format = &pg_markdown;
+ else if (cont->opt->format == PRINT_RST)
+ format = &pg_rst;
+
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 661,668 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
--- 748,759 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
***************
*** 685,692 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
--- 776,787 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
***************
*** 846,853 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
--- 941,952 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
***************
*** 885,892 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
int width,
height;
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
--- 984,995 ----
int width,
height;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
! else
! pg_wcssize_newline((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
***************
*** 907,915 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
--- 1010,1023 ----
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
! else
! pg_wcsformat_newline((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
***************
*** 963,968 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 1071,1079 ----
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_MIDDLE, format, fout);
}
+ else if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_TOP, format, fout);
}
/* print cells, one loop per row */
***************
*** 974,985 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
break;
/*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
--- 1085,1108 ----
break;
/*
+ * line after first row for markdown with only tuples option
+ */
+ if(opt_tuples_only && format == &pg_markdown && i == col_count)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_MIDDLE, format, fout);
+
+
+ /*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
! else
! pg_wcsformat_newline((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1175,1186 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1249,1282 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1332,1341 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
+ else if (format == &pg_markdown)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1401,1414 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ format = &pg_markdown;
+ else if (cont->opt->format == PRINT_RST)
+ format = &pg_rst;
+
+ if (format == &pg_rst || format == &pg_markdown) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1293,1300 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
if (width > hwidth)
hwidth = width;
if (height > hheight)
--- 1445,1457 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
!
if (width > hwidth)
hwidth = width;
if (height > hheight)
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1462,1474 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
+
+ /* if hwidth < reclen fromheader */
+ if (format == &pg_markdown && !opt_tuples_only)
+ if (hwidth < floor (log10 (abs (cont->nrows))) + 12)
+ hwidth = floor (log10 (abs (cont->nrows))) + 12;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1313,1320 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
if (width > dwidth)
dwidth = width;
if (height > dheight)
--- 1477,1489 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
!
if (width > dwidth)
dwidth = width;
if (height > dheight)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1672,1678 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1538 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
/*
* Loop through header and data in parallel dealing with newlines and
--- 1687,1745 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && (format != &pg_rst && format != &pg_markdown))
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (!opt_tuples_only && format == &pg_rst)
! {
! if (i ==0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! print_aligned_vertical_line(format, opt_border, record++,
! 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! }
! else if (!opt_tuples_only && format == &pg_markdown)
! {
! print_aligned_vertical_line(format, opt_border, record++,
! lhwidth, dwidth, PRINT_RULE_DATA, fout);
! if (i == 0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, PRINT_RULE_MIDDLE, fout);
! }
! else if ((i != 0 || !cont->opt->start_table || opt_border == 2) && format != &pg_markdown)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
+ else if (i != 0 && format == &pg_markdown)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, PRINT_RULE_DATA, fout);
}
! if (i == 1 && format == &pg_markdown && opt_tuples_only)
! print_aligned_vertical_line(format, opt_border, 0, hwidth,
! dwidth, pos, fout);
!
! if (format != &pg_markdown)
! {
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
! else
! {
! /* Format the header */
! pg_wcsformat_newline((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
/*
* Loop through header and data in parallel dealing with newlines and
***************
*** 1565,1577 **** print_aligned_vertical(const printTableContent *cont,
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
*/
! swidth -= target_width;
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
--- 1772,1791 ----
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
*/
! if (format == &pg_rst)
! swidth -= target_width + 4;
! else
! swidth -= target_width;
!
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1854,1865 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1922,1935 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3483,3501 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
diff --git a/src/include/feindex 56626f631b..70684155b5 100644
*** a/src/include/fe_utils/mbprint.h
--- b/src/include/fe_utils/mbprint.h
***************
*** 25,29 **** extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 25,33 ----
struct lineptr * lines, int count);
extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
int *width, int *height, int *format_size);
+ extern void pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count);
+ extern void pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *width, int *height, int *format_size);
#endif /* MBPRINT_H */
diff --git a/src/include/fe_utils/priindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex d602aeef42..c242abc4a3 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2964,2966 **** SELECT 3
--- 2964,3080 ----
UNION SELECT 4
UNION SELECT 5
ORDER BY 1;
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |-------------------------------------------------------------------------------------------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo,</br>squirrel, gorilla | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | goat, rhinoceros,</br>monkey, ape | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ (3 rows)
+
+ \x
+ \pset format rst
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ \pset format markdown
+ execute q;
+ | **RECORD 1** | |
+ |--------------|-------------------------------------------------------------------------------------------------------------|
+ | column1 | Elephant, kangaroo,</br>squirrel, gorilla |
+ | column2 | 121 |
+ | column3 | 1.0035971223021583 |
+ | column4 | 0.1111 |
+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | **RECORD 2** | |
+ | column1 | goat, rhinoceros,</br>monkey, ape |
+ | column2 | 11121 |
+ | column3 | 1.0007824726134585 |
+ | column4 | 5.1111 |
+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | **RECORD 3** | |
+ | column1 | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat |
+ | column2 | 14351 |
+ | column3 | 50.3877551020408163 |
+ | column4 | 345.11 |
+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex b56a05f7f0..fa32a60a28 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 560,562 **** UNION SELECT 5
--- 560,580 ----
ORDER BY 1;
\r
\p
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \x
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ deallocate q;
Hello Jan,
It seems that the patch does not apply anymore on head due to changes in
psql non regression tests. Could you rebase?This should work on current master (all test passed).
Patch applies, compiles and make check is ok.
There are different flavour of markdown, maybe you should document which
one is targetted. Should it be CommonMark? Another variant? Why?
ISTM that the md format lacks escaping for special md characters:
fabien=# SELECT E'\\n\n</br>' AS foo;
│ foo │
|--------------|
│ \n</br></br>
I'd say that you need to do escaping more or less similar to html?
Also, it seems that you use distinct vertical bar characters in the
format? Or is this a trick of my terminal?? It seems that your patch
introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
in some places. Maybe you copy-pasted things from the unicode linestyle.
Why are *_newline variants added for length and formatting? Would it be
possible to do without, say by relying on the line count computed by the
standard function for instance?
The help line is too long, I would suggest not to add the new formats,
the list is already truncated with "..." for other formats.
In the sgml documentation, you introduce tab characters, where only spaces
should be used.
pg_markdown contains a spurious space between a comma and a newline.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-04-18 12:06 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
Hello Jan,
It seems that the patch does not apply anymore on head due to changes in
psql non regression tests. Could you rebase?
This should work on current master (all test passed).
Patch applies, compiles and make check is ok.
There are different flavour of markdown, maybe you should document which
one is targetted. Should it be CommonMark? Another variant? Why?
This should be pandoc pipe table. It's because it is similar to aligned
format. I need add this to documentation (i have it in recent TODO)
ISTM that the md format lacks escaping for special md characters:
fabien=# SELECT E'\\n\n</br>' AS foo;
│ foo │
|--------------|
│ \n</br></br>I'd say that you need to do escaping more or less similar to html?
There is problem with markown and newlines. Replacing newline by br was
only solution that I was able to find.
Also, it seems that you use distinct vertical bar characters in the
format? Or is this a trick of my terminal?? It seems that your patch
introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
in some places. Maybe you copy-pasted things from the unicode linestyle.
Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.
Why are *_newline variants added for length and formatting? Would it be
possible to do without, say by relying on the line count computed by the
standard function for instance?
It`s because newlines in markdown, If I need to do it without copy this
function, i had to add parameter for markdown to this functions.
The help line is too long, I would suggest not to add the new formats, the
list is already truncated with "..." for other formats.
OK
In the sgml documentation, you introduce tab characters, where only spaces
should be used.
OK, I modified vimrc as it is in documentation, maybe i do something wrong.
I will correct this.
pg_markdown obsahuje falešný prostor mezi čárkou a nový řádek.
I will look on this.
--
Fabien.
--
Jelen
Starší čeledín datovýho chlíva
Hello,
There are different flavour of markdown, maybe you should document which
one is targetted. Should it be CommonMark? Another variant? Why?This should be pandoc pipe table. It's because it is similar to aligned
format. I need add this to documentation (i have it in recent TODO)
I still do not understand "why" this variant vs CommonMark or whatever
other version.
ISTM that the md format lacks escaping for special md characters [...]
I'd say that you need to do escaping more or less similar to html?There is problem with markown and newlines. Replacing newline by br was
only solution that I was able to find.
Fine. That does not answer the question about escaping other special md
characters.
Also, it seems that you use distinct vertical bar characters in the
format? Or is this a trick of my terminal?? It seems that your patch
introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
in some places. Maybe you copy-pasted things from the unicode linestyle.Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.
Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
point.
Why are *_newline variants added for length and formatting? Would it be
possible to do without, say by relying on the line count computed by the
standard function for instance?It`s because newlines in markdown, If I need to do it without copy this
function, i had to add parameter for markdown to this functions.
Then maybe it is an option to consider to avoid duplicating code.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-04-18 23:06 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
Hello,
There are different flavour of markdown, maybe you should document which
one is targetted. Should it be CommonMark? Another variant? Why?
This should be pandoc pipe table. It's because it is similar to aligned
format. I need add this to documentation (i have it in recent TODO)I still do not understand "why" this variant vs CommonMark or whatever
other version.
Because of simply implementation and readability (looks similar to aligned
format) and it is comfortable to edit generated table (changing values,
aligning columns etc.).
ISTM that the md format lacks escaping for special md characters [...] I'd
say that you need to do escaping more or less similar to html?
There is problem with markown and newlines. Replacing newline by br was
only solution that I was able to find.Fine. That does not answer the question about escaping other special md
characters.
Sorry, maybe I`m not understanding, there is problems with characters like
pipe in cells, pipe should be escaped. What other special markdown
characters? Escaping html code in cells?
Also, it seems that you use distinct vertical bar characters in the
format? Or is this a trick of my terminal?? It seems that your patch
introduces U+2502 (BOX DRAWINGS LIGHT VERTICAL) instead of the usual pipe
in some places. Maybe you copy-pasted things from the unicode linestyle.Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
point.
Could you send me example where?
Why are *_newline variants added for length and formatting? Would it be
possible to do without, say by relying on the line count computed by the
standard function for instance?It`s because newlines in markdown, If I need to do it without copy this
function, i had to add parameter for markdown to this functions.Then maybe it is an option to consider to avoid duplicating code.
--
Fabien.
--
Jelen
Starší čeledín datovýho chlíva
I still do not understand "why" this variant vs CommonMark or whatever
other version.Because of simply implementation and readability (looks similar to aligned
format) and it is comfortable to edit generated table (changing values,
aligning columns etc.).
Hmmm. Why not.
Sorry, maybe I`m not understanding, there is problems with characters like
pipe in cells, pipe should be escaped. What other special markdown
characters? Escaping html code in cells?
Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.
Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
point.Could you send me example where?
I already did in the first mail with the example output copy pasted from
psql. Some characters are pipe and others are BOX DRAWINGS LIGHT VERTICAL
characters.
Maybe this is because I have in my ~/.psqlrc:
\pset linestyle unicode
\pset border 2
in which case your reuse of the the aligned stuff should take care of the
border setting to avoid using special UTF8 characters..
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
2017-04-19 9:18 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
I still do not understand "why" this variant vs CommonMark or whatever
other version.
Because of simply implementation and readability (looks similar to aligned
format) and it is comfortable to edit generated table (changing values,
aligning columns etc.).Hmmm. Why not.
Sorry, maybe I`m not understanding, there is problems with characters like
pipe in cells, pipe should be escaped. What other special markdown
characters? Escaping html code in cells?Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.
I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.
My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.
Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than standart
pipe, it shouldn`t work.Sure. ISTM that you are currently using U+2502 instead of pipe, hence my
point.
Could you send me example where?
I already did in the first mail with the example output copy pasted from
psql. Some characters are pipe and others are BOX DRAWINGS LIGHT VERTICAL
characters.Maybe this is because I have in my ~/.psqlrc:
\pset linestyle unicode
\pset border 2in which case your reuse of the the aligned stuff should take care of the
border setting to avoid using special UTF8 characters..
Yes, it looks it is done by linestyle.
jelen=# SELECT 1;
| ?column? |
|----------|
| 1 |
(1 row)
jelen=# \pset linestyle unicode
Line style is unicode.
jelen=# SELECT 1;
│ ?column? │
|----------|
│ 1 │
(1 row)
jelen=#
I have prepared linestyle for rst and md, but I can`t switch linestyle
outside, because if i did it
\pset linestyle
wrote "markdown" or "rst".
I see, problem is only in cells borders, I will correct this.
Jan
--
Fabien.
--
Jelen
Starší čeledín datovýho chlíva
2017-04-19 10:05 GMT+02:00 Jan Michálek <godzilalalala@gmail.com>:
2017-04-19 9:18 GMT+02:00 Fabien COELHO <coelho@cri.ensmp.fr>:
I still do not understand "why" this variant vs CommonMark or whatever
other version.
Because of simply implementation and readability (looks similar to
aligned
format) and it is comfortable to edit generated table (changing values,
aligning columns etc.).Hmmm. Why not.
Sorry, maybe I`m not understanding, there is problems with characters like
pipe in cells, pipe should be escaped. What other special markdown
characters? Escaping html code in cells?Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.
I have treated "_*|<>"
jelen=# SELECT E'**1**</br>\nrrr';
| **RECORD 1** | |
|--------------|------------------------------|
| ?column? | \*\*1\*\*</br></br>rrr |
jelen=#
I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.Main of the functionality is used from aligned format. I tested returned
tables in retext and it works. If i have another character than
standart
pipe, it shouldn`t work.Sure. ISTM that you are currently using U+2502 instead of pipe, hence
my
point.Could you send me example where?
I already did in the first mail with the example output copy pasted from
psql. Some characters are pipe and others are BOX DRAWINGS LIGHT VERTICAL
characters.Maybe this is because I have in my ~/.psqlrc:
\pset linestyle unicode
\pset border 2in which case your reuse of the the aligned stuff should take care of the
border setting to avoid using special UTF8 characters..
I corrected it.
jelen=# \pset linestyle unicode
Line style is unicode.
jelen=# SELECT 1,2,3,4;
| **RECORD 1** | |
|--------------|---|
| ?column? | 1 |
| ?column? | 2 |
| ?column? | 3 |
| ?column? | 4 |
jelen=#
Regards
Jan
Yes, it looks it is done by linestyle.
jelen=# SELECT 1;
| ?column? |
|----------|
| 1 |(1 row)
jelen=# \pset linestyle unicode
Line style is unicode.
jelen=# SELECT 1;│ ?column? │
|----------|
│ 1 │(1 row)
jelen=#
I have prepared linestyle for rst and md, but I can`t switch linestyle
outside, because if i did it
\pset linestyle
wrote "markdown" or "rst".
I see, problem is only in cells borders, I will correct this.Jan
--
Fabien.--
Jelen
Starší čeledín datovýho chlíva
--
Jelen
Starší čeledín datovýho chlíva
Attachments:
psql-markdown-rst.patchtext/x-patch; charset=US-ASCII; name=psql-markdown-rst.patchDownload
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 3b86612862..97d8612359 100644
*** a/doc/src/sgml/ref/psql-ref.sgml
--- b/doc/src/sgml/ref/psql-ref.sgml
***************
*** 2536,2542 **** lo_import 152801
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
--- 2536,2543 ----
<literal>aligned</literal>, <literal>wrapped</literal>,
<literal>html</literal>, <literal>asciidoc</literal>,
<literal>latex</literal> (uses <literal>tabular</literal>),
! <literal>latex-longtable</literal>,
! <literal>rst</literal>, <literal>markdown</literal>, or
<literal>troff-ms</literal>.
Unique abbreviations are allowed. (That would mean one letter
is enough.)
***************
*** 2564,2570 **** lo_import 152801
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, and <literal>troff-ms</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
--- 2565,2572 ----
<para>
The <literal>html</>, <literal>asciidoc</>, <literal>latex</>,
! <literal>latex-longtable</literal>, <literal>troff-ms</>,
! <literal>markdown</> and <literal>rst</>
formats put out tables that are intended to
be included in documents using the respective mark-up
language. They are not complete documents! This might not be
diff --git a/src/bin/psql/command.c bindex 859ded71f6..5bca425d22 100644
*** a/src/bin/psql/command.c
--- b/src/bin/psql/command.c
***************
*** 3693,3698 **** _align2string(enum printFormat in)
--- 3693,3704 ----
case PRINT_TROFF_MS:
return "troff-ms";
break;
+ case PRINT_MARKDOWN:
+ return "markdown";
+ break;
+ case PRINT_RST:
+ return "rst";
+ break;
}
return "unknown";
}
***************
*** 3764,3772 **** do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms\n");
return false;
}
}
--- 3770,3782 ----
popt->topt.format = PRINT_LATEX_LONGTABLE;
else if (pg_strncasecmp("troff-ms", value, vallen) == 0)
popt->topt.format = PRINT_TROFF_MS;
+ else if (pg_strncasecmp("markdown", value, vallen) == 0)
+ popt->topt.format = PRINT_MARKDOWN;
+ else if (pg_strncasecmp("rst", value, vallen) == 0)
+ popt->topt.format = PRINT_RST;
else
{
! psql_error("\\pset: allowed formats are unaligned, aligned, wrapped, html, asciidoc, latex, latex-longtable, troff-ms, markdown, rst\n");
return false;
}
}
diff --git a/src/bin/psql/helindex ac435220e6..13f2e44add 100644
*** a/src/bin/psql/help.c
--- b/src/bin/psql/help.c
***************
*** 382,388 **** helpVariables(unsigned short int pager)
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
--- 382,388 ----
fprintf(output, _(" fieldsep field separator for unaligned output (default \"%s\")\n"), DEFAULT_FIELD_SEP);
fprintf(output, _(" fieldsep_zero set field separator for unaligned output to zero byte\n"));
fprintf(output, _(" footer enable or disable display of the table footer [on, off]\n"));
! fprintf(output, _(" format set output format [unaligned, aligned, wrapped, html, asciidoc, rst, markdown ...]\n"));
fprintf(output, _(" linestyle set the border line drawing style [ascii, old-ascii, unicode]\n"));
fprintf(output, _(" null set the string to be printed in place of a null value\n"));
fprintf(output, _(" numericlocale enable or disable display of a locale-specific character to separate\n"
diff --git a/src/bin/psql/index e2a3351210..96b0067919 100644
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
***************
*** 3444,3450 **** psql_completion(const char *text, int start, int end)
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
--- 3444,3450 ----
{
static const char *const my_list[] =
{"unaligned", "aligned", "wrapped", "html", "asciidoc",
! "latex", "latex-longtable", "troff-ms", "markdown", "rst", NULL};
COMPLETE_WITH_LIST_CS(my_list);
}
diff --git a/src/fe_utils/mbprint.index d186fc4c91..6736839283 100644
*** a/src/fe_utils/mbprint.c
--- b/src/fe_utils/mbprint.c
***************
*** 285,290 **** pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
--- 285,393 ----
}
/*
+ * version of pg_wcssize for markdown
+ * replace newline with </br>
+ */
+ void
+ pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *result_width, int *result_height, int *result_format_size)
+ {
+ int w,
+ chlen = 0,
+ linewidth = 0;
+ int width = 0;
+ int height = 1;
+ int format_size = 0;
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ linewidth += 5;
+ format_size += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ linewidth++;
+ format_size++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (*pwcs == '|')
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '<')
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else if (*pwcs == '>')
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else if (*pwcs == '*')
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (*pwcs == '_')
+ {
+ linewidth += 2;
+ format_size += 2;
+ }
+ else if (w < 0) /* Other control char */
+ {
+ linewidth += 4;
+ format_size += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ format_size += 1;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ linewidth += 6; /* \u0000 */
+ format_size += 6;
+ }
+ else /* All other chars */
+ {
+ linewidth += w;
+ format_size += chlen;
+ }
+ len -= chlen;
+ }
+ if (linewidth > width)
+ width = linewidth;
+ format_size += 1; /* For NUL char */
+
+ /* Set results */
+ if (result_width)
+ *result_width = width;
+ if (result_height)
+ *result_height = height;
+ if (result_format_size)
+ *result_format_size = format_size;
+ }
+
+ /*
* Format a string into one or more "struct lineptr" lines.
* lines[i].ptr == NULL indicates the end of the array.
*
***************
*** 382,387 **** pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 485,610 ----
(lines + 1)->ptr = NULL; /* terminate line array */
}
+ /*
+ * version of pg_wcsformat for markdown
+ * replace newline with </br>
+ */
+
+ void
+ pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count)
+ {
+ int w,
+ chlen = 0;
+ int linewidth = 0;
+ unsigned char *ptr = lines->ptr; /* Pointer to data area */
+
+ for (; *pwcs && len > 0; pwcs += chlen)
+ {
+ chlen = PQmblen((const char *) pwcs, encoding);
+ if (len < (size_t) chlen)
+ break;
+ w = PQdsplen((const char *) pwcs, encoding);
+
+ if (chlen == 1) /* single-byte char */
+ {
+ if (*pwcs == '\n') /* Newline */
+ {
+ strcpy((char *) ptr, "</br>");
+ linewidth += 5;
+ ptr += 5;
+ }
+ else if (*pwcs == '\r') /* Linefeed */
+ {
+ strcpy((char *) ptr, "\\r");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '\t') /* Tab */
+ {
+ do
+ {
+ *ptr++ = ' ';
+ linewidth++;
+ } while (linewidth % 8 != 0);
+ }
+ else if (*pwcs == '|')
+ {
+ strcpy((char *) ptr, "\\|");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '<')
+ {
+ strcpy((char *) ptr, "<");
+ linewidth += 4;
+ ptr += 4;
+ }
+ else if (*pwcs == '>')
+ {
+ strcpy((char *) ptr, ">");
+ linewidth += 4;
+ ptr += 4;
+ }
+ else if (*pwcs == '*')
+ {
+ strcpy((char *) ptr, "\\*");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (*pwcs == '_')
+ {
+ strcpy((char *) ptr, "\\_");
+ linewidth += 2;
+ ptr += 2;
+ }
+ else if (w < 0) /* Other control char */
+ {
+ sprintf((char *) ptr, "\\x%02X", *pwcs);
+ linewidth += 4;
+ ptr += 4;
+ }
+ else /* Output it as-is */
+ {
+ linewidth += w;
+ *ptr++ = *pwcs;
+ }
+ }
+ else if (w < 0) /* Non-ascii control char */
+ {
+ if (encoding == PG_UTF8)
+ sprintf((char *) ptr, "\\u%04X", utf8_to_unicode(pwcs));
+ else
+ {
+ /*
+ * This case cannot happen in the current code because only
+ * UTF-8 signals multibyte control characters. But we may need
+ * to support it at some stage
+ */
+ sprintf((char *) ptr, "\\u????");
+ }
+ ptr += 6;
+ linewidth += 6;
+ }
+ else /* All other chars */
+ {
+ int i;
+
+ for (i = 0; i < chlen; i++)
+ *ptr++ = pwcs[i];
+ linewidth += w;
+ }
+ len -= chlen;
+ }
+ lines->width = linewidth;
+ *ptr++ = '\0'; /* Terminate formatted string */
+
+ if (count <= 0)
+ exit(1); /* Screwup */
+
+ (lines + 1)->ptr = NULL; /* terminate line array */
+ }
+
/*
* Encoding validation: delete any unvalidatable characters from the string
diff --git a/src/fe_utils/priindex 9180b90004..20d1ce99b1 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
***************
*** 56,61 **** static char default_footer[100];
--- 56,104 ----
static printTableFooter default_footer_cell = {default_footer, NULL};
/* Line style control structures */
+
+ const printTextFormat pg_markdown =
+ {
+ "markdown",
+ {
+ {"", "", "", ""},
+ {"-", "|", "|", "|"},
+ {"", "", "", ""},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
+ const printTextFormat pg_rst =
+ {
+ "rst",
+ {
+ {"-", "+", "+", "+"},
+ {"=", "+", "+", "+"},
+ {"-", "+", "+", "+"},
+ {" ", "|", "|", "|"}
+ },
+ "|",
+ "|",
+ "|",
+ " ",
+ "+",
+ " ",
+ " ",
+ ".",
+ ".",
+ true
+ };
+
const printTextFormat pg_asciiformat =
{
"ascii",
***************
*** 205,210 **** static void IsPagerNeeded(const printTableContent *cont, int extra_lines, bool e
--- 248,255 ----
static void print_aligned_vertical(const printTableContent *cont,
FILE *fout, bool is_pager);
+ static void skip_leading_spaces_print(const char *in, FILE *fout);
+
/* Count number of digits in integral part of number */
static int
***************
*** 574,579 **** _print_horizontal_line(const unsigned int ncolumns, const unsigned int *widths,
--- 619,655 ----
fputc('\n', fout);
}
+ /*
+ * skip leading spaces
+ */
+ static void
+ skip_leading_spaces_print(const char *in, FILE *fout)
+ {
+ const char *p;
+ bool leading_space = true;
+ unsigned int spac; /**leading spaces*/
+ spac = 0;
+
+ for (p = in; *p; p++)
+ {
+ if (*p != ' ' && *p != '\n')
+ {
+ leading_space = false;
+ fputc(*p, fout);
+ }
+ else if (*p == '\n')
+ {
+ fputc(*p, fout);
+ leading_space = true;
+ }
+ else if (leading_space)
+ spac++;
+ else
+ fputc(*p, fout);
+ }
+ if (spac != 0)
+ fprintf(fout, "%*s", spac, " ");
+ }
/*
* Print pretty boxes around cells.
***************
*** 622,627 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 698,721 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ {
+ format = &pg_markdown;
+ dformat = &format->lrule[PRINT_RULE_DATA];
+ }
+
+ else if (cont->opt->format == PRINT_RST)
+ {
+ format = &pg_rst;
+ dformat = &format->lrule[PRINT_RULE_DATA];
+ }
+
+ if (format == &pg_markdown)
+ opt_border = 2;
+
+ if (format == &pg_rst)
+ opt_border = 2;
+
if (cont->ncolumns > 0)
{
col_count = cont->ncolumns;
***************
*** 661,668 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
--- 755,766 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &nl_lines, &bytes_required);
if (width > max_width[i])
max_width[i] = width;
if (nl_lines > max_nl_lines[i])
***************
*** 685,692 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
--- 783,794 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
if (width > max_width[i % col_count])
max_width[i % col_count] = width;
***************
*** 846,853 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
nl_lines,
bytes_required;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
--- 948,959 ----
nl_lines,
bytes_required;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &nl_lines, &bytes_required);
/*
* A row can have both wrapping and newlines that cause it to
***************
*** 885,892 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
int width,
height;
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
--- 991,1002 ----
int width,
height;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
! else
! pg_wcssize_newline((const unsigned char *) cont->title, strlen(cont->title),
! encoding, &width, &height, NULL);
if (width >= width_total)
/* Aligned */
fprintf(fout, "%s\n", cont->title);
***************
*** 907,915 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
--- 1017,1030 ----
PRINT_RULE_TOP, format, fout);
for (i = 0; i < col_count; i++)
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
! else
! pg_wcsformat_newline((const unsigned char *) cont->headers[i],
! strlen(cont->headers[i]), encoding,
! col_lineptrs[i], max_nl_lines[i]);
more_col_wrapping = col_count;
curr_nl_line = 0;
***************
*** 963,968 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
--- 1078,1086 ----
_print_horizontal_line(col_count, width_wrap, opt_border,
PRINT_RULE_MIDDLE, format, fout);
}
+ else if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_TOP, format, fout);
}
/* print cells, one loop per row */
***************
*** 974,985 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
break;
/*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
--- 1092,1115 ----
break;
/*
+ * line after first row for markdown with only tuples option
+ */
+ if(opt_tuples_only && format == &pg_markdown && i == col_count)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_MIDDLE, format, fout);
+
+
+ /*
* Format each cell.
*/
for (j = 0; j < col_count; j++)
{
! if (format != &pg_markdown)
! pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
! else
! pg_wcsformat_newline((const unsigned char *) ptr[j], strlen(ptr[j]), encoding,
! col_lineptrs[j], max_nl_lines[j]);
curr_nl_line[j] = 0;
}
***************
*** 1052,1060 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
else /* Left aligned cell */
{
/* spaces second */
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
}
bytes_output[j] += bytes_to_output;
--- 1182,1193 ----
else /* Left aligned cell */
{
/* spaces second */
! if (format != &pg_rst)
! fputnbytes(fout,
! (char *) (this_line->ptr + bytes_output[j]),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (this_line->ptr + bytes_output[j]), fout);
}
bytes_output[j] += bytes_to_output;
***************
*** 1123,1142 **** print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
fputc('\n', fout);
} while (more_lines);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if (opt_border == 2 && !cancel_pressed)
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
--- 1256,1289 ----
fputc('\n', fout);
} while (more_lines);
+
+ if (format == &pg_rst)
+ _print_horizontal_line(col_count, width_wrap, opt_border,
+ PRINT_RULE_BOTTOM, format, fout);
}
if (cont->opt->stop_table)
{
printTableFooter *footers = footers_with_default(cont);
! if ((opt_border == 2 && format != &pg_rst) && !cancel_pressed)
! /*
! * dont add line after last row, because line is added after every row
! */
_print_horizontal_line(col_count, width_wrap, opt_border,
! PRINT_RULE_BOTTOM, format, fout);
/* print footers */
if (footers && !opt_tuples_only && !cancel_pressed)
{
printTableFooter *f;
+ /*
+ * add newline after table because rst needs empty line after table
+ */
+ if (format == &pg_rst || format == &pg_markdown)
+ {
+ fprintf(fout, "\n");
+ }
for (f = footers; f; f = f->next)
fprintf(fout, "%s\n", f->data);
***************
*** 1192,1197 **** print_aligned_vertical_line(const printTextFormat *format,
--- 1339,1348 ----
{
if (opt_border == 0)
reclen = fprintf(fout, "* Record %lu", record);
+ else if (format == &pg_rst)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
+ else if (format == &pg_markdown)
+ reclen = fprintf(fout, "**RECORD %lu**", record);
else
reclen = fprintf(fout, "[ RECORD %lu ]", record);
}
***************
*** 1257,1262 **** print_aligned_vertical(const printTableContent *cont,
--- 1408,1427 ----
if (opt_border > 2)
opt_border = 2;
+ if (cont->opt->format == PRINT_MARKDOWN)
+ {
+ format = &pg_markdown;
+ dformat = &format->lrule[PRINT_RULE_DATA];
+ }
+ else if (cont->opt->format == PRINT_RST)
+ {
+ format = &pg_rst;
+ dformat = &format->lrule[PRINT_RULE_DATA];
+ }
+
+ if (format == &pg_rst || format == &pg_markdown) /*rst works only with border 2*/
+ opt_border = 2;
+
if (cont->cells[0] == NULL && cont->opt->start_table &&
cont->opt->stop_table)
{
***************
*** 1293,1300 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
if (width > hwidth)
hwidth = width;
if (height > hheight)
--- 1458,1470 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) cont->headers[i], strlen(cont->headers[i]),
! encoding, &width, &height, &fs);
!
if (width > hwidth)
hwidth = width;
if (height > hheight)
***************
*** 1305,1310 **** print_aligned_vertical(const printTableContent *cont,
--- 1475,1487 ----
if (fs > hformatsize)
hformatsize = fs;
}
+ if (format == &pg_rst)
+ hwidth = hwidth + 4;
+
+ /* if hwidth < reclen fromheader */
+ if (format == &pg_markdown && !opt_tuples_only)
+ if (hwidth < floor (log10 (abs (cont->nrows))) + 12)
+ hwidth = floor (log10 (abs (cont->nrows))) + 12;
/* find longest data cell */
for (i = 0, ptr = cont->cells; *ptr; ptr++, i++)
***************
*** 1313,1320 **** print_aligned_vertical(const printTableContent *cont,
height,
fs;
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
if (width > dwidth)
dwidth = width;
if (height > dheight)
--- 1490,1502 ----
height,
fs;
! if (format != &pg_markdown)
! pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
! else
! pg_wcssize_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! &width, &height, &fs);
!
if (width > dwidth)
dwidth = width;
if (height > dheight)
***************
*** 1503,1509 **** print_aligned_vertical(const printTableContent *cont,
if (cancel_pressed)
break;
! if (i == 0)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
--- 1685,1691 ----
if (cancel_pressed)
break;
! if (i == 0 || format == &pg_rst)
pos = PRINT_RULE_TOP;
else
pos = PRINT_RULE_MIDDLE;
***************
*** 1518,1538 **** print_aligned_vertical(const printTableContent *cont,
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only)
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (i != 0 || !cont->opt->start_table || opt_border == 2)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
}
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
/*
* Loop through header and data in parallel dealing with newlines and
--- 1700,1758 ----
(format == &pg_asciiformat_old))
lhwidth++; /* for newline indicators */
! if (!opt_tuples_only && (format != &pg_rst && format != &pg_markdown))
print_aligned_vertical_line(format, opt_border, record++,
lhwidth, dwidth, pos, fout);
! else if (!opt_tuples_only && format == &pg_rst)
! {
! if (i ==0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! print_aligned_vertical_line(format, opt_border, record++,
! 0, lhwidth + dwidth, PRINT_RULE_DATA, fout); /* because need of only one column*/
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, pos, fout);
! }
! else if (!opt_tuples_only && format == &pg_markdown)
! {
! print_aligned_vertical_line(format, opt_border, record++,
! lhwidth, dwidth, PRINT_RULE_DATA, fout);
! if (i == 0)
! print_aligned_vertical_line(format, opt_border, 0, lhwidth,
! dwidth, PRINT_RULE_MIDDLE, fout);
! }
! else if ((i != 0 || !cont->opt->start_table || opt_border == 2) && format != &pg_markdown)
print_aligned_vertical_line(format, opt_border, 0, lhwidth,
dwidth, pos, fout);
+ else if (i != 0 && format == &pg_markdown)
+ print_aligned_vertical_line(format, opt_border, 0, lhwidth,
+ dwidth, PRINT_RULE_DATA, fout);
}
! if (i == 1 && format == &pg_markdown && opt_tuples_only)
! print_aligned_vertical_line(format, opt_border, 0, hwidth,
! dwidth, pos, fout);
!
! if (format != &pg_markdown)
! {
! /* Format the header */
! pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
! else
! {
! /* Format the header */
! pg_wcsformat_newline((const unsigned char *) cont->headers[i % cont->ncolumns],
! strlen(cont->headers[i % cont->ncolumns]),
! encoding, hlineptr, hheight);
! /* Format the data */
! pg_wcsformat_newline((const unsigned char *) *ptr, strlen(*ptr), encoding,
! dlineptr, dheight);
! }
/*
* Loop through header and data in parallel dealing with newlines and
***************
*** 1565,1577 **** print_aligned_vertical(const printTableContent *cont,
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! fprintf(fout, "%-s", hlineptr[hline].ptr);
/*
* Spacer
*/
! swidth -= target_width;
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
--- 1785,1804 ----
* Header text
*/
strlen_max_width(hlineptr[hline].ptr, &target_width,
! encoding);
! if (format != &pg_rst)
! fprintf(fout, "%-s", hlineptr[hline].ptr);
! else
! fprintf(fout, "**%-s**", hlineptr[hline].ptr); /*header bold*/
/*
* Spacer
*/
! if (format == &pg_rst)
! swidth -= target_width + 4;
! else
! swidth -= target_width;
!
if (swidth > 0)
fprintf(fout, "%*s", swidth, " ");
***************
*** 1640,1647 **** print_aligned_vertical(const printTableContent *cont,
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
chars_to_output -= target_width;
offset += bytes_to_output;
--- 1867,1878 ----
*/
bytes_to_output = strlen_max_width(dlineptr[dline].ptr + offset,
&target_width, encoding);
!
! if (format != &pg_rst)
! fputnbytes(fout, (char *) (dlineptr[dline].ptr + offset),
! bytes_to_output);
! else
! skip_leading_spaces_print((char *) (dlineptr[dline].ptr + offset), fout);
chars_to_output -= target_width;
offset += bytes_to_output;
***************
*** 1704,1714 **** print_aligned_vertical(const printTableContent *cont,
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
--- 1935,1948 ----
fprintf(fout, "%*s %s\n", dwidth, "", dformat->rightvrule);
}
}
+ if (opt_border == 2 && format == &pg_rst)
+ print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
+ PRINT_RULE_BOTTOM, fout);
}
if (cont->opt->stop_table)
{
! if (opt_border == 2 && !cancel_pressed && format != &pg_rst)
print_aligned_vertical_line(format, opt_border, 0, hwidth, dwidth,
PRINT_RULE_BOTTOM, fout);
***************
*** 3262,3267 **** printTable(const printTableContent *cont,
--- 3496,3514 ----
else
print_troff_ms_text(cont, fout);
break;
+ case PRINT_RST:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+ case PRINT_MARKDOWN:
+ if (cont->opt->expanded == 1)
+ print_aligned_vertical(cont, fout, false);
+ else
+ print_aligned_text(cont, fout, false);
+ break;
+
default:
fprintf(stderr, _("invalid output format (internal error): %d"),
cont->opt->format);
diff --git a/src/include/feindex 56626f631b..70684155b5 100644
*** a/src/include/fe_utils/mbprint.h
--- b/src/include/fe_utils/mbprint.h
***************
*** 25,29 **** extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
--- 25,33 ----
struct lineptr * lines, int count);
extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding,
int *width, int *height, int *format_size);
+ extern void pg_wcsformat_newline(const unsigned char *pwcs, size_t len, int encoding,
+ struct lineptr * lines, int count);
+ extern void pg_wcssize_newline(const unsigned char *pwcs, size_t len, int encoding,
+ int *width, int *height, int *format_size);
#endif /* MBPRINT_H */
diff --git a/src/include/fe_utils/priindex d89b6febcb..e8b7532bbf 100644
*** a/src/include/fe_utils/print.h
--- b/src/include/fe_utils/print.h
***************
*** 33,39 **** enum printFormat
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS
/* add your favourite output format here ... */
};
--- 33,41 ----
PRINT_ASCIIDOC,
PRINT_LATEX,
PRINT_LATEX_LONGTABLE,
! PRINT_TROFF_MS,
! PRINT_MARKDOWN,
! PRINT_RST
/* add your favourite output format here ... */
};
***************
*** 176,181 **** typedef struct printQueryOpt
--- 178,185 ----
extern volatile bool cancel_pressed;
extern const printTextFormat pg_asciiformat;
+ extern const printTextFormat pg_markdown; /*linestyle markdown*/
+ extern const printTextFormat pg_rst; /*linestyle rst*/
extern const printTextFormat pg_asciiformat_old;
extern printTextFormat pg_utf8format; /* ideally would be const, but... */
diff --git a/src/test/regress/expecindex d602aeef42..c242abc4a3 100644
*** a/src/test/regress/expected/psql.out
--- b/src/test/regress/expected/psql.out
***************
*** 2964,2966 **** SELECT 3
--- 2964,3080 ----
UNION SELECT 4
UNION SELECT 5
ORDER BY 1;
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+ \pset format rst
+ execute q;
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | column1 | column2 | column3 | column4 | column5 |
+ +==========================+=========+=====================+=========+========================================================================+
+ | Elephant, kangaroo, | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | squirrel, gorilla | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | goat, rhinoceros, | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | monkey, ape | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+ | donkey, cow, horse, tit, | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ | eagle, whale, | | | | |
+ | aligator, | | | | |
+ | pelican, | | | | |
+ | grasshoper | | | | |
+ | pig | | | | |
+ | bat | | | | |
+ +--------------------------+---------+---------------------+---------+------------------------------------------------------------------------+
+
+ (3 rows)
+
+ \pset format markdown
+ execute q;
+
+ | column1 | column2 | column3 | column4 | column5 |
+ |-------------------------------------------------------------------------------------------------------------|---------|---------------------|---------|------------------------------------------------------------------------|
+ | Elephant, kangaroo,</br>squirrel, gorilla | 121 | 1.0035971223021583 | 0.1111 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | goat, rhinoceros,</br>monkey, ape | 11121 | 1.0007824726134585 | 5.1111 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat | 14351 | 50.3877551020408163 | 345.11 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ (3 rows)
+
+ \x
+ \pset format rst
+ execute q;
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 1** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | Elephant, kangaroo, |
+ | | squirrel, gorilla |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0035971223021583 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 0.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 2** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | goat, rhinoceros, |
+ | | monkey, ape |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 11121 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 1.0007824726134585 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 5.1111 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ +-------------+------------------------------------------------------------------------+
+ | **RECORD 3** |
+ +-------------+------------------------------------------------------------------------+
+ | **column1** | donkey, cow, horse, tit, |
+ | | eagle, whale, |
+ | | aligator, |
+ | | pelican, |
+ | | grasshoper |
+ | | pig |
+ | | bat |
+ +-------------+------------------------------------------------------------------------+
+ | **column2** | 14351 |
+ +-------------+------------------------------------------------------------------------+
+ | **column3** | 50.3877551020408163 |
+ +-------------+------------------------------------------------------------------------+
+ | **column4** | 345.11 |
+ +-------------+------------------------------------------------------------------------+
+ | **column5** | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+ +-------------+------------------------------------------------------------------------+
+
+ \pset format markdown
+ execute q;
+ | **RECORD 1** | |
+ |--------------|-------------------------------------------------------------------------------------------------------------|
+ | column1 | Elephant, kangaroo,</br>squirrel, gorilla |
+ | column2 | 121 |
+ | column3 | 1.0035971223021583 |
+ | column4 | 0.1111 |
+ | column5 | Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello |
+ | **RECORD 2** | |
+ | column1 | goat, rhinoceros,</br>monkey, ape |
+ | column2 | 11121 |
+ | column3 | 1.0007824726134585 |
+ | column4 | 5.1111 |
+ | column5 | xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx xxxxxx |
+ | **RECORD 3** | |
+ | column1 | donkey, cow, horse, tit,</br>eagle, whale,</br>aligator,</br> pelican,</br>grasshoper</br>pig</br> bat |
+ | column2 | 14351 |
+ | column3 | 50.3877551020408163 |
+ | column4 | 345.11 |
+ | column5 | yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy yyyyyy |
+
+
+ deallocate q;
diff --git a/src/test/regress/sql/psql.sqindex b56a05f7f0..fa32a60a28 100644
*** a/src/test/regress/sql/psql.sql
--- b/src/test/regress/sql/psql.sql
***************
*** 560,562 **** UNION SELECT 5
--- 560,580 ----
ORDER BY 1;
\r
\p
+ prepare q AS VALUES(E'Elephant, kangaroo,\nsquirrel, gorilla', 121,
+ (279./278.)::text, 0.1111, repeat('Hello ', 10))
+ , (E'goat, rhinoceros,\nmonkey, ape', 11121, (1279./1278.)::text, 5.1111,
+ repeat('xxxxxx ', 10))
+ , (E'donkey, cow, horse, tit,\neagle, whale,\naligator,
+ pelican,\ngrasshoper\npig\n\tbat', 14351, (12345./245.)::text, 345.11,
+ repeat('yyyyyy ', 10));
+
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ \x
+ \pset format rst
+ execute q;
+ \pset format markdown
+ execute q;
+ deallocate q;
Hello Jan,
Please give a number to submitted patches. I think that this was v3.
The patch does NOT fix various issues I pointed out in my previous review:
- tabs introduced in "doc/src/sgml/ref/psql-ref.sgml"
- too long help line in "src/bin/psql/help.c"
- spurious space after a comma in "src/fe_utils/print.c"
and possibly elsewhere.
On Sun, 23 Apr 2017, Jan Michálek wrote:
Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.I have treated "_*|<>"
Probably not enough, see below. Note the escaping chars should also be
escaped.
I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.
I do not know whether only those are necessary. Have you checked? Guessing
is probably not the right approach.
Concerning MARKDOWN, and according to the following source about github
markdown implementation:
https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf
The following characters may need to be backslash escaped, although it
does not cover HTML stuff.
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamation
Another source https://genius.com/3057216 suggests (* # / ( ) [ ] < >),
which should protect HTML.
However, the escaping seems to be the backslash character, NOT using html
encoding < as done in your version.
Where did you find the precise escaping rules for markdown? I do not think
that it should be invented...
I have looked at RST, according to this reference:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables
The good news is that you do not need to handle a special | case because
you would only produce clean tables.
I've tested UTF-8 with plane 1 (你好!) and plane 2 (𠀡) and the alignment
seems to worked well, incredible!
My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.
Then maybe only do RST?!
It looks much simpler anyway, and if you do MARKDOWN the support needs to
be clean.
About the code:
I'm still at odds with the code which needs to test for markdown to call
for different functions in multiple places. If you keep md and in order to
avoid that, I would suggest to extend the pg_wcs* functions with a list of
caracters which may have different sizes with additionnal args, say:
pg_wcssize(// same args, plus:
char * escaped_chars, // will require escaping
int escape_len, // how many chars added when escaping
int nllen // len of newline if substituted
);
So that pg_wcssize(..., "\r", 1, 1) would behave as before (\n and \t are
rather special cases), and the various constants could be held in the
format description so the whole thing would be parametric.
Same approach with format.
That would allow to simplify the code significantly and to share it
between MARKDOWN and others. Also, the multiple "else if" list would be
simplified by using strchr or the escaped_chars string.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
<resent, wrong from, sorry for those who may get multiple copies>
Hello Jan,
Please give a number to submitted patches. I think that this was v3.
The patch does NOT fix various issues I pointed out in my previous review:
- tabs introduced in "doc/src/sgml/ref/psql-ref.sgml"
- too long help line in "src/bin/psql/help.c"
- spurious space after a comma in "src/fe_utils/print.c"
and possibly elsewhere.
On Sun, 23 Apr 2017, Jan Michálek wrote:
Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.I have treated "_*|<>"
Probably not enough, see below. Note the escaping chars should also be escaped.
I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.
I do not know whether only those are necessary. Have you checked? Guessing is
probably not the right approach.
Concerning MARKDOWN, and according to the following source about github markdown
implementation:
https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf
The following characters may need to be backslash escaped, although it does not
cover HTML stuff.
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamation
Another source https://genius.com/3057216 suggests (* # / ( ) [ ] < >),
which should protect HTML.
However, the escaping seems to be the backslash character, NOT using html
encoding < as done in your version.
Where did you find the precise escaping rules for markdown? I do not think that
it should be invented...
I have looked at RST, according to this reference:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-
tables
The good news is that you do not need to handle a special | case because you
would only produce clean tables.
I've tested UTF-8 with plane 1 (你好!) and plane 2 (𠀡) and the alignment seems
to worked well, incredible!
My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.
Then maybe only do RST?!
It looks much simpler anyway, and if you do MARKDOWN the support needs to be
clean.
About the code:
I'm still at odds with the code which needs to test for markdown to call for
different functions in multiple places. If you keep md and in order to avoid
that, I would suggest to extend the pg_wcs* functions with a list of caracters
which may have different sizes with additionnal args, say:
pg_wcssize(// same args, plus:
char * escaped_chars, // will require escaping
int escape_len, // how many chars added when escaping
int nllen // len of newline if substituted
);
So that pg_wcssize(..., "\r", 1, 1) would behave as before (\n and \t are rather
special cases), and the various constants could be held in the format
description so the whole thing would be parametric.
Same approach with format.
That would allow to simplify the code significantly and to share it between
MARKDOWN and others. Also, the multiple "else if" list would be simplified by
using strchr or the escaped_chars string.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 08 May 2017, at 12:02, Fabien COELHO <fabien.coelho@mines-paristech.fr> wrote:
Hello Jan,
Please give a number to submitted patches. I think that this was v3.
The patch does NOT fix various issues I pointed out in my previous review:
- tabs introduced in "doc/src/sgml/ref/psql-ref.sgml"
- too long help line in "src/bin/psql/help.c"
- spurious space after a comma in "src/fe_utils/print.c"
and possibly elsewhere.On Sun, 23 Apr 2017, Jan Michálek wrote:
Markdown include characters/sequences which are interpreted as markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probably they
should be escaped somehow.I have treated "_*|<>"
Probably not enough, see below. Note the escaping chars should also be escaped.
I`m able to sanitize characters, but complex sequences will be problem. I
will look on this, but I don`t know, if I`m able to do this.I do not know whether only those are necessary. Have you checked? Guessing is probably not the right approach.
Concerning MARKDOWN, and according to the following source about github markdown implementation:
https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf
The following characters may need to be backslash escaped, although it does not cover HTML stuff.
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamationAnother source https://genius.com/3057216 suggests (* # / ( ) [ ] < >),
which should protect HTML.However, the escaping seems to be the backslash character, NOT using html encoding < as done in your version.
Where did you find the precise escaping rules for markdown? I do not think that it should be invented...
I have looked at RST, according to this reference:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#grid-tables
The good news is that you do not need to handle a special | case because you would only produce clean tables.
I've tested UTF-8 with plane 1 (你好!) and plane 2 (𠀡) and the alignment seems to worked well, incredible!
My main interest on this was in rst. I`m using markdown only in github issues and my knowldge about md is poor.
Then maybe only do RST?!
It looks much simpler anyway, and if you do MARKDOWN the support needs to be clean.
About the code:
I'm still at odds with the code which needs to test for markdown to call for different functions in multiple places. If you keep md and in order to avoid that, I would suggest to extend the pg_wcs* functions with a list of caracters which may have different sizes with additionnal args, say:
pg_wcssize(// same args, plus:
char * escaped_chars, // will require escaping
int escape_len, // how many chars added when escaping
int nllen // len of newline if substituted
);So that pg_wcssize(..., "\r", 1, 1) would behave as before (\n and \t are rather special cases), and the various constants could be held in the format description so the whole thing would be parametric.
Same approach with format.
That would allow to simplify the code significantly and to share it between MARKDOWN and others. Also, the multiple "else if" list would be simplified by using strchr or the escaped_chars string.
This patch was moved into the current Commitfest marked “Waiting for author”
with the above review. Have you had a chance to work on it addressing the
review comments such that we can expect a new version within this CF?
cheers ./daniel
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
I have`t any new version recently, because i was waiting for new version.
But I will have some time on this in next months. How many time I have to
next freeze?
Thanks Je;
2017-09-13 1:14 GMT+02:00 Daniel Gustafsson <daniel@yesql.se>:
On 08 May 2017, at 12:02, Fabien COELHO <fabien.coelho@mines-
paristech.fr> wrote:
Hello Jan,
Please give a number to submitted patches. I think that this was v3.
The patch does NOT fix various issues I pointed out in my previous
review:
- tabs introduced in "doc/src/sgml/ref/psql-ref.sgml"
- too long help line in "src/bin/psql/help.c"
- spurious space after a comma in "src/fe_utils/print.c"
and possibly elsewhere.On Sun, 23 Apr 2017, Jan Michálek wrote:
Markdown include characters/sequences which are interpreted as
markers:
_Italic_, **Bold**, *** => horizontal rules, > block quote... `inline
code`... If they are interpreted within a table cell then probablythey
should be escaped somehow.
I have treated "_*|<>"
Probably not enough, see below. Note the escaping chars should also be
escaped.
I`m able to sanitize characters, but complex sequences will be
problem. I
will look on this, but I don`t know, if I`m able to do this.
I do not know whether only those are necessary. Have you checked?
Guessing is probably not the right approach.
Concerning MARKDOWN, and according to the following source about github
markdown implementation:
https://enterprise.github.com/downloads/en/markdown-cheatsheet.pdf
The following characters may need to be backslash escaped, although it
does not cover HTML stuff.
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamationAnother source https://genius.com/3057216 suggests (* # / ( ) [ ] < >),
which should protect HTML.However, the escaping seems to be the backslash character, NOT using
html encoding < as done in your version.
Where did you find the precise escaping rules for markdown? I do not
think that it should be invented...
I have looked at RST, according to this reference:
restructuredtext.html#grid-tables
The good news is that you do not need to handle a special | case because
you would only produce clean tables.
I've tested UTF-8 with plane 1 (你好!) and plane 2 (𠀡) and the alignment
seems to worked well, incredible!
My main interest on this was in rst. I`m using markdown only in github
issues and my knowldge about md is poor.
Then maybe only do RST?!
It looks much simpler anyway, and if you do MARKDOWN the support needs
to be clean.
About the code:
I'm still at odds with the code which needs to test for markdown to call
for different functions in multiple places. If you keep md and in order to
avoid that, I would suggest to extend the pg_wcs* functions with a list of
caracters which may have different sizes with additionnal args, say:pg_wcssize(// same args, plus:
char * escaped_chars, // will require escaping
int escape_len, // how many chars added when escaping
int nllen // len of newline if substituted
);So that pg_wcssize(..., "\r", 1, 1) would behave as before (\n and \t
are rather special cases), and the various constants could be held in the
format description so the whole thing would be parametric.Same approach with format.
That would allow to simplify the code significantly and to share it
between MARKDOWN and others. Also, the multiple "else if" list would be
simplified by using strchr or the escaped_chars string.This patch was moved into the current Commitfest marked “Waiting for
author”
with the above review. Have you had a chance to work on it addressing the
review comments such that we can expect a new version within this CF?cheers ./daniel
--
Jelen
Starší čeledín datovýho chlíva
On 18 Sep 2017, at 15:31, Jan Michálek <godzilalalala@gmail.com> wrote:
I have`t any new version recently, because i was waiting for new version. But I will have some time on this in next months. How many time I have to next freeze?
The next commitfest runs from 2017-11-01 to 2017-11-30, I will move your patch
there.
cheers ./daniel
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Thanks
2017-09-18 15:33 GMT+02:00 Daniel Gustafsson <daniel@yesql.se>:
On 18 Sep 2017, at 15:31, Jan Michálek <godzilalalala@gmail.com> wrote:
I have`t any new version recently, because i was waiting for new
version. But I will have some time on this in next months. How many time I
have to next freeze?The next commitfest runs from 2017-11-01 to 2017-11-30, I will move your
patch
there.cheers ./daniel
--
Jelen
Starší čeledín datovýho chlíva
On Mon, Sep 18, 2017 at 10:33 PM, Daniel Gustafsson <daniel@yesql.se> wrote:
On 18 Sep 2017, at 15:31, Jan Michálek <godzilalalala@gmail.com> wrote:
I have`t any new version recently, because i was waiting for new version. But I will have some time on this in next months. How many time I have to next freeze?
The next commitfest runs from 2017-11-01 to 2017-11-30, I will move your patch
there.
It's been 1 month and a half since this last status, and no updates
have showed up. I am marking this patch as returned with feedback. If
you are able to reproduce a new version, please make sure to register
it in the commit fest for review.
--
Michael
Sorry, I haven`t any new progres.
Can you move my patch to next (or it is problem)? I have to solve some
personal issues. I want to finish this, but im not able to promise, that it
will be in next months.
Je;
2017-11-28 2:43 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Mon, Sep 18, 2017 at 10:33 PM, Daniel Gustafsson <daniel@yesql.se>
wrote:On 18 Sep 2017, at 15:31, Jan Michálek <godzilalalala@gmail.com> wrote:
I have`t any new version recently, because i was waiting for new
version. But I will have some time on this in next months. How many time I
have to next freeze?The next commitfest runs from 2017-11-01 to 2017-11-30, I will move your
patch
there.
It's been 1 month and a half since this last status, and no updates
have showed up. I am marking this patch as returned with feedback. If
you are able to reproduce a new version, please make sure to register
it in the commit fest for review.
--
Michael
--
Jelen
Starší čeledín datovýho chlíva
On 28 Nov 2017, at 12:01, Jan Michálek <godzilalalala@gmail.com> wrote:
Sorry, I haven`t any new progres.
Can you move my patch to next (or it is problem)? I have to solve some personal issues. I want to finish this, but im not able to promise, that it will be in next months.
No problems, it has been returned with feedback which doesn’t mean “no thanks,
it means “re-register it in the then open commitfest when you have had time to
fix a new version.
When you have had time to hack on it, just add it again and it will be up for
review.
cheers ./daniel
Thanks
My english is little bit poor and my understanding of formal part of commit
process is only partial.
2017-11-28 12:07 GMT+01:00 Daniel Gustafsson <daniel@yesql.se>:
On 28 Nov 2017, at 12:01, Jan Michálek <godzilalalala@gmail.com> wrote:
Sorry, I haven`t any new progres.
Can you move my patch to next (or it is problem)? I have to solve somepersonal issues. I want to finish this, but im not able to promise, that it
will be in next months.No problems, it has been returned with feedback which doesn’t mean “no
thanks,
it means “re-register it in the then open commitfest when you have had
time to
fix a new version.When you have had time to hack on it, just add it again and it will be up
for
review.cheers ./daniel
--
Jelen
Starší čeledín datovýho chlíva
On Tue, Nov 28, 2017 at 9:20 PM, Jan Michálek <godzilalalala@gmail.com> wrote:
Thanks
Please avoid top-posting. This breaks the thread logic.
My english is little bit poor and my understanding of formal part of commit
process is only partial.
Don't worry, we'll all here to learn. If you are able to hack a new
version, please feel free to post a new patch and register a new entry
in the commit fest application.
--
Michael
2017-11-28 13:32 GMT+01:00 Michael Paquier <michael.paquier@gmail.com>:
On Tue, Nov 28, 2017 at 9:20 PM, Jan Michálek <godzilalalala@gmail.com>
wrote:Thanks
Please avoid top-posting. This breaks the thread logic.
Oh, sorry
My english is little bit poor and my understanding of formal part of
commit
process is only partial.
Don't worry, we'll all here to learn. If you are able to hack a new
version, please feel free to post a new patch and register a new entry
in the commit fest application.
--
Michael
--
Jelen
Starší čeledín datovýho chlíva