From 607ee01a75b6dfabe031806b6c6b884fc79a9fcd Mon Sep 17 00:00:00 2001 From: zhaosen Date: Fri, 10 May 2024 11:43:42 +0800 Subject: [PATCH] =?UTF-8?q?ustore=E5=AD=98=E5=82=A8=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E7=9A=84regression=E7=94=A8=E4=BE=8B10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expected/cast_privileges_test_ustore.out | 33 +++++++++++++++++++ .../sql/cast_privileges_test_ustore.sql | 25 ++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/test/regress/expected/cast_privileges_test_ustore.out create mode 100644 src/test/regress/sql/cast_privileges_test_ustore.sql diff --git a/src/test/regress/expected/cast_privileges_test_ustore.out b/src/test/regress/expected/cast_privileges_test_ustore.out new file mode 100644 index 000000000..e02b52fa8 --- /dev/null +++ b/src/test/regress/expected/cast_privileges_test_ustore.out @@ -0,0 +1,33 @@ +create user user1 password '1234567i*'; +grant all on schema public to user1; +set role user1 password '1234567i*'; +CREATE TYPE public.int111 AS (f1 int, f2 int); +CREATE TYPE public.text111 AS (f1 text, f2 text); +create table public.aa_int(aa int111) with (storage_type = ustore); +create table public.bb_text(bb text111) with (storage_type = ustore); +insert into public.aa_int values((111,222)); +insert into public.bb_text values((111,222)); +CREATE OR REPLACE FUNCTION public.text_int(text111)RETURNS int111 AS $$ +declare +res public.int111; +begin + alter USER user1 with sysadmin; + res:=($1.f1::int,$1.f2::int); + return res; +end;$$ language plpgsql security invoker; +ERROR: permission denied to create function "text_int" +HINT: must be sysadmin to create a function in public schema. +select public.text_int((111,222)); +ERROR: function public.text_int(record) does not exist +LINE 1: select public.text_int((111,222)); + ^ +HINT: No function matches the given name and argument types. You might need to add explicit type casts. +CONTEXT: referenced column: text_int +CREATE CAST (text111 AS int111) WITH FUNCTION public.text_int(text111) AS IMPLICIT; +ERROR: function public.text_int(text111) does not exist +reset role; +select aa ,bb from aa_int ,bb_text where aa_int.aa=bb_text.bb::int111; +ERROR: cannot cast type text111 to int111 +LINE 1: ...bb from aa_int ,bb_text where aa_int.aa=bb_text.bb::int111; + ^ +DROP USER IF EXISTS user1 cascade; diff --git a/src/test/regress/sql/cast_privileges_test_ustore.sql b/src/test/regress/sql/cast_privileges_test_ustore.sql new file mode 100644 index 000000000..ad4398630 --- /dev/null +++ b/src/test/regress/sql/cast_privileges_test_ustore.sql @@ -0,0 +1,25 @@ +create user user1 password '1234567i*'; +grant all on schema public to user1; + +set role user1 password '1234567i*'; +CREATE TYPE public.int111 AS (f1 int, f2 int); +CREATE TYPE public.text111 AS (f1 text, f2 text); +create table public.aa_int(aa int111) with (storage_type = ustore); +create table public.bb_text(bb text111) with (storage_type = ustore); +insert into public.aa_int values((111,222)); +insert into public.bb_text values((111,222)); + +CREATE OR REPLACE FUNCTION public.text_int(text111)RETURNS int111 AS $$ +declare +res public.int111; +begin + alter USER user1 with sysadmin; + res:=($1.f1::int,$1.f2::int); + return res; +end;$$ language plpgsql security invoker; + +select public.text_int((111,222)); +CREATE CAST (text111 AS int111) WITH FUNCTION public.text_int(text111) AS IMPLICIT; +reset role; +select aa ,bb from aa_int ,bb_text where aa_int.aa=bb_text.bb::int111; +DROP USER IF EXISTS user1 cascade;