Index: doc/src/sgml/ref/psql-ref.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v
retrieving revision 1.209
diff -u -p -u -r1.209 psql-ref.sgml
--- doc/src/sgml/ref/psql-ref.sgml	3 Jul 2008 03:37:16 -0000	1.209
+++ doc/src/sgml/ref/psql-ref.sgml	23 Aug 2008 14:00:47 -0000
@@ -1570,7 +1570,7 @@ lo_import 152801
           <acronym>HTML</acronym> mode, this will translate directly
           into the <literal>border=...</literal> attribute, in the
           others only values 0 (no border), 1 (internal dividing lines),
-          and 2 (table frame) make sense.
+          2 (table frame) and 3 (individual cells) make sense.
           </para>
           </listitem>
           </varlistentry>
@@ -2973,6 +2973,22 @@ peter@localhost testdb=&gt; <userinput>S
 +-------+--------+
 (4 rows)
 
+peter@localhost testdb=&gt; <userinput>\pset border 3</userinput>
+Border style is 3.
+peter@localhost testdb=&gt; <userinput>SELECT * FROM my_table;</userinput>
++-------+--------+
+| first | second |
++=======+========+
+|     1 | one    |
++-------+--------+
+|     2 | two    |
++-------+--------+
+|     3 | three  |
++-------+--------+
+|     4 | four   |
++-------+--------+
+(4 rows)
+
 peter@localhost testdb=&gt; <userinput>\pset border 0</userinput>
 Border style is 0.
 peter@localhost testdb=&gt; <userinput>SELECT * FROM my_table;</userinput>
Index: src/bin/psql/print.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.109
diff -u -p -u -r1.109 print.c
--- src/bin/psql/print.c	14 Jul 2008 22:00:04 -0000	1.109
+++ src/bin/psql/print.c	23 Aug 2008 14:00:47 -0000
@@ -364,30 +364,40 @@ _print_horizontal_line(const unsigned in
 {
 	unsigned int i,
 				j;
+	char dash = (border == 0x83) ? '=' : '-';
 
-	if (border == 1)
-		fputc('-', fout);
-	else if (border == 2)
-		fputs("+-", fout);
+	border &= 0x7f;
+
+	if (border >= 2)
+		fputc('+', fout);
+
+	if (border >= 1)
+		fputc(dash, fout);
 
 	for (i = 0; i < ncolumns; i++)
 	{
 		for (j = 0; j < widths[i]; j++)
-			fputc('-', fout);
+			fputc(dash, fout);
 
 		if (i < ncolumns - 1)
 		{
 			if (border == 0)
 				fputc(' ', fout);
 			else
-				fputs("-+-", fout);
+			{
+				fputc(dash, fout);
+				fputc('+', fout);
+				fputc(dash, fout);
+			}
 		}
 	}
 
-	if (border == 2)
-		fputs("-+", fout);
-	else if (border == 1)
-		fputc('-', fout);
+	if (border >= 1)
+		fputc(dash, fout);
+
+	if (border >= 2)
+		fputc('+', fout);
+
 
 	fputc('\n', fout);
 }
@@ -434,8 +444,8 @@ print_aligned_text(const printTableConte
 	if (cancel_pressed)
 		return;
 
-	if (opt_border > 2)
-		opt_border = 2;
+	if (opt_border > 3)
+		opt_border = 3;
 
 	if (cont->ncolumns > 0)
 	{
@@ -707,7 +717,7 @@ print_aligned_text(const printTableConte
 			int			more_col_wrapping;
 			int			curr_nl_line;
 
-			if (opt_border == 2)
+			if (opt_border >= 2)
 				_print_horizontal_line(col_count, width_wrap, opt_border, fout);
 
 			for (i = 0; i < col_count; i++)
@@ -720,7 +730,7 @@ print_aligned_text(const printTableConte
 			memset(header_done, false, col_count * sizeof(bool));
 			while (more_col_wrapping)
 			{
-				if (opt_border == 2)
+				if (opt_border >= 2)
 					fprintf(fout, "|%c", curr_nl_line ? '+' : ' ');
 				else if (opt_border == 1)
 					fputc(curr_nl_line ? '+' : ' ', fout);
@@ -757,14 +767,14 @@ print_aligned_text(const printTableConte
 				}
 				curr_nl_line++;
 
-				if (opt_border == 2)
+				if (opt_border >= 2)
 					fputs(" |", fout);
 				else if (opt_border == 1)
 					fputc(' ', fout);
 				fputc('\n', fout);
 			}
 
-			_print_horizontal_line(col_count, width_wrap, opt_border, fout);
+			_print_horizontal_line(col_count,width_wrap,opt_border|0x80, fout);
 		}
 	}
 
@@ -809,7 +819,7 @@ print_aligned_text(const printTableConte
 			more_lines = false;
 
 			/* left border */
-			if (opt_border == 2)
+			if (opt_border >= 2)
 				fputs("| ", fout);
 			else if (opt_border == 1)
 				fputc(' ', fout);
@@ -821,7 +831,7 @@ print_aligned_text(const printTableConte
 				struct lineptr *this_line = &col_lineptrs[j][curr_nl_line[j]];
 				int		bytes_to_output;
 				int		chars_to_output = width_wrap[j];
-				bool	finalspaces = (opt_border == 2 || j < col_count - 1);
+				bool	finalspaces = (opt_border >= 2 || j < col_count - 1);
 
 				if (!this_line->ptr)
 				{
@@ -897,10 +907,12 @@ print_aligned_text(const printTableConte
 			}
 
 			/* end-of-row border */
-			if (opt_border == 2)
+			if (opt_border >= 2)
 				fputs(" |", fout);
 			fputc('\n', fout);
 
+			if (opt_border == 3)
+				_print_horizontal_line(col_count, width_wrap, opt_border, fout);
 		} while (more_lines);
 	}
 
