mirror of
				https://github.com/sqlite/sqlite.git
				synced 2025-11-03 16:53:36 +03:00 
			
		
		
		
	Add the -mmap option to the command-line shell, for setting the default
mmap_limit. FossilOrigin-Name: fc30d06c94c8212abb0477fb4cec4520d05bea34
This commit is contained in:
		
							
								
								
									
										12
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								manifest
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
C Fix\sthe\sunix\sdriver\sto\scheck\sdefined(_BSD_SOURCE)\srather\sthan\sjust\sthe\splain\n_BSD_SOURCE\smacro.\s\sThis\sfixes\sthe\sbuild\sfor\sOpenBSD.
 | 
					C Add\sthe\s-mmap\soption\sto\sthe\scommand-line\sshell,\sfor\ssetting\sthe\sdefault\nmmap_limit.
 | 
				
			||||||
D 2013-04-03T00:42:01.544
 | 
					D 2013-04-03T01:26:54.789
 | 
				
			||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
					F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 | 
				
			||||||
F Makefile.in df3e48659d80e1b7765785d8d66c86b320f72cc7
 | 
					F Makefile.in df3e48659d80e1b7765785d8d66c86b320f72cc7
 | 
				
			||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
					F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
 | 
				
			||||||
@@ -175,7 +175,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
 | 
				
			|||||||
F src/resolve.c 9079da7d59aed2bb14ec8315bc7f720dd85b5b65
 | 
					F src/resolve.c 9079da7d59aed2bb14ec8315bc7f720dd85b5b65
 | 
				
			||||||
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 | 
					F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 | 
				
			||||||
F src/select.c 01540bcd3df3c8f1187158e77986028b1c667258
 | 
					F src/select.c 01540bcd3df3c8f1187158e77986028b1c667258
 | 
				
			||||||
F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca
 | 
					F src/shell.c 319b7791cee6c763b60fde1b590bfaf62613cf37
 | 
				
			||||||
F src/sqlite.h.in 42c69ea00dfcce84394d6ce0d8dac7bb3d2ecff2
 | 
					F src/sqlite.h.in 42c69ea00dfcce84394d6ce0d8dac7bb3d2ecff2
 | 
				
			||||||
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
 | 
					F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
 | 
				
			||||||
F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75
 | 
					F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75
 | 
				
			||||||
@@ -1042,7 +1042,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 | 
				
			|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
					F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 | 
				
			||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 | 
					F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 | 
				
			||||||
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
 | 
					F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
 | 
				
			||||||
P b29cda03fe4e8d8f5b5acbbea2d69f284a2bdf23
 | 
					P 1dd42ef4144ee08fb4ee1676d934a56a0e34bac2
 | 
				
			||||||
R 12d119a8bfdd7260b7f76958004bb415
 | 
					R 414201a51e65d2b5d08b22317803af41
 | 
				
			||||||
U drh
 | 
					U drh
 | 
				
			||||||
