From 41c89ab622967d84c212d7062411f2bfe2a0f29e Mon Sep 17 00:00:00 2001 From: Chengxiong Ruan Date: Fri, 12 Aug 2022 00:03:01 -0400 Subject: [PATCH] sql: logic test to inform maximum builtin function oid change This commit adds a logic test to let engineers who added a new builtin function know that the new builtin function is constructed earlier than some existing builtin functions at init time. Release note: None --- pkg/sql/logictest/testdata/logic_test/pg_catalog | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index 56b92f683e27..128aa545be89 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -4670,6 +4670,21 @@ query T SELECT proname FROM pg_catalog.pg_proc WHERE oid = 0 ---- +let $cur_max_builtin_oid +SELECT cur_max_builtin_oid FROM [SELECT max(oid) as cur_max_builtin_oid FROM pg_catalog.pg_proc] + +## If this test failed (proname is the same, but oid increased), it's likely that a +## new builtin function is implemented and it's somewhere in the middle of the +## existing functions at init time. Though the changes to builtin function OID is +## generally ok, it's still better if we could move the new implement to end of the +## list at init time (see all_builtins.go) +## TODO(chengxiong): consider to have a deterministic list of builtin function oids +## so that new implementations can just be added to it. +query TT +SELECT proname, oid FROM pg_catalog.pg_proc WHERE oid = $cur_max_builtin_oid +---- +to_regtype 2031 + ## Ensure that unnest works with oid wrapper arrays query O