Eval implements the TypedExpr interface.
(ctx *EvalContext)
| 3926 | |
| 3927 | // Eval implements the TypedExpr interface. |
| 3928 | func (expr *IndirectionExpr) Eval(ctx *EvalContext) (Datum, error) { |
| 3929 | var subscriptIdx int |
| 3930 | for i, t := range expr.Indirection { |
| 3931 | if t.Slice || i > 0 { |
| 3932 | return nil, errors.AssertionFailedf("unsupported feature should have been rejected during planning") |
| 3933 | } |
| 3934 | |
| 3935 | d, err := t.Begin.(TypedExpr).Eval(ctx) |
| 3936 | if err != nil { |
| 3937 | return nil, err |
| 3938 | } |
| 3939 | if d == DNull { |
| 3940 | return d, nil |
| 3941 | } |
| 3942 | subscriptIdx = int(MustBeDInt(d)) |
| 3943 | } |
| 3944 | |
| 3945 | d, err := expr.Expr.(TypedExpr).Eval(ctx) |
| 3946 | if err != nil { |
| 3947 | return nil, err |
| 3948 | } |
| 3949 | if d == DNull { |
| 3950 | return d, nil |
| 3951 | } |
| 3952 | |
| 3953 | // Index into the DArray, using 1-indexing. |
| 3954 | arr := MustBeDArray(d) |
| 3955 | |
| 3956 | // VECTOR types use 0-indexing. |
| 3957 | switch arr.customOid { |
| 3958 | case oid.T_oidvector, oid.T_int2vector: |
| 3959 | subscriptIdx++ |
| 3960 | } |
| 3961 | if subscriptIdx < 1 || subscriptIdx > arr.Len() { |
| 3962 | return DNull, nil |
| 3963 | } |
| 3964 | return arr.Array[subscriptIdx-1], nil |
| 3965 | } |
| 3966 | |
| 3967 | // Eval implements the TypedExpr interface. |
| 3968 | func (expr *CollateExpr) Eval(ctx *EvalContext) (Datum, error) { |
nothing calls this directly
no test coverage detected