| 3009 | // |
| 3010 | |
| 3011 | RecordSource* Optimizer::generateRetrieval(StreamType stream, |
| 3012 | SortNode** sortClause, |
| 3013 | bool outerFlag, |
| 3014 | bool innerFlag, |
| 3015 | BoolExprNode** returnBoolean) |
| 3016 | { |
| 3017 | const auto tail = &csb->csb_rpt[stream]; |
| 3018 | const auto relation = tail->csb_relation; |
| 3019 | fb_assert(relation); |
| 3020 | |
| 3021 | const string alias = makeAlias(stream); |
| 3022 | tail->activate(); |
| 3023 | |
| 3024 | // Time to find inversions. For each index on the relation |
| 3025 | // match all unused booleans against the index looking for upper |
| 3026 | // and lower bounds that can be computed by the index. When |
| 3027 | // all unused conjunctions are exhausted, see if there is enough |
| 3028 | // information for an index retrieval. If so, build up an |
| 3029 | // inversion component of the boolean. |
| 3030 | |
| 3031 | RecordSource* rsb = nullptr; |
| 3032 | InversionNode* inversion = nullptr; |
| 3033 | BoolExprNode* condition = nullptr; |
| 3034 | Array<DbKeyRangeNode*> dbkeyRanges; |
| 3035 | double scanSelectivity = MAXIMUM_SELECTIVITY; |
| 3036 | |
| 3037 | if (relation->rel_file) |
| 3038 | { |
| 3039 | // External table |
| 3040 | rsb = FB_NEW_POOL(getPool()) ExternalTableScan(csb, alias, stream, relation); |
| 3041 | } |
| 3042 | else if (relation->isVirtual()) |
| 3043 | { |
| 3044 | // Virtual table: monitoring or security |
| 3045 | switch (relation->rel_id) |
| 3046 | { |
| 3047 | case rel_global_auth_mapping: |
| 3048 | rsb = FB_NEW_POOL(getPool()) GlobalMappingScan(csb, alias, stream, relation); |
| 3049 | break; |
| 3050 | |
| 3051 | case rel_sec_users: |
| 3052 | case rel_sec_user_attributes: |
| 3053 | rsb = FB_NEW_POOL(getPool()) UsersTableScan(csb, alias, stream, relation); |
| 3054 | break; |
| 3055 | |
| 3056 | case rel_sec_db_creators: |
| 3057 | rsb = FB_NEW_POOL(getPool()) DbCreatorsScan(csb, alias, stream, relation); |
| 3058 | break; |
| 3059 | |
| 3060 | case rel_time_zones: |
| 3061 | rsb = FB_NEW_POOL(getPool()) TimeZonesTableScan(csb, alias, stream, relation); |
| 3062 | break; |
| 3063 | |
| 3064 | case rel_config: |
| 3065 | rsb = FB_NEW_POOL(getPool()) ConfigTableScan(csb, alias, stream, relation); |
| 3066 | break; |
| 3067 | |
| 3068 | case rel_keywords: |
no test coverage detected