From b46a82ea338e5c0b60834ea5b9d1a19e1eff5084 Mon Sep 17 00:00:00 2001 From: pokeeffe-molecula <85502298+pokeeffe-molecula@users.noreply.github.com> Date: Wed, 14 Dec 2022 10:15:42 -0600 Subject: [PATCH] added updated_at column to show tables output (#2364) (cherry picked from commit 9759602f94f26f3b7f10a58c3d97467a34f2ba9c) --- sql3/planner/compileshow.go | 10 ++++++++-- sql3/planner/opfeaturebasetables.go | 11 +++++++++-- sql3/sql_complex_test.go | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sql3/planner/compileshow.go b/sql3/planner/compileshow.go index 14fb27eeb..2952dc394 100644 --- a/sql3/planner/compileshow.go +++ b/sql3/planner/compileshow.go @@ -53,14 +53,20 @@ func (p *ExecutionPlanner) compileShowTablesStatement(stmt parser.Statement) (ty }, &qualifiedRefPlanExpression{ tableName: "fb_tables", - columnName: "keys", + columnName: "updated_at", columnIndex: 5, + dataType: parser.NewDataTypeTimestamp(), + }, + &qualifiedRefPlanExpression{ + tableName: "fb_tables", + columnName: "keys", + columnIndex: 6, dataType: parser.NewDataTypeBool(), }, &qualifiedRefPlanExpression{ tableName: "fb_tables", columnName: "description", - columnIndex: 6, + columnIndex: 7, dataType: parser.NewDataTypeString(), }} diff --git a/sql3/planner/opfeaturebasetables.go b/sql3/planner/opfeaturebasetables.go index 8a2c0d3cb..1268a815a 100644 --- a/sql3/planner/opfeaturebasetables.go +++ b/sql3/planner/opfeaturebasetables.go @@ -76,6 +76,11 @@ func (p *PlanOpFeatureBaseTables) Schema() types.Schema { ColumnName: "created_at", Type: parser.NewDataTypeTimestamp(), }, + &types.PlannerColumn{ + RelationName: "fb_tables", + ColumnName: "updated_at", + Type: parser.NewDataTypeTimestamp(), + }, &types.PlannerColumn{ RelationName: "fb_tables", ColumnName: "keys", @@ -112,13 +117,15 @@ var _ types.RowIterator = (*showTablesRowIter)(nil) func (i *showTablesRowIter) Next(ctx context.Context) (types.Row, error) { if i.rowIndex < len(i.indexInfo) { - tm := time.Unix(0, i.indexInfo[i.rowIndex].CreatedAt) + createdAt := time.Unix(0, i.indexInfo[i.rowIndex].CreatedAt) + updatedAt := time.Unix(0, i.indexInfo[i.rowIndex].UpdatedAt) row := []interface{}{ i.indexInfo[i.rowIndex].Name, i.indexInfo[i.rowIndex].Name, i.indexInfo[i.rowIndex].Owner, i.indexInfo[i.rowIndex].LastUpdateUser, - tm.Format(time.RFC3339), + createdAt.Format(time.RFC3339), + updatedAt.Format(time.RFC3339), i.indexInfo[i.rowIndex].Options.Keys, i.indexInfo[i.rowIndex].Options.Description, } diff --git a/sql3/sql_complex_test.go b/sql3/sql_complex_test.go index 08967a77e..3bbca6d1d 100644 --- a/sql3/sql_complex_test.go +++ b/sql3/sql_complex_test.go @@ -174,6 +174,7 @@ func TestPlanner_Show(t *testing.T) { wireQueryFieldString("owner"), wireQueryFieldString("updated_by"), wireQueryFieldTimestamp("created_at"), + wireQueryFieldTimestamp("updated_at"), wireQueryFieldBool("keys"), wireQueryFieldString("description"), }, columns); diff != "" {