Skip to content

Commit

Permalink
[pg15] test: re-port many tests in TestPgRegressPgMiscIndependent
Browse files Browse the repository at this point in the history
Summary:
Re-port pg_regress tests in TestPgRegressPgMiscIndependent =
yb_pg_misc_independent_serial_schedule:

- yb_pg_copydml: identical to original
- yb_pg_index_including: move YB-introduced queries out to new
  yb_index_including in yb_index_serial_schedule
- yb_pg_create_function_sql: some differences
- yb_pg_create_cast: identical to original
- yb_pg_drop_if_exists: run failing queries
- yb_pg_case: skip since porting this may be easier after the work to
  generate ybrowid sequentially
- yb_pg_namespace: some differences
- yb_pg_security_label: identical to original
- yb_pg_lock: skip since LOCK is not well supported
- yb_pg_drop_operator: some differences
- yb_pg_alter_generic: some differences
- yb_pg_alter_operator: move YB-introduced queries out to new
  yb_alter_operator in yb_misc_independent_schedule
- yb_pg_dbsize: identical to original
- yb_pg_indirect_toast: skip since toast is likely not well supported
- yb_pg_conversion: port up to CREATE CONVERSION failure
- yb_pg_truncate: delete some YB-introduced queries that are don't seem
  very important
- yb_pg_sequence: some differences
- yb_pg_identity: crashes ever since YB pg15 merge
  4e08225 merging in YB master
  02998f5.  It also has parts that
  could benefit from the work to generate ybrowid sequentially.  Port
  some error message changes, but leave it failing besides that.

Split up test_D31292.sh to move the TestPgRegressPgMiscIndependent
portion to a new test_pg_misc_independent.sh.  Then, change it to expect
all regress tests to pass except yb_pg_identity.

Test Plan:
On Almalinux 8:

    #!/usr/bin/env bash
    set -eu
    ./yb_build.sh fastdebug --gcc11
    yes "$(pg15_tests/get_shell_test_specs.sh | grep pg_misc_independent)" | head -50 | pg15_tests/run_tests.sh
    pg15_tests/test_D31292.sh

Manually check Java tests TestPgRegressMisc#testPgRegressMiscIndependent
and TestPgRegressIndex pass yb_index_including and yb_alter_operator
regress tests.

Jenkins: rebase: pg15, test regex: TestPgRegress

Reviewers: fizaa, tfoucher

Reviewed By: tfoucher

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D35842
  • Loading branch information
jaki committed Jun 14, 2024
1 parent 03af397 commit 9690419
Show file tree
Hide file tree
Showing 33 changed files with 1,724 additions and 805 deletions.
5 changes: 0 additions & 5 deletions pg15_tests/test_D31292.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ failing_java_test 'TestPgRegressTypesUDT'
grep_in_java_test \
'failed tests: [yb_base_type, yb_create_type]' \
'TestPgRegressTypesUDT'

failing_java_test 'TestPgRegressPgMiscIndependent'
grep_in_java_test \
'failed tests: [yb_pg_dbsize, yb_pg_identity, yb_pg_index_including, yb_pg_sequence]' \
'TestPgRegressPgMiscIndependent'
7 changes: 7 additions & 0 deletions pg15_tests/test_pg_misc_independent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
source "${BASH_SOURCE[0]%/*}"/common.sh

failing_java_test TestPgRegressPgMiscIndependent
grep_in_java_test \
"failed tests: [yb_pg_identity]" \
TestPgRegressPgMiscIndependent
49 changes: 49 additions & 0 deletions src/postgres/src/test/regress/expected/yb_alter_operator.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
PROCEDURE = alter_op_test_fn,
COMMUTATOR = ===,
NEGATOR = !==,
RESTRICT = customcontsel,
JOIN = contjoinsel,
HASHES, MERGES
);
CREATE USER regress_alter_op_user;
ALTER OPERATOR === (boolean, boolean) OWNER TO regress_alter_op_user;
DROP USER regress_alter_op_user; -- error
ERROR: role "regress_alter_op_user" cannot be dropped because some objects depend on it
DETAIL: owner of operator ===(boolean,boolean)
SET SESSION AUTHORIZATION regress_alter_op_user;
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
SELECT oprrest FROM pg_operator WHERE oprname = '==='
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
oprrest
---------
-
(1 row)

-- Cleanup
RESET SESSION AUTHORIZATION;
ALTER OPERATOR === (boolean, boolean) OWNER TO yugabyte;
DROP USER regress_alter_op_user;
--
-- Test SET SCHEMA
--
CREATE SCHEMA op_schema;
ALTER OPERATOR === (boolean, boolean) SET SCHEMA op_schema;
SELECT ns.nspname FROM pg_operator op
INNER JOIN pg_namespace ns ON ns.oid = op.oprnamespace
WHERE op.oprname = '==='
AND op.oprleft = 'boolean'::regtype AND op.oprright = 'boolean'::regtype;
nspname
-----------
op_schema
(1 row)

