* transformRangeTableFunc - * Transform a raw RangeTableFunc into TableFunc. * * Transform the namespace clauses, the document-generating expression, the * row-generating expression, the column-generating expressions, and the * default value expressions. */
| 902 | * default value expressions. |
| 903 | */ |
| 904 | static ParseNamespaceItem * |
| 905 | transformRangeTableFunc(ParseState *pstate, RangeTableFunc *rtf) |
| 906 | { |
| 907 | TableFunc *tf = makeNode(TableFunc); |
| 908 | const char *constructName; |
| 909 | Oid docType; |
| 910 | bool is_lateral; |
| 911 | ListCell *col; |
| 912 | char **names; |
| 913 | int colno; |
| 914 | |
| 915 | /* Currently only XMLTABLE is supported */ |
| 916 | constructName = "XMLTABLE"; |
| 917 | docType = XMLOID; |
| 918 | |
| 919 | /* |
| 920 | * We make lateral_only names of this level visible, whether or not the |
| 921 | * RangeTableFunc is explicitly marked LATERAL. This is needed for SQL |
| 922 | * spec compliance and seems useful on convenience grounds for all |
| 923 | * functions in FROM. |
| 924 | * |
| 925 | * (LATERAL can't nest within a single pstate level, so we don't need |
| 926 | * save/restore logic here.) |
| 927 | */ |
| 928 | Assert(!pstate->p_lateral_active); |
| 929 | pstate->p_lateral_active = true; |
| 930 | |
| 931 | /* Transform and apply typecast to the row-generating expression ... */ |
| 932 | Assert(rtf->rowexpr != NULL); |
| 933 | tf->rowexpr = coerce_to_specific_type(pstate, |
| 934 | transformExpr(pstate, rtf->rowexpr, EXPR_KIND_FROM_FUNCTION), |
| 935 | TEXTOID, |
| 936 | constructName); |
| 937 | assign_expr_collations(pstate, tf->rowexpr); |
| 938 | |
| 939 | /* ... and to the document itself */ |
| 940 | Assert(rtf->docexpr != NULL); |
| 941 | tf->docexpr = coerce_to_specific_type(pstate, |
| 942 | transformExpr(pstate, rtf->docexpr, EXPR_KIND_FROM_FUNCTION), |
| 943 | docType, |
| 944 | constructName); |
| 945 | assign_expr_collations(pstate, tf->docexpr); |
| 946 | |
| 947 | /* undef ordinality column number */ |
| 948 | tf->ordinalitycol = -1; |
| 949 | |
| 950 | /* Process column specs */ |
| 951 | names = palloc(sizeof(char *) * list_length(rtf->columns)); |
| 952 | |
| 953 | colno = 0; |
| 954 | foreach(col, rtf->columns) |
| 955 | { |
| 956 | RangeTableFuncCol *rawc = (RangeTableFuncCol *) lfirst(col); |
| 957 | Oid typid; |
| 958 | int32 typmod; |
| 959 | Node *colexpr; |
| 960 | Node *coldefexpr; |
| 961 | int j; |
no test coverage detected