flydata 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/flydata-core/.gitignore +16 -0
  4. data/flydata-core/.rspec +1 -0
  5. data/flydata-core/.travis.yml +6 -0
  6. data/flydata-core/Gemfile +11 -0
  7. data/flydata-core/Gemfile.lock +51 -0
  8. data/flydata-core/lib/flydata-core/core_ext/module/include.rb +5 -0
  9. data/flydata-core/lib/flydata-core/core_ext/module.rb +1 -0
  10. data/flydata-core/lib/flydata-core/core_ext/object/prepend.rb +17 -0
  11. data/flydata-core/lib/flydata-core/core_ext/object.rb +1 -0
  12. data/flydata-core/lib/flydata-core/core_ext.rb +3 -0
  13. data/flydata-core/lib/flydata-core/errors.rb +334 -0
  14. data/flydata-core/lib/flydata-core/logger.rb +205 -0
  15. data/{lib/flydata → flydata-core/lib/flydata-core}/table_def/mysql_table_def.rb +6 -8
  16. data/{lib/flydata → flydata-core/lib/flydata-core}/table_def/redshift_table_def.rb +17 -2
  17. data/flydata-core/lib/flydata-core/table_def.rb +2 -0
  18. data/flydata-core/lib/flydata-core/thread_context.rb +31 -0
  19. data/flydata-core/lib/flydata-core.rb +1 -0
  20. data/flydata-core/spec/spec_helper.rb +2 -0
  21. data/{spec/flydata → flydata-core/spec}/table_def/mysql_table_def_spec.rb +22 -8
  22. data/flydata-core/spec/table_def/mysql_to_redshift_table_def_spec.rb +428 -0
  23. data/flydata-core/spec/table_def/mysqldump_test_bit_table.dump +51 -0
  24. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_foreign_key.dump +0 -0
  25. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_table_all.dump +0 -0
  26. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_table_column_comment.dump +0 -0
  27. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_table_enum.dump +0 -0
  28. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_table_multi_pk.dump +0 -0
  29. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_table_no_pk.dump +0 -0
  30. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_unique_key.dump +0 -0
  31. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_unique_key2.dump +0 -0
  32. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_unique_key3.dump +0 -0
  33. data/{spec/flydata → flydata-core/spec}/table_def/mysqldump_test_unsigned.dump +0 -0
  34. data/{spec/flydata → flydata-core/spec}/table_def/redshift_table_def_spec.rb +63 -16
  35. data/flydata.gemspec +34 -18
  36. data/lib/flydata/command/sync.rb +11 -8
  37. data/lib/flydata/parser/mysql/mysql_alter_table.treetop +128 -18
  38. data/lib/flydata/parser_provider.rb +1 -1
  39. data/lib/flydata.rb +11 -1
  40. data/spec/flydata/parser/mysql/alter_table_parser_spec.rb +173 -2
  41. data/spec/spec_helper.rb +3 -1
  42. metadata +34 -18
  43. data/.gitignore +0 -49
  44. data/lib/flydata/table_def.rb +0 -2
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
- require 'flydata/table_def'
2
+ require 'flydata-core/table_def'
3
3
 
4
- module Flydata
4
+ module FlydataCore
5
5
  module TableDef
6
6
 
7
7
  describe RedshiftTableDef do
@@ -233,7 +233,7 @@ EOT
233
233
  it_behaves_like *examples
234
234
  end
235
235
  end
236
-
236
+
237
237
  context 'with medium blob column def' do
238
238
  context 'when size exceeds max size' do
239
239
  let(:default_value) { "something" }
@@ -246,9 +246,9 @@ EOT
246
246
  let(:type_sql) { %Q|"col_medium_blob" varchar(65535)| }
247
247
 
248
248
  it_behaves_like *examples
249
- end
249
+ end
250
250
  end
251
-
251
+
252
252
  context 'with unsigned column def' do
253
253
  let(:default_value) { 4 }
254
254
  let(:default_value_sql) { "'#{default_value}'" }
@@ -312,8 +312,8 @@ EOT
312
312
 
