SQLite

Check-in [34439fe3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix the "box" output mode in the shell when statement returns zero-column rows (for example from "PRAGMA incremental_vacuum").
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 34439fe3aeea7cbbc817245d39c345a7f5df7a82ac15ee4d71bb9a4d818198ed
User & Date: drh 2021-03-20 23:15:52
References
2024-03-05
17:39
Reformulate [34439fe3aeea7cbb] slightly to resolve a false-positive OOM reported in forum post 2eadfe94e3. (check-in: 320ccb5d user: stephan tags: branch-3.45)
17:33
Reformulate [34439fe3aeea7cbb] slightly to resolve a false-positive OOM reported in forum post 2eadfe94e3. (check-in: 82906467 user: stephan tags: trunk)
Context
2021-03-21
17:52
Add a better comment and an assert() on the code inside sqlite3CreateIndex() that REPLACE indexes come at the end of the index list. forum post ceb51d83f7 (check-in: 71e4da13 user: drh tags: trunk)
2021-03-20
23:15
Fix the "box" output mode in the shell when statement returns zero-column rows (for example from "PRAGMA incremental_vacuum"). (check-in: 34439fe3 user: drh tags: trunk)
01:00
Fix a faulty assert() in the OP_SkipScan opcode. dbsqlfuzz a15a9b2ca82e812ad52f62c86cc93dca0dc72f01. Test cases in TH3. (check-in: 1805b9aa user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

3059
3060
3061
3062
3063
3064
3065

3066
3067
3068
3069
3070
3071
3072
  const char *colSep = 0;
  const char *rowSep = 0;

  rc = sqlite3_step(pStmt);
  if( rc!=SQLITE_ROW ) return;
  nColumn = sqlite3_column_count(pStmt);
  nAlloc = nColumn*4;

  azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
  if( azData==0 ) shell_out_of_memory();
  for(i=0; i<nColumn; i++){
    azData[i] = strdup(sqlite3_column_name(pStmt,i));
  }
  do{
    if( (nRow+2)*nColumn >= nAlloc ){







>







3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
  const char *colSep = 0;
  const char *rowSep = 0;

  rc = sqlite3_step(pStmt);
  if( rc!=SQLITE_ROW ) return;
  nColumn = sqlite3_column_count(pStmt);
  nAlloc = nColumn*4;
  if( nAlloc<=0 ) nAlloc = 1;
  azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
  if( azData==0 ) shell_out_of_memory();
  for(i=0; i<nColumn; i++){
    azData[i] = strdup(sqlite3_column_name(pStmt,i));
  }
  do{
    if( (nRow+2)*nColumn >= nAlloc ){
3098
3099
3100
3101
3102
3103
3104

3105
3106
3107
3108
3109
3110
3111
    z = azData[i];
    if( z==0 ) z = p->nullValue;
    n = strlenChar(z);
    j = i%nColumn;
    if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
  }
  if( seenInterrupt ) goto columnar_end;

  switch( p->cMode ){
    case MODE_Column: {
      colSep = "  ";
      rowSep = "\n";
      if( p->showHeader ){
        for(i=0; i<nColumn; i++){
          w = p->actualWidth[i];







>







3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
    z = azData[i];
    if( z==0 ) z = p->nullValue;
    n = strlenChar(z);
    j = i%nColumn;
    if( n>p->actualWidth[j] ) p->actualWidth[j] = n;
  }
  if( seenInterrupt ) goto columnar_end;
  if( nColumn==0 ) goto columnar_end;
  switch( p->cMode ){
    case MODE_Column: {
      colSep = "  ";
      rowSep = "\n";
      if( p->showHeader ){
        for(i=0; i<nColumn; i++){
          w = p->actualWidth[i];