mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 15:50:51 +03:00 
			
		
		
		
	(Note: This affects only comments, not variable names.) extra/perror.c: Fix skipp -> skip once and for all. heap/hp_hash.c: Fix skipp -> skip once and for all. isam/_dynrec.c: Fix skipp -> skip once and for all. isam/isamchk.c: Fix skipp -> skip once and for all. isam/isamlog.c: Fix skipp -> skip once and for all. isam/pack_isam.c: Fix skipp -> skip once and for all. isam/test1.c: Fix skipp -> skip once and for all. merge/mrg_open.c: Fix skipp -> skip once and for all. myisam/mi_check.c: Fix skipp -> skip once and for all. myisam/mi_delete.c: Fix skipp -> skip once and for all. myisam/mi_key.c: Fix skipp -> skip once and for all. myisam/mi_search.c: Fix skipp -> skip once and for all. myisam/myisamlog.c: Fix skipp -> skip once and for all. mysys/ChangeLog: Fix skipp -> skip once and for all. mysys/default.c: Fix skipp -> skip once and for all. mysys/mf_iocache.c: Fix skipp -> skip once and for all. mysys/mf_iocache2.c: Fix skipp -> skip once and for all. mysys/mf_pack.c: Fix skipp -> skip once and for all. mysys/mf_soundex.c: Fix skipp -> skip once and for all. mysys/mf_wfile.c: Fix skipp -> skip once and for all. mysys/my_error.c: Fix skipp -> skip once and for all. mysys/my_getwd.c: Fix skipp -> skip once and for all. scripts/mysql_find_rows.sh: Fix skipp -> skip once and for all. sql/sql_yacc.yy: Fix skipp -> skip once and for all. sql/time.cc: Fix skipp -> skip once and for all. strings/ctype-big5.c: Fix skipp -> skip once and for all. strings/ctype-gbk.c: Fix skipp -> skip once and for all. strings/ctype-tis620.c: Fix skipp -> skip once and for all.
		
			
				
	
	
		
			149 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!@PERL@
 | |
| 
 | |
| $version="1.02";
 | |
| 
 | |
| use Getopt::Long;
 | |
| 
 | |
| $opt_help=$opt_Information=$opt_skip_use_db=0;
 | |
| $opt_regexp=$opt_dbregexp=".*";
 | |
| $opt_start_row=1; $opt_rows=9999999999;
 | |
| 
 | |
| GetOptions("Information","help","regexp=s","start_row=i","rows=i",
 | |
| 	   "dbregexp=s", "skip-use-db")
 | |
|   || usage();
 | |
| usage() if ($opt_help || $opt_Information);
 | |
| 
 | |
| $query=$search=$database=$set=""; $eoq=0;
 | |
| while (<>)
 | |
| {
 | |
|   next if (length($query) == 0 && /^\#/); # Skip comments
 | |
|   $query.=search($_);
 | |
|   if ($eoq)
 | |
|   {
 | |
|     if ($query =~ /^use /i || $query =~ /^SET / ||
 | |
| 	($query =~ /$opt_regexp/o && $database =~ /$opt_dbregexp/o))
 | |
|     {
 | |
|       if ($opt_skip_use_db && $query =~ /^use /i)
 | |
|       {
 | |
| 	$query="";
 | |
| 	next;
 | |
|       }
 | |
|       if ($opt_start_row <= 1)
 | |
|       {
 | |
| 	if ($database)
 | |
| 	{
 | |
| 	  print $database, $set;
 | |
| 	  $database=$set="";
 | |
| 	}
 | |
| 	print $query;
 | |
| 	last if (--$opt_rows == 0);
 | |
|       }
 | |
|       else
 | |
|       {
 | |
| 	$opt_start_row--;
 | |
| 	if ($query =~ /^use /)
 | |
| 	{
 | |
| 	  $database=$query;
 | |
| 	  $set="";
 | |
| 	}
 | |
| 	elsif ($query =~ /^SET/)
 | |
| 	{
 | |
| 	  $set=$query;
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 	  $set="";
 | |
| 	}
 | |
|       }
 | |
|     }
 | |
|     $query=""; $search=""; $eoq=0;
 | |
|   }
 | |
| }
 | |
| 
 | |
| exit 0;
 | |
| 
 | |
| sub search
 | |
| {
 | |
|   my($row)=shift;
 | |
|   my($i);
 | |
| 
 | |
|   for ($i=0 ; $i < length($row) ; $i++)
 | |
|   {
 | |
|     if (length($search))
 | |
|     {
 | |
|       if (length($search) > 1)
 | |
|       {				# Comment
 | |
| 	next if (substr($row,$i,length($search)) ne $search);
 | |
| 	$i+=length($search)-1;
 | |
| 	$search="";
 | |
|       }
 | |
|       elsif (substr($row,$i,1) eq '\\') # Escaped char in string
 | |
|       {
 | |
| 	$i++;
 | |
|       }
 | |
|       elsif (substr($row,$i,1) eq $search)
 | |
|       {
 | |
| 	if (substr($row,$i+1,1) eq $search)	# Double " or '
 | |
| 	{
 | |
| 	  $i++;
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 	  $search="";
 | |
| 	}
 | |
|       }
 | |
|       next;	
 | |
|     }
 | |
|     if (substr($row,$i,2) eq '/*')	# Comment
 | |
|     {
 | |
|       $search="*/";
 | |
|       $i++;
 | |
|     }
 | |
|     elsif (substr($row,$i,1) eq "'" || substr($row,$i,1) eq '"')
 | |
|     {
 | |
|       $search=substr($row,$i,1);
 | |
|      }
 | |
|   }
 | |
|   $eoq=1 if (!length($search) && $row =~ /;\s*$/);
 | |
|   return $row;
 | |
| }
 | |
| 
 | |
| 
 | |
| sub usage
 | |
| {
 | |
|     print <<EOF;
 | |
| $0  Ver $version
 | |
| 
 | |
| TCX Datakonsult AB, by Monty.
 | |
| This software comes with NO WARRANTY: see the file PUBLIC for details.
 | |
| 
 | |
| Prints all SQL queries that matches a regexp or contains a 'use
 | |
| database' or 'set ..' command to stdout.  A SQL query may contain
 | |
| newlines.  This is useful to find things in a MySQL update log.
 | |
| 
 | |
| $0 takes the following options:
 | |
| 
 | |
| --help or --Information
 | |
|   Shows this help
 | |
| 
 | |
| --regexp=#
 | |
|   Print queries that matches this.
 | |
| 
 | |
| --start_row=#
 | |
|   Start output from this row (first row = 1)
 | |
| 
 | |
| --skip-use-db
 | |
|   Don\'t include \'use database\' commands in the output.
 | |
| 
 | |
| --rows=#
 | |
|   Quit after this many rows.
 | |
| 
 | |
| Example:
 | |
| 
 | |
| $0 --regexp "problem_table" < update.log
 | |
| 
 | |
| $0 --regexp "problem_table" update-log.1 update-log.2
 | |
| EOF
 | |
|   exit(0);
 | |
| }
 |