313
313
  context 'with decimal column def' do
314
314
  context 'when precision exceeds max allowed' do
315
- let(:default_value) { 4 }
316
- let(:default_value_sql) { "'#{default_value}'" }
315
+ let(:default_value) { "'4'" }
316
+ let(:default_value_sql) { default_value }
317
317
  let(:not_null_default_sql) { " DEFAULT '0'" }
318
318
  before do
319
319
  column[:column] = "value"
@@ -324,8 +324,8 @@ EOT
324
324
  it_behaves_like *examples
325
325
  end
326
326
  context 'when scale exceeds max allowed' do #not possible
327
- let(:default_value) { 4 }
328
- let(:default_value_sql) { "'#{default_value}'" }
327
+ let(:default_value) { "'4'" }
328
+ let(:default_value_sql) { default_value }
329
329
  let(:not_null_default_sql) { " DEFAULT '0'" }
330
330
  before do
331
331
  column[:column] = "value"
@@ -337,8 +337,8 @@ EOT
337
337
  end
338
338
 
339
339
  context 'when precision and scale exceeds max allowed (for unsigned)' do
340
- let(:default_value) { 4 }
341
- let(:default_value_sql) { "'#{default_value}'" }
340
+ let(:default_value) { "'4'" }
341
+ let(:default_value_sql) { default_value }
342
342
  let(:not_null_default_sql) { " DEFAULT '0'" }
343
343
  before do
344
344
  column[:column] = "value"
@@ -350,8 +350,8 @@ EOT
350
350
  end
351
351
 
352
352
  context 'when precision and scale are within limit (for unsigned)' do
353
- let(:default_value) { 4 }
354
- let(:default_value_sql) { "'#{default_value}'" }
353
+ let(:default_value) { "'4'" }
354
+ let(:default_value_sql) { default_value }
355
355
  let(:not_null_default_sql) { " DEFAULT '0'" }
356
356
  before do
357
357
  column[:column] = "value"
@@ -362,6 +362,52 @@ EOT
362
362
  it_behaves_like *examples
363
363
  end
364
364
  end
365
+
366
+ context 'with bit column def' do
367
+ before do
368
+ column[:column] = "value_bit"
369
+ column[:type] = "bit(1)"
370
+ end
371
+ let(:type_sql) { %Q|"value_bit" bigint| }
372
+ let(:not_null_default_sql) { " DEFAULT '0'" }
373
+
374
+ context 'when default_value is small bit' do
375
+ let(:default_value) { "b'1'" }
376
+ let(:default_value_sql) { "1" }
377
+ it_behaves_like *examples
378
+ end
379
+
380
+ context 'when default_value is large bit' do
381
+ let(:default_value) { "b'10110'" }
382
+ let(:default_value_sql) { "22" }
383
+ it_behaves_like *examples
384
+ end
385
+
386
+ # it's not real case
387
+ context "when default_value is x'' format" do
388
+ let(:default_value) { "x'12'" }
389
+ let(:default_value_sql) { "18" }
390
+ it_behaves_like *examples
391
+ end
392
+
393
+ context "when default_value is X'' format" do
394
+ let(:default_value) { "X'2a'" }
395
+ let(:default_value_sql) { "42" }
396
+ it_behaves_like *examples
397
+ end
398
+
399
+ context 'when default_value is 0x format' do
400
+ let(:default_value) { "0x0013" }
401
+ let(:default_value_sql) { "19" }
402
+ it_behaves_like *examples
403
+ end
404
+
405
+ context 'when default_value is 0b format' do
406
+ let(:default_value) { "0b1011" }
407
+ let(:default_value_sql) { "11" }
408
+ it_behaves_like *examples
409
+ end
410
+ end
365
411
  end
366
412
 
367
413
  context 'for create table' do
@@ -378,7 +424,7 @@ EOT
378
424
  context "without not null" do
