From 939697f11dbfefb7531ed51ebd74785c8df1b184 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Thu, 9 Jul 2026 14:33:27 +0900 Subject: [PATCH 1/2] in_sql: fix all_tables crash by passing a Config::Element to TableElement#configure all_tables built each discovered table by passing a plain Hash to TableElement#configure, but Fluent::Configurable#configure expects a Fluent::Config::Element and calls #corresponding_proxies on it, so every discovered table raised NoMethodError and #start failed. Wrap the attributes in a Fluent::Config::Element. update_column defaults to nil, so it no longer needs to be passed explicitly. Fixes #177 Signed-off-by: Shizuo Fujita --- lib/fluent/plugin/in_sql.rb | 5 ++--- test/plugin/test_in_sql.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/fluent/plugin/in_sql.rb b/lib/fluent/plugin/in_sql.rb index 2478bd1..f93d21d 100644 --- a/lib/fluent/plugin/in_sql.rb +++ b/lib/fluent/plugin/in_sql.rb @@ -219,11 +219,10 @@ def start nil else te = TableElement.new - te.configure({ + te.configure(Fluent::Config::Element.new('table', '', { 'table' => table_name, 'tag' => table_name, - 'update_column' => nil, - }) + }, [])) te end end.compact diff --git a/test/plugin/test_in_sql.rb b/test/plugin/test_in_sql.rb index ddb0db5..875f208 100644 --- a/test/plugin/test_in_sql.rb +++ b/test/plugin/test_in_sql.rb @@ -30,6 +30,22 @@ def teardown ] + ALL_TABLES_CONFIG = %[ + adapter postgresql + host localhost + port 5432 + database fluentd_test + + username fluentd + password fluentd + + schema_search_path public + + tag_prefix db + + all_tables true + ] + def create_driver(conf = CONFIG) Fluent::Test::Driver::Input.new(Fluent::Plugin::SQLInput).configure(conf) end @@ -64,6 +80,18 @@ def test_configure assert_equal("logs", messages.tag) end + def test_all_tables + d = create_driver(ALL_TABLES_CONFIG) + d.instance.start + begin + table_names = d.instance.instance_variable_get(:@tables).map(&:table) + assert { table_names.include?("messages") } + assert { !table_names.include?("schema_migrations") } + ensure + d.instance.shutdown + end + end + def test_message d = create_driver(CONFIG + "select_interval 1") Message.create!(message: "message 1") From 5c88dee713510b7ab54a01e0ea590387c5db2536 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Fri, 10 Jul 2026 13:38:16 +0900 Subject: [PATCH 2/2] Use SKIP_TABLE_REGEXP instead Co-authored-by: Kentaro Hayashi Signed-off-by: Shizuo Fujita --- test/plugin/test_in_sql.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/test_in_sql.rb b/test/plugin/test_in_sql.rb index 875f208..1ad29e8 100644 --- a/test/plugin/test_in_sql.rb +++ b/test/plugin/test_in_sql.rb @@ -86,7 +86,7 @@ def test_all_tables begin table_names = d.instance.instance_variable_get(:@tables).map(&:table) assert { table_names.include?("messages") } - assert { !table_names.include?("schema_migrations") } + assert { table_names.none? { |table_name| table_name.match?(Fluent::Plugin::SQLInput::SKIP_TABLE_REGEXP) }} ensure d.instance.shutdown end