flydata 0.5.16 → 0.5.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 145b738aa44e8337c13b426d551c12d62d3f688b
4
- data.tar.gz: 9597729174fa3a8d1e55eed087eb77ebd3e39cfd
3
+ metadata.gz: db5ab3ad859c85fb9fcdb2171ad04b0f2e468eb9
4
+ data.tar.gz: 1225c311e10046702a2cf89b5b2d3f8114022ee9
5
5
  SHA512:
6
- metadata.gz: 62a90057efd34adb6be5187d932d53d961f80f4e3f6138baa8dba840aaa0e91e22be96ba58fb5ce117e89d74048a4eb234244e59dde2fbe1ff4d86be3f246ffa
7
- data.tar.gz: b0eb15b12279ea4865ef9bd93835bbddbb25a4b7d6b04d1711d14a470e6265224e7ded1c733866c9ea93fc1846e6327d5b116181611170ed54da151685eb59bf
6
+ metadata.gz: c4c2d116d3279e3794b510898bf385aa7aaa22703afdca15bfcae4d7574764ccaa84731b159a98cac7b745de1f46b6fc4e1cf547e06183ee8e46a2c1abc95b60
7
+ data.tar.gz: 746ccd2cc7cac24b1745e9c08a3184acaa9b7f37a0ed25f2015dd077acb997a3cf25caa812d17c0f78a5591d95b7dd618a38efb61e3f9722e7da13183df34825
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.16
1
+ 0.5.17
@@ -262,7 +262,7 @@ static VALUE rb_json_generate_kv_pairs(VALUE self, VALUE key_ary, VALUE value_ar
262
262
  }
263
263
  ss << "}";
264
264
 
265
- std::string str = ss.str();
265
+ const std::string& str = ss.str();
266
266
  VALUE json = rb_str_new(str.data(), str.size());
267
267
  int enc = rb_enc_find_index("UTF-8");
268
268
  rb_enc_associate_index(json, enc);
@@ -54,7 +54,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
54
54
  break;
55
55
 
56
56
  case value:
