Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2.20][#24217] YSQL: fill definition of a shell type require…
…s catalog version increment Summary: Steps to repro: 1. In one ysqlsh session: ``` yugabyte=# CREATE TYPE base_type; -- create shell type CREATE TYPE yugabyte=# CREATE FUNCTION base_type_in(cstring) RETURNS base_type yugabyte-# LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS 'int2in'; NOTICE: return type base_type is only a shell CREATE FUNCTION yugabyte=# CREATE FUNCTION base_type_out(base_type) RETURNS cstring yugabyte-# LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS 'int2out'; NOTICE: argument type base_type is only a shell CREATE FUNCTION yugabyte=# CREATE FUNCTION base_type_recv(internal) RETURNS base_type yugabyte-# LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS 'int2recv'; NOTICE: return type base_type is only a shell CREATE FUNCTION yugabyte=# CREATE FUNCTION base_type_send(base_type) RETURNS bytea yugabyte-# LANGUAGE internal IMMUTABLE STRICT PARALLEL SAFE AS 'int2send'; NOTICE: argument type base_type is only a shell CREATE FUNCTION ``` 2. In a second session: ``` yugabyte=# CREATE TABLE default_test (f1 base_type, f2 int); ERROR: type "base_type" is only a shell LINE 1: CREATE TABLE default_test (f1 base_type, f2 int); ``` This ERROR is expected. 3. Back to the first session to fill the definition of the shell type ``` yugabyte=# CREATE TYPE base_type ( yugabyte(# INPUT = base_type_in, yugabyte(# OUTPUT = base_type_out, yugabyte(# RECEIVE = base_type_recv, yugabyte(# SEND = base_type_send, yugabyte(# LIKE = smallint, yugabyte(# CATEGORY = 'N', yugabyte(# PREFERRED = FALSE, yugabyte(# DELIMITER = ',', yugabyte(# COLLATABLE = FALSE yugabyte(# ); -- fill definition CREATE TYPE ``` 4. Back to the second session ``` yugabyte=# CREATE TABLE default_test (f1 base_type, f2 int); ERROR: type "base_type" is only a shell LINE 1: CREATE TABLE default_test (f1 base_type, f2 int); ``` This ERROR is not expected because the first session has already filled the definition of the shell type. To fix this bug I added code to detect the update of an existing shell type and make this DDL to increment the catalog version. A new unit test is added. Jira: DB-13103 Original commit: 17c45ff / D38575 Test Plan: ./yb_build.sh debug --cxx-test pgwrapper_pg_libpq-test --gtest_filter=PgLibPqTest.FillShellTypeDefinition Reviewers: kfranz, mihnea Reviewed By: kfranz Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D38697
- Loading branch information