| 2009 | // |
| 2010 | |
| 2011 | static act* act_create_table() |
| 2012 | { |
| 2013 | gpre_req* request = MSC_request(REQ_ddl); |
| 2014 | gpre_rel* relation = par_relation(request); |
| 2015 | |
| 2016 | if (MSC_match(KW_EXTERNAL)) |
| 2017 | { |
| 2018 | TEXT* string = NULL; |
| 2019 | MSC_match(KW_FILE); |
| 2020 | if (isQuoted(gpreGlob.token_global.tok_type)) |
| 2021 | { |
| 2022 | string = (TEXT*) MSC_alloc(gpreGlob.token_global.tok_length + 1); |
| 2023 | relation->rel_ext_file = string; |
| 2024 | MSC_copy(gpreGlob.token_global.tok_string, gpreGlob.token_global.tok_length, string); |
| 2025 | PAR_get_token(); |
| 2026 | } |
| 2027 | else |
| 2028 | CPR_s_error("<quoted filename>"); |
| 2029 | |
| 2030 | if (!check_filename(string)) |
| 2031 | PAR_error("node name not permitted"); // a node name is not permitted in external file name |
| 2032 | } |
| 2033 | |
| 2034 | // CHECK Constraints require the context to be set to the |
| 2035 | // current relation |
| 2036 | |
| 2037 | gpre_ctx* context = MSC_context(request); |
| 2038 | request->req_contexts = context; |
| 2039 | context->ctx_relation = relation; |
| 2040 | |
| 2041 | // Reserve context 1 for relation on which constraint is |
| 2042 | // being defined |
| 2043 | context->ctx_internal++; |
| 2044 | request->req_internal++; |
| 2045 | |
| 2046 | // create action block |
| 2047 | |
| 2048 | act* action = MSC_action(request, ACT_create_table); |
| 2049 | action->act_whenever = gen_whenever(); |
| 2050 | action->act_object = (ref*) relation; |
| 2051 | |
| 2052 | EXP_left_paren(0); |
| 2053 | gpre_fld** ptr = &relation->rel_fields; |
| 2054 | cnstrt** cnstrt_ptr = &relation->rel_constraints; |
| 2055 | |
| 2056 | for (;;) |
| 2057 | { |
| 2058 | switch (gpreGlob.token_global.tok_keyword) |
| 2059 | { |
| 2060 | case KW_CONSTRAINT: |
| 2061 | case KW_PRIMARY: |
| 2062 | case KW_UNIQUE: |
| 2063 | case KW_FOREIGN: |
| 2064 | case KW_CHECK: |
| 2065 | *cnstrt_ptr = par_table_constraint(request); |
| 2066 | cnstrt_ptr = &(*cnstrt_ptr)->cnstrt_next; |
| 2067 | break; |
| 2068 |
no test coverage detected