57
- if ($DEBUG) std::cout << "value[" << *current << "]: " << std::endl << std::flush;
57
+ if ($DEBUG) std::cout << "value[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
58
58
  if (*current == '\'') {
59
59
  status = first_char;
60
60
  } else if (*current == 'N') {
@@ -76,7 +76,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
76
76
  break;
77
77
 
78
78
  case first_zero:
79
- if ($DEBUG) std::cout << "first_zero[" << *current << "]: " << std::endl << std::flush;
79
+ if ($DEBUG) std::cout << "first_zero[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
80
80
  if (*current == ',') {
81
81
  ch.value_callback(mark, value_len - 1, true);//value_callback :end_value
82
82
  mark = 0; value_len = 0; //mark_reset
@@ -102,7 +102,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
102
102
  break;
103
103
 
104
104
  case leading_zero:
105
- if ($DEBUG) std::cout << "leading_zero[" << *current << "]: " << std::endl << std::flush;
105
+ if ($DEBUG) std::cout << "leading_zero[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
106
106
  if (*current == ',') {
107
107
  ch.value_callback(mark, value_len - 1, true);//value_callback :end_value
108
108
  mark = 0; value_len = 0; //mark_reset
@@ -126,7 +126,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
126
126
  break;
127
127
 
128
128
  case number:
129
- if ($DEBUG) std::cout << "number[" << *current << "]: " << std::endl << std::flush;
129
+ if ($DEBUG) std::cout << "number[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
130
130
  if ((*current >= '0' && *current <= '9') || *current == '.' || *current == 'e' || *current == 'E' || *current == '-') {
131
131
  status = number;
132
132
  } else if (*current == ',') {
@@ -144,7 +144,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
144
144
  break;
145
145
 
146
146
  case null_n:
147
- if ($DEBUG) std::cout << "null_n[" << *current << "]: " << std::endl << std::flush;
147
+ if ($DEBUG) std::cout << "null_n[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
148
148
  if (*current == 'U') {
149
149
  status = null_u;
150
150
  } else {
@@ -153,7 +153,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
153
153
  break;
154
154
 
155
155
  case null_u:
156
- if ($DEBUG) std::cout << "null_u[" << *current << "]: " << std::endl << std::flush;
156
+ if ($DEBUG) std::cout << "null_u[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
157
157
  if (*current == 'L') {
158
158
  status = null_l1;
159
159
  } else {
@@ -162,7 +162,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
162
162
  break;
163
163
 
164
164
  case null_l1:
165
- if ($DEBUG) std::cout << "null_l1[" << *current << "]: " << std::endl << std::flush;
165
+ if ($DEBUG) std::cout << "null_l1[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
166
166
  if (*current == 'L') {
167
167
  status = null_l2;
168
168
  } else {
@@ -171,7 +171,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
171
171
  break;
172
172
 
173
173
  case null_l2:
174
- if ($DEBUG) std::cout << "null_l2[" << *current << "]: " << std::endl << std::flush;
174
+ if ($DEBUG) std::cout << "null_l2[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
175
175
  if (*current == ',') {
176
176
  //# 0 is NULL pointer
177
177
  ch.value_callback(0, 0, true);//value_callback 0 :end_value
@@ -189,7 +189,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
189
189
  break;
190
190
 
191
191
  case hex_blob:
192
- if ($DEBUG) std::cout << "hex_blob[" << *current << "]: " << std::endl << std::flush;
192
+ if ($DEBUG) std::cout << "hex_blob[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
193
193
  if ((*current >= '0' && *current <= '9') ||
194
194
  (*current >= 'A' && *current <= 'F') ||
195
195
  (*current >= 'a' && *current <= 'f')) {
@@ -200,7 +200,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
200
200
  break;
201
201
 
202
202
  case hex_blob_number:
203
- if ($DEBUG) std::cout << "hex_blob_number[" << *current << "]: " << std::endl << std::flush;
203
+ if ($DEBUG) std::cout << "hex_blob_number[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
204
204
  if ((*current >= '0' && *current <= '9') ||
205
205
  (*current >= 'A' && *current <= 'F') ||
206
206
  (*current >= 'a' && *current <= 'f')) {
@@ -220,7 +220,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
220
220
  break;
221
221
 
222
222
  case first_char:
223
- if ($DEBUG) std::cout << "first_char[" << *current << "]: " << std::endl << std::flush;
223
+ if ($DEBUG) std::cout << "first_char[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
224
224
  if (*current == '\'') {
225
225
  mark = current; value_len = 1; //mark
226
226
  ch.value_callback(mark, value_len - 1, true);//value_callback, :end_value
@@ -248,8 +248,8 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
248
248
  break;
249
249
 
250
250
  case utf8_2_firstbyte:
251
- if ($DEBUG) std::cout << "utf8_2_firstbyte[" << *current << "]: " << std::endl << std::flush;
252
- if ((*current & 0xe0) == 0x80) {
251
+ if ($DEBUG) std::cout << "utf8_2_firstbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
252
+ if ((*current & 0xc0) == 0x80) {
253
253
  temp_mark = 0; //temp_mark reset)
254
254
  status = following_char;
255
255
  } else {
@@ -262,8 +262,8 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
262
262
  break;
263
263
 
264
264
  case utf8_3_firstbyte:
265
- if ($DEBUG) std::cout << "utf8_3_firstbyte[" << *current << "]: " << std::endl << std::flush;
266
- if ((*current & 0xe0) == 0x80) {
265
+ if ($DEBUG) std::cout << "utf8_3_firstbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
266
+ if ((*current & 0xc0) == 0x80) {
267
267
  status = utf8_3_secondbyte;
268
268
  } else {
269
269
  status = utf8_3_err_secondbyte;
@@ -271,8 +271,8 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
271
271
  break;
272
272
 
273
273
  case utf8_3_secondbyte:
274
- if ($DEBUG) std::cout << "utf8_3_secondbyte[" << *current << "]: " << std::endl << std::flush;
275
- if ((*current & 0xe0) == 0x80) {
274
+ if ($DEBUG) std::cout << "utf8_3_secondbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
275
+ if ((*current & 0xc0) == 0x80) {
276
276
  temp_mark = 0; //temp_mark reset)
277
277
  status = following_char;
278
278
  } else {
@@ -285,7 +285,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
285
285
  break;
286
286
 
287
287
  case utf8_3_err_secondbyte:
288
- if ($DEBUG) std::cout << "utf8_3_err_secondbyte[" << *current << "]: " << std::endl << std::flush;
288
+ if ($DEBUG) std::cout << "utf8_3_err_secondbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
289
289
  ch.value_callback(mark, temp_mark - mark, false);//value_callback mark...temp_mark
290
290
  mark = 0; value_len = 0; //mark_reset
291
291
  ch.value_callback("\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd", 9, false); //value_callback "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"
@@ -294,8 +294,8 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
294
294
  break;
295
295
 
296
296
  case utf8_4_firstbyte:
297
- if ($DEBUG) std::cout << "utf8_4_firstbyte[" << *current << "]: " << std::endl << std::flush;
298
- if ((*current & 0xe0) == 0x80) {
297
+ if ($DEBUG) std::cout << "utf8_4_firstbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
298
+ if ((*current & 0xc0) == 0x80) {
299
299
  status = utf8_4_secondbyte;
300
300
  } else {
301
301
  status = utf8_4_err_secondbyte;
@@ -303,8 +303,8 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
303
303
  break;
304
304
 
305
305
  case utf8_4_secondbyte:
306
- if ($DEBUG) std::cout << "utf8_4_secondbyte[" << *current << "]: " << std::endl << std::flush;
307
- if ((*current & 0xe0) == 0x80) {
306
+ if ($DEBUG) std::cout << "utf8_4_secondbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
307
+ if ((*current & 0xc0) == 0x80) {
308
308
  status = utf8_4_thirdbyte;
309
309
  } else {
310
310
  status = utf8_4_err_thirdbyte;
@@ -312,13 +312,13 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
312
312
  break;
313
313
 
314
314
  case utf8_4_err_secondbyte:
315
- if ($DEBUG) std::cout << "utf8_4_err_secondbyte[" << *current << "]: " << std::endl << std::flush;
315
+ if ($DEBUG) std::cout << "utf8_4_err_secondbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
316
316
  status = utf8_4_err_thirdbyte;
317
317
  break;
318
318
 
319
319
  case utf8_4_thirdbyte:
320
- if ($DEBUG) std::cout << "utf8_4_thirdbyte[" << *current << "]: " << std::endl << std::flush;
321
- if ((*current & 0xe0) == 0x80) {
320
+ if ($DEBUG) std::cout << "utf8_4_thirdbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
321
+ if ((*current & 0xc0) == 0x80) {
322
322
  temp_mark = 0; //temp_mark reset)
323
323
  status = following_char;
324
324
  } else {
@@ -331,7 +331,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
331
331
  break;
332
332
 
333
333
  case utf8_4_err_thirdbyte:
334
- if ($DEBUG) std::cout << "utf8_4_err_thirdbyte[" << *current << "]: " << std::endl << std::flush;
334
+ if ($DEBUG) std::cout << "utf8_4_err_thirdbyte[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
335
335
  ch.value_callback(mark, temp_mark - mark, false);//value_callback mark...temp_mark
336
336
  mark = 0; value_len = 0; //mark_reset
337
337
  ch.value_callback("\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd", 12, false); //value_callback "\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd"
@@ -340,7 +340,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
340
340
  break;
341
341
 
342
342
  case following_char:
343
- if ($DEBUG) std::cout << "following_char[" << *current << "]: " << std::endl << std::flush;
343
+ if ($DEBUG) std::cout << "following_char[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
344
344
  if (*current == '\'') {
345
345
  ch.value_callback(mark, value_len - 1, true);//value_callback, :end_value
346
346
  mark = 0; value_len = 0; //mark_reset
@@ -364,7 +364,7 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
364
364
  break;
365
365
 
366
366
  case escape:
367
- if ($DEBUG) std::cout << "escape[" << *current << "]: " << std::endl << std::flush;
367
+ if ($DEBUG) std::cout << "escape[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
368
368
  if (*current == '\"') {
369
369
  ch.value_callback("\"", 1, false);//value_callback '\"'
370
370
  mark = 0; value_len = 0;
@@ -401,12 +401,12 @@ long parse_insert_query(const char* sql, long len, ParserCallbackHandler& ch)
401
401
  break;
402
402
 
403
403
  case error:
404
- if ($DEBUG) std::cout << "error[" << *current << "]: " << std::endl << std::flush;
404
+ if ($DEBUG) std::cout << "error[" << *current << std::endl << std::flush;
405
405
  ret = pos - 1;
406
406
  break;
407
407
 
408
408
  default:
409
- if ($DEBUG) std::cout << "default[" << *current << "]: " << std::endl << std::flush;
409
+ if ($DEBUG) std::cout << "default[" << *current << "(0x" << std::hex << (*current & 0xff) << ")]: " << std::endl << std::flush;
410
410
  break;
411
411
  }//switch
412
412
  if (ret != -1)
data/flydata.gemspec CHANGED
Binary file
@@ -21,6 +21,13 @@ module ExclusiveRunnable
21
21
  begin
22
22
  info = self.class.load_exclusive_run_info
23
23
  if info
24
+ #TODO If the previous command terminates abnormally,
25
+ # 'exclusive_run.info' file won't be deleted even the pid
26
+ # doesn't exist anymore.
27
+ # This prevents execution of any commands afterwards, and
28
+ # the user will see this misleading error message.
29
+ # Introducing "--force-run" option can be a solution.
30
+
24
31
  raise "Command `#{info['command']}` is already running. Wait until the command completes or stop the command. (pid:#{info['pid']})"
25
32
  end
26
33
  exclusive_run_info = { command: self.class.command(method, options), pid: Process.pid }
@@ -177,6 +177,7 @@ EOS
177
177
  if @input_tables.empty? or @full_tables.empty? or @full_tables.all?{|ft| new_tables_after_reset.include?(ft)}
178
178
  delete_files << sync_fm.binlog_path
179
179
  delete_files << sync_fm.sent_binlog_path
180
+ delete_files << sync_fm.lock_pid_file
180
181
  end
181
182
  delete_files.flatten.each do |path|
182
183
  FileUtils.rm(path) if File.exists?(path)
@@ -240,6 +240,10 @@ module Flydata
240
240
  File.open(file) {|f| f.read}
241
241
  end
242
242
 
243
+ def lock_pid_file
244
+ FLYDATA_LOCK
245
+ end
246
+
243
247
  def sync_info_file
244
248
  File.join(dump_dir, "sync.info")
245
249
  end
@@ -291,7 +291,7 @@ CREATE TABLE `users_login` (
291
291
 
292
292
  LOCK TABLES `users_login` WRITE;
293
293
  /*!40000 ALTER TABLE `users_login` DISABLE KEYS */;
294
- INSERT INTO `users_login` VALUES (15,46,'moodier\xED\xB1\xA2','2001-10-02 08:18:08','1986-06-11 22:50:10'),(35,6,'missあいうえおteer','1991-10-15 19:38:07','1970-10-01 22:03:10'),(52,33,'sub\\\\field','1972-08-23 20:16:08','1974-10-10 23:28:11');
294
+ INSERT INTO `users_login` VALUES (15,46,'moodier\xED\xB1\x22','2001-10-02 08:18:08','1986-06-11 22:50:10'),(35,6,'missあいうえおteer','1991-10-15 19:38:07','1970-10-01 22:03:10'),(52,33,'sub\\\\field','1972-08-23 20:16:08','1974-10-10 23:28:11');
295
295
  INSERT INTO `users_login` VALUES (373,31,'out\\'swearing','1979-10-07 08:10:08','2006-02-22 16:26:04'),(493,8,'schizophrenic','1979-07-06 07:34:07','1970-08-09 01:21:01');
296
296
  /*!40000 ALTER TABLE `users_login` ENABLE KEYS */;
297
297
  UNLOCK TABLES;
@@ -1080,6 +1080,33 @@ EOS
1080
1080
  expect(subject).to eq([["test\x1ctest"]])
1081
1081
  end
1082
1082
  end
1083
+
1084
+ context 'with various characters' do
1085
+ context 'UTF-8 1 byte char' do
1086
+ let(:target_line) {"INSERT INTO `test_table` VALUES ('testtest');"}
1087
+ it 'should convert correctly' do
1088
+ expect(subject).to eq([["testtest"]])
1089
+ end
1090
+ end
1091
+ context 'UTF-8 2 byte char' do
1092
+ let(:target_line) {"INSERT INTO `test_table` VALUES ('testðtest');"}
1093
+ it 'should convert correctly' do
1094
+ expect(subject).to eq([["testðtest"]])
1095
+ end
1096
+ end
1097
+ context 'UTF-8 3 byte char' do
1098
+ let(:target_line) {"INSERT INTO `test_table` VALUES ('testあtest');"}
1099
+ it 'should convert correctly' do
1100
+ expect(subject).to eq([["testあtest"]])
1101
+ end
1102
+ end
1103
+ context 'UTF-8 4 byte char' do
1104
+ let(:target_line) {"INSERT INTO `test_table` VALUES ('test\xf0\x90\x85\x83test');"}
1105
+ it 'should convert correctly' do
1106
+ expect(subject).to eq([["test\xf0\x90\x85\x83test"]])
1107
+ end
1108
+ end
1109
+ end
1083
1110
  end
1084
1111
  end
1085
1112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flydata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.16
4
+ version: 0.5.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Fujikawa
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-11-02 00:00:00.000000000 Z
15
+ date: 2015-11-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rest-client