split_pgdump 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/split_pgdump +13 -4
- metadata +1 -1
data/bin/split_pgdump
CHANGED
@@ -46,11 +46,14 @@ class CWorker
|
|
46
46
|
def process_schema_line(out, line)
|
47
47
|
if line =~ /^COPY (\w+) \(([^)]+)\) FROM stdin;/
|
48
48
|
table_name, columns = $1, $2.split(', ')
|
49
|
-
@table = Table.new(tables_dir, table_name, columns)
|
49
|
+
@table = Table.new(tables_dir, @schema, table_name, columns)
|
50
50
|
@tables << @table
|
51
51
|
puts "Start to write table #{table_name}" if $debug
|
52
52
|
@state = :table
|
53
53
|
else
|
54
|
+
if line =~ /^SET search_path = ([^,]+)/
|
55
|
+
@schema = $1
|
56
|
+
end
|
54
57
|
out.write line
|
55
58
|
end
|
56
59
|
end
|
@@ -70,6 +73,7 @@ class CWorker
|
|
70
73
|
@state = :schema
|
71
74
|
@table = nil
|
72
75
|
@tables = []
|
76
|
+
@schema = 'public'
|
73
77
|
|
74
78
|
File.open(output_file, 'w') do |out|
|
75
79
|
STDIN.each_line do |line|
|
@@ -196,9 +200,10 @@ class Table
|
|
196
200
|
end
|
197
201
|
|
198
202
|
attr_reader :name, :columns, :files, :sort_line
|
199
|
-
def initialize(dir, name, columns)
|
203
|
+
def initialize(dir, schema, name, columns)
|
200
204
|
@dir = dir
|
201
205
|
@table = name
|
206
|
+
@schema = schema
|
202
207
|
@columns = columns.map{|c| c.sub(/^"(.+)"$/, '\\1')}
|
203
208
|
if @rule = Worker.find_rule(name)
|
204
209
|
apply_rule
|
@@ -239,7 +244,7 @@ class Table
|
|
239
244
|
eval <<-"EOF"
|
240
245
|
def self.file_name(values)
|
241
246
|
name = %{#{split_string}}.gsub(/\\.\\.|\\s|\\?|\\*/, '_')
|
242
|
-
"
|
247
|
+
"\#{table_schema}/\#{name}.dat"
|
243
248
|
end
|
244
249
|
EOF
|
245
250
|
|
@@ -251,8 +256,12 @@ class Table
|
|
251
256
|
end
|
252
257
|
end
|
253
258
|
|
259
|
+
def table_schema
|
260
|
+
@schema == 'public' ? @table : "#@schema/#@table"
|
261
|
+
end
|
262
|
+
|
254
263
|
def file_name(values)
|
255
|
-
"
|
264
|
+
"#{table_schema}.dat"
|
256
265
|
end
|
257
266
|
|
258
267
|
def add_line(line)
|