Project

General

Profile

« Previous | Next » 

Revision 9570

lib/sh/resume_import.sh: resume_import(): run connection preamble (first few lines of dumpfile) before continuing with main file at offset, so that connection setting are reapplied

View differences:

resume_import.sh
1 1
#!/bin/bash -e
2 2
. "$(dirname "${BASH_SOURCE[0]}")"/util.sh
3 3
. "$(dirname "${BASH_SOURCE[0]}")"/binsearch.sh
4
. "$(dirname "${BASH_SOURCE[0]}")"/make.sh
4 5

  
5 6
if self_not_included; then
6 7

  
......
50 51
	binsearch is_pkey_at_pos_imported
51 52
}
52 53

  
54

  
55
### sql_preamble()
56

  
57
sql_preamble() # usage: sql_preamble <file
58
{
59
	echo_func
60
	echo_run sed -n '/^-- Dumping data for table /{
61
q # stop after first match
62
}
63
p # passthru until first match
64
' "$@"
65
}
66

  
67
preamble_file="${top_file/%.sql/.preamble.sql}"
68

  
69
^.preamble.sql/make()
70
{
71
	echo_func; set_make_vars
72
	local target="$preamble_file"; check_target_exists
73
	to_target sql_preamble <"$top_file"
74
}
75

  
76

  
53 77
resume_import() # usage: [pos=#] resume_import
54 78
{
55 79
	echo_func; kw_params pos
56 80
	if ! isset pos; then local pos; pos="$(import_resume_pos)"; fi
57 81
	
82
	^.preamble.sql/make
58 83
	use_local_remote
59
	echo_run tail -c +"$pos" "$top_file"|mysql
84
	# run connection preamble (first few lines of dumpfile) before continuing
85
	# with main file at offset, so that connection setting are reapplied
86
	(cat "$preamble_file"; echo_run tail -c +"$pos" "$top_file")|mysql
60 87
}
61 88

  
62 89
fi

Also available in: Unified diff