Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
Parsed test spec with 32 sessions
 
starting permutation: create_public duplicate_public incompatible_private
step create_public: 
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_CP_SHARED_Ж'::varchar2,
        private => false);
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step duplicate_public: 
    SELECT dbms_pipe_create_pipe(
        'dbms_pipe_cp_shared_ж'::varchar2,
        private => false);
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step incompatible_private: 
    SELECT dbms_pipe_create_pipe(
        'dbms_pipe_cp_shared_ж'::varchar2,
        private => true);
 
ERROR:  ORA-23322: Privilege error accessing pipe
 
starting permutation: pack_a_max pack_b_max pack_a_extra pack_b_extra
step pack_a_max: 
    SELECT dbms_pipe_pack_message(repeat('a', 32760)::varchar2);
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
step pack_b_max: 
    SELECT dbms_pipe_pack_message(repeat('b', 32760)::varchar2);
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
step pack_a_extra: 
    SELECT dbms_pipe_pack_message('x'::varchar2);
 
ERROR:  ORA-06558: buffer in dbms_pipe package is full.  No more items allowed
step pack_b_extra: 
    SELECT dbms_pipe_pack_message('y'::varchar2);
 
ERROR:  ORA-06558: buffer in dbms_pipe package is full.  No more items allowed
 
starting permutation: pack_null
step pack_null: 
    SELECT dbms_pipe_pack_message(NULL::varchar2);
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
 
starting permutation: tx_pack tx_pack_32753 tx_pack_extra
step tx_pack: 
    BEGIN;
    SELECT dbms_pipe_pack_message('x'::varchar2);
    ROLLBACK;
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
step tx_pack_32753: 
    SELECT dbms_pipe_pack_message(repeat('z', 32753)::varchar2);
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
step tx_pack_extra: 
    SELECT dbms_pipe_pack_message('q'::varchar2);
 
ERROR:  ORA-06558: buffer in dbms_pipe package is full.  No more items allowed
 
starting permutation: create_remove_public remove_public_other_backend recreate_after_remove
step create_remove_public: 
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_REMOVE_SHARED_Ж'::varchar2,
        private => false);
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step remove_public_other_backend: 
    SELECT dbms_pipe_remove_pipe(
        'dbms_pipe_remove_shared_ж'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
step recreate_after_remove: 
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_REMOVE_SHARED_Ж'::varchar2,
        private => false);
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: fifo_setup fifo_send fifo_recv1 fifo_recv2 fifo_cleanup
step fifo_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_FIFO_ISO'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_FIFO_ISO'::varchar2, 1000, false, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step fifo_send: 
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message('M1'::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_FIFO_ISO'::varchar2, 0, 1000, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message('M2'::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_FIFO_ISO'::varchar2, 0, 1000, false, 0);
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step fifo_recv1: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_FIFO_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
M1                               
(1 row)
 
step fifo_recv2: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_FIFO_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
M2                               
(1 row)
 
step fifo_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_FIFO_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: wake_setup wake_wait wake_send wake_value wake_cleanup
step wake_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_WAKE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
step wake_wait: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_WAKE_ISO'::varchar2, 5, NULL::varchar2);
 <waiting ...>
