MCPcopy Create free account
hub / github.com/apecloud/myduckserver / NewSqlRowIter

Function NewSqlRowIter

pgserver/iter.go:94–133  ·  view source on GitHub ↗
(rows *stdsql.Rows, schema sql.Schema)

Source from the content-addressed store, hash-verified

92}
93
94func NewSqlRowIter(rows *stdsql.Rows, schema sql.Schema) (*SqlRowIter, error) {
95 columns, err := rows.ColumnTypes()
96 if err != nil {
97 return nil, err
98 }
99
100 width := max(len(columns), len(schema))
101 buf := make([]any, width)
102 ptrs := make([]any, width)
103 for i := range buf {
104 ptrs[i] = &buf[i]
105 }
106
107 var decimals []int
108 for i, c := range columns {
109 if strings.HasPrefix(c.DatabaseTypeName(), "DECIMAL") {
110 decimals = append(decimals, i)
111 }
112 }
113
114 var lists []int
115 for i, t := range columns {
116 if strings.HasSuffix(t.DatabaseTypeName(), "[]") {
117 lists = append(lists, i)
118 }
119 }
120
121 var hugeInts []int
122 for i, t := range columns {
123 if t.DatabaseTypeName() == "HUGEINT" {
124 hugeInts = append(hugeInts, i)
125 }
126 }
127
128 iter := &SqlRowIter{rows, columns, schema, buf, ptrs, decimals, lists, hugeInts}
129 if logrus.GetLevel() >= logrus.DebugLevel {
130 logrus.Debug("New " + iter.String())
131 }
132 return iter, nil
133}
134
135func (iter *SqlRowIter) String() string {
136 return fmt.Sprintf("SqlRowIter: columns=[%s], schema=[%s]", formatColumnTypes(iter.columns), formatSchema(iter.schema))

Callers 1

executeBoundPlanMethod · 0.85

Calls 1

StringMethod · 0.95

Tested by

no test coverage detected