Skip to content

Commit 84b17da

Browse files
authored
Fix for #7823 (#7936)
1 parent 2906dad commit 84b17da

File tree

3 files changed

+35
-49
lines changed

3 files changed

+35
-49
lines changed

src/isql/extract.epp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,13 +2102,11 @@ static void list_create_db()
21022102
isqlGlob.printf("CREATE DATABASE '%s' ", isqlGlob.global_Target_db);
21032103

21042104
// Get the page size from db_info call
2105-
SCHAR info_buf[20];
21062105
// CVC: Finally I got the idea: translate is associated with WISQL that
21072106
// no longer exists. Localizing the messages means also not printing
21082107
// any CRLF and therefore the output looks ugly.
21092108
const bool translate = true;
2110-
if (SHOW_dbb_parameters(DB, info_buf, page_items, sizeof(page_items), translate, " "))
2111-
isqlGlob.printf("%s", info_buf);
2109+
SHOW_dbb_parameters(DB, page_items, sizeof(page_items), translate, " ");
21122110

21132111
FOR DBP IN RDB$DATABASE
21142112
WITH DBP.RDB$CHARACTER_SET_NAME NOT MISSING

src/isql/show.epp

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ void SHOW_comments(bool force)
389389
}
390390

391391

392-
bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
393-
SCHAR* info_buf,
392+
void SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
394393
const UCHAR* db_itemsL,
395394
unsigned item_length,
396395
bool translate,
@@ -407,7 +406,6 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
407406
*
408407
* Arguments:
409408
* db_handle -- database handle
410-
* info_buf -- info_bufput file pointer
411409
* db_itemsL -- list of db_info items to process
412410
*
413411
**************************************/
@@ -419,13 +417,10 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
419417
Firebird::CheckStatusWrapper statusWrapper(status_vector);
420418
db_handle->getInfo(&statusWrapper, item_length, db_itemsL, sizeof(buffer), buffer);
421419
if (ISQL_errmsg(status_vector))
422-
return false;
420+
return;
423421

424422
bool crdatePrinted = false;
425423

426-
*info_buf = '\0';
427-
SCHAR* info = info_buf;
428-
429424
for (Firebird::ClumpletReader p(Firebird::ClumpletReader::InfoResponse, buffer, sizeof(buffer)); !p.isEof(); p.moveNext())
430425
{
431426
UCHAR item = p.getClumpTag();
@@ -444,40 +439,40 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
444439

445440
case isc_info_page_size:
446441
value_out = p.getInt();
447-
sprintf(info, "PAGE_SIZE %" SQUADFORMAT"%s", value_out, separator);
442+
isqlGlob.printf("PAGE_SIZE %" SQUADFORMAT"%s", value_out, separator);
448443
break;
449444

450445
case isc_info_db_size_in_pages:
451446
value_out = p.getInt();
452447
if (translate)
453448
{
454449
IUTILS_msg_get(NUMBER_PAGES, msg, SafeArg() << value_out);
455-
sprintf(info, "%s%s", msg, separator);
450+
isqlGlob.printf("%s%s", msg, separator);
456451
}
457452
else
458-
sprintf(info, "Number of DB pages allocated = %" SQUADFORMAT"%s", value_out, separator);
453+
isqlGlob.printf("Number of DB pages allocated = %" SQUADFORMAT"%s", value_out, separator);
459454
break;
460455

461456
case fb_info_pages_used:
462457
value_out = p.getInt();
463458
if (translate)
464459
{
465460
IUTILS_msg_get(NUMBER_USED_PAGES, msg, SafeArg() << value_out);
466-
sprintf(info, "%s%s", msg, separator);
461+
isqlGlob.printf("%s%s", msg, separator);
467462
}
468463
else
469-
sprintf(info, "Number of DB pages used = %" SQUADFORMAT"%s", value_out, separator);
464+
isqlGlob.printf("Number of DB pages used = %" SQUADFORMAT"%s", value_out, separator);
470465
break;
471466

472467
case fb_info_pages_free:
473468
value_out = p.getInt();
474469
if (translate)
475470
{
476471
IUTILS_msg_get(NUMBER_FREE_PAGES, msg, SafeArg() << value_out);
477-
sprintf(info, "%s%s", msg, separator);
472+
isqlGlob.printf("%s%s", msg, separator);
478473
}
479474
else
480-
sprintf(info, "Number of DB pages free = %" SQUADFORMAT"%s", value_out, separator);
475+
isqlGlob.printf("Number of DB pages free = %" SQUADFORMAT"%s", value_out, separator);
481476
break;
482477

483478
case fb_info_crypt_state:
@@ -499,11 +494,11 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
499494
s += msg;
500495
}
501496

