/ Check-in [ab99faca]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:In shell, in shell_exec() logic, use type info if available when outputting in "insert" mode for other types in addition to blobs. Changed shell_exec() to use sqlite_prepare_v2(). Ticket [72adc99de9] and [7b61b6c6ce].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ab99faca6ce57a5e37405dfc8dc55d149cf3f8a3
User & Date: shane 2009-10-22 18:12:59
Original Comment: In shell, in shell_exec() logic, use type info if available when outputting in "insert" mode for other types in addition to blobs. Changed shell_exec() to use sqlite_prepare_v2(). Ticket [72adc99de9].
References
2009-10-22
19:38 Fixed ticket [7b61b6c6]: insert mode is incorrectly converting text to numbers plus 4 other changes artifact: 91fba9fd user: shane
18:15 Ticket [72adc99d] shell mode insert doesn't output blobs as blobs status still Review with 1 other change artifact: 4fc3cc9e user: shane
Context
2009-10-22
20:50
Add some sample requirement implementation comments to where.c. check-in: 9854ad00 user: drh tags: trunk
18:12
In shell, in shell_exec() logic, use type info if available when outputting in "insert" mode for other types in addition to blobs. Changed shell_exec() to use sqlite_prepare_v2(). Ticket [72adc99de9] and [7b61b6c6ce]. check-in: ab99faca user: shane tags: trunk
17:30
Updated shell to output blobs in X'1234' form when in "insert" mode. Ticket [72adc99de9]. check-in: a2ad9e63 user: shane tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

  1643   1643         break;
  1644   1644       }
  1645   1645       case MODE_Insert: {
  1646   1646         if( azArg==0 ) break;
  1647   1647         fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
  1648   1648         for(i=0; i<nArg; i++){
  1649   1649           char *zSep = i>0 ? ",": "";
  1650         -        if( azArg[i]==0 ){
         1650  +        if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
  1651   1651             fprintf(p->out,"%sNULL",zSep);
         1652  +        }else if( aiType && aiType[i]==SQLITE_TEXT ){
         1653  +          if( zSep[0] ) fprintf(p->out,"%s",zSep);
         1654  +          output_quoted_string(p->out, azArg[i]);
         1655  +        }else if( aiType && (aiType[i]==SQLITE_INTEGER || aiType[i]==SQLITE_FLOAT) ){
         1656  +          fprintf(p->out,"%s%s",zSep, azArg[i]);
  1652   1657           }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
  1653   1658             const void *pBlob = sqlite3_column_blob(p->pStmt, i);
  1654   1659             int nBlob = sqlite3_column_bytes(p->pStmt, i);
  1655   1660             if( zSep[0] ) fprintf(p->out,"%s",zSep);
  1656   1661             output_hex_blob(p->out, pBlob, nBlob);
  1657   1662           }else if( isNumber(azArg[i], 0) ){
  1658   1663             fprintf(p->out,"%s%s",zSep, azArg[i]);
................................................................................
  1826   1831     sqlite3_stmt *pStmt = NULL;
  1827   1832     int rc, rc2;
  1828   1833   
  1829   1834     if( pzErrMsg ){
  1830   1835       *pzErrMsg = NULL;
  1831   1836     }
  1832   1837   
  1833         -  rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
         1838  +  rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
  1834   1839     if( (SQLITE_OK != rc) || !pStmt ){
  1835   1840       if( pzErrMsg ){
  1836   1841         *pzErrMsg = save_err_msg(db);
  1837   1842       }
  1838   1843     }else{
  1839   1844       /* perform the first step.  this will tell us if we
  1840   1845       ** have a result set or not and how wide it is.