Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the rest of the pg_catalog table schemas #422

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions server/tables/pgcatalog/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
90 changes: 90 additions & 0 deletions server/tables/pgcatalog/pg_subscription.go
Original file line number Diff line number Diff line change
@@ -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
}
80 changes: 80 additions & 0 deletions server/tables/pgcatalog/pg_subscription_rel.go
Original file line number Diff line number Diff line change
@@ -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
}
81 changes: 81 additions & 0 deletions server/tables/pgcatalog/pg_tablespace.go
Original file line number Diff line number Diff line change
@@ -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
}
81 changes: 81 additions & 0 deletions server/tables/pgcatalog/pg_transform.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading