/ Check-in [f795afd6]
Login

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

Overview
Comment:Modify the shell so that when it is doing a ".dump" it always uses single quotes and not double quotes for quoting literal strings. This is for portability to other databases that only support single quote string literals. (CVS 574)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f795afd63f19ab61c2b3b96621cb6dda31ce0379
User & Date: drh 2002-05-21 13:02:24
Context
2002-05-21
13:18
Clean up some compiler warnings. (CVS 575) check-in: 3399b012 user: drh tags: trunk
13:02
Modify the shell so that when it is doing a ".dump" it always uses single quotes and not double quotes for quoting literal strings. This is for portability to other databases that only support single quote string literals. (CVS 574) check-in: f795afd6 user: drh tags: trunk
12:56
Fix for ticket #45: Allow an UPDATE statement to change the INTEGER PRIMARY KEY to itself without triggering a constraint error. (CVS 573) check-in: 592da134 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/shell.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.56 2002/04/21 19:06:22 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................

/*
** Output the given string as a quoted string using SQL quoting conventions.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  int nSingle = 0;
  int nDouble = 0;
  for(i=0; z[i]; i++){
    if( z[i]=='\'' ) nSingle++;
    else if( z[i]=='"' ) nDouble++;
  }
  if( nSingle==0 ){
    fprintf(out,"'%s'",z);
  }else if( nDouble==0 ){
    fprintf(out,"\"%s\"",z);
  }else{
    fprintf(out,"'");
    while( *z ){
      for(i=0; z[i] && z[i]!='\''; i++){}
      if( i==0 ){
        fprintf(out,"''");
        z++;







|







 







<


<



<
<







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
219
220
221
222
223
224
225

226
227

228
229
230


231
232
233
234
235
236
237
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.57 2002/05/21 13:02:24 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sqlite.h"
#include <ctype.h>

................................................................................

/*
** Output the given string as a quoted string using SQL quoting conventions.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  int nSingle = 0;

  for(i=0; z[i]; i++){
    if( z[i]=='\'' ) nSingle++;

  }
  if( nSingle==0 ){
    fprintf(out,"'%s'",z);


  }else{
    fprintf(out,"'");
    while( *z ){
      for(i=0; z[i] && z[i]!='\''; i++){}
      if( i==0 ){
        fprintf(out,"''");
        z++;