Skip to content

Commit

Permalink
Fix resolving of positional macros in item name in case of MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
i-ky committed Oct 21, 2019
1 parent e9eb5d4 commit affe913
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/history_influxdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ char *itemid_to_influx_data(zbx_uint64_t itemid)
// +------------------------------------------------+-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
// find first '[' and last ']' in the key_ and for what is between use substring_index() to extract correct parameter
"replace(replace(replace(replace(replace(replace(replace(replace(replace(i.name,"
" '$1', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 1)),"
" '$2', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 2)),"
" '$3', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 3)),"
" '$4', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 4)),"
" '$5', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 5)),"
" '$6', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 6)),"
" '$7', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 7)),"
" '$8', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 8)),"
" '$9', substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 9)),"
" '$1', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 1), ',', -1)),"
" '$2', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 2), ',', -1)),"
" '$3', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 3), ',', -1)),"
" '$4', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 4), ',', -1)),"
" '$5', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 5), ',', -1)),"
" '$6', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 6), ',', -1)),"
" '$7', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 7), ',', -1)),"
" '$8', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 8), ',', -1)),"
" '$9', substring_index(substring_index(substring(i.key_, position('[' in i.key_)+1, length(i.key_) - position('[' in i.key_) - position(']' in reverse(i.key_))), ',', 9), ',', -1)),"
// or use plain item name if no variables to replace
"i.name"
"), "
Expand Down

0 comments on commit affe913

Please sign in to comment.