diff --git a/server/tables/pgcatalog/init.go b/server/tables/pgcatalog/init.go index 51bec31950..e5e04495fa 100644 --- a/server/tables/pgcatalog/init.go +++ b/server/tables/pgcatalog/init.go @@ -140,12 +140,22 @@ func Init() { InitPgStats() InitPgStatsExt() InitPgStatsExtExprs() + InitPgSubscription() + InitPgSubscriptionRel() InitPgTables() + InitPgTablespace() InitPgTimezoneAbbrevs() InitPgTimezoneNames() + InitPgTransform() InitPgTrigger() + InitPgTsConfig() + InitPgTsConfigMap() + InitPgTsDict() + InitPgTsParser() + InitPgTsTemplate() InitPgType() InitPgUser() + InitPgUserMapping() InitPgUserMappings() InitPgViews() } diff --git a/server/tables/pgcatalog/pg_subscription.go b/server/tables/pgcatalog/pg_subscription.go new file mode 100644 index 0000000000..c9f6fbcd10 --- /dev/null +++ b/server/tables/pgcatalog/pg_subscription.go @@ -0,0 +1,90 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgSubscriptionName is a constant to the pg_subscription name. +const PgSubscriptionName = "pg_subscription" + +// InitPgSubscription handles registration of the pg_subscription handler. +func InitPgSubscription() { + tables.AddHandler(PgCatalogName, PgSubscriptionName, PgSubscriptionHandler{}) +} + +// PgSubscriptionHandler is the handler for the pg_subscription table. +type PgSubscriptionHandler struct{} + +var _ tables.Handler = PgSubscriptionHandler{} + +// Name implements the interface tables.Handler. +func (p PgSubscriptionHandler) Name() string { + return PgSubscriptionName +} + +// RowIter implements the interface tables.Handler. +func (p PgSubscriptionHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_subscription row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgSubscriptionHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgSubscriptionSchema, + PkOrdinals: nil, + } +} + +// pgSubscriptionSchema is the schema for pg_subscription. +var pgSubscriptionSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subdbid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subskiplsn", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgSubscriptionName}, // TODO: pg_lsn type + {Name: "subname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subowner", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subenabled", Type: pgtypes.Bool, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subbinary", Type: pgtypes.Bool, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "substream", Type: pgtypes.Bool, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subtwophasestate", Type: pgtypes.BpChar, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subdisableonerr", Type: pgtypes.Bool, Default: nil, Nullable: false, Source: PgSubscriptionName}, + {Name: "subconninfo", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgSubscriptionName}, // TODO: collation C + {Name: "subslotname", Type: pgtypes.Name, Default: nil, Nullable: true, Source: PgSubscriptionName}, + {Name: "subsynccommit", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgSubscriptionName}, // TODO: collation C + {Name: "subpublications", Type: pgtypes.TextArray, Default: nil, Nullable: false, Source: PgSubscriptionName}, // TODO: collation C +} + +// pgSubscriptionRowIter is the sql.RowIter for the pg_subscription table. +type pgSubscriptionRowIter struct { +} + +var _ sql.RowIter = (*pgSubscriptionRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgSubscriptionRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgSubscriptionRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_subscription_rel.go b/server/tables/pgcatalog/pg_subscription_rel.go new file mode 100644 index 0000000000..9ea8ba1fa3 --- /dev/null +++ b/server/tables/pgcatalog/pg_subscription_rel.go @@ -0,0 +1,80 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgSubscriptionRelName is a constant to the pg_subscription_rel name. +const PgSubscriptionRelName = "pg_subscription_rel" + +// InitPgSubscriptionRel handles registration of the pg_subscription_rel handler. +func InitPgSubscriptionRel() { + tables.AddHandler(PgCatalogName, PgSubscriptionRelName, PgSubscriptionRelHandler{}) +} + +// PgSubscriptionRelHandler is the handler for the pg_subscription_rel table. +type PgSubscriptionRelHandler struct{} + +var _ tables.Handler = PgSubscriptionRelHandler{} + +// Name implements the interface tables.Handler. +func (p PgSubscriptionRelHandler) Name() string { + return PgSubscriptionRelName +} + +// RowIter implements the interface tables.Handler. +func (p PgSubscriptionRelHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_subscription_rel row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgSubscriptionRelHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgSubscriptionRelSchema, + PkOrdinals: nil, + } +} + +// pgSubscriptionRelSchema is the schema for pg_subscription_rel. +var pgSubscriptionRelSchema = sql.Schema{ + {Name: "srsubid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgSubscriptionRelName}, + {Name: "srrelid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgSubscriptionRelName}, + {Name: "srsubstate", Type: pgtypes.BpChar, Default: nil, Nullable: false, Source: PgSubscriptionRelName}, + {Name: "srsublsn", Type: pgtypes.Text, Default: nil, Nullable: true, Source: PgSubscriptionRelName}, // TODO: pg_lsn type +} + +// pgSubscriptionRelRowIter is the sql.RowIter for the pg_subscription_rel table. +type pgSubscriptionRelRowIter struct { +} + +var _ sql.RowIter = (*pgSubscriptionRelRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgSubscriptionRelRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgSubscriptionRelRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_tablespace.go b/server/tables/pgcatalog/pg_tablespace.go new file mode 100644 index 0000000000..a211ea9be9 --- /dev/null +++ b/server/tables/pgcatalog/pg_tablespace.go @@ -0,0 +1,81 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTablespaceName is a constant to the pg_tablespace name. +const PgTablespaceName = "pg_tablespace" + +// InitPgTablespace handles registration of the pg_tablespace handler. +func InitPgTablespace() { + tables.AddHandler(PgCatalogName, PgTablespaceName, PgTablespaceHandler{}) +} + +// PgTablespaceHandler is the handler for the pg_tablespace table. +type PgTablespaceHandler struct{} + +var _ tables.Handler = PgTablespaceHandler{} + +// Name implements the interface tables.Handler. +func (p PgTablespaceHandler) Name() string { + return PgTablespaceName +} + +// RowIter implements the interface tables.Handler. +func (p PgTablespaceHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_tablespace row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTablespaceHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTablespaceSchema, + PkOrdinals: nil, + } +} + +// pgTablespaceSchema is the schema for pg_tablespace. +var pgTablespaceSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTablespaceName}, + {Name: "spcname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgTablespaceName}, + {Name: "spcowner", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTablespaceName}, + {Name: "spcacl", Type: pgtypes.TextArray, Default: nil, Nullable: true, Source: PgTablespaceName}, // TODO: aclitem[] type + {Name: "spcoptions", Type: pgtypes.TextArray, Default: nil, Nullable: true, Source: PgTablespaceName}, // TODO: collation C +} + +// pgTablespaceRowIter is the sql.RowIter for the pg_tablespace table. +type pgTablespaceRowIter struct { +} + +var _ sql.RowIter = (*pgTablespaceRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTablespaceRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTablespaceRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_transform.go b/server/tables/pgcatalog/pg_transform.go new file mode 100644 index 0000000000..f9a1370bdf --- /dev/null +++ b/server/tables/pgcatalog/pg_transform.go @@ -0,0 +1,81 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTransformName is a constant to the pg_transform name. +const PgTransformName = "pg_transform" + +// InitPgTransform handles registration of the pg_transform handler. +func InitPgTransform() { + tables.AddHandler(PgCatalogName, PgTransformName, PgTransformHandler{}) +} + +// PgTransformHandler is the handler for the pg_transform table. +type PgTransformHandler struct{} + +var _ tables.Handler = PgTransformHandler{} + +// Name implements the interface tables.Handler. +func (p PgTransformHandler) Name() string { + return PgTransformName +} + +// RowIter implements the interface tables.Handler. +func (p PgTransformHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_transform row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTransformHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTransformSchema, + PkOrdinals: nil, + } +} + +// pgTransformSchema is the schema for pg_transform. +var pgTransformSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTransformName}, + {Name: "trftype", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTransformName}, + {Name: "trflang", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTransformName}, + {Name: "trffromsql", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTransformName}, // TODO: regproc type + {Name: "trftosql", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTransformName}, // TODO: regproc type +} + +// pgTransformRowIter is the sql.RowIter for the pg_transform table. +type pgTransformRowIter struct { +} + +var _ sql.RowIter = (*pgTransformRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTransformRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTransformRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_ts_config.go b/server/tables/pgcatalog/pg_ts_config.go new file mode 100644 index 0000000000..58b5c806e8 --- /dev/null +++ b/server/tables/pgcatalog/pg_ts_config.go @@ -0,0 +1,81 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTsConfigName is a constant to the pg_ts_config name. +const PgTsConfigName = "pg_ts_config" + +// InitPgTsConfig handles registration of the pg_ts_config handler. +func InitPgTsConfig() { + tables.AddHandler(PgCatalogName, PgTsConfigName, PgTsConfigHandler{}) +} + +// PgTsConfigHandler is the handler for the pg_ts_config table. +type PgTsConfigHandler struct{} + +var _ tables.Handler = PgTsConfigHandler{} + +// Name implements the interface tables.Handler. +func (p PgTsConfigHandler) Name() string { + return PgTsConfigName +} + +// RowIter implements the interface tables.Handler. +func (p PgTsConfigHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_ts_config row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTsConfigHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTsConfigSchema, + PkOrdinals: nil, + } +} + +// pgTsConfigSchema is the schema for pg_ts_config. +var pgTsConfigSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigName}, + {Name: "cfgname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgTsConfigName}, + {Name: "cfgnamespace", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigName}, + {Name: "cfgowner", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigName}, + {Name: "cfgparser", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigName}, +} + +// pgTsConfigRowIter is the sql.RowIter for the pg_ts_config table. +type pgTsConfigRowIter struct { +} + +var _ sql.RowIter = (*pgTsConfigRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTsConfigRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTsConfigRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_ts_config_map.go b/server/tables/pgcatalog/pg_ts_config_map.go new file mode 100644 index 0000000000..0d2918205d --- /dev/null +++ b/server/tables/pgcatalog/pg_ts_config_map.go @@ -0,0 +1,80 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTsConfigMapName is a constant to the pg_ts_config_map name. +const PgTsConfigMapName = "pg_ts_config_map" + +// InitPgTsConfigMap handles registration of the pg_ts_config_map handler. +func InitPgTsConfigMap() { + tables.AddHandler(PgCatalogName, PgTsConfigMapName, PgTsConfigMapHandler{}) +} + +// PgTsConfigMapHandler is the handler for the pg_ts_config_map table. +type PgTsConfigMapHandler struct{} + +var _ tables.Handler = PgTsConfigMapHandler{} + +// Name implements the interface tables.Handler. +func (p PgTsConfigMapHandler) Name() string { + return PgTsConfigMapName +} + +// RowIter implements the interface tables.Handler. +func (p PgTsConfigMapHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_ts_config_map row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTsConfigMapHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTsConfigMapSchema, + PkOrdinals: nil, + } +} + +// pgTsConfigMapSchema is the schema for pg_ts_config_map. +var pgTsConfigMapSchema = sql.Schema{ + {Name: "mapcfg", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigMapName}, + {Name: "maptokentype", Type: pgtypes.Int32, Default: nil, Nullable: false, Source: PgTsConfigMapName}, + {Name: "mapseqno", Type: pgtypes.Int32, Default: nil, Nullable: false, Source: PgTsConfigMapName}, + {Name: "mapdict", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsConfigMapName}, +} + +// pgTsConfigMapRowIter is the sql.RowIter for the pg_ts_config_map table. +type pgTsConfigMapRowIter struct { +} + +var _ sql.RowIter = (*pgTsConfigMapRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTsConfigMapRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTsConfigMapRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_ts_dict.go b/server/tables/pgcatalog/pg_ts_dict.go new file mode 100644 index 0000000000..2a649ae063 --- /dev/null +++ b/server/tables/pgcatalog/pg_ts_dict.go @@ -0,0 +1,82 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTsDictName is a constant to the pg_ts_dict name. +const PgTsDictName = "pg_ts_dict" + +// InitPgTsDict handles registration of the pg_ts_dict handler. +func InitPgTsDict() { + tables.AddHandler(PgCatalogName, PgTsDictName, PgTsDictHandler{}) +} + +// PgTsDictHandler is the handler for the pg_ts_dict table. +type PgTsDictHandler struct{} + +var _ tables.Handler = PgTsDictHandler{} + +// Name implements the interface tables.Handler. +func (p PgTsDictHandler) Name() string { + return PgTsDictName +} + +// RowIter implements the interface tables.Handler. +func (p PgTsDictHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_ts_dict row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTsDictHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTsDictSchema, + PkOrdinals: nil, + } +} + +// pgTsDictSchema is the schema for pg_ts_dict. +var pgTsDictSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsDictName}, + {Name: "dictname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgTsDictName}, + {Name: "dictnamespace", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsDictName}, + {Name: "dictowner", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsDictName}, + {Name: "dicttemplate", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsDictName}, + {Name: "dictinitoption", Type: pgtypes.Text, Default: nil, Nullable: true, Source: PgTsDictName}, // TODO: collation C +} + +// pgTsDictRowIter is the sql.RowIter for the pg_ts_dict table. +type pgTsDictRowIter struct { +} + +var _ sql.RowIter = (*pgTsDictRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTsDictRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTsDictRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_ts_parser.go b/server/tables/pgcatalog/pg_ts_parser.go new file mode 100644 index 0000000000..72779b3a97 --- /dev/null +++ b/server/tables/pgcatalog/pg_ts_parser.go @@ -0,0 +1,84 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTsParserName is a constant to the pg_ts_parser name. +const PgTsParserName = "pg_ts_parser" + +// InitPgTsParser handles registration of the pg_ts_parser handler. +func InitPgTsParser() { + tables.AddHandler(PgCatalogName, PgTsParserName, PgTsParserHandler{}) +} + +// PgTsParserHandler is the handler for the pg_ts_parser table. +type PgTsParserHandler struct{} + +var _ tables.Handler = PgTsParserHandler{} + +// Name implements the interface tables.Handler. +func (p PgTsParserHandler) Name() string { + return PgTsParserName +} + +// RowIter implements the interface tables.Handler. +func (p PgTsParserHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_ts_parser row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTsParserHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTsParserSchema, + PkOrdinals: nil, + } +} + +// pgTsParserSchema is the schema for pg_ts_parser. +var pgTsParserSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsParserName}, + {Name: "prsname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgTsParserName}, + {Name: "prsnamespace", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsParserName}, + {Name: "prsstart", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsParserName}, // TODO: regproc type + {Name: "prstoken", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsParserName}, // TODO: regproc type + {Name: "prsend", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsParserName}, // TODO: regproc type + {Name: "prsheadline", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsParserName}, // TODO: regproc type + {Name: "prslextype", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsParserName}, // TODO: regproc type +} + +// pgTsParserRowIter is the sql.RowIter for the pg_ts_parser table. +type pgTsParserRowIter struct { +} + +var _ sql.RowIter = (*pgTsParserRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTsParserRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTsParserRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_ts_template.go b/server/tables/pgcatalog/pg_ts_template.go new file mode 100644 index 0000000000..4e0de57852 --- /dev/null +++ b/server/tables/pgcatalog/pg_ts_template.go @@ -0,0 +1,81 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgTsTemplateName is a constant to the pg_ts_template name. +const PgTsTemplateName = "pg_ts_template" + +// InitPgTsTemplate handles registration of the pg_ts_template handler. +func InitPgTsTemplate() { + tables.AddHandler(PgCatalogName, PgTsTemplateName, PgTsTemplateHandler{}) +} + +// PgTsTemplateHandler is the handler for the pg_ts_template table. +type PgTsTemplateHandler struct{} + +var _ tables.Handler = PgTsTemplateHandler{} + +// Name implements the interface tables.Handler. +func (p PgTsTemplateHandler) Name() string { + return PgTsTemplateName +} + +// RowIter implements the interface tables.Handler. +func (p PgTsTemplateHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_ts_template row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgTsTemplateHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgTsTemplateSchema, + PkOrdinals: nil, + } +} + +// pgTsTemplateSchema is the schema for pg_ts_template. +var pgTsTemplateSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsTemplateName}, + {Name: "tmplname", Type: pgtypes.Name, Default: nil, Nullable: false, Source: PgTsTemplateName}, + {Name: "tmplnamespace", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgTsTemplateName}, + {Name: "tmplinit", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsTemplateName}, // TODO: regproc type + {Name: "tmpllexize", Type: pgtypes.Text, Default: nil, Nullable: false, Source: PgTsTemplateName}, // TODO: regproc type +} + +// pgTsTemplateRowIter is the sql.RowIter for the pg_ts_template table. +type pgTsTemplateRowIter struct { +} + +var _ sql.RowIter = (*pgTsTemplateRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgTsTemplateRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgTsTemplateRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/server/tables/pgcatalog/pg_user_mapping.go b/server/tables/pgcatalog/pg_user_mapping.go new file mode 100644 index 0000000000..c6c4fa392e --- /dev/null +++ b/server/tables/pgcatalog/pg_user_mapping.go @@ -0,0 +1,80 @@ +// Copyright 2024 Dolthub, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pgcatalog + +import ( + "io" + + "github.com/dolthub/go-mysql-server/sql" + + "github.com/dolthub/doltgresql/server/tables" + pgtypes "github.com/dolthub/doltgresql/server/types" +) + +// PgUserMappingName is a constant to the pg_user_mapping name. +const PgUserMappingName = "pg_user_mapping" + +// InitPgUserMapping handles registration of the pg_user_mapping handler. +func InitPgUserMapping() { + tables.AddHandler(PgCatalogName, PgUserMappingName, PgUserMappingHandler{}) +} + +// PgUserMappingHandler is the handler for the pg_user_mapping table. +type PgUserMappingHandler struct{} + +var _ tables.Handler = PgUserMappingHandler{} + +// Name implements the interface tables.Handler. +func (p PgUserMappingHandler) Name() string { + return PgUserMappingName +} + +// RowIter implements the interface tables.Handler. +func (p PgUserMappingHandler) RowIter(ctx *sql.Context) (sql.RowIter, error) { + // TODO: Implement pg_user_mapping row iter + return emptyRowIter() +} + +// Schema implements the interface tables.Handler. +func (p PgUserMappingHandler) Schema() sql.PrimaryKeySchema { + return sql.PrimaryKeySchema{ + Schema: pgUserMappingSchema, + PkOrdinals: nil, + } +} + +// pgUserMappingSchema is the schema for pg_user_mapping. +var pgUserMappingSchema = sql.Schema{ + {Name: "oid", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgUserMappingName}, + {Name: "umuser", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgUserMappingName}, + {Name: "umserver", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: PgUserMappingName}, + {Name: "umoptions", Type: pgtypes.TextArray, Default: nil, Nullable: true, Source: PgUserMappingName}, // TODO: collation C +} + +// pgUserMappingRowIter is the sql.RowIter for the pg_user_mapping table. +type pgUserMappingRowIter struct { +} + +var _ sql.RowIter = (*pgUserMappingRowIter)(nil) + +// Next implements the interface sql.RowIter. +func (iter *pgUserMappingRowIter) Next(ctx *sql.Context) (sql.Row, error) { + return nil, io.EOF +} + +// Close implements the interface sql.RowIter. +func (iter *pgUserMappingRowIter) Close(ctx *sql.Context) error { + return nil +} diff --git a/testing/go/pgcatalog_test.go b/testing/go/pgcatalog_test.go index 8e0110b7de..f0a63e080e 100644 --- a/testing/go/pgcatalog_test.go +++ b/testing/go/pgcatalog_test.go @@ -126,11 +126,11 @@ func TestPgAttribute(t *testing.T) { Assertions: []ScriptTestAssertion{ { Query: `SELECT * FROM "pg_catalog"."pg_attribute" WHERE attname='pk';`, - Expected: []sql.Row{{0, "pk", 0, 0, 1271, -1, -1, 0, "f", "i", "p", "", "t", "f", "f", "", "", "f", "t", 0, -1, 0, nil, nil, nil, nil}}, + Expected: []sql.Row{{0, "pk", 0, 0, 1331, -1, -1, 0, "f", "i", "p", "", "t", "f", "f", "", "", "f", "t", 0, -1, 0, nil, nil, nil, nil}}, }, { Query: `SELECT * FROM "pg_catalog"."pg_attribute" WHERE attname='v1';`, - Expected: []sql.Row{{0, "v1", 0, 0, 1272, -1, -1, 0, "f", "i", "p", "", "f", "t", "f", "", "", "f", "t", 0, -1, 0, nil, nil, nil, nil}}, + Expected: []sql.Row{{0, "v1", 0, 0, 1332, -1, -1, 0, "f", "i", "p", "", "f", "t", "f", "", "", "f", "t", 0, -1, 0, nil, nil, nil, nil}}, }, { // Different cases and quoted, so it fails Query: `SELECT * FROM "PG_catalog"."pg_attribute";`, @@ -353,17 +353,17 @@ func TestPgClass(t *testing.T) { // Table { Query: `SELECT * FROM "pg_catalog"."pg_class" WHERE relname='testing';`, - Expected: []sql.Row{{131, "testing", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "t", "f", "p", "r", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, + Expected: []sql.Row{{141, "testing", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "t", "f", "p", "r", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, }, // Index { Query: `SELECT * FROM "pg_catalog"."pg_class" WHERE relname='PRIMARY';`, - Expected: []sql.Row{{130, "PRIMARY", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "f", "f", "p", "i", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, + Expected: []sql.Row{{140, "PRIMARY", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "f", "f", "p", "i", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, }, // View { Query: `SELECT * FROM "pg_catalog"."pg_class" WHERE relname='testview';`, - Expected: []sql.Row{{132, "testview", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "f", "f", "p", "v", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, + Expected: []sql.Row{{142, "testview", 0, 0, 0, 0, 0, 0, 0, 0, float32(0), 0, 0, "f", "f", "p", "v", 0, 0, "f", "f", "f", "f", "f", "t", "d", "f", 0, 0, 0, nil, nil, nil}}, }, { // Different cases and quoted, so it fails Query: `SELECT * FROM "PG_catalog"."pg_class";`, @@ -3195,6 +3195,58 @@ func TestPgStatsExtExprs(t *testing.T) { }) } +func TestPgSubscription(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_subscription", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_subscription";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_subscription";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_subscription";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT subname FROM PG_catalog.pg_SUBSCRIPTION ORDER BY subname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + +func TestPgSubscriptionRel(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_subscription_rel", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_subscription_rel";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_subscription_rel";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_subscription_rel";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT srsubid FROM PG_catalog.pg_SUBSCRIPTION_REL ORDER BY srsubid;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + func TestPgTables(t *testing.T) { RunScripts(t, []ScriptTest{ { @@ -3221,6 +3273,32 @@ func TestPgTables(t *testing.T) { }) } +func TestPgTablespace(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_tablespace", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_tablespace";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_tablespace";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_tablespace";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT spcname FROM PG_catalog.pg_TABLESPACE ORDER BY spcname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + func TestPgTimezoneAbbrevs(t *testing.T) { RunScripts(t, []ScriptTest{ { @@ -3273,6 +3351,32 @@ func TestPgPgTimezoneNames(t *testing.T) { }) } +func TestPgTransform(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_transform", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_transform";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_transform";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_transform";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT oid FROM PG_catalog.pg_TRANSFORM ORDER BY oid;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + func TestPgTrigger(t *testing.T) { RunScripts(t, []ScriptTest{ { @@ -3299,6 +3403,136 @@ func TestPgTrigger(t *testing.T) { }) } +func TestPgTsConfig(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_ts_config", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_ts_config";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_ts_config";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_ts_config";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT cfgname FROM PG_catalog.pg_TS_CONFIG ORDER BY cfgname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + +func TestPgTsConfigMap(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_ts_config_map", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_ts_config_map";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_ts_config_map";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_ts_config_map";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT mapcfg FROM PG_catalog.pg_TS_CONFIG_MAP ORDER BY mapcfg;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + +func TestPgTsDict(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_ts_dict", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_ts_dict";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_ts_dict";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_ts_dict";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT dictname FROM PG_catalog.pg_TS_DICT ORDER BY dictname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + +func TestPgTsParser(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_ts_parser", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_ts_parser";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_ts_parser";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_ts_parser";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT prsname FROM PG_catalog.pg_TS_PARSER ORDER BY prsname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + +func TestPgTsTemplate(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_ts_template", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_ts_template";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_ts_template";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_ts_template";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT tmplname FROM PG_catalog.pg_TS_TEMPLATE ORDER BY tmplname;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + func TestPgType(t *testing.T) { RunScripts(t, []ScriptTest{ { @@ -3351,6 +3585,32 @@ func TestPgUser(t *testing.T) { }) } +func TestPgUserMapping(t *testing.T) { + RunScripts(t, []ScriptTest{ + { + Name: "pg_user_mapping", + Assertions: []ScriptTestAssertion{ + { + Query: `SELECT * FROM "pg_catalog"."pg_user_mapping";`, + Expected: []sql.Row{}, + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "PG_catalog"."pg_user_mapping";`, + ExpectedErr: "not", + }, + { // Different cases and quoted, so it fails + Query: `SELECT * FROM "pg_catalog"."PG_user_mapping";`, + ExpectedErr: "not", + }, + { // Different cases but non-quoted, so it works + Query: "SELECT umuser FROM PG_catalog.pg_USER_MAPPING ORDER BY umuser;", + Expected: []sql.Row{}, + }, + }, + }, + }) +} + func TestPgUserMappings(t *testing.T) { RunScripts(t, []ScriptTest{ {