File: execute_list_command.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (56 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# ==== Purpose ====
#
# The sql statement containing REPLACE_STRING_VAL string is replaced by given
# list of parameters and executed.
#
# ==== Usage ====
#
# --let $execute_list= <param1>,<param2>,<param3>
# --let $execute_sql_statement= SELECT REPLACE_STRING_VAL
# --source include/execute_list_command.inc
#
# Parameters:
#
#   $execute_list
#     The REPLACE_STRING_VAL string in execute_sql_statement statement is
#     replaced by list of parameters and executed.
#
#   $execute_sql_statement
#     The sql statement containing REPLACE_STRING_VAL string is replaced by
#     given list of parameters and executed.


--let $result_file = $MYSQLTEST_VARDIR/tmp/exec_list_tmp.inc
--let _RESULT_FILE = $result_file
--let _STATEMENT=$execute_sql_statement
--let $_list= $execute_list

while ($_list)
{
  # Set $_rpl_diff_server_i to the first number in the list
  --let $_list_i= `SELECT SUBSTRING_INDEX('$_list', ',', 1)`
  # Remove $_rpl_diff_server_i from the list
  --let $_list= `SELECT SUBSTRING('$_list', LENGTH('$_list_i') + 2)`

  --let _REPLACE_STRING_VAL=$_list_i

--perl
  use strict;
  my $_statement= $ENV{'_STATEMENT'} or die "execute_sql_statement is not set";
  my $_replace= $ENV{'_REPLACE_STRING_VAL'} or die "execute_list is not set properly";
  my $_search = "REPLACE_STRING_VAL";
  my $outfile = $ENV{'_RESULT_FILE'};

  $_statement =~ s/$_search/$_replace/;

  open(FILE, ">", $outfile) or die "Error $? opening $outfile: $!";
  print FILE $_statement or die "Error $? writing to $outfile: $!";
  close FILE or die "Error $? closing $outfile: $!";
  chmod 0777, $outfile;
EOF

  --let $exec_sql_string = `SELECT LOAD_FILE('$result_file')`
  --eval $exec_sql_string
}

--remove_file $result_file