MCPcopy Create free account
hub / github.com/MariaDB/server / make_cond

Function make_cond

plugin/feedback/feedback.cc:90–134  ·  view source on GitHub ↗

Generate the COND tree for the condition pushdown This function takes a list of strings and generates an Item tree corresponding to the following expression: field LIKE str1 OR field LIKE str2 OR field LIKE str3 OR ... where 'field' is the first field in the table - VARIABLE_NAME field - and str1, str2... are strings from the list. This condition is used to filter the selected ro

Source from the content-addressed store, hash-verified

88 SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE ...
89*/
90static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
91{
92 Item_cond_or *res= NULL;
93 /* A reference to this context will be stored in Item_field */
94 Name_resolution_context *nrc= new (thd->mem_root) Name_resolution_context;
95 LEX_CSTRING &db= tables->db;
96 LEX_CSTRING &table= tables->alias;
97 LEX_CSTRING &field= tables->table->field[0]->field_name;
98 CHARSET_INFO *cs= &my_charset_latin1;
99
100 if (!filter->str || !nrc)
101 return 0;
102
103 nrc->resolve_in_table_list_only(tables);
104 nrc->select_lex= tables->select_lex;
105
106 res= new (thd->mem_root) Item_cond_or(thd);
107 if (!res)
108 return OOM;
109
110 for (; filter->str; filter++)
111 {
112 Item_field *fld= new (thd->mem_root) Item_field(thd, nrc, db, table,
113 field);
114 Item_string *pattern= new (thd->mem_root) Item_string(thd, filter->str,
115 (uint) filter->length, cs);
116 Item_string *escape= new (thd->mem_root) Item_string(thd, "\\", 1, cs);
117
118 if (!fld || !pattern || !escape)
119 return OOM;
120
121 Item_func_like *like= new (thd->mem_root) Item_func_like(thd, fld, pattern,
122 escape, 0);
123
124 if (!like)
125 return OOM;
126
127 res->add(like, thd->mem_root);
128 }
129
130 if (res->fix_fields(thd, (Item**)&res))
131 return OOM;
132
133 return res;
134}
135
136/**
137 System variables that we want to see in the feedback report

Callers 1

fill_feedbackFunction · 0.85

Calls 3

addMethod · 0.45
fix_fieldsMethod · 0.45

Tested by

no test coverage detected