RowIter implements the interface sql.ExecSourceRel.
(ctx *sql.Context, r sql.Row)
| 57 | |
| 58 | // RowIter implements the interface sql.ExecSourceRel. |
| 59 | func (s *ShowSequences) RowIter(ctx *sql.Context, r sql.Row) (sql.RowIter, error) { |
| 60 | database := s.database |
| 61 | if database == "" { |
| 62 | database = ctx.GetCurrentDatabase() |
| 63 | if database == "" { |
| 64 | return nil, errors.New("no database selected (this is a bug)") |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | seqs, err := core.GetSequencesCollectionFromContext(ctx, database) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | |
| 73 | var rows []sql.Row |
| 74 | err = seqs.IterateSequences(ctx, func(seq *sequences.Sequence) (stop bool, err error) { |
| 75 | name := seq.Name() |
| 76 | rows = append(rows, sql.Row{name.Schema, name.Name}) |
| 77 | return false, nil |
| 78 | }) |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | |
| 83 | return sql.RowsToRowIter(rows...), nil |
| 84 | } |
| 85 | |
| 86 | // Schema implements the interface sql.ExecSourceRel. |
| 87 | func (s *ShowSequences) Schema(ctx *sql.Context) sql.Schema { |
nothing calls this directly
no test coverage detected