Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: remove release guard for pg sql review (#2122)

rebelice1d77cfc36da4
diff --git a/api/task_check_run.go b/api/task_check_run.go
index b52c0bdc35..ef746f5945 100644
--- a/api/task_check_run.go
+++ b/api/task_check_run.go
@@ -199,8 +199,8 @@ type TaskCheckRunStatusPatch struct {
}
// IsSyntaxCheckSupported checks the engine type if syntax check supports it.
-func IsSyntaxCheckSupported(dbType db.Type, mode common.ReleaseMode) bool {
- if mode == common.ReleaseModeDev || dbType == db.MySQL || dbType == db.TiDB {
+func IsSyntaxCheckSupported(dbType db.Type, _ common.ReleaseMode) bool {
+ if dbType == db.Postgres || dbType == db.MySQL || dbType == db.TiDB {
advisorDB, err := advisorDB.ConvertToAdvisorDBType(string(dbType))
if err != nil {
return false
@@ -213,8 +213,8 @@ func IsSyntaxCheckSupported(dbType db.Type, mode common.ReleaseMode) bool {
}
// IsSQLReviewSupported checks the engine type if schema review supports it.
-func IsSQLReviewSupported(dbType db.Type, mode common.ReleaseMode) bool {
- if mode == common.ReleaseModeDev || dbType == db.MySQL || dbType == db.TiDB {
+func IsSQLReviewSupported(dbType db.Type, _ common.ReleaseMode) bool {
+ if dbType == db.Postgres || dbType == db.MySQL || dbType == db.TiDB {
advisorDB, err := advisorDB.ConvertToAdvisorDBType(string(dbType))
if err != nil {
return false
diff --git a/store/table_index.go b/store/table_index.go
index 002d434384..c422b9e1e3 100644
--- a/store/table_index.go
+++ b/store/table_index.go
@@ -90,10 +90,9 @@ func generateIndexActions(oldIndexList []*api.Index, indexList []db.Index, datab
}
// createIndexImpl creates a new index.
-func (s *Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.IndexCreate) (*api.Index, error) {
- if s.db.mode == common.ReleaseModeDev {
- // Insert row into index.
- query := `
+func (*Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.IndexCreate) (*api.Index, error) {
+ // Insert row into index.
+ query := `
INSERT INTO idx (
creator_id,
updater_id,
@@ -110,63 +109,6 @@ func (s *Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.Ind
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, table_id, name, expression, position, type, "unique", "primary", visible, comment
- `
- var index api.Index
- if err := tx.QueryRowContext(ctx, query,
- create.CreatorID,
- create.CreatorID,
- create.DatabaseID,
- create.TableID,
- create.Name,
- create.Expression,
- create.Position,
- create.Type,
- create.Unique,
- create.Primary,
- create.Visible,
- create.Comment,
- ).Scan(
- &index.ID,
- &index.CreatorID,
- &index.CreatedTs,
- &index.UpdaterID,
- &index.UpdatedTs,
- &index.DatabaseID,
- &index.TableID,
- &index.Name,
- &index.Expression,
- &index.Position,
- &index.Type,
- &index.Unique,
- &index.Primary,
- &index.Visible,
- &index.Comment,
- ); err != nil {
- if err == sql.ErrNoRows {
- return nil, common.FormatDBErrorEmptyRowWithQuery(query)
- }
- return nil, FormatError(err)
- }
-
- return &index, nil
- }
- // Insert row into index.
- query := `
- INSERT INTO idx (
- creator_id,
- updater_id,
- database_id,
- table_id,
- name,
- expression,
- position,
- type,
- "unique",
- visible,
- comment
- )
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, table_id, name, expression, position, type, "unique", visible, comment
`
var index api.Index
if err := tx.QueryRowContext(ctx, query,
@@ -179,6 +121,7 @@ func (s *Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.Ind
create.Position,
create.Type,
create.Unique,
+ create.Primary,
create.Visible,
create.Comment,
).Scan(
@@ -194,6 +137,7 @@ func (s *Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.Ind
&index.Position,
&index.Type,
&index.Unique,
+ &index.Primary,
&index.Visible,
&index.Comment,
); err != nil {
@@ -202,10 +146,11 @@ func (s *Store) createIndexImpl(ctx context.Context, tx *sql.Tx, create *api.Ind
}
return nil, FormatError(err)
}
+
return &index, nil
}
-func (s *Store) findIndexImpl(ctx context.Context, tx *sql.Tx, find *api.IndexFind) ([]*api.Index, error) {
+func (*Store) findIndexImpl(ctx context.Context, tx *sql.Tx, find *api.IndexFind) ([]*api.Index, error) {
// Build WHERE clause.
where, args := []string{"1 = 1"}, []interface{}{}
if v := find.ID; v != nil {
@@ -224,8 +169,7 @@ func (s *Store) findIndexImpl(ctx context.Context, tx *sql.Tx, find *api.IndexFi
where, args = append(where, fmt.Sprintf("expression = $%d", len(args)+1)), append(args, *v)
}
- if s.db.mode == common.ReleaseModeDev {
- rows, err := tx.QueryContext(ctx, `
+ rows, err := tx.QueryContext(ctx, `
SELECT
id,
creator_id,
@@ -245,65 +189,6 @@ func (s *Store) findIndexImpl(ctx context.Context, tx *sql.Tx, find *api.IndexFi
FROM idx
WHERE `+strings.Join(where, " AND ")+`
ORDER BY database_id, table_id, CASE WHEN "primary" THEN 1 ELSE 2 END, name ASC, position ASC`,
- args...,
- )
- if err != nil {
- return nil, FormatError(err)
- }
- defer rows.Close()
-
- // Iterate over result set and deserialize rows into indexList.
- var indexList []*api.Index
- for rows.Next() {
- var index api.Index
- if err := rows.Scan(
- &index.ID,
- &index.CreatorID,
- &index.CreatedTs,
- &index.UpdaterID,
- &index.UpdatedTs,
- &index.DatabaseID,
- &index.TableID,
- &index.Name,
- &index.Expression,
- &index.Position,
- &index.Type,
- &index.Unique,
- &index.Primary,
- &index.Visible,
- &index.Comment,
- ); err != nil {
- return nil, FormatError(err)
- }
-
- indexList = append(indexList, &index)
- }
- if err := rows.Err(); err != nil {
- return nil, FormatError(err)
- }
-
- return indexList, nil
- }
-
- rows, err := tx.QueryContext(ctx, `
- SELECT
- id,
- creator_id,
- created_ts,
- updater_id,
- updated_ts,
- database_id,
- table_id,
- name,
- expression,
- position,
- type,
- "unique",
- visible,
- comment
- FROM idx
- WHERE `+strings.Join(where, " AND ")+`
- ORDER BY database_id, table_id, CASE name WHEN 'PRIMARY' THEN 1 ELSE 2 END, name ASC, position ASC`,
args...,
)
if err != nil {
@@ -328,6 +213,7 @@ func (s *Store) findIndexImpl(ctx context.Context, tx *sql.Tx, find *api.IndexFi
&index.Position,
&index.Type,
&index.Unique,
+ &index.Primary,
&index.Visible,
&index.Comment,
); err != nil {