379
425
  let(:expected_query) { %Q| #{type_sql}#{default_sql}| }
380
426
  let(:no_default_sql) { "" }
381
-
427
+
382
428
  it_behaves_like "test column types", "default values", "test generated Redshift SQL for column"
383
429
  end
384
430
  context "with not null false" do
@@ -387,16 +433,17 @@ EOT
387
433
  column[:not_null] = false
388
434
  end
389
435
  let(:no_default_sql) { "" }
390
-
436
+
391
437
  it_behaves_like "test column types", "default values", "test generated Redshift SQL for column"
392
438
  end
439
+
393
440
  context "with not null true" do
394
441
  let(:expected_query) { %Q| #{type_sql} NOT NULL#{default_sql}| }
395
442
  before do
396
443
  column[:not_null] = true
397
444
  end
398
445
  let(:no_default_sql) { not_null_default_sql }
399
-
446
+
400
447
  it_behaves_like "test column types", "default values", "test generated Redshift SQL for column"
401
448
  end
402
449
  end
data/flydata.gemspec CHANGED
@@ -5,16 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "flydata"
8
- s.version = "0.2.17"
8
+ s.version = "0.2.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
12
- s.date = "2014-11-24"
12
+ s.date = "2014-11-27"
13
13
  s.description = "FlyData Agent"
14
14
  s.email = "sysadmin@flydata.com"
15
15
  s.executables = ["fdmysqldump", "flydata", "serverinfo"]
16
16
  s.files = [
17
- ".gitignore",
18
17
  ".rspec",
19
18
  "Gemfile",
20
19
  "Gemfile.lock",
@@ -28,6 +27,38 @@ Gem::Specification.new do |s|
28
27
  "bin/fdmysqldump",
29
28
  "bin/flydata",
30
29
  "bin/serverinfo",
30
+ "flydata-core/.gitignore",
31
+ "flydata-core/.rspec",
32
+ "flydata-core/.travis.yml",
33
+ "flydata-core/Gemfile",
34
+ "flydata-core/Gemfile.lock",
35
+ "flydata-core/lib/flydata-core.rb",
36
+ "flydata-core/lib/flydata-core/core_ext.rb",
37
+ "flydata-core/lib/flydata-core/core_ext/module.rb",
38
+ "flydata-core/lib/flydata-core/core_ext/module/include.rb",
39
+ "flydata-core/lib/flydata-core/core_ext/object.rb",
40
+ "flydata-core/lib/flydata-core/core_ext/object/prepend.rb",
41
+ "flydata-core/lib/flydata-core/errors.rb",
42
+ "flydata-core/lib/flydata-core/logger.rb",
43
+ "flydata-core/lib/flydata-core/table_def.rb",
44
+ "flydata-core/lib/flydata-core/table_def/mysql_table_def.rb",
45
+ "flydata-core/lib/flydata-core/table_def/redshift_table_def.rb",
46
+ "flydata-core/lib/flydata-core/thread_context.rb",
47
+ "flydata-core/spec/spec_helper.rb",
48
+ "flydata-core/spec/table_def/mysql_table_def_spec.rb",
49
+ "flydata-core/spec/table_def/mysql_to_redshift_table_def_spec.rb",
50
+ "flydata-core/spec/table_def/mysqldump_test_bit_table.dump",
51
+ "flydata-core/spec/table_def/mysqldump_test_foreign_key.dump",
52
+ "flydata-core/spec/table_def/mysqldump_test_table_all.dump",
53
+ "flydata-core/spec/table_def/mysqldump_test_table_column_comment.dump",
54
+ "flydata-core/spec/table_def/mysqldump_test_table_enum.dump",
55
+ "flydata-core/spec/table_def/mysqldump_test_table_multi_pk.dump",
56
+ "flydata-core/spec/table_def/mysqldump_test_table_no_pk.dump",
57
+ "flydata-core/spec/table_def/mysqldump_test_unique_key.dump",
58
+ "flydata-core/spec/table_def/mysqldump_test_unique_key2.dump",
59
+ "flydata-core/spec/table_def/mysqldump_test_unique_key3.dump",
60
+ "flydata-core/spec/table_def/mysqldump_test_unsigned.dump",
61
+ "flydata-core/spec/table_def/redshift_table_def_spec.rb",
31
62
  "flydata.gemspec",
32
63
  "lib/fly_data_model.rb",
33
64
  "lib/flydata.rb",
@@ -83,9 +114,6 @@ Gem::Specification.new do |s|
83
114
  "lib/flydata/preference/data_entry_preference.rb",
84
115
  "lib/flydata/proxy.rb",
85
116
  "lib/flydata/sync_file_manager.rb",
86
- "lib/flydata/table_def.rb",
87
- "lib/flydata/table_def/mysql_table_def.rb",
88
- "lib/flydata/table_def/redshift_table_def.rb",
89
117
  "lib/flydata/util/encryptor.rb",
90
118
  "spec/fluent_plugins_spec_helper.rb",
91
119
  "spec/fly_data_model_spec.rb",
@@ -103,18 +131,6 @@ Gem::Specification.new do |s|
103
131
  "spec/flydata/parser/mysql/alter_table_parser_spec.rb",
104
132
  "spec/flydata/parser/mysql/dump_parser_spec.rb",
105
133
  "spec/flydata/sync_file_manager_spec.rb",
106
- "spec/flydata/table_def/mysql_table_def_spec.rb",
107
- "spec/flydata/table_def/mysqldump_test_foreign_key.dump",
108
- "spec/flydata/table_def/mysqldump_test_table_all.dump",
109
- "spec/flydata/table_def/mysqldump_test_table_column_comment.dump",
110
- "spec/flydata/table_def/mysqldump_test_table_enum.dump",
111
- "spec/flydata/table_def/mysqldump_test_table_multi_pk.dump",
112
- "spec/flydata/table_def/mysqldump_test_table_no_pk.dump",
113
- "spec/flydata/table_def/mysqldump_test_unique_key.dump",
114
- "spec/flydata/table_def/mysqldump_test_unique_key2.dump",
115
- "spec/flydata/table_def/mysqldump_test_unique_key3.dump",
116
- "spec/flydata/table_def/mysqldump_test_unsigned.dump",
117
- "spec/flydata/table_def/redshift_table_def_spec.rb",
118
134
  "spec/flydata/util/encryptor_spec.rb",
119
135
  "spec/flydata_spec.rb",
120
136
  "spec/spec_helper.rb",
@@ -5,9 +5,9 @@ require 'mysql2'
5
5
  require 'flydata/sync_file_manager'
6
6
  require 'flydata/agent_errors'
7
7
  require 'flydata/compatibility_check'
8
- require 'flydata/table_def'
9
8
  require 'flydata/output/forwarder'
10
9
  require 'flydata/parser/mysql/dump_parser'
10
+ require 'flydata-core/table_def'
11
11
  #require 'ruby-prof'
12
12
 
13
13
  module Flydata
@@ -26,6 +26,7 @@ module Flydata
26
26
  on 'c', 'skip-cleanup', 'Skip server cleanup'
27
27
  on 'y', 'yes', 'Skip command prompt assuming yes to all questions. Use this for batch operation.'
28
28
  on 'd', 'dump-file', 'Dump mysqldump into a file. Use this for debugging after making sure the free space.'
29
+ on 'n', 'no-flydata-start', 'Don\'t start the flydata agent after initial sync.'
29
30
  end
30
31
  end
31
32
 
@@ -150,6 +151,7 @@ module Flydata
150
151
  Slop.new do
151
152
  on 'c', 'ctl-only', 'Only generate FlyData Control definitions'
152
153
  on 'y', 'yes', 'Skip command prompt assuming yes to all questions. Use this for batch operation.'
154
+ on 's', 'skip-primary-key-check', 'Skip primary key check when generating DDL'
153
155
  end
154
156
  end
155
157
 
@@ -241,14 +243,14 @@ module Flydata
241
243
  create_flydata_ctl_table = mp['initial_sync']
242
244
  while !stdout.eof?
243
245
  begin
244
- mysql_tabledef = Flydata::TableDef::MysqlTableDef.create(stdout)
246
+ mysql_tabledef = FlydataCore::TableDef::MysqlTableDef.create(stdout, skip_primary_key_check: opts.skip_primary_key_check?)
245
247
  if mysql_tabledef.nil?
246
248
  # stream had no more create table definition
247
249
  break
248
250
  end
249
251
  flydata_tabledef = mysql_tabledef.to_flydata_tabledef
250
- puts Flydata::TableDef::RedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_ctl_table: create_flydata_ctl_table, schema_name: schema_name, ctl_only: opts.ctl_only?)
251
- rescue TableDefError=> e
252
+ puts FlydataCore::TableDef::RedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_ctl_table: create_flydata_ctl_table, schema_name: schema_name, ctl_only: opts.ctl_only?)
253
+ rescue FlydataCore::TableDefError=> e
252
254
  error_list << e.err_hash
253
255
  next
254
256
  end
@@ -515,16 +517,17 @@ Thank you for using FlyData!
515
517
  sync_fm = Flydata::FileUtil::SyncFileManager.new(de)
516
518
  info = sync_fm.load_dump_pos
517
519
  if info[:status] == STATUS_COMPLETE
518
- puts "Starting FlyData Agent..."
519
520
  if de['mysql_data_entry_preference']['initial_sync']
520
521
  sync_fm.save_binlog(info[:binlog_pos])
521
522
  end
522
523
  sync_fm.move_table_binlog_files(de['mysql_data_entry_preference']['tables'].split(','))
523
524
  sync_fm.reset_table_position_files(de['mysql_data_entry_preference']['tables'].split(','))
524
525
  sync_fm.backup_dump_dir
525
- Flydata::Command::Sender.new.start(quiet: true)
526
- puts " -> Done"
527
-
526
+ unless opts.no_flydata_start?
527
+ puts "Starting FlyData Agent..."
528
+ Flydata::Command::Sender.new.start(quiet: true)
529
+ puts " -> Done"
530
+ end
528
531
  dashboard_url = "#{flydata.flydata_api_host}/dashboard"
529
532
  redshift_console_url = "#{flydata.flydata_api_host}/redshift_clusters/query/new"
530
533
  last_message = ALL_DONE_MESSAGE_TEMPLATE % [redshift_console_url, dashboard_url]
@@ -10,7 +10,7 @@
10
10
  # - ADD COLUMN (col_name, col_def, ...)
11
11
  # - DROP COLUMN col_name
12
12
 
13
- require 'flydata/table_def/mysql_table_def'
13
+ require 'flydata-core/table_def/mysql_table_def'
14
14
 
15
15
  grammar MysqlAlterTable
16
16
 
@@ -182,6 +182,20 @@ grammar MysqlAlterTable
182
182
  }
