/ Changes On Branch shell-fix
Login

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

Changes In Branch shell-fix Excluding Merge-Ins

This is equivalent to a diff from 48826b222c to 4c2b572969

2017-04-07
20:20
Use replace() instead of char() to quote newline and return characters in strings in the output of .dump, to avoid excess expression complexity. (check-in: 7307352988 user: drh tags: trunk)
19:41
Proof of concept for the ability to use the expression columns in an index on expressions in place of equivalent expressions in the result set or in the WHERE clause. This check-in compiles but is mostly untested. (check-in: a52ef2ad7c user: drh tags: covering-index-on-expr)
11:45
Use replace() instead of char() to quote newline and return characters in strings in the output of .dump, to avoid excess expression complexity. (Closed-Leaf check-in: 4c2b572969 user: drh tags: shell-fix)
2017-04-06
14:56
Fix the ".lint fkey" shell command for cases where the child key is also an INTEGER PRIMARY KEY. (check-in: 48826b222c user: dan tags: trunk)
12:06
Fix the ".lint fkey" shell tool command so that it works for foreign keys that refer implicitly to primary key columns with non-BINARY default collation sequences. (check-in: 327eff25ba user: dan tags: trunk)

Changes to src/shell.c.

1483
1484
1485
1486
1487
1488
1489





















1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504


1505
1506














1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530

1531
1532


1533
1534
1535

1536

1537

1538

1539
1540
1541
1542
1543
1544
1545
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
  int i;
  char *zBlob = (char *)pBlob;
  raw_printf(out,"X'");
  for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
  raw_printf(out,"'");
}






















/*
** Output the given string as a quoted string using SQL quoting conventions.
**
** The "\n" and "\r" characters are converted to char(10) and char(13)
** to prevent them from being transformed by end-of-line translators.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  char c;
  setBinaryMode(out, 1);
  for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
  if( c==0 ){
    utf8_printf(out,"'%s'",z);
  }else{


    int inQuote = 0;
    int bStarted = 0;














    while( *z ){
      for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
      if( c=='\'' ) i++;
      if( i ){
        if( !inQuote ){
          if( bStarted ) raw_printf(out, "||");
          raw_printf(out, "'");
          inQuote = 1;
        }
        utf8_printf(out, "%.*s", i, z);
        z += i;
        bStarted = 1;
      }
      if( c=='\'' ){
        raw_printf(out, "'");
        continue;
      }
      if( inQuote ){
        raw_printf(out, "'");
        inQuote = 0;
      }
      if( c==0 ){
        break;
      }

      for(i=0; (c = z[i])=='\r' || c=='\n'; i++){
        if( bStarted ) raw_printf(out, "||");


        raw_printf(out, "char(%d)", c);
        bStarted = 1;
      }

      z += i;

    }

    if( inQuote ) raw_printf(out, "'");

  }
  setTextMode(out, 1);
}

/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>




<
<
<
<
<


<





<
<
<
<



>
|
|
>
>
|
<
|
>
|
>

>
|
>







1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547





1548
1549

1550
1551
1552
1553
1554




1555
1556
1557
1558
1559
1560
1561
1562
1563

1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
  int i;
  char *zBlob = (char *)pBlob;
  raw_printf(out,"X'");
  for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
  raw_printf(out,"'");
}

/*
** Find a string that is not found anywhere in z[].  Return a pointer
** to that string.
**
** Try to use zA and zB first.  If both of those are already found in z[]
** then make up some string and store it in the buffer zBuf.
*/
static const char *unused_string(
  const char *z,                    /* Result must not appear anywhere in z */
  const char *zA, const char *zB,   /* Try these first */
  char *zBuf                        /* Space to store a generated string */
){
  unsigned i = 0;
  if( strstr(z, zA)==0 ) return zA;
  if( strstr(z, zB)==0 ) return zB;
  do{
    sqlite3_snprintf(20,zBuf,"(%s%u)", zA, i++);
  }while( strstr(z,zBuf)!=0 );
  return zBuf;
}

/*
** Output the given string as a quoted string using SQL quoting conventions.
**
** The "\n" and "\r" characters are converted to char(10) and char(13)
** to prevent them from being transformed by end-of-line translators.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  char c;
  setBinaryMode(out, 1);
  for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}
  if( c==0 ){
    utf8_printf(out,"'%s'",z);
  }else{
    const char *zNL = 0;
    const char *zCR = 0;
    int nNL = 0;
    int nCR = 0;
    char zBuf1[20], zBuf2[20];
    for(i=0; z[i]; i++){
      if( z[i]=='\n' ) nNL++;
      if( z[i]=='\r' ) nCR++;
    }
    if( nNL ){
      raw_printf(out, "replace(");
      zNL = unused_string(z, "\\n", "\\012", zBuf1);
    }
    if( nCR ){
      raw_printf(out, "replace(");
      zCR = unused_string(z, "\\r", "\\015", zBuf2);
    }
    raw_printf(out, "'");
    while( *z ){
      for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
      if( c=='\'' ) i++;
      if( i ){





        utf8_printf(out, "%.*s", i, z);
        z += i;

      }
      if( c=='\'' ){
        raw_printf(out, "'");
        continue;
      }




      if( c==0 ){
        break;
      }
      z++;
      if( c=='\n' ){
        raw_printf(out, "%s", zNL);
        continue;
      }
      raw_printf(out, "%s", zCR);

    }
    raw_printf(out, "'");
    if( nCR ){
      raw_printf(out, ",'%s',char(13))", zCR);
    }
    if( nNL ){
      raw_printf(out, ",'%s',char(10))", zNL);
    }
  }
  setTextMode(out, 1);
}

/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/