step wake_send: 
    -- Ждём подтверждённого ожидания внутри DBMS_PIPE, чтобы исключить гонку теста с SEND.
    DO $$
    DECLARE
        deadline timestamptz := clock_timestamp() + interval '2 seconds';
    BEGIN
        LOOP
            EXIT WHEN EXISTS (
                SELECT 1
                  FROM pg_stat_activity
                 WHERE application_name =
                       'isolation/dbms_pipe/wake_receiver'
                   AND wait_event_type = 'Extension');
            IF clock_timestamp() >= deadline THEN
                RAISE EXCEPTION 'wake receiver did not enter DBMS_PIPE wait';
            END IF;
            PERFORM pg_sleep(0.01);
        END LOOP;
    END
    $$;
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message('WAKE'::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_WAKE_ISO'::varchar2, 0, 1000, false, 0);
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step wake_wait: <... completed>
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
step wake_value: 
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_unpack_message_varchar2
---------------------------------
WAKE                             
(1 row)
 
step wake_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_WAKE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: capacity_setup capacity_wait capacity_drain capacity_cleanup
step capacity_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_CAP_ISO'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_CAP_ISO'::varchar2, 100, false, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('A' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_CAP_ISO'::varchar2, 0, 100, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('B' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_CAP_ISO'::varchar2, 0, 100, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step capacity_wait: 
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('C' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_CAP_ISO'::varchar2, 5, 100, false, 0);
 <waiting ...>
step capacity_drain: 
    -- Сначала убеждаемся, что отправитель действительно ждёт свободного места, и только потом освобождаем его.
    DO $$
    DECLARE
        deadline timestamptz := clock_timestamp() + interval '2 seconds';
    BEGIN
        LOOP
            EXIT WHEN EXISTS (
                SELECT 1
                  FROM pg_stat_activity
                 WHERE application_name =
                       'isolation/dbms_pipe/capacity_sender'
                   AND wait_event_type = 'Extension');
            IF clock_timestamp() >= deadline THEN
                RAISE EXCEPTION 'capacity sender did not enter DBMS_PIPE wait';
            END IF;
            PERFORM pg_sleep(0.01);
        END LOOP;
    END
    $$;
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_CAP_ISO'::varchar2, 0, NULL::varchar2);
    SELECT left(dbms_pipe_unpack_message_varchar2()::text, 1);
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
left
----
A   
(1 row)
 
step capacity_wait: <... completed>
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step capacity_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_CAP_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: remove_receiver_setup remove_receiver_wait remove_receiver_remove
step remove_receiver_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_REMOVE_WAIT_RECV'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_REMOVE_WAIT_RECV'::varchar2, 100, false, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step remove_receiver_wait: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_REMOVE_WAIT_RECV'::varchar2, 2, NULL::varchar2);
 <waiting ...>
step remove_receiver_remove: 
    -- Удаляем pipe только после подтверждения, что receiver действительно вошёл в DBMS_PIPE wait.
    DO $$
    DECLARE
        deadline timestamptz := clock_timestamp() + interval '2 seconds';
    BEGIN
        LOOP
            EXIT WHEN EXISTS (
                SELECT 1
                  FROM pg_stat_activity
                 WHERE application_name =
                       'isolation/dbms_pipe/remove_receiver_waiter'
                   AND wait_event_type = 'Extension');
            IF clock_timestamp() >= deadline THEN
                RAISE EXCEPTION 'receiver did not enter DBMS_PIPE wait';
            END IF;
            PERFORM pg_sleep(0.01);
        END LOOP;
    END
    $$;
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_REMOVE_WAIT_RECV'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
step remove_receiver_wait: <... completed>
dbms_pipe_receive_message
-------------------------
                        1
(1 row)
 
 
starting permutation: remove_sender_setup remove_sender_wait remove_sender_remove
step remove_sender_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2, 100, false, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('A' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2, 0, 100, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('B' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2, 0, 100, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step remove_sender_wait: 
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('C' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2, 2, 100, false, 0);
 <waiting ...>
step remove_sender_remove: 
    -- Полный pipe удаляем только после того, как третий sender подтвердил ожидание capacity.
    DO $$
    DECLARE
        deadline timestamptz := clock_timestamp() + interval '2 seconds';
    BEGIN
        LOOP
            EXIT WHEN EXISTS (
                SELECT 1
                  FROM pg_stat_activity
                 WHERE application_name =
                       'isolation/dbms_pipe/remove_sender_waiter'
                   AND wait_event_type = 'Extension');
            IF clock_timestamp() >= deadline THEN
                RAISE EXCEPTION 'sender did not enter DBMS_PIPE wait';
            END IF;
            PERFORM pg_sleep(0.01);
        END LOOP;
    END
    $$;
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_REMOVE_WAIT_SEND'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
step remove_sender_wait: <... completed>
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     1
(1 row)
 
 
starting permutation: purge_setup purge_wait purge_run purge_read purge_cleanup
step purge_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_PURGE_ISO'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 100, false, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('A' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 0, 100, false, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('B' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 0, 100, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step purge_wait: 
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(('C' || repeat('x', 40))::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 5, 100, false, 0);
 <waiting ...>
step purge_run: 
    -- PURGE запускаем только после подтверждения, что отправитель действительно ждёт.
    DO $$
    DECLARE
        deadline timestamptz := clock_timestamp() + interval '2 seconds';
    BEGIN
        LOOP
            EXIT WHEN EXISTS (
                SELECT 1
                  FROM pg_stat_activity
                 WHERE application_name =
                       'isolation/dbms_pipe/purge_sender'
                   AND wait_event_type = 'Extension');
            IF clock_timestamp() >= deadline THEN
                RAISE EXCEPTION 'purge sender did not enter DBMS_PIPE wait';
            END IF;
            PERFORM pg_sleep(0.01);
        END LOOP;
    END
    $$;
    SELECT dbms_pipe_purge('DBMS_PIPE_PURGE_ISO'::varchar2);
 
dbms_pipe_purge
---------------
               
(1 row)
 
step purge_wait: <... completed>
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step purge_read: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT left(dbms_pipe_unpack_message_varchar2()::text, 1);
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_PURGE_ISO'::varchar2, 0, NULL::varchar2);
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
left
----
C   
(1 row)
 
dbms_pipe_receive_message
-------------------------
                        1
(1 row)
 
step purge_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_PURGE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: unique_setup unique_a_store unique_b_store unique_check unique_cleanup
step unique_setup: 
    CREATE TABLE dbms_pipe_unique_iso
    (
        session_name text NOT NULL,
        call_no integer NOT NULL,
        pipe_name text NOT NULL
    );
 
step unique_a_store: 
    INSERT INTO dbms_pipe_unique_iso
    VALUES
        ('A', 1, dbms_pipe_unique_session_name()),
        ('A', 2, dbms_pipe_unique_session_name());
 
step unique_b_store: 
    INSERT INTO dbms_pipe_unique_iso
    VALUES
        ('B', 1, dbms_pipe_unique_session_name()),
        ('B', 2, dbms_pipe_unique_session_name());
 
step unique_check: 
    SELECT count(*) = 4 AS row_count_ok,
           count(DISTINCT pipe_name) FILTER (
               WHERE session_name = 'A') = 1 AS session_a_stable,
           count(DISTINCT pipe_name) FILTER (
               WHERE session_name = 'B') = 1 AS session_b_stable,
           count(DISTINCT pipe_name) = 2 AS sessions_distinct
      FROM dbms_pipe_unique_iso;
 
row_count_ok|session_a_stable|session_b_stable|sessions_distinct
------------+----------------+----------------+-----------------
t           |t               |t               |t                
(1 row)
 
step unique_cleanup: 
    DROP TABLE dbms_pipe_unique_iso;
 
 
starting permutation: singleton_setup singleton_read_a singleton_read_b singleton_read_after_peers singleton_overwrite singleton_cleanup
step singleton_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_SINGLE_ISO'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 1000, false, true, 0);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message('shared-singleton'::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, 1000, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step singleton_read_a: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
shared-singleton                 
(1 row)
 
step singleton_read_b: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
shared-singleton                 
(1 row)
 
step singleton_read_after_peers: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
shared-singleton                 
(1 row)
 
step singleton_overwrite: 
    -- После чтения из двух backend новый SEND заменяет сообщение singleton и сразу виден управляющему backend.
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message('singleton-overwrite'::varchar2);
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, 1000, false, 0);
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_SINGLE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
singleton-overwrite              
(1 row)
 
step singleton_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_SINGLE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: cache_setup cache_refresh cache_peer_read cache_cleanup
step cache_setup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_CACHE_ISO'::varchar2);
    SELECT dbms_pipe_create_pipe(
        'DBMS_PIPE_CACHE_ISO'::varchar2, 1000, false, true, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_create_pipe
---------------------
                    0
(1 row)
 
step cache_refresh: 
    -- Пустой singleton вызывает cache_func и возвращает созданное им сообщение.
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_CACHE_ISO'::varchar2,
        1,
        'public.dbms_pipe_cache_iso'::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
cache-shared                     
(1 row)
 
step cache_peer_read: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_CACHE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_unpack_message_varchar2();
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
dbms_pipe_unpack_message_varchar2
---------------------------------
cache-shared                     
(1 row)
 
step cache_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_CACHE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
 
starting permutation: date_send date_receive date_cleanup
step date_send: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_DATE_ISO'::varchar2);
    SELECT dbms_pipe_reset_buffer();
    SELECT dbms_pipe_pack_message(TIMESTAMP '2026-10-06 01:02:03.999');
    SELECT dbms_pipe_send_message(
        'DBMS_PIPE_DATE_ISO'::varchar2, 0, 1000, false, 0);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)
 
dbms_pipe_reset_buffer
----------------------
                      
(1 row)
 
dbms_pipe_pack_message
----------------------
                      
(1 row)
 
dbms_pipe_send_message
----------------------
                     0
(1 row)
 
step date_receive: 
    SELECT dbms_pipe_receive_message(
        'DBMS_PIPE_DATE_ISO'::varchar2, 0, NULL::varchar2);
    SELECT dbms_pipe_next_item_type() AS date_type;
    SELECT dbms_pipe_unpack_message_date() IS NOT DISTINCT FROM
           TIMESTAMP '2026-10-06 01:02:03' AS date_matches;
 
dbms_pipe_receive_message
-------------------------
                        0
(1 row)
 
date_type
---------
       12
(1 row)
 
date_matches
------------
t           
(1 row)
 
step date_cleanup: 
    SELECT dbms_pipe_remove_pipe('DBMS_PIPE_DATE_ISO'::varchar2);
 
dbms_pipe_remove_pipe
---------------------
                    0
(1 row)