Skip to content

Commit

Permalink
sql: populate pg_proc.prokind
Browse files Browse the repository at this point in the history
Release note (bug fix): The `prokind` column of `pg_catalog.pg_proc`
is now populated properly.
  • Loading branch information
knz committed Jan 17, 2023
1 parent 83232a4 commit 02015bc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 9 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -2367,6 +2367,15 @@ json_extract_path 25 2 3802 3802 25 {i,v}

user root

query TT rowsort
SELECT DISTINCT proname, prokind FROM pg_catalog.pg_proc
WHERE proname IN ('lag', 'abs', 'max')
----
abs f
lag w
max a


## pg_catalog.pg_range
query IIIIII colnames
SELECT * from pg_catalog.pg_range
Expand Down
10 changes: 5 additions & 5 deletions pkg/sql/logictest/testdata/logic_test/udf
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ CREATE SCHEMA sc;
statement
CREATE FUNCTION sc.proc_f_2(STRING) RETURNS STRING LANGUAGE SQL AS $$ SELECT 'hello' $$;

query TTTTTBBBTITTTTT
SELECT oid, proname, pronamespace, proowner, prolang, proleakproof, proisstrict, proretset, provolatile, pronargs, prorettype, proargtypes, proargmodes, proargnames, prosrc
query TTTTTBBBTITTTTTT
SELECT oid, proname, pronamespace, proowner, prolang, proleakproof, proisstrict, proretset, provolatile, pronargs, prorettype, proargtypes, proargmodes, proargnames, prokind, prosrc
FROM pg_catalog.pg_proc WHERE proname IN ('proc_f', 'proc_f_2');
----
100118 proc_f 105 1546506610 14 false false false v 1 20 20 {i} NULL SELECT 1;
100119 proc_f 105 1546506610 14 true true false i 2 25 25 20 {i,i} {"",b} SELECT 'hello';
100121 proc_f_2 120 1546506610 14 false false false v 1 25 25 {i} NULL SELECT 'hello';
100118 proc_f 105 1546506610 14 false false false v 1 20 20 {i} NULL f SELECT 1;
100119 proc_f 105 1546506610 14 true true false i 2 25 25 20 {i,i} {"",b} f SELECT 'hello';
100121 proc_f_2 120 1546506610 14 false false false v 1 25 25 {i} NULL f SELECT 'hello';

# Ensure that the pg_proc virtual index works properly.

Expand Down
14 changes: 12 additions & 2 deletions pkg/sql/pg_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,16 @@ func addPgProcBuiltinRow(name string, addRow func(...tree.Datum) error) error {
name = name[len(crdbInternal):]
}

var kind tree.Datum
switch {
case isAggregate:
kind = tree.NewDString("a")
case isWindow:
kind = tree.NewDString("w")
default:
kind = tree.NewDString("f")
}

for _, builtin := range overloads {
dName := tree.NewDName(name)
dSrc := tree.NewDString(name)
Expand Down Expand Up @@ -2435,8 +2445,8 @@ func addPgProcBuiltinRow(name string, addRow func(...tree.Datum) error) error {
tree.DNull, // probin
tree.DNull, // proconfig
tree.DNull, // proacl
kind, // prokind
// These columns were automatically created by pg_catalog_test's missing column generator.
tree.DNull, // prokind
tree.DNull, // prosupport
)
if err != nil {
Expand Down Expand Up @@ -2511,8 +2521,8 @@ func addPgProcUDFRow(
tree.DNull, // probin
tree.DNull, // proconfig
tree.DNull, // proacl
tree.NewDString("f"), // prokind
// These columns were automatically created by pg_catalog_test's missing column generator.
tree.DNull, // prokind
tree.DNull, // prosupport
)
}
Expand Down

0 comments on commit 02015bc

Please sign in to comment.