Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7292131

Browse files
committed
Enable locale, so case conversion (identifier processing) and number
formatting (\timing) works correctly. Change "Total time" to "Time"since there is nothing that "total" refers to. Remove non-multibytecode.
1 parent7af5ea7 commit7292131

File tree

8 files changed

+18
-140
lines changed

8 files changed

+18
-140
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.73 2002/08/23 01:27:44 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.74 2002/08/27 20:16:48 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1591,7 +1591,7 @@ lo_import 152801
15911591
<term><literal>\timing</literal></term>
15921592
<listitem>
15931593
<para>
1594-
Toggles a display of how long eachquery takes, in milliseconds.
1594+
Toggles a display of how long eachSQL statement takes, in milliseconds.
15951595
</para>
15961596
</listitem>
15971597
</varlistentry>

‎src/bin/psql/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.42 2002/08/10 19:35:00 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.43 2002/08/27 20:16:48 petere Exp $
77
*/
88
#include"postgres_fe.h"
99

@@ -466,7 +466,7 @@ SendQuery(const char *query)
466466

467467
/* Possible microtiming output */
468468
if (pset.timing&&success)
469-
printf(gettext("Total time: %.2fmsec\n"),
469+
printf(gettext("Time: %.2fms\n"),
470470
((after.tv_sec-before.tv_sec)*1000000+after.tv_usec-before.tv_usec) /1000.0);
471471

472472
returnsuccess;

‎src/bin/psql/describe.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000-2002 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.65 2002/08/2718:28:28 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.66 2002/08/2720:16:48 petere Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"describe.h"
@@ -305,11 +305,9 @@ listAllDbs(bool verbose)
305305
"SELECT d.datname as \"%s\",\n"
306306
" u.usename as \"%s\"",
307307
_("Name"),_("Owner"));
308-
#ifdefMULTIBYTE
309308
appendPQExpBuffer(&buf,
310309
",\n pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\"",
311310
_("Encoding"));
312-
#endif
313311
if (verbose)
314312
appendPQExpBuffer(&buf,
315313
",\n pg_catalog.obj_description(d.oid, 'pg_database') as \"%s\"",

‎src/bin/psql/mbprint.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.3 2001/10/28 06:25:58 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/mbprint.c,v 1.4 2002/08/27 20:16:48 petere Exp $
77
*/
88

99
#include"postgres_fe.h"
1010
#include"mbprint.h"
1111

12-
#ifdefMULTIBYTE
13-
1412
#include"mb/pg_wchar.h"
1513
#include"settings.h"
1614

@@ -195,7 +193,7 @@ utf2ucs(const unsigned char *c)
195193
/* mb_utf_wcwidth : calculate column length for the utf8 string pwcs
196194
*/
197195
staticint
198-
mb_utf_wcswidth(unsignedchar*pwcs,intlen)
196+
mb_utf_wcswidth(unsignedchar*pwcs,size_tlen)
199197
{
200198
intw,
201199
l=0;
@@ -312,7 +310,7 @@ mb_utf_validate(unsigned char *pwcs)
312310
*/
313311

314312
int
315-
pg_wcswidth(unsignedchar*pwcs,intlen)
313+
pg_wcswidth(unsignedchar*pwcs,size_tlen)
316314
{
317315
if (pset.encoding==PG_UTF8)
318316
returnmb_utf_wcswidth(pwcs,len);
@@ -340,14 +338,3 @@ mbvalidate(unsigned char *pwcs)
340338
returnpwcs;
341339
}
342340
}
343-
344-
#else/* !MULTIBYTE */
345-
346-
/* in single-byte environment, all cells take 1 column */
347-
int
348-
pg_wcswidth(unsignedchar*pwcs,intlen)
349-
{
350-
returnlen;
351-
}
352-
353-
#endif

‎src/bin/psql/mbprint.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
/* $Id: mbprint.h,v 1.4 2001/11/05 17:46:31 momjian Exp $ */
1+
/* $Id: mbprint.h,v 1.5 2002/08/27 20:16:48 petere Exp $ */
22
#ifndefMBPRINT_H
33
#defineMBPRINT_H
44

5-
6-
#ifdefMULTIBYTE
7-
85
#include"mb/pg_wchar.h"
96

107
pg_wcharutf2ucs(constunsignedchar*c);
118

129
unsignedchar*mbvalidate(unsignedchar*pwcs);
13-
#endif/* MULTIBYTE */
1410

15-
intpg_wcswidth(unsignedchar*pwcs,intlen);
11+
intpg_wcswidth(unsignedchar*pwcs,size_tlen);
1612

1713
#endif/* MBPRINT_H */

‎src/bin/psql/print.c

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.28 2002/07/18 04:46:24 momjian Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/print.c,v 1.29 2002/08/27 20:16:48 petere Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"print.h"
@@ -209,13 +209,9 @@ print_aligned_text(const char *title, const char *const * headers,
209209
FILE*fout)
210210
{
211211
unsignedintcol_count=0;
212-
213-
#ifdefMULTIBYTE
214212
unsignedintcell_count=0;
215213
unsignedint*head_w,
216214
*cell_w;
217-
#endif
218-
219215
unsignedinti,
220216
tmp;
221217
unsignedint*widths,
@@ -233,7 +229,6 @@ print_aligned_text(const char *title, const char *const * headers,
233229
exit(EXIT_FAILURE);
234230
}
235231

236-
#ifdefMULTIBYTE
237232
head_w=calloc(col_count,sizeof(*head_w));
238233
if (!head_w)
239234
{
@@ -256,26 +251,21 @@ print_aligned_text(const char *title, const char *const * headers,
256251
}
257252
else
258253
cell_w=0;
259-
#endif
260254

261255

262256
/* calc column widths */
263257
for (i=0;i<col_count;i++)
264258
{
265259
if ((tmp=pg_wcswidth((unsignedchar*)headers[i],strlen(headers[i])))>widths[i])
266260
widths[i]=tmp;
267-
#ifdefMULTIBYTE
268261
head_w[i]=tmp;
269-
#endif
270262
}
271263

272264
for (i=0,ptr=cells;*ptr;ptr++,i++)
273265
{
274266
if ((tmp=pg_wcswidth((unsignedchar*)*ptr,strlen(*ptr)))>widths[i %col_count])
275267
widths[i %col_count]=tmp;
276-
#ifdefMULTIBYTE
277268
cell_w[i]=tmp;
278-
#endif
279269
}
280270
if (opt_border==0)
281271
total_w=col_count-1;
@@ -313,11 +303,7 @@ print_aligned_text(const char *title, const char *const * headers,
313303
{
314304
intnbspace;
315305

316-
#ifdefMULTIBYTE
317306
nbspace=widths[i]-head_w[i];
318-
#else
319-
nbspace=widths[i]-strlen(headers[i]);
320-
#endif
321307

322308
/* centered */
323309
fprintf(fout,"%-*s%s%-*s",
@@ -356,26 +342,16 @@ print_aligned_text(const char *title, const char *const * headers,
356342
/* content */
357343
if (opt_align[(i) %col_count]=='r')
358344
{
359-
#ifdefMULTIBYTE
360345
fprintf(fout,"%*s%s",
361346
widths[i %col_count]-cell_w[i],"",cells[i]);
362-
#else
363-
fprintf(fout,"%*s",widths[i %col_count],cells[i]);
364-
#endif
365347
}
366348
else
367349
{
368350
if ((i+1) %col_count==0&&opt_border!=2)
369351
fputs(cells[i],fout);
370352
else
371-
{
372-
#ifdefMULTIBYTE
373353
fprintf(fout,"%-s%*s",cells[i],
374354
widths[i %col_count]-cell_w[i],"");
375-
#else
376-
fprintf(fout,"%-*s",widths[i %col_count],cells[i]);
377-
#endif
378-
}
379355
}
380356

381357
/* divider */
@@ -406,10 +382,8 @@ print_aligned_text(const char *title, const char *const * headers,
406382
fputc('\n',fout);
407383

408384
/* clean up */
409-
#ifdefMULTIBYTE
410385
free(cell_w);
411386
free(head_w);
412-
#endif
413387
free(widths);
414388
}
415389

@@ -429,21 +403,17 @@ print_aligned_vertical(const char *title, const char *const * headers,
429403
hwidth=0,
430404
dwidth=0;
431405
char*divider;
432-
433-
#ifdefMULTIBYTE
434406
unsignedintcell_count=0;
435407
unsignedint*cell_w,
436408
*head_w;
437-
#endif
438409

439410
if (cells[0]==NULL)
440411
{
441412
puts(gettext("(No rows)\n"));
442413
return;
443414
}
444415

445-
#ifdefMULTIBYTE
446-
/* pre-count headers */
416+
/* count headers and find longest one */
447417
for (ptr=headers;*ptr;ptr++)
448418
col_count++;
449419
head_w=calloc(col_count,sizeof(*head_w));
@@ -480,22 +450,6 @@ print_aligned_vertical(const char *title, const char *const * headers,
480450
dwidth=tmp;
481451
cell_w[i]=tmp;
482452
}
483-
#else
484-
/* count columns and find longest header */
485-
for (ptr=headers;*ptr;ptr++)
486-
{
487-
col_count++;
488-
if ((tmp=strlen(*ptr))>hwidth)
489-
hwidth=tmp;/* don't wanna call strlen twice */
490-
}
491-
492-
/* find longest data cell */
493-
for (ptr=cells;*ptr;ptr++)
494-
{
495-
if ((tmp=strlen(*ptr))>dwidth)
496-
dwidth=tmp;
497-
}
498-
#endif
499453

500454
/* print title */
501455
if (!opt_barebones&&title)
@@ -569,12 +523,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
569523

570524
if (opt_border==2)
571525
fputs("| ",fout);
572-
#ifMULTIBYTE
573526
fprintf(fout,"%-s%*s",headers[i %col_count],
574527
hwidth-head_w[i %col_count],"");
575-
#else
576-
fprintf(fout,"%-*s",hwidth,headers[i %col_count]);
577-
#endif
578528

579529
if (opt_border>0)
580530
fputs(" | ",fout);
@@ -584,13 +534,7 @@ print_aligned_vertical(const char *title, const char *const * headers,
584534
if (opt_border<2)
585535
fprintf(fout,"%s\n",*ptr);
586536
else
587-
{
588-
#ifdefMULTIBYTE
589537
fprintf(fout,"%-s%*s |\n",*ptr,dwidth-cell_w[i],"");
590-
#else
591-
fprintf(fout,"%-*s |\n",dwidth,*ptr);
592-
#endif
593-
}
594538
}
595539

596540
if (opt_border==2)
@@ -610,10 +554,8 @@ print_aligned_vertical(const char *title, const char *const * headers,
610554
fputc('\n',fout);
611555
free(divider);
612556

613-
#ifdefMULTIBYTE
614557
free(cell_w);
615558
free(head_w);
616-
#endif
617559
}
618560

619561

@@ -1167,13 +1109,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
11671109
}
11681110

11691111
for (i=0;i<nfields;i++)
1170-
{
1171-
#ifdefMULTIBYTE
11721112
headers[i]=mbvalidate(PQfname(result,i));
1173-
#else
1174-
headers[i]=PQfname(result,i);
1175-
#endif
1176-
}
11771113

11781114
/* set cells */
11791115

@@ -1189,13 +1125,7 @@ printQuery(const PGresult *result, const printQueryOpt *opt, FILE *fout)
11891125
if (PQgetisnull(result,i /nfields,i %nfields))
11901126
cells[i]=opt->nullPrint ?opt->nullPrint :"";
11911127
else
1192-
{
1193-
#ifdefMULTIBYTE
11941128
cells[i]=mbvalidate(PQgetvalue(result,i /nfields,i %nfields));
1195-
#else
1196-
cells[i]=PQgetvalue(result,i /nfields,i %nfields);
1197-
#endif
1198-
}
11991129
}
12001130

12011131
/* set footers */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp