(ctx context.Context, session *Session)
| 767 | } |
| 768 | |
| 769 | func (s *ShowIndexStatement) Execute(ctx context.Context, session *Session) (*Result, error) { |
| 770 | if session.InReadWriteTransaction() { |
| 771 | // INFORMATION_SCHEMA can not be used in read-write transaction. |
| 772 | // https://cloud.google.com/spanner/docs/information-schema |
| 773 | return nil, errors.New(`"SHOW INDEX" can not be used in a read-write transaction`) |
| 774 | } |
| 775 | |
| 776 | stmt := spanner.Statement{ |
| 777 | SQL: `SELECT |
| 778 | TABLE_NAME as Table, |
| 779 | PARENT_TABLE_NAME as Parent_table, |
| 780 | INDEX_NAME as Index_name, |
| 781 | INDEX_TYPE as Index_type, |
| 782 | IS_UNIQUE as Is_unique, |
| 783 | IS_NULL_FILTERED as Is_null_filtered, |
| 784 | INDEX_STATE as Index_state |
| 785 | FROM |
| 786 | INFORMATION_SCHEMA.INDEXES I |
| 787 | WHERE |
| 788 | LOWER(I.TABLE_SCHEMA) = @table_schema AND LOWER(TABLE_NAME) = LOWER(@table_name)`, |
| 789 | Params: map[string]interface{}{"table_name": s.Table, "table_schema": s.Schema}} |
| 790 | |
| 791 | iter, _ := session.RunQuery(ctx, stmt) |
| 792 | defer iter.Stop() |
| 793 | |
| 794 | rows, columnNames, err := parseQueryResult(iter) |
| 795 | if err != nil { |
| 796 | return nil, err |
| 797 | } |
| 798 | if len(rows) == 0 { |
| 799 | return nil, fmt.Errorf("table %q doesn't exist in schema %q", s.Table, s.Schema) |
| 800 | } |
| 801 | |
| 802 | return &Result{ |
| 803 | ColumnNames: columnNames, |
| 804 | Rows: rows, |
| 805 | AffectedRows: len(rows), |
| 806 | }, nil |
| 807 | } |
| 808 | |
| 809 | type TruncateTableStatement struct { |
| 810 | Table string |
nothing calls this directly
no test coverage detected