DropTable overrides sqle.Database.DropTable to prevent dropping virtual pg_catalog tables.
(ctx *sql.Context, tableName string)
| 123 | |
| 124 | // DropTable overrides sqle.Database.DropTable to prevent dropping virtual pg_catalog tables. |
| 125 | func (d *PgDatabase) DropTable(ctx *sql.Context, tableName string) error { |
| 126 | if resolve.UseSearchPath && d.Database.Schema() == "" && strings.HasPrefix(strings.ToLower(tableName), "pg_") { |
| 127 | sdb, found, err := d.GetSchema(ctx, "pg_catalog") |
| 128 | if err != nil { |
| 129 | return err |
| 130 | } |
| 131 | if found { |
| 132 | _, foundTbl, err := sdb.GetTableInsensitive(ctx, tableName) |
| 133 | if err != nil { |
| 134 | return err |
| 135 | } |
| 136 | if foundTbl { |
| 137 | return sql.ErrDropTableNotSupported.New("pg_catalog") |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | return d.Database.DropTable(ctx, tableName) |
| 142 | } |
| 143 | |
| 144 | // AllSchemas overrides sqle.ReadOnlyDatabase.AllSchemas to apply Doltgres schema wrapping. |
| 145 | func (d *PgReadOnlyDatabase) AllSchemas(ctx *sql.Context) ([]sql.DatabaseSchema, error) { |
nothing calls this directly
no test coverage detected