Skip to content

Commit

Permalink
sql: implement pg_extension virtual table
Browse files Browse the repository at this point in the history
CockroachDB doesn't support extensions, so this is an empty table. It's
needed for ORM support.
  • Loading branch information
jordanlewis committed Feb 7, 2017
1 parent 4d19c56 commit 3a1bae1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/sql/pg_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var pgCatalog = virtualSchema{
pgCatalogDependTable,
pgCatalogDescriptionTable,
pgCatalogEnumTable,
pgCatalogExtensionTable,
pgCatalogForeignServerTable,
pgCatalogForeignTableTable,
pgCatalogIndexTable,
Expand Down Expand Up @@ -746,6 +747,25 @@ CREATE TABLE pg_catalog.pg_enum (
},
}

// See: https://www.postgresql.org/docs/9.6/static/catalog-pg-extension.html.
var pgCatalogExtensionTable = virtualSchemaTable{
schema: `
CREATE TABLE pg_catalog.pg_extension (
extname NAME,
extowner OID,
extnamespace OID,
extrelocatable BOOL,
extversion STRING,
extconfig STRING,
extcondition STRING
);
`,
populate: func(p *planner, addRow func(...parser.Datum) error) error {
// Extensions are not supported.
return nil
},
}

// See: https://www.postgresql.org/docs/9.6/static/catalog-pg-foreign-server.html.
var pgCatalogForeignServerTable = virtualSchemaTable{
schema: `
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/testdata/information_schema
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pg_database
pg_depend
pg_description
pg_enum
pg_extension
pg_foreign_server
pg_foreign_table
pg_index
Expand Down Expand Up @@ -275,6 +276,7 @@ pg_indexes
pg_index
pg_foreign_table
pg_foreign_server
pg_extension
pg_enum
pg_description
pg_depend
Expand Down Expand Up @@ -312,6 +314,7 @@ def pg_catalog pg_database SYSTEM VIEW 1
def pg_catalog pg_depend SYSTEM VIEW 1
def pg_catalog pg_description SYSTEM VIEW 1
def pg_catalog pg_enum SYSTEM VIEW 1
def pg_catalog pg_extension SYSTEM VIEW 1
def pg_catalog pg_foreign_server SYSTEM VIEW 1
def pg_catalog pg_foreign_table SYSTEM VIEW 1
def pg_catalog pg_index SYSTEM VIEW 1
Expand Down Expand Up @@ -369,6 +372,7 @@ def pg_catalog pg_database SYSTEM VIEW 1
def pg_catalog pg_depend SYSTEM VIEW 1
def pg_catalog pg_description SYSTEM VIEW 1
def pg_catalog pg_enum SYSTEM VIEW 1
def pg_catalog pg_extension SYSTEM VIEW 1
def pg_catalog pg_foreign_server SYSTEM VIEW 1
def pg_catalog pg_foreign_table SYSTEM VIEW 1
def pg_catalog pg_index SYSTEM VIEW 1
Expand Down Expand Up @@ -417,6 +421,7 @@ def pg_catalog pg_database SYSTEM VIEW 1
def pg_catalog pg_depend SYSTEM VIEW 1
def pg_catalog pg_description SYSTEM VIEW 1
def pg_catalog pg_enum SYSTEM VIEW 1
def pg_catalog pg_extension SYSTEM VIEW 1
def pg_catalog pg_foreign_server SYSTEM VIEW 1
def pg_catalog pg_foreign_table SYSTEM VIEW 1
def pg_catalog pg_index SYSTEM VIEW 1
Expand Down
7 changes: 7 additions & 0 deletions pkg/sql/testdata/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pg_database
pg_depend
pg_description
pg_enum
pg_extension
pg_foreign_server
pg_foreign_table
pg_index
Expand Down Expand Up @@ -894,6 +895,12 @@ SELECT * FROM pg_catalog.pg_enum
----
oid enumtypid enumsortorder enumlabel

## pg_catalog.pg_extension
query TOOBTTT colnames
SELECT * FROM pg_catalog.pg_extension
----
extname extowner extnamespace extrelocatable extversion extconfig extcondition

## pg_catalog.pg_settings

query TTTTTT colnames
Expand Down

0 comments on commit 3a1bae1

Please sign in to comment.