@note Note: The 'buf' parameter is necessary, even if it is unused here. - fix_fields functions has a "dummy" buffer large enough for the corresponding exec. (Thus we only have to check in fix_fields.) - Passing to check_stack_overrun() prevents the compiler from removing it. */
| 843 | - Passing to check_stack_overrun() prevents the compiler from removing it. |
| 844 | */ |
| 845 | bool check_stack_overrun(THD *thd, long margin, |
| 846 | uchar *buf __attribute__((unused))) |
| 847 | { |
| 848 | long stack_used; |
| 849 | DBUG_ASSERT(thd == current_thd); |
| 850 | if ((stack_used=used_stack(thd->thread_stack,(char*) &stack_used)) >= |
| 851 | (long) (my_thread_stack_size - margin)) |
| 852 | { |
| 853 | /* |
| 854 | Do not use stack for the message buffer to ensure correct |
| 855 | behaviour in cases we have close to no stack left. |
| 856 | */ |
| 857 | char* ebuff= new (std::nothrow) char[MYSQL_ERRMSG_SIZE]; |
| 858 | if (ebuff) { |
| 859 | my_snprintf(ebuff, MYSQL_ERRMSG_SIZE, ER(ER_STACK_OVERRUN_NEED_MORE), |
| 860 | stack_used, my_thread_stack_size, margin); |
| 861 | my_message(ER_STACK_OVERRUN_NEED_MORE, ebuff, MYF(ME_FATALERROR)); |
| 862 | delete [] ebuff; |
| 863 | } |
| 864 | return 1; |
| 865 | } |
| 866 | #ifndef DBUG_OFF |
| 867 | max_stack_used= max(max_stack_used, stack_used); |
| 868 | #endif |
| 869 | return 0; |
| 870 | } |
| 871 | |
| 872 | |
| 873 | #define MY_YACC_INIT 1000 // Start with big alloc |
no test coverage detected