github-vet / github-vet/rangeloop-pointer-findings
cockroachdb/cockroach: pkg/sql/pg_catalog.go; 100 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cockroachdb/cockroach](https://www.github.com/cockroachdb/cockroach) at [pkg/sql/pg_catalog.go](https://github.com/cockroachdb/cockroach/blob/4e3a9ccdb9cac89ae32d6248bb9b119b5bc250f7/pkg/sql/pg_catalog.go#L1907-L2006)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to builtin was used in a composite literal at line 1972
[Click here to see the code in its original context.](https://github.com/cockroachdb/cockroach/blob/4e3a9ccdb9cac89ae32d6248bb9b119b5bc250f7/pkg/sql/pg_catalog.go#L1907-L2006)
Click here to show the 100 line(s) of Go which triggered the analyzer.
```go
for _, builtin := range overloads {
dName := tree.NewDName(name)
dSrc := tree.NewDString(name)
var retType tree.Datum
isRetSet := false
if fixedRetType := builtin.FixedReturnType(); fixedRetType != nil {
var retOid oid.Oid
if fixedRetType.Family() == types.TupleFamily && builtin.Generator != nil {
isRetSet = true
// Functions returning tables with zero, or more than one
// columns are marked to return "anyelement"
// (e.g. `unnest`)
retOid = oid.T_anyelement
if len(fixedRetType.TupleContents()) == 1 {
// Functions returning tables with exactly one column
// are marked to return the type of that column
// (e.g. `generate_series`).
retOid = fixedRetType.TupleContents()[0].Oid()
}
} else {
retOid = fixedRetType.Oid()
}
retType = tree.NewDOid(tree.DInt(retOid))
}
argTypes := builtin.Types
dArgTypes := tree.NewDArray(types.Oid)
for _, argType := range argTypes.Types() {
if err := dArgTypes.Append(tree.NewDOid(tree.DInt(argType.Oid()))); err != nil {
return err
}
}
var argmodes tree.Datum
var variadicType tree.Datum
switch v := argTypes.(type) {
case tree.VariadicType:
if len(v.FixedTypes) == 0 {
argmodes = proArgModeVariadic
} else {
ary := tree.NewDArray(types.String)
for range v.FixedTypes {
if err := ary.Append(tree.NewDString("i")); err != nil {
return err
}
}
if err := ary.Append(tree.NewDString("v")); err != nil {
return err
}
argmodes = ary
}
variadicType = tree.NewDOid(tree.DInt(v.VarType.Oid()))
case tree.HomogeneousType:
argmodes = proArgModeVariadic
argType := types.Any
oid := argType.Oid()
variadicType = tree.NewDOid(tree.DInt(oid))
default:
argmodes = tree.DNull
variadicType = oidZero
}
provolatile, proleakproof := builtin.Volatility.ToPostgres()
err := addRow(
h.BuiltinOid(name, &builtin), // oid
dName, // proname
nspOid, // pronamespace
tree.DNull, // proowner
oidZero, // prolang
tree.DNull, // procost
tree.DNull, // prorows
variadicType, // provariadic
tree.DNull, // protransform
tree.MakeDBool(tree.DBool(isAggregate)), // proisagg
tree.MakeDBool(tree.DBool(isWindow)), // proiswindow
tree.DBoolFalse, // prosecdef
tree.MakeDBool(tree.DBool(proleakproof)), // proleakproof
tree.DBoolFalse, // proisstrict
tree.MakeDBool(tree.DBool(isRetSet)), // proretset
tree.NewDString(provolatile), // provolatile
tree.DNull, // proparallel
tree.NewDInt(tree.DInt(builtin.Types.Length())), // pronargs
tree.NewDInt(tree.DInt(0)), // pronargdefaults
retType, // prorettype
tree.NewDOidVectorFromDArray(dArgTypes), // proargtypes
tree.DNull, // proallargtypes
argmodes, // proargmodes
tree.DNull, // proargnames
tree.DNull, // proargdefaults
tree.DNull, // protrftypes
dSrc, // prosrc
tree.DNull, // probin
tree.DNull, // proconfig
tree.DNull, // proacl
)
if err != nil {
return err
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 4e3a9ccdb9cac89ae32d6248bb9b119b5bc250f7
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.