Z 8724856398770e48d9cea9c9c7fa6257
 | 
					Z ee0a75b1373c6c61317486123f3b4064
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
1dd42ef4144ee08fb4ee1676d934a56a0e34bac2
 | 
					fc30d06c94c8212abb0477fb4cec4520d05bea34
 | 
				
			||||||
							
								
								
									
										53
									
								
								src/shell.c
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								src/shell.c
									
									
									
									
									
								
							@@ -1552,6 +1552,43 @@ static int booleanValue(char *zArg){
 | 
				
			|||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					** Interpret zArg as an integer value, possibly with suffixes.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					static sqlite3_int64 integerValue(const char *zArg){
 | 
				
			||||||
 | 
					  sqlite3_int64 v = 0;
 | 
				
			||||||
 | 
					  static const struct { char *zSuffix; int iMult; } aMult[] = {
 | 
				
			||||||
 | 
					    { "KiB", 1024 },
 | 
				
			||||||
 | 
					    { "MiB", 1024*1024 },
 | 
				
			||||||
 | 
					    { "GiB", 1024*1024*1024 },
 | 
				
			||||||
 | 
					    { "KB",  1000 },
 | 
				
			||||||
 | 
					    { "MB",  1000000 },
 | 
				
			||||||
 | 
					    { "GB",  1000000000 },
 | 
				
			||||||
 | 
					    { "K",   1000 },
 | 
				
			||||||
 | 
					    { "M",   1000000 },
 | 
				
			||||||
 | 
					    { "G",   1000000000 },
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  int i;
 | 
				
			||||||
 | 
					  int isNeg = 0;
 | 
				
			||||||
 | 
					  if( zArg[0]=='-' ){
 | 
				
			||||||
 | 
					    isNeg = 1;
 | 
				
			||||||
 | 
					    zArg++;
 | 
				
			||||||
 | 
					  }else if( zArg[0]=='+' ){
 | 
				
			||||||
 | 
					    zArg++;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  while( isdigit(zArg[0]) ){
 | 
				
			||||||
 | 
					    v = v*10 + zArg[0] - '0';
 | 
				
			||||||
 | 
					    zArg++;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
 | 
				
			||||||
 | 
					    if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
 | 
				
			||||||
 | 
					      v *= aMult[i].iMult;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return isNeg? -v : v;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
** Close an output file, assuming it is not stderr or stdout
 | 
					** Close an output file, assuming it is not stderr or stdout
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
@@ -2469,7 +2506,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
 | 
				
			|||||||
        /* sqlite3_test_control(int, uint) */
 | 
					        /* sqlite3_test_control(int, uint) */
 | 
				
			||||||
        case SQLITE_TESTCTRL_PENDING_BYTE:        
 | 
					        case SQLITE_TESTCTRL_PENDING_BYTE:        
 | 
				
			||||||
          if( nArg==3 ){
 | 
					          if( nArg==3 ){
 | 
				
			||||||
            unsigned int opt = (unsigned int)atoi(azArg[2]);        
 | 
					            unsigned int opt = (unsigned int)integerValue(azArg[2]);        
 | 
				
			||||||
            rc = sqlite3_test_control(testctrl, opt);
 | 
					            rc = sqlite3_test_control(testctrl, opt);
 | 
				
			||||||
            printf("%d (0x%08x)\n", rc, rc);
 | 
					            printf("%d (0x%08x)\n", rc, rc);
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
@@ -2561,7 +2598,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
 | 
				
			|||||||
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
 | 
					#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
 | 
				
			||||||
  if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
 | 
					  if( c=='w' && strncmp(azArg[0], "wheretrace", n)==0 ){
 | 
				
			||||||
    extern int sqlite3WhereTrace;
 | 
					    extern int sqlite3WhereTrace;
 | 
				
			||||||
    sqlite3WhereTrace = atoi(azArg[1]);
 | 
					    sqlite3WhereTrace = booleanValue(azArg[1]);
 | 
				
			||||||
  }else
 | 
					  }else
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2882,6 +2919,7 @@ static const char zOptions[] =
 | 
				
			|||||||
  "   -interactive         force interactive I/O\n"
 | 
					  "   -interactive         force interactive I/O\n"
 | 
				
			||||||
  "   -line                set output mode to 'line'\n"
 | 
					  "   -line                set output mode to 'line'\n"
 | 
				
			||||||
  "   -list                set output mode to 'list'\n"
 | 
					  "   -list                set output mode to 'list'\n"
 | 
				
			||||||
 | 
					  "   -mmap N              default mmap size set to N\n"
 | 
				
			||||||
#ifdef SQLITE_ENABLE_MULTIPLEX
 | 
					#ifdef SQLITE_ENABLE_MULTIPLEX
 | 
				
			||||||
  "   -multiplex           enable the multiplexor VFS\n"
 | 
					  "   -multiplex           enable the multiplexor VFS\n"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -3001,12 +3039,7 @@ int main(int argc, char **argv){
 | 
				
			|||||||
      sqlite3_int64 szHeap;
 | 
					      sqlite3_int64 szHeap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      zSize = cmdline_option_value(argc, argv, ++i);
 | 
					      zSize = cmdline_option_value(argc, argv, ++i);
 | 
				
			||||||
      szHeap = atoi(zSize);
 | 
					      szHeap = integerValue(zSize);
 | 
				
			||||||
      for(j=0; (c = zSize[j])!=0; j++){
 | 
					 | 
				
			||||||
        if( c=='M' ){ szHeap *= 1000000; break; }
 | 
					 | 
				
			||||||
        if( c=='K' ){ szHeap *= 1000; break; }
 | 
					 | 
				
			||||||
        if( c=='G' ){ szHeap *= 1000000000; break; }
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
 | 
					      if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
 | 
				
			||||||
      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
 | 
					      sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -3026,6 +3059,8 @@ int main(int argc, char **argv){
 | 
				
			|||||||
      extern int sqlite3_multiple_initialize(const char*,int);
 | 
					      extern int sqlite3_multiple_initialize(const char*,int);
 | 
				
			||||||
      sqlite3_multiplex_initialize(0, 1);
 | 
					      sqlite3_multiplex_initialize(0, 1);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					    }else if( strcmp(z,"-mmap")==0 ){
 | 
				
			||||||
 | 
					      sqlite3_config(SQLITE_CONFIG_MMAP_LIMIT, integerValue(cmdline_option_value(argc,argv,++i)));
 | 
				
			||||||
    }else if( strcmp(z,"-vfs")==0 ){
 | 
					    }else if( strcmp(z,"-vfs")==0 ){
 | 
				
			||||||
      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
 | 
					      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
 | 
				
			||||||
      if( pVfs ){
 | 
					      if( pVfs ){
 | 
				
			||||||
@@ -3111,6 +3146,8 @@ int main(int argc, char **argv){
 | 
				
			|||||||
      stdin_is_interactive = 0;
 | 
					      stdin_is_interactive = 0;
 | 
				
			||||||
    }else if( strcmp(z,"-heap")==0 ){
 | 
					    }else if( strcmp(z,"-heap")==0 ){
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
 | 
					    }else if( strcmp(z,"-mmap")==0 ){
 | 
				
			||||||
 | 
					      i++;
 | 
				
			||||||
    }else if( strcmp(z,"-vfs")==0 ){
 | 
					    }else if( strcmp(z,"-vfs")==0 ){
 | 
				
			||||||
      i++;
 | 
					      i++;
 | 
				
			||||||
#ifdef SQLITE_ENABLE_VFSTRACE
 | 
					#ifdef SQLITE_ENABLE_VFSTRACE
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user