502-
sprintf(info, "%s%s", s.c_str(), separator);
497+
isqlGlob.printf("%s%s", s.c_str(), separator);
503498
}
504499
else
505500
{
506-
sprintf(info, "DB %sencrypted%s%s",
501+
isqlGlob.printf("DB %sencrypted%s%s",
507502
(value_out & fb_info_crypt_encrypted ? "" : "not "),
508503
(value_out & fb_info_crypt_process ? ", crypt thread not complete" : ""),
509504
separator);
@@ -515,79 +510,79 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
515510
if (translate)
516511
{
517512
IUTILS_msg_get(SWEEP_INTERV, msg, SafeArg() << value_out);
518-
sprintf(info, "%s%s", msg, separator);
513+
isqlGlob.printf("%s%s", msg, separator);
519514
}
520515
else
521-
sprintf(info, "Sweep interval = %" SQUADFORMAT"%s", value_out, separator);
516+
isqlGlob.printf("Sweep interval = %" SQUADFORMAT"%s", value_out, separator);
522517
break;
523518

524519
case isc_info_forced_writes:
525520
value_out = p.getInt();
526-
sprintf (info, "Forced Writes are %s%s", (value_out == 1 ? "ON" : "OFF"), separator);
521+
isqlGlob.printf("Forced Writes are %s%s", (value_out == 1 ? "ON" : "OFF"), separator);
527522
break;
528523

529524
case isc_info_oldest_transaction :
530525
value_out = p.getInt();
531-
sprintf(info, "Transaction - oldest = %" SQUADFORMAT"%s", value_out, separator);
526+
isqlGlob.printf("Transaction - oldest = %" SQUADFORMAT"%s", value_out, separator);
532527
break;
533528

534529
case isc_info_oldest_active :
535530
value_out = p.getInt();
536-
sprintf(info, "Transaction - oldest active = %" SQUADFORMAT"%s", value_out, separator);
531+
isqlGlob.printf("Transaction - oldest active = %" SQUADFORMAT"%s", value_out, separator);
537532
break;
538533

539534
case isc_info_oldest_snapshot :
540535
value_out = p.getInt();
541-
sprintf(info, "Transaction - oldest snapshot = %" SQUADFORMAT"%s", value_out, separator);
536+
isqlGlob.printf("Transaction - oldest snapshot = %" SQUADFORMAT"%s", value_out, separator);
542537
break;
543538

544539
case isc_info_next_transaction :
545540
value_out = p.getInt();
546-
sprintf (info, "Transaction - Next = %" SQUADFORMAT"%s", value_out, separator);
541+
isqlGlob.printf("Transaction - Next = %" SQUADFORMAT"%s", value_out, separator);
547542
break;
548543

549544
case isc_info_base_level:
550545
value_out = p.getInt();
551546
if (translate)
552547
{
553548
IUTILS_msg_get(BASE_LEVEL, msg, SafeArg() << value_out);
554-
sprintf(info, "%s%s", msg, separator);
549+
isqlGlob.printf("%s%s", msg, separator);
555550
}
556551
else
557-
sprintf(info, "Base level = %" SQUADFORMAT"%s", value_out, separator);
552+
isqlGlob.printf("Base level = %" SQUADFORMAT"%s", value_out, separator);
558553
break;
559554

560555
case isc_info_limbo:
561556
value_out = p.getInt();
562557
if (translate)
563558
{
564559
IUTILS_msg_get(LIMBO, msg, SafeArg() << value_out);
565-
sprintf(info, "%s%s", msg, separator);
560+
isqlGlob.printf("%s%s", msg, separator);
566561
}
567562
else
568-
sprintf(info, "Transaction in limbo = %" SQUADFORMAT"%s", value_out, separator);
563+
isqlGlob.printf("Transaction in limbo = %" SQUADFORMAT"%s", value_out, separator);
569564
break;
570565

571566
case isc_info_ods_version:
572567
isqlGlob.major_ods = p.getInt();
573568
break;
574569
case isc_info_ods_minor_version:
575570
value_out = p.getInt();
576-
sprintf(info, "ODS = %" SLONGFORMAT".%" SQUADFORMAT"%s",
571+
isqlGlob.printf("ODS = %" SLONGFORMAT".%" SQUADFORMAT"%s",
577572
(SLONG) isqlGlob.major_ods, value_out, separator);
578573
break;
579574

580575
case fb_info_wire_crypt:
581576
if (p.getClumpLength())
582-
sprintf (info, "Wire crypt plugin: %.*s%s", p.getClumpLength(), p.getBytes(), separator);
577+
isqlGlob.printf("Wire crypt plugin: %.*s%s", p.getClumpLength(), p.getBytes(), separator);
583578
break;
584579

585580
case fb_info_protocol_version:
586581
value_out = p.getInt();
587582
if (value_out)
588-
sprintf(info, "Protocol version = %" SQUADFORMAT"%s", value_out, separator);
583+
isqlGlob.printf("Protocol version = %" SQUADFORMAT"%s", value_out, separator);
589584
else
590-
sprintf(info, "Embedded connection%s", separator);
585+
isqlGlob.printf("Embedded connection%s", separator);
591586
break;
592587

593588
case isc_info_creation_date:
@@ -603,7 +598,7 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
603598
struct tm time;
604599
isc_decode_timestamp(&ts, &time);
605600

606-
sprintf(info, "Creation date: %s %d, %d %d:%02d:%02d%s",
601+
isqlGlob.printf("Creation date: %s %d, %d %d:%02d:%02d%s",
607602
FB_SHORT_MONTHS[time.tm_mon], time.tm_mday, time.tm_year + 1900,
608603
time.tm_hour, time.tm_min, time.tm_sec, separator);
609604
}
@@ -630,7 +625,7 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
630625
if (ISQL_errmsg(fbStatus))
631626
break;
632627

633-
sprintf(info, "Creation date: %s %d, %d %d:%02d:%02d %s%s",
628+
isqlGlob.printf("Creation date: %s %d, %d %d:%02d:%02d %s%s",
634629
FB_SHORT_MONTHS[month - 1], day, year,
635630
hours, minutes, seconds, timeZone, separator);
636631

@@ -647,12 +642,12 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
647642
const UCHAR* end = s + p.getClumpLength();
648643
++s; // Skip useless indicator.
649644
int len = *s++;
650-
printf("DB = %.*s\n", len, s);
645+
isqlGlob.printf("DB = %.*s\n", len, s);
651646
s += len;
652647
while (s < end)
653648
{
654649
len = *s++;
655-
printf("Host = %.*s\n", len, s);
650+
isqlGlob.printf("Host = %.*s\n", len, s);
656651
s += len;
657652
}
658653
}
@@ -667,17 +662,14 @@ bool SHOW_dbb_parameters(Firebird::IAttachment* db_handle,
667662
(value_out == fb_info_replica_read_only) ? "READ_ONLY" :
668663
(value_out == fb_info_replica_read_write) ? "READ_WRITE" :
669664
"unknown";
670-
sprintf(info, "Replica mode: %s%s", mode, separator);
665+
isqlGlob.printf("Replica mode: %s%s", mode, separator);
671666
}
672667
break;
673668

674669
case isc_info_truncated:
675-
return info > info_buf; // If we got some items, we are (partially) successful.
670+
return;
676671
}
677-
info += strlen(info);
678672
}
679-
680-
return info > info_buf;
681673
}
682674

