SHARE
TWEET

user vars, mysql 5.6, attempt I

a guest Aug 6th, 2017 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. define print_user_var
  3.     set $user_var=(user_var_entry*)($arg0)
  4.     printf "@%s\n",$user_var->entry_name.m_str
  5.     printf "----\n"
  6.     printf "   Unsigned: %d\n", (int)$user_var->unsigned_flag
  7.     printf "   Length  : %lu\n",(unsigned long)$user_var->m_length
  8.     set $type=""
  9.     if $user_var->m_type == 0
  10.         printf "   Type    : STRING_RESULT\n"
  11.         printf "   Value   : "
  12.         print $user_var->m_ptr
  13.     end
  14.     if $user_var->m_type == 1
  15.         printf "   Type    : REAL_RESULT\n"
  16.         printf "   Value   : %f\n", *(double*)$user_var->m_ptr
  17.     end
  18.     if $user_var->m_type == 2
  19.         printf "   Type    : INT_RESULT\n"
  20.         if $user_var->m_ptr
  21.           printf "   Value   : %d\n", *(long*)$user_var->m_ptr
  22.         else
  23.           printf "   Value   : null\n"
  24.         end
  25.             end
  26.     if $user_var->m_type == 3
  27.         printf "   Type    : ROW_RESULT\n"
  28.         printf "   Value   : %x\n",$user_var->m_ptr
  29.     end
  30.     if $user_var->m_type == 4
  31.         printf "   Type    : DECIMAL_RESULT\n"
  32.         #printf "   Value   : todo: print this decimal value...\n"
  33.         #if $user_var->m_ptr
  34.         #   print *(my_decimal*)$user_var->m_ptr
  35.         #   print "\n"
  36.         #else
  37.         #   printf "   Value   : null\n"
  38.         #end
  39.     end
  40. end
  41.  
  42. document print_user_var
  43.     print_user_var: Prints the given (user_var_entry*) pointer
  44. end
  45.  
  46. define print_user_vars56
  47.     set $thd=(THD*)($arg0)
  48.     set $user_vars=$thd->user_vars
  49.     set $records=$user_vars.records
  50.     set $array = (DYNAMIC_ARRAY) $user_vars.array
  51.     printf "------------------------------\n"
  52.     printf " User Variables               \n"
  53.     printf "------------------------------\n"
  54.     printf "Total Variables     : %lu\n\n",(unsigned long)$records
  55.     set $var_count = 0
  56.         while($var_count < $records)
  57.             set $hashlink = (struct st_hash_info*)((unsigned char*)($array.buffer) + sizeof(struct st_hash_info) * $var_count)
  58.             set $user_var = (user_var_entry*)$hashlink->data
  59.             print_user_var $user_var
  60.             printf "\n\n"
  61.             set $var_count=$var_count + 1
  62.         end
  63. end
  64.  
  65.  
  66.  
  67. document print_user_vars56
  68.     print_user_vars56: Prints user variables associated with the given thd object
  69. end
RAW Paste Data
Top