Created
August 1, 2017 18:32
-
-
Save emiel/4d4fd8c5c5ba9173e3175a08bb055be4 to your computer and use it in GitHub Desktop.
Test case for https://github.com/citusdata/cstore_fdw/issues/132
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table queue | |
( | |
id integer, | |
diff integer | |
); | |
create table cache | |
( | |
id integer primary key, | |
count integer not null, | |
last_update_at timestamptz | |
); | |
create or replace function process_queue() | |
returns bool language plpgsql | |
as $body$ | |
begin | |
insert into cache (id, count, last_update_at) | |
select id, sum(diff), now() | |
from queue | |
group by id | |
on conflict (id) do update set | |
count = cache.count + EXCLUDED.count, | |
last_update_at = EXCLUDED.last_update_at | |
; | |
-- removing the truncate line resolves the issue | |
truncate queue; | |
return true; | |
end; | |
$body$; | |
-- Need to invoke the following a number of times to trigger the segfault in cstore_fdw.so | |
-- No data is required | |
select process_queue(); | |
select process_queue(); | |
select process_queue(); | |
select process_queue(); | |
select process_queue(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment