Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #55: Correct the order of the columns returned by pgmq_read() and pgmq_pop(). #56

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

rzavalet
Copy link
Contributor

The result set columns of pgmq_send() and pgmq_pop() is currently inconsistent with the order of columns in the underlying queue table (See Issue #55). This PR makes the order consistent.

Sample output for pgmq_send():

testdb=# select * from pgmq_send('my_queue', '{"foo": "bar1"}');
 pgmq_send 
-----------
         1
(1 row)

testdb=# select * from pgmq_send('my_queue', '{"foo": "bar2"}');
 pgmq_send 
-----------
         2
(1 row)

testdb=# select * from pgmq_read('my_queue', 30, 2);
 msg_id | read_ct |          enqueued_at          |              vt               |     message     
--------+---------+-------------------------------+-------------------------------+-----------------
      1 |       1 | 2023-08-15 22:59:54.335146-06 | 2023-08-15 23:00:47.513264-06 | {"foo": "bar1"}
      2 |       1 | 2023-08-15 23:00:04.972114-06 | 2023-08-15 23:00:47.513264-06 | {"foo": "bar2"}
(2 rows)

testdb=# select * from pgmq_my_queue;
 msg_id | read_ct |          enqueued_at          |              vt               |     message     
--------+---------+-------------------------------+-------------------------------+-----------------
      1 |       1 | 2023-08-15 22:59:54.335146-06 | 2023-08-15 23:00:47.513264-06 | {"foo": "bar1"}
      2 |       1 | 2023-08-15 23:00:04.972114-06 | 2023-08-15 23:00:47.513264-06 | {"foo": "bar2"}
(2 rows)

Sample output for pgmq_pop():

testdb=# select * from pgmq_send('my_queue', '{"foo": "bar3"}');
 pgmq_send 
-----------
         3
(1 row)

testdb=# select * from pgmq_pop('my_queue');
 msg_id | read_ct |          enqueued_at          |              vt               |     message     
--------+---------+-------------------------------+-------------------------------+-----------------
      3 |       0 | 2023-08-15 23:00:37.947369-06 | 2023-08-15 23:00:37.947369-06 | {"foo": "bar3"}
(1 row)

I verified that the following tests still pass:

> cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running unittests src/lib.rs (target/debug/deps/pgmq-c90b88e7628f9490)

running 7 tests
    Building extension with features pg_test pg15
     Running command "/home/rzavalet/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo" "build" "--features" "pg_test pg15" "--no-default-features" "--message-format=json-render-diagnostics"
  Installing extension
     Copying control file to /opt/postgres/share/extension/pgmq.control
     Copying shared library to /opt/postgres/lib/pgmq.so
     Copying extension schema upgrade file to /opt/postgres/share/extension/pgmq--0.7.4--0.7.5.sql
     Copying extension schema upgrade file to /opt/postgres/share/extension/pgmq--0.11.1--0.11.2.sql
     Copying extension schema upgrade file to /opt/postgres/share/extension/pgmq--0.7.3--0.7.4.sql
     Copying extension schema upgrade file to /opt/postgres/share/extension/pgmq--0.7.5--0.8.0.sql
     Copying extension schema upgrade file to /opt/postgres/share/extension/pgmq--0.8.0--0.8.1.sql
    Finished installing pgmq
test tests::pg_test_validate_same_type ... ok
test partition::tests::pg_test_map_partition_col ... ok
test tests::pg_test_internal ... ok
test tests::pg_test_default ... ok
test tests::pg_test_creat_non_partitioned ... ok
test tests::pg_test_archive ... ok
test tests::pg_test_partitioned ... ok

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.39s

stopping postgres (pid=273762)
     Running tests/integration_tests.rs (target/debug/deps/integration_tests-2cedb8858eeabbb1)

running 1 test
test test_lifecycle ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.63s

Let me know if I should test something else.

The order now matches that of the underlying queue table.
@ChuckHend
Copy link
Member

All the tests passed in CI too. Thank you for helping!

@ChuckHend ChuckHend merged commit 5b5aa84 into tembo-io:main Aug 16, 2023
7 checks passed
@ChuckHend
Copy link
Member

closes #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants