#105·textql

Infinite loop generating newlines with semicolon and newline in the query

Author: v-from-meiroCreated Aug 15, 2018Updated Jan 21, 2021

Hello there!

I was working on a query and using textql (by the way, great job, thanks for this!) and noticed funny thing.

Usually the command I am using looks like this:

textql -header -output-header -sql "select distinct ex_account_id as account_id , substr( end_time ,1,10) as date , group_concat(case when name ='page_views_total' and period ='day' then value end) as page_views , group_concat(case when name ='page_fan_adds' and period ='day' then value end) as page_fan_adds , group_concat(case when name ='page_fan_removes' and period ='day' then value end) as page_fan_removes , group_concat(case when name ='page_impressions_unique' and period ='day' then value end) as page_reach , group_concat(case when name ='page_fans' and period ='lifetime' then value end) as page_fans from page_insights as pi group by ex_account_id , date " page_insights.csv

Now when you run it is all OK. But check what happens when you put semicolon followed by newline in the end of the query:

textql -header -output-header -sql "select distinct ex_account_id as account_id , substr( end_time ,1,10) as date , group_concat(case when name ='page_views_total' and period ='day' then value end) as page_views , group_concat(case when name ='page_fan_adds' and period ='day' then value end) as page_fan_adds , group_concat(case when name ='page_fan_removes' and period ='day' then value end) as page_fan_removes , group_concat(case when name ='page_impressions_unique' and period ='day' then value end) as page_reach , group_concat(case when name ='page_fans' and period ='lifetime' then value end) as page_fans from page_insights as pi group by ex_account_id , date; " page_insights.csv

When you run it, textql gets probably into an infinite loop and starts to generate a bunch of newlines in the end of an actual result. I ran this without knowing on a server an it crashed in few minutes because of disk space :-D

Let me know if it is just me or you too have this problem :)

Thanks and have a great day!