GetTableInsensitive overrides sqle.Database.GetTableInsensitive to check the pg_catalog virtual schema before falling back to user tables.
(ctx *sql.Context, tblName string)
| 103 | // GetTableInsensitive overrides sqle.Database.GetTableInsensitive to check the pg_catalog |
| 104 | // virtual schema before falling back to user tables. |
| 105 | func (d *PgDatabase) GetTableInsensitive(ctx *sql.Context, tblName string) (sql.Table, bool, error) { |
| 106 | if resolve.UseSearchPath && d.Database.Schema() == "" && strings.HasPrefix(strings.ToLower(tblName), "pg_") { |
| 107 | sdb, found, err := d.GetSchema(ctx, "pg_catalog") |
| 108 | if err != nil { |
| 109 | return nil, false, err |
| 110 | } |
| 111 | if found { |
| 112 | tbl, foundTbl, err := sdb.GetTableInsensitive(ctx, tblName) |
| 113 | if err != nil { |
| 114 | return nil, false, err |
| 115 | } |
| 116 | if foundTbl { |
| 117 | return tbl, true, nil |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | return d.Database.GetTableInsensitive(ctx, tblName) |
| 122 | } |
| 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 { |
no test coverage detected