-
-
Notifications
You must be signed in to change notification settings - Fork 71
more built in functions to support clients #3102
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // Copyright 2026 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 functions | ||
|
|
||
| import ( | ||
| "github.com/dolthub/go-mysql-server/sql" | ||
|
|
||
| "github.com/dolthub/doltgresql/server/functions/framework" | ||
| pgtypes "github.com/dolthub/doltgresql/server/types" | ||
| ) | ||
|
|
||
| // initAclexplode registers the functions to the catalog. | ||
| func initAclexplode() { | ||
| framework.RegisterFunction(aclexplode) // TODO: This breaks pgAdmin 4 because of the unsupported aclitem[] type | ||
| } | ||
|
|
||
| // aclexplodeName is the name for aclexplode function. | ||
| const aclexplodeName = "aclexplode" | ||
|
|
||
| // aclexplode represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var aclexplode = framework.Function1{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Name: aclexplodeName, | ||
| Return: pgtypes.Record, // SETOF record | ||
| Parameters: [1]*pgtypes.DoltgresType{pgtypes.TextArray}, // TODO: type aclitem[] | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [2]*pgtypes.DoltgresType, val any) (any, error) { | ||
| return nil, nil | ||
| }, | ||
| OutParams: aclexplodeOutArgs, | ||
| } | ||
|
|
||
| // aclexplodeOutArgs is the schema for aclexplode table function. Each column is OUT argument. | ||
| var aclexplodeOutArgs = sql.Schema{ | ||
| {Name: "grantor", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: aclexplodeName}, | ||
| {Name: "grantee", Type: pgtypes.Oid, Default: nil, Nullable: false, Source: aclexplodeName}, | ||
| {Name: "privilege_type", Type: pgtypes.Text, Default: nil, Nullable: false, Source: aclexplodeName}, | ||
| {Name: "is_grantable", Type: pgtypes.Bool, Default: nil, Nullable: false, Source: aclexplodeName}, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // Copyright 2026 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 functions | ||
|
|
||
| import ( | ||
| "github.com/dolthub/go-mysql-server/sql" | ||
|
|
||
| "github.com/dolthub/doltgresql/server/functions/framework" | ||
| pgtypes "github.com/dolthub/doltgresql/server/types" | ||
| ) | ||
|
|
||
| // initHasTablePrivilege registers the functions to the catalog. | ||
| func initHasTablePrivilege() { | ||
| framework.RegisterFunction(has_table_privilege_name_text_text) | ||
| framework.RegisterFunction(has_table_privilege_name_oid_text) | ||
| framework.RegisterFunction(has_table_privilege_oid_text_text) | ||
| framework.RegisterFunction(has_table_privilege_oid_oid_text) | ||
| framework.RegisterFunction(has_table_privilege_text_text) | ||
| framework.RegisterFunction(has_table_privilege_oid_text) | ||
| } | ||
|
|
||
| // has_table_privilege_name_text_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_name_text_text = framework.Function3{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [3]*pgtypes.DoltgresType{pgtypes.Name, pgtypes.Text, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [4]*pgtypes.DoltgresType, val1, val2, val3 any) (any, error) { | ||
| // TODO does user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
|
|
||
| // has_table_privilege_name_oid_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_name_oid_text = framework.Function3{ | ||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [3]*pgtypes.DoltgresType{pgtypes.Name, pgtypes.Oid, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [4]*pgtypes.DoltgresType, val1, val2, val3 any) (any, error) { | ||
| // TODO does user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
|
|
||
| // has_table_privilege_oid_text_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_oid_text_text = framework.Function3{ | ||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [3]*pgtypes.DoltgresType{pgtypes.Oid, pgtypes.Text, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [4]*pgtypes.DoltgresType, val1, val2, val3 any) (any, error) { | ||
| // TODO does user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
|
|
||
| // has_table_privilege_oid_oid_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_oid_oid_text = framework.Function3{ | ||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [3]*pgtypes.DoltgresType{pgtypes.Oid, pgtypes.Oid, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [4]*pgtypes.DoltgresType, val1, val2, val3 any) (any, error) { | ||
| // TODO does user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
|
|
||
| // has_table_privilege_text_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_text_text = framework.Function2{ | ||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [2]*pgtypes.DoltgresType{pgtypes.Text, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1, val2 any) (any, error) { | ||
| // TODO does current user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
|
|
||
| // has_table_privilege_oid_text represents the PostgreSQL function of the same name, taking the same parameters. | ||
| var has_table_privilege_oid_text = framework.Function2{ | ||
| Name: "has_table_privilege", | ||
| Return: pgtypes.Bool, | ||
| Parameters: [2]*pgtypes.DoltgresType{pgtypes.Oid, pgtypes.Text}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [3]*pgtypes.DoltgresType, val1, val2 any) (any, error) { | ||
| // TODO does current user have privilege for schema | ||
| return true, nil | ||
| }, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright 2026 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 functions | ||
|
|
||
| import ( | ||
| "github.com/dolthub/go-mysql-server/sql" | ||
|
|
||
| "github.com/dolthub/doltgresql/server/functions/framework" | ||
| pgtypes "github.com/dolthub/doltgresql/server/types" | ||
| ) | ||
|
|
||
| // initPgBlockingPids registers the functions to the catalog. | ||
| func initPgBlockingPids() { | ||
| framework.RegisterFunction(pg_blocking_pids) | ||
| } | ||
|
|
||
| // pg_blocking_pids represents the PostgreSQL system catalog information function. | ||
| var pg_blocking_pids = framework.Function1{ | ||
| Name: "pg_blocking_pids", | ||
| Return: pgtypes.Int32Array, | ||
| Parameters: [1]*pgtypes.DoltgresType{pgtypes.Int32}, | ||
| Strict: true, | ||
| Callable: func(ctx *sql.Context, _ [2]*pgtypes.DoltgresType, val any) (any, error) { | ||
| // TODO | ||
| return nil, nil | ||
| }, | ||
| } |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What failed: Each concurrent client failed with an error saying it could not find field 1 in a row with 1 column. The same failure was reproducible after the concurrent work finished.
Impact · Steps · Stub / mock · Analysis · Why this is likely a bug
Relevant code
server/functions/aclexplode.go:33-41server/functions/aclexplode.go:44-50server/initialization/initialization.go:48-63Evidence Package
Copy prompt for an agent