You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add tests for GUC of PGC_STRING type value rollback
GUC values of PGC_STRING type should be quoted or parsing
at GUC value rollback will fail otherwise.
As failed SET command leads to transaction abort that leads to
backend exit that triggers RemoveTempRelationsCallback to remove
temp relations, the new tests verify that after GUC PGC_STRING value
rollback no temp relation is removed.
Test for empty search_path GUC value from 620bdbd
replaced with new one that required no Fault Injector and keeps the
source code clean.
-- when the original string guc is empty, we change the guc to new value during executing a command.
412
-
-- this guc will be added to gp_guc_restore_list, and they will be restored
413
-
-- to original value to qe when the next command is executed.
414
-
-- however, the dispatch command is "set xxx to ;" that is wrong.
415
-
create extension if not exists gp_inject_fault;
416
-
create table public.restore_guc_test(tc1 int);
417
-
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'tc1' as the Cloudberry Database data distribution key for this table.
411
+
-- Test single query default_tablespace GUC rollback
412
+
-- Function just to save default_tablespace GUC to gp_guc_restore_list
413
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
414
+
AS $$
415
+
BEGIN
416
+
EXECUTE 'SELECT 1;';
417
+
END;
418
+
$$ LANGUAGE plpgsql
419
+
SET default_tablespace TO '';
420
+
-- Create temp table to create temp schema
421
+
CREATE TEMP TABLE just_a_temp_table (a int);
422
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
418
423
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
419
-
-- inject fault to change the value of search_path during creating materialized view
-- Trigger default_tablespace GUC restore from gp_guc_restore_list
439
+
SELECT 1;
440
+
?column?
441
+
----------
442
+
1
443
+
(1 row)
444
+
445
+
-- When default_tablespace GUC is restored from gp_guc_restore_list
446
+
-- successfully no RemoveTempRelationsCallback is called.
447
+
-- So check that segments still have temp schemas
448
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
449
+
count
450
+
-------
451
+
3
452
+
(1 row)
453
+
454
+
-- Cleanup
455
+
DROP TABLE just_a_temp_table;
456
+
-- Test single query gp_default_storage_options GUC rollback
457
+
-- Function just to save gp_default_storage_options to gp_guc_restore_list
458
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
459
+
AS $$
460
+
BEGIN
461
+
EXECUTE 'SELECT 1;';
462
+
END;
463
+
$$ LANGUAGE plpgsql
464
+
SET gp_default_storage_options TO 'blocksize=32768,compresstype=none,checksum=false';
465
+
-- Create temp table to create temp schema
466
+
CREATE TEMP TABLE just_a_temp_table (a int);
467
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
468
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
469
+
-- Temp schema should be created for each segment
470
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
471
+
count
472
+
-------
473
+
3
474
+
(1 row)
475
+
476
+
-- Save gp_default_storage_options GUC to gp_guc_restore_list
477
+
SELECT set_conf_param();
478
+
set_conf_param
479
+
----------------
437
480
438
481
(1 row)
439
482
440
-
-- trigger inject fault of change_string_guc, and add this guc to gp_guc_restore_list
441
-
create MATERIALIZED VIEW public.view_restore_guc_test as select * from public.restore_guc_test;
442
-
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause. Creating a NULL policy entry.
443
-
--we should restore gucs in gp_guc_restore_list to qe, no error occurs.
444
-
drop MATERIALIZED VIEW public.view_restore_guc_test;
-- When gp_default_storage_options GUC is restored from gp_guc_restore_list
491
+
-- successfully no RemoveTempRelationsCallback is called.
492
+
-- So check that segments still have temp schemas
493
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
494
+
count
495
+
-------
496
+
3
497
+
(1 row)
498
+
499
+
-- Cleanup
500
+
DROP TABLE just_a_temp_table;
501
+
-- Test single query lc_numeric GUC rollback
502
+
-- Set lc_numeric to OS-friendly value
503
+
SET lc_numeric TO 'C';
504
+
-- Function just to save lc_numeric GUC to gp_guc_restore_list
505
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
506
+
AS $$
507
+
BEGIN
508
+
EXECUTE 'SELECT 1;';
509
+
END;
510
+
$$ LANGUAGE plpgsql
511
+
SET lc_numeric TO 'C';
512
+
-- Create temp table to create temp schema
513
+
CREATE TEMP TABLE just_a_temp_table (a int);
514
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
515
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
516
+
-- Temp schema should be created for each segment
517
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
518
+
count
519
+
-------
520
+
3
521
+
(1 row)
522
+
523
+
-- Save lc_numeric GUC to gp_guc_restore_list
524
+
SELECT set_conf_param();
525
+
set_conf_param
526
+
----------------
527
+
528
+
(1 row)
529
+
530
+
-- Trigger lc_numeric GUC restore from gp_guc_restore_list
531
+
SELECT 1;
532
+
?column?
533
+
----------
534
+
1
535
+
(1 row)
536
+
537
+
-- When lc_numeric GUC is restored from gp_guc_restore_list
538
+
-- successfully no RemoveTempRelationsCallback is called.
539
+
-- So check that segments still have temp schemas
540
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
541
+
count
542
+
-------
543
+
3
544
+
(1 row)
545
+
546
+
-- Cleanup
547
+
DROP TABLE just_a_temp_table;
548
+
-- Test single query pljava_classpath GUC rollback
549
+
-- Function just to save pljava_classpath GUC to gp_guc_restore_list
550
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
551
+
AS $$
552
+
BEGIN
553
+
EXECUTE 'SELECT 1;';
554
+
END;
555
+
$$ LANGUAGE plpgsql
556
+
SET pljava_classpath TO '';
557
+
-- Create temp table to create temp schema
558
+
CREATE TEMP TABLE just_a_temp_table (a int);
559
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
560
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
561
+
-- Temp schema should be created for each segment
562
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
563
+
count
564
+
-------
565
+
3
566
+
(1 row)
567
+
568
+
-- Save pljava_classpath GUC to gp_guc_restore_list
569
+
SELECT set_conf_param();
570
+
set_conf_param
571
+
----------------
572
+
573
+
(1 row)
574
+
575
+
-- Trigger pljava_classpath GUC restore from gp_guc_restore_list
576
+
SELECT 1;
577
+
?column?
578
+
----------
579
+
1
580
+
(1 row)
581
+
582
+
-- When pljava_classpath GUC is restored from gp_guc_restore_list
583
+
-- successfully no RemoveTempRelationsCallback is called.
584
+
-- So check that segments still have temp schemas
585
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
586
+
count
587
+
-------
588
+
3
589
+
(1 row)
590
+
591
+
-- Cleanup
592
+
DROP TABLE just_a_temp_table;
593
+
-- Test single query pljava_vmoptions GUC rollback
594
+
-- Function just to save pljava_vmoptions GUC to gp_guc_restore_list
595
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
596
+
AS $$
597
+
BEGIN
598
+
EXECUTE 'SELECT 1;';
599
+
END;
600
+
$$ LANGUAGE plpgsql
601
+
SET pljava_vmoptions TO '';
602
+
-- Create temp table to create temp schema
603
+
CREATE TEMP TABLE just_a_temp_table (a int);
604
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
605
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
606
+
-- Temp schema should be created for each segment
607
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
608
+
count
609
+
-------
610
+
3
611
+
(1 row)
612
+
613
+
-- Save pljava_vmoptions GUC to gp_guc_restore_list
614
+
SELECT set_conf_param();
615
+
set_conf_param
616
+
----------------
617
+
618
+
(1 row)
619
+
620
+
-- Trigger pljava_vmoptions GUC restore from gp_guc_restore_list
621
+
SELECT 1;
622
+
?column?
623
+
----------
624
+
1
625
+
(1 row)
626
+
627
+
-- When pljava_vmoptions GUC is restored from gp_guc_restore_list
628
+
-- successfully no RemoveTempRelationsCallback is called.
629
+
-- So check that segments still have temp schemas
630
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
631
+
count
632
+
-------
633
+
3
634
+
(1 row)
635
+
636
+
-- Cleanup
637
+
DROP TABLE just_a_temp_table;
638
+
-- Test single query GUC TimeZone rollback
639
+
-- Set TimeZone to value that has to be quoted due to slash
640
+
SET TimeZone TO 'Africa/Mbabane';
641
+
-- Function just to save TimeZone to gp_guc_restore_list
642
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
643
+
AS $$
644
+
BEGIN
645
+
EXECUTE 'SELECT 1;';
646
+
END;
647
+
$$ LANGUAGE plpgsql
648
+
SET TimeZone TO 'UTC';
649
+
-- Create temp table to create temp schema
650
+
CREATE TEMP TABLE just_a_temp_table (a int);
651
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
652
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
653
+
-- Temp schema should be created for each segment
654
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
655
+
count
656
+
-------
657
+
3
658
+
(1 row)
659
+
660
+
-- Save TimeZone GUC to gp_guc_restore_list
661
+
SELECT set_conf_param();
662
+
set_conf_param
663
+
----------------
664
+
665
+
(1 row)
666
+
667
+
-- Trigger TimeZone GUC restore from gp_guc_restore_list
668
+
SELECT 1;
669
+
?column?
670
+
----------
671
+
1
458
672
(1 row)
459
673
674
+
-- When TimeZone GUC is restored from gp_guc_restore_list
675
+
-- successfully no RemoveTempRelationsCallback is called.
676
+
-- So check that segments still have temp schemas
677
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
678
+
count
679
+
-------
680
+
3
681
+
(1 row)
682
+
683
+
-- Cleanup
684
+
DROP TABLE just_a_temp_table;
685
+
-- Test single query search_path GUC rollback
686
+
-- Add empty value to search_path that caused issues before
687
+
-- to verify that rollback it it will be successful.
688
+
SET search_path TO public, '';
689
+
-- Function just to save default_tablespace GUC to gp_guc_restore_list
690
+
CREATE OR REPLACE FUNCTION set_conf_param() RETURNS VOID
691
+
AS $$
692
+
BEGIN
693
+
EXECUTE 'SELECT 1;';
694
+
END;
695
+
$$ LANGUAGE plpgsql
696
+
SET search_path TO "public";
697
+
-- Create temp table to create temp schema
698
+
CREATE TEMP TABLE just_a_temp_table (a int);
699
+
-- Temp schema should be created for each segment
700
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
701
+
count
702
+
-------
703
+
3
704
+
(1 row)
705
+
706
+
-- Save default_tablespace GUC to gp_guc_restore_list
707
+
SELECT set_conf_param();
708
+
set_conf_param
709
+
----------------
710
+
711
+
(1 row)
712
+
713
+
-- Trigger default_tablespace GUC restore from gp_guc_restore_list
714
+
SELECT 1;
715
+
?column?
716
+
----------
717
+
1
718
+
(1 row)
719
+
720
+
-- When search_path GUC is restored from gp_guc_restore_list
721
+
-- successfully no RemoveTempRelationsCallback is called.
722
+
-- So check that segments still have temp schemas
723
+
SELECT count(nspname) FROM gp_dist_random('pg_namespace') WHERE nspname LIKE 'pg_temp%';
724
+
count
725
+
-------
726
+
3
727
+
(1 row)
728
+
729
+
-- Cleanup
730
+
DROP TABLE just_a_temp_table;
731
+
RESET search_path;
460
732
-- enabling gp_force_random_redistribution makes sure random redistribution happens
0 commit comments