* make_parsestate * Allocate and initialize a new ParseState. * * Caller should eventually release the ParseState via free_parsestate(). */
| 41 | * Caller should eventually release the ParseState via free_parsestate(). |
| 42 | */ |
| 43 | ParseState * |
| 44 | make_parsestate(ParseState *parentParseState) |
| 45 | { |
| 46 | ParseState *pstate; |
| 47 | |
| 48 | pstate = palloc0(sizeof(ParseState)); |
| 49 | |
| 50 | pstate->parentParseState = parentParseState; |
| 51 | |
| 52 | /* Fill in fields that don't start at null/false/zero */ |
| 53 | pstate->p_next_resno = 1; |
| 54 | pstate->p_resolve_unknowns = true; |
| 55 | |
| 56 | if (parentParseState) |
| 57 | { |
| 58 | pstate->p_sourcetext = parentParseState->p_sourcetext; |
| 59 | /* all hooks are copied from parent */ |
| 60 | pstate->p_pre_columnref_hook = parentParseState->p_pre_columnref_hook; |
| 61 | pstate->p_post_columnref_hook = parentParseState->p_post_columnref_hook; |
| 62 | pstate->p_paramref_hook = parentParseState->p_paramref_hook; |
| 63 | pstate->p_coerce_param_hook = parentParseState->p_coerce_param_hook; |
| 64 | pstate->p_ref_hook_state = parentParseState->p_ref_hook_state; |
| 65 | /* query environment stays in context for the whole parse analysis */ |
| 66 | pstate->p_queryEnv = parentParseState->p_queryEnv; |
| 67 | } |
| 68 | |
| 69 | return pstate; |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * free_parsestate |