183
183
  end
184
184
  }
185
+ / alter_sym opt_column sp field_ident sp set_sym sp default_sym sp signed_literal {
186
+ def action
187
+ { action: :alter_column,
188
+ support_level: :nonbreaking,
189
+ }
190
+ end
191
+ }
192
+ / alter_sym opt_column sp field_ident sp drop_sym sp default_sym {
193
+ def action
194
+ { action: :alter_column,
195
+ support_level: :nonbreaking,
196
+ }
197
+ end
198
+ }
185
199
  / rename_sym opt_to nsp table_ident {
186
200
  def action
187
201
  { action: :rename_table }
@@ -202,13 +216,27 @@ grammar MysqlAlterTable
202
216
  { action: :default_charset }
203
217
  end
204
218
  }
205
- /force_sym {
219
+ / force_sym {
206
220
  def action
207
221
  { action: :force,
208
222
  support_level: :nonbreaking,
209
223
  }
210
224
  end
211
225
  }
226
+ / alter_algorithm_option {
227
+ def action
228
+ { action: :algorithm,
229
+ support_level: :nonbreaking
230
+ }
231
+ end
232
+ }
233
+ / alter_lock_option {
234
+ def action
235
+ { action: :lock,
236
+ support_level: :nonbreaking
237
+ }
238
+ end
239
+ }
212
240
  / [^,]+ {
213
241
  def action
214
242
  raise "unsupported ALTER TABLE query. Contact FlyData Support"
@@ -309,7 +337,20 @@ grammar MysqlAlterTable
309
337
  end
310
338
  end
311
339
  }
312
- / opt_constraint 'foreign'i key_sym opt_ident nsp '(' key_list ')' sp references
340
+ / constraint_sym sp foreign_sym sp key_sym opt_ident nsp '(' key_list ')' sp references {
341
+ def action
342
+ { action: :add_foreign_key_constraint,
343
+ support_level: :nonbreaking,
344
+ }
345
+ end
346
+ }
347
+ / opt_constraint foreign_sym sp key_sym opt_ident nsp '(' key_list ')' sp references {
348
+ def action
349
+ { action: :add_foreign_key_constraint,
350
+ support_level: :nonbreaking,
351
+ }
352
+ end
353
+ }
313
354
  / constraint_sym sp check_constraint {
314
355
  def action
315
356
  { action: :add_check_constraint,
@@ -335,7 +376,7 @@ grammar MysqlAlterTable
335
376
  end
336
377
 
337
378
  rule references
338
- 'references'i sp table_ident opt_ref_list opt_match_clause opt_on_update_delete
379
+ references_sym sp table_ident opt_ref_list opt_match_clause opt_on_update_delete
339
380
  end
340
381
 
341
382
  rule table_ident
@@ -354,25 +395,25 @@ grammar MysqlAlterTable
354
395
  end
355
396
 
356
397
  rule opt_match_clause
357
- ( sp ( 'match'i sp 'full'i / 'match'i sp 'partial'i / 'match'i sp 'simple'i ) )?
398
+ ( sp ( match_sym sp full_sym / match_sym sp partial_sym / match_sym sp simple_sym ) )?
358
399
  end
359
400
 
360
401
  rule opt_on_update_delete
361
402
  ( sp (
362
- 'on'i sp 'update'i delete_option sp 'on'i sp 'delete'i sp delete_option
363
- / 'on'i sp 'delete'i delete_option sp 'on'i sp 'update'i sp delete_option
364
- / 'on'i sp 'update'i sp delete_option
365
- / 'on'i sp 'delete'i sp delete_option
403
+ on_sym sp update_sym sp delete_option sp on_sym sp delete_sym sp delete_option
404
+ / on_sym sp delete_sym sp delete_option sp on_sym sp update_sym sp delete_option
405
+ / on_sym sp update_sym sp delete_option
406
+ / on_sym sp delete_sym sp delete_option
366
407
  )
367
408
  )?
368
409
  end
369
410
 
370
411
  rule delete_option
371
- 'restrict'i
372
- / 'cascade'i
373
- / 'set'i sp 'null'i
374
- / 'no'i sp 'action'i
375
- / 'set'i sp 'default'i
412
+ restrict_sym
413
+ / cascade_sym
414
+ / set_sym sp null_sym
415
+ / no_sym sp action_sym
416
+ / set_sym sp default_sym
376
417
  end
377
418
 
378
419
  rule opt_constraint
@@ -384,7 +425,7 @@ grammar MysqlAlterTable
384
425
  end
385
426
 
386
427
  rule constraint_sym
387
- 'constraint'i
428
+ 'constraint'i ![A-Za-z0-9_]
388
429
  end
389
430
 
390
431
  rule constraint_key_type
@@ -407,7 +448,7 @@ grammar MysqlAlterTable
407
448
  end
408
449
 
409
450
  rule key_sym
410
- 'key'i
451
+ 'key'i ![A-Za-z0-9_]
411
452
  end
412
453
 
413
454
  rule keys_sym
@@ -431,7 +472,55 @@ grammar MysqlAlterTable
431
472
  end
432
473
 
433
474
  rule foreign_sym
434
- 'foreign'i
475
+ 'foreign'i ![A-Za-z0-9_]
476
+ end
477
+
478
+ rule references_sym
479
+ 'references'i ![A-Za-z0-9_]
480
+ end
481
+
482
+ rule on_sym
483
+ 'on'i ![A-Za-z0-9_]
484
+ end
485
+
486
+ rule match_sym
487
+ 'match'i ![A-Za-z0-9_]
488
+ end
489
+
490
+ rule full_sym
491
+ 'full'i ![A-Za-z0-9_]
492
+ end
493
+
494
+ rule partial_sym
495
+ 'partial'i ![A-Za-z0-9_]
496
+ end
497
+
498
+ rule simple_sym
499
+ 'simple'i ![A-Za-z0-9_]
500
+ end
501
+
502
+ rule update_sym
503
+ 'update'i ![A-Za-z0-9_]
504
+ end
505
+
506
+ rule delete_sym
507
+ 'delete'i ![A-Za-z0-9_]
508
+ end
509
+
510
+ rule restrict_sym
511
+ 'restrict'i ![A-Za-z0-9_]
512
+ end
513
+
514
+ rule cascade_sym
515
+ 'cascade'i ![A-Za-z0-9_]
516
+ end
517
+
518
+ rule no_sym
519
+ 'no'i ![A-Za-z0-9_]
520
+ end
521
+
522
+ rule action_sym
523
+ 'action'i ![A-Za-z0-9_]
435
524
  end
436
525
 
437
526
  rule fulltext
@@ -649,7 +738,7 @@ grammar MysqlAlterTable
649
738
  def data_type
650
739
  meta = (meta_text.text_value.size > 1) ? meta_text.text_value : ''
651
740
  type = data_type_name.text_value.downcase + meta
652
- type = Flydata::TableDef::MysqlTableDef.convert_to_flydata_type(type)
741
+ type = FlydataCore::TableDef::MysqlTableDef.convert_to_flydata_type(type)
653
742
  type << " unsigned" if !unsigned.terminal?
654
743
  ret = { type: type }
655
744
  ret[:zefofill] = true if !zerofill.terminal?
@@ -1357,4 +1446,25 @@ grammar MysqlAlterTable
1357
1446
  ( sp column_sym )?
1358
1447
  end
1359
1448
 
1449
+ rule alter_algorithm_option
1450
+ algorithm_sym opt_equal nsp default_sym
1451
+ / algorithm_sym opt_equal nsp ident
1452
+ end
1453
+
1454
+ rule algorithm_sym
1455
+ 'algorithm'i ![A-Za-z0-9_]
1456
+ end
1457
+
1458
+ rule alter_sym
1459
+ 'alter'i ![A-Za-z0-9_]
1460
+ end
1461
+
1462
+ rule lock_sym
1463
+ 'lock'i ![A-Za-z0-9_]
1464
+ end
1465
+
1466
+ rule alter_lock_option
1467
+ lock_sym opt_equal nsp default_sym
1468
+ / lock_sym opt_equal nsp ident
1469
+ end
1360
1470
  end
@@ -1,6 +1,6 @@
1
1
  require 'thread'
2
2
  require 'treetop'
3
- require 'flydata/table_def'
3
+ require 'flydata-core/table_def'
4
4
 
5
5
  module Mysql
6
6
  class ParserProvider
data/lib/flydata.rb CHANGED
@@ -1,4 +1,14 @@
1
- # common
1
+ # load_path settings
2
+ def append_load_path_if_not_exist(new_lib_path)
3
+ absolute_path = File.realpath(new_lib_path)
4
+ $LOAD_PATH.unshift absolute_path unless $LOAD_PATH.include? absolute_path
5
+ end
6
+ flydata_top_dir = File.realpath('../../', __FILE__)
7
+ flydata_core_dir = File.join(flydata_top_dir, 'flydata-core')
8
+ flydata_core_lib_dir = File.realpath('lib', flydata_core_dir)
9
+ append_load_path_if_not_exist(flydata_core_lib_dir)
10
+
11
+ # require common libs
2
12
  require 'active_support/core_ext/string'
3
13
  require 'active_support/dependencies'
4
14
  require 'active_support/time'