683675

@@ -3672,15 +3664,11 @@ static void show_db()
36723664
return;
36733665
END_ERROR;
36743666

3675-
SCHAR info_buf[BUFFER_LENGTH512];
3676-
36773667
// First general database parameters
36783668

36793669
bool translate = true;
36803670

3681-
if (SHOW_dbb_parameters(DB, info_buf, db_items, sizeof(db_items), translate, NEWLINE)) {
3682-
isqlGlob.prints(info_buf);
3683-
}
3671+
SHOW_dbb_parameters(DB, db_items, sizeof(db_items), translate, NEWLINE);
36843672

36853673
FOR DBB IN RDB$DATABASE
36863674
CROSS CS IN RDB$CHARACTER_SETS

src/isql/show_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "../jrd/obj.h"
3030

3131
void SHOW_comments(bool force);
32-
bool SHOW_dbb_parameters (Firebird::IAttachment*, SCHAR*, const UCHAR*, unsigned, bool, const char*);
32+
void SHOW_dbb_parameters (Firebird::IAttachment*, const UCHAR*, unsigned, bool, const char*);
3333
processing_state SHOW_grants (const SCHAR*, const SCHAR*, ObjectType);
3434
processing_state SHOW_grants2 (const SCHAR*, const SCHAR*, ObjectType, const TEXT*, bool);
3535
void SHOW_grant_roles (const SCHAR*, bool*);

0 commit comments

Comments
 (0)