| 643 | // |
| 644 | |
| 645 | gpre_rel* EXP_relation() |
| 646 | { |
| 647 | if (!gpreGlob.isc_databases) |
| 648 | PAR_error("no database for operation"); |
| 649 | |
| 650 | // The current token is (i.e. should be) either a relation |
| 651 | // name or a database name. If it's a database name, search |
| 652 | // it for the relation name. If it's an unqualified relation |
| 653 | // name, search all databases for the name |
| 654 | |
| 655 | gpre_rel* relation = NULL; |
| 656 | |
| 657 | SQL_resolve_identifier("<identifier>", NULL, NAME_SIZE); |
| 658 | gpre_sym* symbol = MSC_find_symbol(gpreGlob.token_global.tok_symbol, SYM_database); |
| 659 | if (symbol) |
| 660 | { |
| 661 | gpre_dbb* db = (gpre_dbb*) symbol->sym_object; |
| 662 | PAR_get_token(); |
| 663 | if (!MSC_match(KW_DOT)) |
| 664 | CPR_s_error("period after database name"); |
| 665 | SQL_resolve_identifier("<Table name>", NULL, NAME_SIZE); |
| 666 | relation = MET_get_relation(db, gpreGlob.token_global.tok_string, ""); |
| 667 | } |
| 668 | else |
| 669 | { |
| 670 | for (gpre_dbb* db = gpreGlob.isc_databases; db; db = db->dbb_next) |
| 671 | { |
| 672 | gpre_rel* temp = MET_get_relation(db, gpreGlob.token_global.tok_string, ""); |
| 673 | if (temp) |
| 674 | { |
| 675 | if (!relation) |
| 676 | relation = temp; |
| 677 | else |
| 678 | { |
| 679 | TEXT s[ERROR_LENGTH]; |
| 680 | fb_utils::snprintf(s, sizeof(s), "relation %s is ambiguous", gpreGlob.token_global.tok_string); |
| 681 | PAR_get_token(); |
| 682 | PAR_error(s); |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | if (!relation) |
| 689 | CPR_s_error("relation name"); |
| 690 | |
| 691 | PAR_get_token(); |
| 692 | |
| 693 | return relation; |
| 694 | } |
| 695 | |
| 696 | |
| 697 | //____________________________________________________________ |
no test coverage detected