MCPcopy Create free account
hub / github.com/apache/cloudberry / makepol

Function makepol

contrib/intarray/_int_bool.c:152–223  ·  view source on GitHub ↗

* make polish notation of query */

Source from the content-addressed store, hash-verified

150 * make polish notation of query
151 */
152static int32
153makepol(WORKSTATE *state)
154{
155 int32 val,
156 type;
157 int32 stack[STACKDEPTH];
158 int32 lenstack = 0;
159
160 /* since this function recurses, it could be driven to stack overflow */
161 check_stack_depth();
162
163 while ((type = gettoken(state, &val)) != END)
164 {
165 switch (type)
166 {
167 case VAL:
168 pushquery(state, type, val);
169 while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
170 stack[lenstack - 1] == (int32) '!'))
171 {
172 lenstack--;
173 pushquery(state, OPR, stack[lenstack]);
174 }
175 break;
176 case OPR:
177 if (lenstack && val == (int32) '|')
178 pushquery(state, OPR, val);
179 else
180 {
181 if (lenstack == STACKDEPTH)
182 ereport(ERROR,
183 (errcode(ERRCODE_STATEMENT_TOO_COMPLEX),
184 errmsg("statement too complex")));
185 stack[lenstack] = val;
186 lenstack++;
187 }
188 break;
189 case OPEN:
190 if (makepol(state) == ERR)
191 return ERR;
192 while (lenstack && (stack[lenstack - 1] == (int32) '&' ||
193 stack[lenstack - 1] == (int32) '!'))
194 {
195 lenstack--;
196 pushquery(state, OPR, stack[lenstack]);
197 }
198 break;
199 case CLOSE:
200 while (lenstack)
201 {
202 lenstack--;
203 pushquery(state, OPR, stack[lenstack]);
204 };
205 return END;
206 break;
207 case ERR:
208 default:
209 ereport(ERROR,

Callers 1

bqarr_inFunction · 0.70

Calls 5

check_stack_depthFunction · 0.85
gettokenFunction · 0.85
pushqueryFunction · 0.70
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected