-
Notifications
You must be signed in to change notification settings - Fork 67
fix: avoid using uninitialized memory #172
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
Open
buriedpot
wants to merge
3
commits into
postgrespro:master
Choose a base branch
from
buriedpot:fix/avoid_using_uninitialized_memory
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| -- Test RUM index scan correctness after concurrent VACUUM removes all | ||
| -- posting tree entry items. | ||
| SET enable_seqscan TO off; | ||
| SET enable_indexscan TO off; | ||
| SET enable_bitmapscan TO on; | ||
| CREATE TABLE test_rum_vacuum (id int, body tsvector); | ||
| ALTER TABLE test_rum_vacuum SET (autovacuum_enabled = false); | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great ann') FROM generate_series(1, 6) i; | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(7, 10000) i; | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great james') FROM generate_series(10001, 10003) i; | ||
| CREATE INDEX ON test_rum_vacuum USING rum (body rum_tsvector_ops); | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'ann'::tsquery AND id <= 5; | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery AND id <= 9999; | ||
| -- test normal result | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| id | body | ||
| ----+------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| (1 row) | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| id | body | ||
| -------+-------------------- | ||
| 10000 | 'great':1 'john':2 | ||
| (1 row) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| 10000 | 'great':1 'john':2 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (5 rows) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 10000 | 'great':1 'john':2 | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (5 rows) | ||
|
|
||
| VACUUM test_rum_vacuum; | ||
| -- this shouldn't cause a core dump | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| id | body | ||
| ----+------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| (1 row) | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| id | body | ||
| -------+-------------------- | ||
| 10000 | 'great':1 'john':2 | ||
| (1 row) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| 10000 | 'great':1 'john':2 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (5 rows) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 10000 | 'great':1 'john':2 | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (5 rows) | ||
|
|
||
| -- test that data can still be found after reinsertion | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(10004, 20000) i; | ||
| SELECT count(*) FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| count | ||
| ------- | ||
| 9998 | ||
| (1 row) | ||
|
|
||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery AND id <= 19999; | ||
| VACUUM test_rum_vacuum; | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| id | body | ||
| ----+------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| (1 row) | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| id | body | ||
| -------+-------------------- | ||
| 20000 | 'great':1 'john':2 | ||
| (1 row) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| 20000 | 'great':1 'john':2 | ||
| (5 rows) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 20000 | 'great':1 'john':2 | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (5 rows) | ||
|
|
||
| -- test if do while loop works when an entry has no non-empty posting tree pages | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(7, 10000) i; | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery; | ||
| VACUUM test_rum_vacuum; | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| id | body | ||
| ----+------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| (1 row) | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| id | body | ||
| ----+------ | ||
| (0 rows) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (4 rows) | ||
|
|
||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
| id | body | ||
| -------+-------------------- | ||
| 6 | 'ann':2 'great':1 | ||
| 10001 | 'great':1 'jame':2 | ||
| 10002 | 'great':1 'jame':2 | ||
| 10003 | 'great':1 'jame':2 | ||
| (4 rows) |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| -- Test RUM index scan correctness after concurrent VACUUM removes all | ||
| -- posting tree entry items. | ||
|
|
||
| SET enable_seqscan TO off; | ||
| SET enable_indexscan TO off; | ||
| SET enable_bitmapscan TO on; | ||
|
|
||
| CREATE TABLE test_rum_vacuum (id int, body tsvector); | ||
| ALTER TABLE test_rum_vacuum SET (autovacuum_enabled = false); | ||
|
|
||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great ann') FROM generate_series(1, 6) i; | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(7, 10000) i; | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great james') FROM generate_series(10001, 10003) i; | ||
|
|
||
| CREATE INDEX ON test_rum_vacuum USING rum (body rum_tsvector_ops); | ||
|
|
||
| DELETE FROM test_rum_vacuum WHERE body @@ 'ann'::tsquery AND id <= 5; | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery AND id <= 9999; | ||
|
|
||
| -- test normal result | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
|
|
||
| VACUUM test_rum_vacuum; | ||
|
|
||
| -- this shouldn't cause a core dump | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
|
|
||
| -- test that data can still be found after reinsertion | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(10004, 20000) i; | ||
| SELECT count(*) FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery AND id <= 19999; | ||
|
|
||
| VACUUM test_rum_vacuum; | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; | ||
|
|
||
| -- test if do while loop works when an entry has no non-empty posting tree pages | ||
| INSERT INTO test_rum_vacuum SELECT i, to_tsvector('great john') FROM generate_series(7, 10000) i; | ||
| DELETE FROM test_rum_vacuum WHERE body @@ 'john'::tsquery; | ||
| VACUUM test_rum_vacuum; | ||
|
|
||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('ann'); | ||
| SELECT * FROM test_rum_vacuum WHERE body @@ to_tsquery('john'); | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('ann') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('ann')) AS sub ORDER BY distance ASC, id ASC; | ||
| SELECT id, body FROM (SELECT id, body, body <=> to_tsquery('john') AS distance FROM test_rum_vacuum ORDER BY body <=> to_tsquery('john')) AS sub ORDER BY distance ASC, id ASC; |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.