|
| 1 | +-- Test the standard flow |
| 2 | +select |
| 3 | + pgmq.create('Foo'); |
| 4 | + create |
| 5 | +-------- |
| 6 | + |
| 7 | +(1 row) |
| 8 | + |
| 9 | +select |
| 10 | + * |
| 11 | +from |
| 12 | + pgmq.send( |
| 13 | + queue_name:='Foo', |
| 14 | + msg:='{"foo": "bar1"}' |
| 15 | + ); |
| 16 | + send |
| 17 | +------ |
| 18 | + 1 |
| 19 | +(1 row) |
| 20 | + |
| 21 | +-- Test queue is not case sensitive |
| 22 | +select |
| 23 | + msg_id, |
| 24 | + read_ct, |
| 25 | + message |
| 26 | +from |
| 27 | + pgmq.send( |
| 28 | + queue_name:='foo', -- note: lowercase useage |
| 29 | + msg:='{"foo": "bar2"}', |
| 30 | + delay:=5 |
| 31 | + ); |
| 32 | +ERROR: column "msg_id" does not exist |
| 33 | +LINE 2: msg_id, |
| 34 | + ^ |
| 35 | +select |
| 36 | + msg_id, |
| 37 | + read_ct, |
| 38 | + message |
| 39 | +from |
| 40 | + pgmq.read( |
| 41 | + queue_name:='Foo', |
| 42 | + vt:=30, |
| 43 | + qty:=2 |
| 44 | + ); |
| 45 | + msg_id | read_ct | message |
| 46 | +--------+---------+----------------- |
| 47 | + 1 | 1 | {"foo": "bar1"} |
| 48 | +(1 row) |
| 49 | + |
| 50 | +select |
| 51 | + msg_id, |
| 52 | + read_ct, |
| 53 | + message |
| 54 | +from |
| 55 | + pgmq.pop('Foo'); |
| 56 | + msg_id | read_ct | message |
| 57 | +--------+---------+--------- |
| 58 | +(0 rows) |
| 59 | + |
| 60 | +-- Archive message with msg_id=2. |
| 61 | +select |
| 62 | + pgmq.archive( |
| 63 | + queue_name:='Foo', |
| 64 | + msg_id:=2 |
| 65 | + ); |
| 66 | + archive |
| 67 | +--------- |
| 68 | + f |
| 69 | +(1 row) |
| 70 | + |
| 71 | +select |
| 72 | + pgmq.create('my_queue'); |
| 73 | + create |
| 74 | +-------- |
| 75 | + |
| 76 | +(1 row) |
| 77 | + |
| 78 | +select |
| 79 | + pgmq.send_batch( |
| 80 | + queue_name:='my_queue', |
| 81 | + msgs:=array['{"foo": "bar3"}','{"foo": "bar4"}','{"foo": "bar5"}']::jsonb[] |
| 82 | +); |
| 83 | + send_batch |
| 84 | +------------ |
| 85 | + 1 |
| 86 | + 2 |
| 87 | + 3 |
| 88 | +(3 rows) |
| 89 | + |
| 90 | +select |
| 91 | + pgmq.archive( |
| 92 | + queue_name:='my_queue', |
| 93 | + msg_ids:=array[3, 4, 5] |
| 94 | + ); |
| 95 | + archive |
| 96 | +--------- |
| 97 | + 3 |
| 98 | +(1 row) |
| 99 | + |
| 100 | +select |
| 101 | + pgmq.delete('my_queue', 6); |
| 102 | + delete |
| 103 | +-------- |
| 104 | + f |
| 105 | +(1 row) |
| 106 | + |
| 107 | +select |
| 108 | + pgmq.drop_queue('my_queue'); |
| 109 | + drop_queue |
| 110 | +------------ |
| 111 | + t |
| 112 | +(1 row) |
| 113 | + |
| 114 | +-- Make sure SQLI enabling characters are blocked |
| 115 | +select pgmq.create('F--oo'); |
| 116 | +ERROR: queue name contains invalid characters: $, ;, --, or \' |
| 117 | +CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE |
| 118 | +PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization |
| 119 | +SQL statement "SELECT pgmq.create_non_partitioned(queue_name)" |
| 120 | +PL/pgSQL function pgmq."create"(text) line 3 at PERFORM |
| 121 | +select pgmq.create('F$oo'); |
| 122 | +ERROR: queue name contains invalid characters: $, ;, --, or \' |
| 123 | +CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE |
| 124 | +PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization |
| 125 | +SQL statement "SELECT pgmq.create_non_partitioned(queue_name)" |
| 126 | +PL/pgSQL function pgmq."create"(text) line 3 at PERFORM |
| 127 | +select pgmq.create($$F'oo$$); |
| 128 | +ERROR: queue name contains invalid characters: $, ;, --, or \' |
| 129 | +CONTEXT: PL/pgSQL function pgmq.format_table_name(text,text) line 5 at RAISE |
| 130 | +PL/pgSQL function pgmq.create_non_partitioned(text) line 3 during statement block local variable initialization |
| 131 | +SQL statement "SELECT pgmq.create_non_partitioned(queue_name)" |
| 132 | +PL/pgSQL function pgmq."create"(text) line 3 at PERFORM |
0 commit comments