diff --git a/contrib/tsm_system_rows/expected/tsm_system_rows.out b/contrib/tsm_system_rows/expected/tsm_system_rows.out index 7e0f72b..4b8bcaa 100644 --- a/contrib/tsm_system_rows/expected/tsm_system_rows.out +++ b/contrib/tsm_system_rows/expected/tsm_system_rows.out @@ -11,14 +11,14 @@ SELECT count(*) FROM test_tablesample TABLESAMPLE system_rows (1000); SELECT id FROM test_tablesample TABLESAMPLE system_rows (8) REPEATABLE (5432); id ---- + 10 + 17 + 24 + 0 7 14 21 28 - 4 - 11 - 18 - 25 (8 rows) EXPLAIN SELECT id FROM test_tablesample TABLESAMPLE system_rows (20) REPEATABLE (10); diff --git a/contrib/tsm_system_time/expected/tsm_system_time.out b/contrib/tsm_system_time/expected/tsm_system_time.out index 32ad03c..e07860a 100644 --- a/contrib/tsm_system_time/expected/tsm_system_time.out +++ b/contrib/tsm_system_time/expected/tsm_system_time.out @@ -11,6 +11,10 @@ SELECT count(*) FROM test_tablesample TABLESAMPLE system_time (1000); SELECT id FROM test_tablesample TABLESAMPLE system_time (1000) REPEATABLE (5432); id ---- + 10 + 17 + 24 + 0 7 14 21 @@ -38,10 +42,6 @@ SELECT id FROM test_tablesample TABLESAMPLE system_time (1000) REPEATABLE (5432) 20 27 3 - 10 - 17 - 24 - 0 (31 rows) EXPLAIN SELECT id FROM test_tablesample TABLESAMPLE system_time (100) REPEATABLE (10); diff --git a/src/backend/utils/misc/sampling.c b/src/backend/utils/misc/sampling.c index aaf1d6c..141dcfd 100644 --- a/src/backend/utils/misc/sampling.c +++ b/src/backend/utils/misc/sampling.c @@ -233,11 +233,11 @@ sampler_random_init_state(long seed, SamplerRandomState randstate) randstate[2] = (unsigned short) (seed >> 16); } -/* Select a random value R uniformly distributed in (0 - 1) */ +/* Select a random value R uniformly distributed in (0.0,1.0] */ double sampler_random_fract(SamplerRandomState randstate) { - return pg_erand48(randstate); + return 1 - pg_erand48(randstate); } diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out index 0ae5557..b2dac30 100644 --- a/src/test/regress/expected/rowsecurity.out +++ b/src/test/regress/expected/rowsecurity.out @@ -102,15 +102,11 @@ NOTICE: f_leak => great manga (4 rows) SELECT * FROM document TABLESAMPLE BERNOULLI (50) REPEATABLE(1) WHERE f_leak(dtitle) ORDER BY did; -NOTICE: f_leak => my first novel -NOTICE: f_leak => my first manga -NOTICE: f_leak => great science fiction - did | cid | dlevel | dauthor | dtitle ------+-----+--------+-------------------+----------------------- - 1 | 11 | 1 | rls_regress_user1 | my first novel - 4 | 44 | 1 | rls_regress_user1 | my first manga - 6 | 22 | 1 | rls_regress_user2 | great science fiction -(3 rows) +NOTICE: f_leak => great manga + did | cid | dlevel | dauthor | dtitle +-----+-----+--------+-------------------+------------- + 8 | 44 | 1 | rls_regress_user2 | great manga +(1 row) -- viewpoint from rls_regress_user2 SET SESSION AUTHORIZATION rls_regress_user2; @@ -157,19 +153,15 @@ NOTICE: f_leak => great manga (8 rows) SELECT * FROM document TABLESAMPLE BERNOULLI (50) REPEATABLE(1) WHERE f_leak(dtitle) ORDER BY did; -NOTICE: f_leak => my first novel -NOTICE: f_leak => my second novel -NOTICE: f_leak => my first manga -NOTICE: f_leak => great science fiction -NOTICE: f_leak => great technology book - did | cid | dlevel | dauthor | dtitle ------+-----+--------+-------------------+----------------------- - 1 | 11 | 1 | rls_regress_user1 | my first novel - 2 | 11 | 2 | rls_regress_user1 | my second novel - 4 | 44 | 1 | rls_regress_user1 | my first manga - 6 | 22 | 1 | rls_regress_user2 | great science fiction - 7 | 33 | 2 | rls_regress_user2 | great technology book -(5 rows) +NOTICE: f_leak => my science fiction +NOTICE: f_leak => my second manga +NOTICE: f_leak => great manga + did | cid | dlevel | dauthor | dtitle +-----+-----+--------+-------------------+-------------------- + 3 | 22 | 2 | rls_regress_user1 | my science fiction + 5 | 44 | 2 | rls_regress_user1 | my second manga + 8 | 44 | 1 | rls_regress_user2 | great manga +(3 rows) EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle); QUERY PLAN diff --git a/src/test/regress/expected/tablesample.out b/src/test/regress/expected/tablesample.out index 04e5eb8..bcd1aba 100644 --- a/src/test/regress/expected/tablesample.out +++ b/src/test/regress/expected/tablesample.out @@ -3,21 +3,21 @@ INSERT INTO test_tablesample SELECT i, repeat(i::text, 200) FROM generate_series SELECT t.id FROM test_tablesample AS t TABLESAMPLE SYSTEM (50) REPEATABLE (10); id ---- - 0 - 1 - 2 3 4 5 + 6 + 7 + 8 9 (7 rows) SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (100.0/11) REPEATABLE (9999); id ---- - 6 - 7 - 8 + 3 + 4 + 5 (3 rows) SELECT count(*) FROM test_tablesample TABLESAMPLE SYSTEM (100); @@ -32,28 +32,26 @@ SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (100); 0 1 2 - 6 - 7 - 8 + 3 + 4 + 5 9 (7 rows) SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (50) REPEATABLE (100); id ---- - 0 - 1 - 3 - 4 - 5 -(5 rows) + 2 + 6 + 7 + 8 +(4 rows) SELECT id FROM test_tablesample TABLESAMPLE BERNOULLI (5.5) REPEATABLE (1); id ---- - 0 - 5 -(2 rows) + 7 +(1 row) CREATE VIEW test_tablesample_v1 AS SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (10*2) REPEATABLE (2); CREATE VIEW test_tablesample_v2 AS SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (99); @@ -94,31 +92,31 @@ FETCH NEXT FROM tablesample_cur; SELECT id FROM test_tablesample TABLESAMPLE SYSTEM (50) REPEATABLE (10); id ---- - 0 - 1 - 2 3 4 5 + 6 + 7 + 8 9 (7 rows) FETCH NEXT FROM tablesample_cur; id ---- - 6 + 3 (1 row) FETCH NEXT FROM tablesample_cur; id ---- - 7 + 4 (1 row) FETCH NEXT FROM tablesample_cur; id ---- - 8 + 5 (1 row) FETCH FIRST FROM tablesample_cur; @@ -142,19 +140,19 @@ FETCH NEXT FROM tablesample_cur; FETCH NEXT FROM tablesample_cur; id ---- - 6 + 3 (1 row) FETCH NEXT FROM tablesample_cur; id ---- - 7 + 4 (1 row) FETCH NEXT FROM tablesample_cur; id ---- - 8 + 5 (1 row) CLOSE tablesample_cur;