/ Check-in [ee431d55]
Login

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

Overview
Comment:Output infinity as 1e999 in the ".dump" command of the command-line shell.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:ee431d55eba618cfba414c3946b3162bc205a70dd4e43d74a7623be332b94c92
User & Date: drh 2018-06-13 17:19:20
Context
2018-06-18
19:09
Fix typo in the 'normalize' extension. check-in: 0c9163ea user: mistachkin tags: trunk
2018-06-14
14:30
Merge latest trunk changes into this branch. check-in: 5cf5f180 user: dan tags: exp-window-functions
2018-06-13
17:19
Output infinity as 1e999 in the ".dump" command of the command-line shell. check-in: ee431d55 user: drh tags: trunk
16:52
Pad out the sqlite3_value structure to be a multiple of 8 bytes. check-in: f76dc33b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/dbdump.c.

   481    481             switch( sqlite3_column_type(pStmt,i) ){
   482    482               case SQLITE_INTEGER: {
   483    483                 output_formatted(p, "%lld", sqlite3_column_int64(pStmt,i));
   484    484                 break;
   485    485               }
   486    486               case SQLITE_FLOAT: {
   487    487                 double r = sqlite3_column_double(pStmt,i);
   488         -              output_formatted(p, "%!.20g", r);
          488  +              sqlite3_uint64 ur;
          489  +              memcpy(&ur,&r,sizeof(r));
          490  +              if( ur==0x7ff0000000000000LL ){
          491  +                p->xCallback("1e999", p->pArg);
          492  +              }else if( ur==0xfff0000000000000LL ){
          493  +                p->xCallback("-1e999", p->pArg);
          494  +              }else{
          495  +                output_formatted(p, "%!.20g", r);
          496  +              }
   489    497                 break;
   490    498               }
   491    499               case SQLITE_NULL: {
   492    500                 p->xCallback("NULL", p->pArg);
   493    501                 break;
   494    502               }
   495    503               case SQLITE_TEXT: {

Changes to src/shell.c.in.

  2029   2029               output_quoted_escaped_string(p->out, azArg[i]);
  2030   2030             }
  2031   2031           }else if( aiType && aiType[i]==SQLITE_INTEGER ){
  2032   2032             utf8_printf(p->out,"%s", azArg[i]);
  2033   2033           }else if( aiType && aiType[i]==SQLITE_FLOAT ){
  2034   2034             char z[50];
  2035   2035             double r = sqlite3_column_double(p->pStmt, i);
  2036         -          sqlite3_snprintf(50,z,"%!.20g", r);
  2037         -          raw_printf(p->out, "%s", z);
         2036  +          sqlite3_uint64 ur;
         2037  +          memcpy(&ur,&r,sizeof(r));
         2038  +          if( ur==0x7ff0000000000000LL ){
         2039  +            raw_printf(p->out, "1e999");
         2040  +          }else if( ur==0xfff0000000000000LL ){
         2041  +            raw_printf(p->out, "-1e999");
         2042  +          }else{
         2043  +            sqlite3_snprintf(50,z,"%!.20g", r);
         2044  +            raw_printf(p->out, "%s", z);
         2045  +          }
  2038   2046           }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
  2039   2047             const void *pBlob = sqlite3_column_blob(p->pStmt, i);
  2040   2048             int nBlob = sqlite3_column_bytes(p->pStmt, i);
  2041   2049             output_hex_blob(p->out, pBlob, nBlob);
  2042   2050           }else if( isNumber(azArg[i], 0) ){
  2043   2051             utf8_printf(p->out,"%s", azArg[i]);
  2044   2052           }else if( ShellHasFlag(p, SHFLG_Newlines) ){