| 1894 | // |
| 1895 | |
| 1896 | static act* act_create_index(bool dups, bool descending) |
| 1897 | { |
| 1898 | // create request block |
| 1899 | |
| 1900 | gpre_req* request = MSC_request(REQ_ddl); |
| 1901 | |
| 1902 | // get index and table names and create index and relation blocks |
| 1903 | |
| 1904 | SCHAR i_name[NAME_SIZE + 1]; |
| 1905 | SQL_resolve_identifier("<index name>", i_name, NAME_SIZE + 1); |
| 1906 | if (gpreGlob.token_global.tok_length >= NAME_SIZE) |
| 1907 | PAR_error("Index name too long"); |
| 1908 | |
| 1909 | PAR_get_token(); |
| 1910 | |
| 1911 | if (!MSC_match(KW_ON)) |
| 1912 | CPR_s_error("ON"); |
| 1913 | |
| 1914 | gpre_rel* relation = par_relation(request); |
| 1915 | |
| 1916 | gpre_index* index = make_index(request, i_name); |
| 1917 | index->ind_relation = relation; |
| 1918 | index->ind_flags |= dups ? IND_dup_flag : 0; |
| 1919 | index->ind_flags |= descending ? IND_descend : 0; |
| 1920 | |
| 1921 | // create action block |
| 1922 | |
| 1923 | act* action = MSC_action(request, ACT_create_index); |
| 1924 | action->act_whenever = gen_whenever(); |
| 1925 | action->act_object = (ref*) index; |
| 1926 | |
| 1927 | // parse field list and create corresponding field blocks |
| 1928 | |
| 1929 | EXP_left_paren(0); |
| 1930 | gpre_fld** ptr = &index->ind_fields; |
| 1931 | |
| 1932 | for (;;) |
| 1933 | { |
| 1934 | *ptr = make_field(relation); |
| 1935 | ptr = &(*ptr)->fld_next; |
| 1936 | if (!MSC_match(KW_COMMA)) |
| 1937 | break; |
| 1938 | } |
| 1939 | |
| 1940 | EXP_match_paren(); |
| 1941 | |
| 1942 | return action; |
| 1943 | } |
| 1944 | |
| 1945 | |
| 1946 | //____________________________________________________________ |
no test coverage detected