@@ -521,6 +521,34 @@ select id, js -> 100 from test_jsonxa_arr order by id;
521
521
20 | 101
522
522
(14 rows)
523
523
524
+ update test_jsonxa_arr set js = json_modify(js, set '$[LAST+1]' = '0') where id = 10;
525
+ select pg_column_size(js) from test_jsonxa_arr where id = 10;
526
+ pg_column_size
527
+ ----------------
528
+ 134
529
+ (1 row)
530
+
531
+ update test_jsonxa_arr set js = json_modify(js, set '$[LAST+1]' = '0') where id = 10;
532
+ select pg_column_size(js) from test_jsonxa_arr where id = 10;
533
+ pg_column_size
534
+ ----------------
535
+ 150
536
+ (1 row)
537
+
538
+ update test_jsonxa_arr set js = json_modify(js, set '$[LAST+1]' = '0') where id = 10;
539
+ select pg_column_size(js) from test_jsonxa_arr where id = 10;
540
+ pg_column_size
541
+ ----------------
542
+ 154
543
+ (1 row)
544
+
545
+ update test_jsonxa_arr set js = json_modify(js, set '$[LAST+1]' = '0') where id = 10;
546
+ select pg_column_size(js) from test_jsonxa_arr where id = 10;
547
+ pg_column_size
548
+ ----------------
549
+ 158
550
+ (1 row)
551
+
524
552
update test_jsonxa_arr set js = json_modify(js, set '$[0 to 3]' = '0');
525
553
select id, json_query(js, '$[0 to 10]' with wrapper) from test_jsonxa_arr order by id;
526
554
id | json_query
@@ -581,6 +609,26 @@ select id, json_query(js, '$[290 to 310]' with wrapper) from test_jsonxa_arr ord
581
609
20 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 298, 299, 300, 301, 302, 303, 304, 305, 306, 307]
582
610
(14 rows)
583
611
612
+ update test_jsonxa_arr set js = json_modify(js, set '$[100,500,1000]' = '0');
613
+ select id, json_query(js, '$[95 to 105, 495 to 505, 995 to 1005]' with wrapper) from test_jsonxa_arr order by id;
614
+ id | json_query
615
+ ----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
616
+ 7 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", null, null, null, null, null, "0", null, null, null, null, null, null, null, null, null, null, "0"]
617
+ 8 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", null, null, null, null, null, "0", null, null, null, null, null, null, null, null, null, null, "0"]
618
+ 9 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, null, null, null, null, null, "0"]
619
+ 10 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
620
+ 11 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
621
+ 12 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
622
+ 13 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
623
+ 14 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
624
+ 15 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
625
+ 16 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
626
+ 17 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
627
+ 18 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
628
+ 19 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
629
+ 20 | ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 492, 493, 494, 495, 496, "0", 498, 499, 500, 501, 502, 992, 993, 994, 995, 996, "0", 998, 999, 1000, 1001, 1002]
630
+ (14 rows)
631
+
584
632
update test_jsonxa_arr set js = json_modify(js, insert '$[1000003 to 1000005]' = '0');
585
633
select id, json_query(js, '$[1000000 to 1000010]' with wrapper) from test_jsonxa_arr order by id;
586
634
id | json_query
@@ -601,3 +649,97 @@ select id, json_query(js, '$[1000000 to 1000010]' with wrapper) from test_jsonxa
601
649
20 | [999997, 999998, 999999, "0", 1000000, "0", 1000001, "0", 1000002, 1000003, 1000004]
602
650
(14 rows)
603
651
652
+ truncate test_jsonxa_arr;
653
+ insert into test_jsonxa_arr
654
+ select i, (select jsonb_agg(j) from generate_series(1, (2 ^ i)::int) j)
655
+ from generate_series(7, 20) i;
656
+ update test_jsonxa_arr set js = json_modify(js, remove '$[0 to 10]');
657
+ select id, json_query(js, '$[0 to 20]' with wrapper) from test_jsonxa_arr order by id;
658
+ id | json_query
659
+ ----+--------------------------------------------------------------------------------------
660
+ 7 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
661
+ 8 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
662
+ 9 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
663
+ 10 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
664
+ 11 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
665
+ 12 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
666
+ 13 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
667
+ 14 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
668
+ 15 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
669
+ 16 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
670
+ 17 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
671
+ 18 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
672
+ 19 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
673
+ 20 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
674
+ (14 rows)
675
+
676
+ update test_jsonxa_arr set js = json_modify(js, remove '$[20 to 200]');
677
+ select id, json_query(js, '$[0 to 30]' with wrapper) from test_jsonxa_arr order by id;
678
+ id | json_query
679
+ ----+-----------------------------------------------------------------------------------------------------------------------------------------
680
+ 7 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
681
+ 8 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
682
+ 9 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
683
+ 10 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
684
+ 11 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
685
+ 12 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
686
+ 13 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
687
+ 14 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
688
+ 15 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
689
+ 16 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
690
+ 17 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
691
+ 18 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
692
+ 19 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
693
+ 20 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]
694
+ (14 rows)
695
+
696
+ update test_jsonxa_arr set js = json_modify(js, remove '$[30 to 100000]');
697
+ select id, json_query(js, '$[0 to 40]' with wrapper) from test_jsonxa_arr order by id;
698
+ id | json_query
699
+ ----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
700
+ 7 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
701
+ 8 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
702
+ 9 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
703
+ 10 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
704
+ 11 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
705
+ 12 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
706
+ 13 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
707
+ 14 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
708
+ 15 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
709
+ 16 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222]
710
+ 17 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 100194, 100195, 100196, 100197, 100198, 100199, 100200, 100201, 100202, 100203, 100204]
711
+ 18 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 100194, 100195, 100196, 100197, 100198, 100199, 100200, 100201, 100202, 100203, 100204]
712
+ 19 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 100194, 100195, 100196, 100197, 100198, 100199, 100200, 100201, 100202, 100203, 100204]
713
+ 20 | [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 100194, 100195, 100196, 100197, 100198, 100199, 100200, 100201, 100202, 100203, 100204]
714
+ (14 rows)
715
+
716
+ -- test vacuum full
717
+ truncate test_jsonxa_arr;
718
+ insert into test_jsonxa_arr
719
+ select i, (select jsonb_agg(j) from generate_series(1, (2 ^ i)::int) j)
720
+ from generate_series(7, 20) i;
721
+ update test_jsonxa_arr set js = json_modify(js, set '$[1, 101, 201, 301, 401, 501, 1001, 1501, 2001, 3001, 5001]' = '0');
722
+ select format('vacuum full pg_toast.pg_toast_%s', 'test_jsonxa_arr'::regclass::oid)
723
+ \gexec
724
+ vacuum full pg_toast.pg_toast_16461
725
+ WARNING: skipping "pg_toast_16461" --- VACUUM FULL is disabled by toaster
726
+ vacuum full test_jsonxa_arr;
727
+ select id, json_query(js, '$[0 to 2, 100 to 102, 200 to 202, 300 to 302, 400 to 402, 500 to 502, 1000 to 1002, 1500 to 1502, 2000 to 2002, 3000 to 3002, 5000 to 5002]' with wrapper) from test_jsonxa_arr order by id;
728
+ id | json_query
729
+ ----+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
730
+ 7 | [1, "0", 3, 101, "0", 103, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0"]
731
+ 8 | [1, "0", 3, 101, "0", 103, 201, "0", 203, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0"]
732
+ 9 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, null, "0", null, null, "0", null, null, "0", null, null, "0", null, null, "0"]
733
+ 10 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, null, "0", null, null, "0", null, null, "0", null, null, "0"]
734
+ 11 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, null, "0", null, null, "0"]
735
+ 12 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, null, "0"]
736
+ 13 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
737
+ 14 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
738
+ 15 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
739
+ 16 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
740
+ 17 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
741
+ 18 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
742
+ 19 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
743
+ 20 | [1, "0", 3, 101, "0", 103, 201, "0", 203, 301, "0", 303, 401, "0", 403, 501, "0", 503, 1001, "0", 1003, 1501, "0", 1503, 2001, "0", 2003, 3001, "0", 3003, 5001, "0", 5003]
744
+ (14 rows)
745
+