-- Cleanup
ALTER OPERATOR op_schema.=== (boolean, boolean) SET SCHEMA public;
DROP SCHEMA op_schema;
16 changes: 16 additions & 0 deletions src/postgres/src/test/regress/expected/yb_index_including.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Unique index and unique constraint. Must fail setting non-unique index as constraint.
CREATE TABLE tbl_include_non_unique (c1 int, c2 int, c3 int, c4 int);
CREATE INDEX tbl_include_non_unique_idx on tbl_include_non_unique (c1);
ALTER TABLE tbl_include_non_unique ADD CONSTRAINT constr_non_unique UNIQUE USING INDEX tbl_include_non_unique_idx;
ERROR: "tbl_include_non_unique_idx" is not a unique index
LINE 1: ALTER TABLE tbl_include_non_unique ADD CONSTRAINT constr_non...
^
DETAIL: Cannot create a primary key or unique constraint using such an index.
-- Unique index and unique constraint. Must fail setting DESC unique index as constraint.
CREATE TABLE tbl_include_desc_unique (c1 int, c2 int, c3 int, c4 int);
CREATE UNIQUE INDEX tbl_include_desc_unique_idx on tbl_include_desc_unique (c1 DESC);
ALTER TABLE tbl_include_desc_unique ADD CONSTRAINT constr_desc_unique UNIQUE USING INDEX tbl_include_desc_unique_idx;
ERROR: index "tbl_include_desc_unique_idx" column number 1 does not have default sorting behavior
LINE 1: ALTER TABLE tbl_include_desc_unique ADD CONSTRAINT constr_de...
^
DETAIL: Cannot create a primary key or unique constraint using such an index.
262 changes: 212 additions & 50 deletions src/postgres/src/test/regress/expected/yb_pg_alter_generic.out

Large diffs are not rendered by default.

45 changes: 2 additions & 43 deletions src/postgres/src/test/regress/expected/yb_pg_alter_operator.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
--
-- ALTER OPERATOR
--
-- Based on "alter_operator" test.
--
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
Expand Down Expand Up @@ -134,47 +129,11 @@ ERROR: operator attribute "Restrict" not recognized
--
CREATE USER regress_alter_op_user;
SET SESSION AUTHORIZATION regress_alter_op_user;
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE); -- error
ERROR: must be owner of operator ===
-- SET OWNER check
RESET SESSION AUTHORIZATION;
ALTER OPERATOR === (boolean, boolean) OWNER TO regress_alter_op_user;
DROP USER regress_alter_op_user; -- error
ERROR: role "regress_alter_op_user" cannot be dropped because some objects depend on it
DETAIL: owner of operator ===(boolean,boolean)
SET SESSION AUTHORIZATION regress_alter_op_user;
ALTER OPERATOR === (boolean, boolean) SET (RESTRICT = NONE);
SELECT oprrest FROM pg_operator WHERE oprname = '==='
AND oprleft = 'boolean'::regtype AND oprright = 'boolean'::regtype;
oprrest
---------
-
(1 row)

-- Cleanup
ERROR: must be owner of operator ===
-- Clean up
RESET SESSION AUTHORIZATION;
ALTER OPERATOR === (boolean, boolean) OWNER TO yugabyte;
DROP USER regress_alter_op_user;
--
-- Test SET SCHEMA
--
CREATE SCHEMA op_schema;
ALTER OPERATOR === (boolean, boolean) SET SCHEMA op_schema;
SELECT ns.nspname FROM pg_operator op
INNER JOIN pg_namespace ns ON ns.oid = op.oprnamespace
WHERE op.oprname = '==='
AND op.oprleft = 'boolean'::regtype AND op.oprright = 'boolean'::regtype;
nspname
-----------
op_schema
(1 row)

-- Cleanup
ALTER OPERATOR op_schema.=== (boolean, boolean) SET SCHEMA public;
DROP SCHEMA op_schema;
--
-- Cleanup
--
DROP OPERATOR === (boolean, boolean);
DROP FUNCTION customcontsel(internal, oid, internal, integer);
DROP FUNCTION alter_op_test_fn(boolean, boolean);
8 changes: 8 additions & 0 deletions src/postgres/src/test/regress/expected/yb_pg_conversion.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, result OUT bytea)
AS :'regresslib', 'test_enc_conversion'
LANGUAGE C STRICT;
CREATE USER regress_conversion_user WITH NOCREATEDB NOCREATEROLE;
SET SESSION AUTHORIZATION regress_conversion_user;
CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
ERROR: CREATE CONVERSION not supported yet
LINE 1: CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859...
^
HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues
-- YB: port remaining queries when CREATE CONVERSION is supported
19 changes: 12 additions & 7 deletions src/postgres/src/test/regress/expected/yb_pg_copydml.out
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ drop rule qqq on copydml_test;
create function qqq_trig() returns trigger as $$
begin
if tg_op in ('INSERT', 'UPDATE') then
raise notice '% %', tg_op, new.id;
raise notice '% % %', tg_when, tg_op, new.id;
return new;
else
raise notice '% %', tg_op, old.id;
raise notice '% % %', tg_when, tg_op, old.id;
return old;
end if;
end
Expand All @@ -97,11 +97,16 @@ create trigger qqqbef before insert or update or delete on copydml_test
create trigger qqqaf after insert or update or delete on copydml_test
for each row execute procedure qqq_trig();
copy (insert into copydml_test (t) values ('f') returning id) to stdout;
NOTICE: INSERT 8
NOTICE: BEFORE INSERT 8
8
NOTICE: INSERT 8
-- TODO(jason): uncomment when issue #2261 is closed or closing.
-- copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout;
-- copy (delete from copydml_test where t = 'g' returning id) to stdout;
NOTICE: AFTER INSERT 8
copy (update copydml_test set t = 'g' where t = 'f' returning id) to stdout;
NOTICE: BEFORE UPDATE 8
8
NOTICE: AFTER UPDATE 8
copy (delete from copydml_test where t = 'g' returning id) to stdout;
NOTICE: BEFORE DELETE 8
8
NOTICE: AFTER DELETE 8
drop table copydml_test;
drop function qqq_trig();
Loading

0 comments on commit 9690419

Please sign in to comment.