github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/colexec/execgen/placeholders.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package execgen 12 13 import "github.com/cockroachdb/cockroach/pkg/sql/colexecbase/colexecerror" 14 15 const nonTemplatePanic = "do not call from non-template code" 16 17 // Remove unused warnings. 18 var ( 19 _ = UNSAFEGET 20 _ = RETURNUNSAFEGET 21 _ = COPYVAL 22 _ = SET 23 _ = SLICE 24 _ = COPYSLICE 25 _ = APPENDSLICE 26 _ = APPENDVAL 27 _ = LEN 28 _ = ZERO 29 _ = RANGE 30 _ = WINDOW 31 ) 32 33 // UNSAFEGET is a template function. Use this if you are not keeping data 34 // around (including passing it to SET). 35 func UNSAFEGET(target, i interface{}) interface{} { 36 colexecerror.InternalError(nonTemplatePanic) 37 return nil 38 } 39 40 // RETURNUNSAFEGET is a template function. Use this if you are not keeping data 41 // around (including passing it to SET). 42 // This function is similar to UNSAFEGET with the only difference is that this 43 // will be called on "return" type of an overload. For example, if we have an 44 // overload like "a = b < c", "b" and "c" are arguments of the overload and can 45 // be accessed via UNSAFEGET, but RETURNUNSAFEGET will operate on "a". At the 46 // moment of this writing, it is used only for the purposes of bounds check 47 // elimination in some templates. 48 func RETURNUNSAFEGET(target, i interface{}) interface{} { 49 colexecerror.InternalError(nonTemplatePanic) 50 return nil 51 } 52 53 // COPYVAL is a template function that can be used to set a scalar to the value 54 // of another scalar in such a way that the destination won't be modified if the 55 // source is. You must use this on the result of UNSAFEGET if you wish to store 56 // that result past the lifetime of the batch you UNSAFEGET'd from. 57 func COPYVAL(dest, src interface{}) { 58 colexecerror.InternalError(nonTemplatePanic) 59 } 60 61 // SET is a template function. 62 func SET(target, i, new interface{}) { 63 colexecerror.InternalError(nonTemplatePanic) 64 } 65 66 // SLICE is a template function. 67 func SLICE(target, start, end interface{}) interface{} { 68 colexecerror.InternalError(nonTemplatePanic) 69 return nil 70 } 71 72 // COPYSLICE is a template function. 73 func COPYSLICE(target, src, destIdx, srcStartIdx, srcEndIdx interface{}) { 74 colexecerror.InternalError(nonTemplatePanic) 75 } 76 77 // APPENDSLICE is a template function. 78 func APPENDSLICE(target, src, destIdx, srcStartIdx, srcEndIdx interface{}) { 79 colexecerror.InternalError(nonTemplatePanic) 80 } 81 82 // APPENDVAL is a template function. 83 func APPENDVAL(target, v interface{}) { 84 colexecerror.InternalError(nonTemplatePanic) 85 } 86 87 // LEN is a template function. 88 func LEN(target interface{}) interface{} { 89 colexecerror.InternalError(nonTemplatePanic) 90 return nil 91 } 92 93 // ZERO is a template function. 94 func ZERO(target interface{}) { 95 colexecerror.InternalError(nonTemplatePanic) 96 } 97 98 // RANGE is a template function. 99 func RANGE(loopVariableIdent, target, start, end interface{}) bool { 100 colexecerror.InternalError(nonTemplatePanic) 101 return false 102 } 103 104 // WINDOW is a template function. 105 func WINDOW(target, start, end interface{}) interface{} { 106 colexecerror.InternalError(nonTemplatePanic) 107 return nil 108 }