From a159bd9aed9f026559bea47dc7b051d1b98c5b31 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 17 Apr 2019 14:40:41 +0300 Subject: [PATCH 1/3] Add order by window_functions --- .../regress/expected/window_functions.out | 70 +++++++++---------- .../regress/expected/window_functions_0.out | 6 +- src/test/regress/sql/window_functions.sql | 6 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/test/regress/expected/window_functions.out b/src/test/regress/expected/window_functions.out index 859efbc91..f9e004cc8 100644 --- a/src/test/regress/expected/window_functions.out +++ b/src/test/regress/expected/window_functions.out @@ -422,7 +422,7 @@ FROM WHERE user_id > 2 AND user_id < 6 ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; user_id | value_1 | array_agg | array_agg ---------+---------+-------------------------------------------------------+----------------------------------------------------- 3 | 0 | {0} | @@ -507,7 +507,7 @@ WINDOW range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING), range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; user_id | value_1 | array_agg | array_agg ---------+---------+---------------------------------------+------------------------------------- 3 | 0 | {0,1,1,1,1,1,1} | {1,1,1,1,1,1} @@ -592,40 +592,40 @@ WINDOW row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING), row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; user_id | value_1 | array_agg | array_agg ---------+---------+-----------+----------- 3 | 0 | {0,1} | {1} - 3 | 1 | {1,1,1} | {1,1} - 3 | 1 | {1,1,2} | {1,2} 3 | 1 | {0,1,1} | {0,1} 3 | 1 | {1,1,1} | {1,1} 3 | 1 | {1,1,1} | {1,1} 3 | 1 | {1,1,1} | {1,1} + 3 | 1 | {1,1,1} | {1,1} + 3 | 1 | {1,1,2} | {1,2} 3 | 2 | {1,2,2} | {1,2} 3 | 2 | {2,2,3} | {2,3} 3 | 3 | {2,3,3} | {2,3} - 3 | 3 | {3,3,4} | {3,4} 3 | 3 | {3,3,3} | {3,3} - 3 | 4 | {4,4,4} | {4,4} - 3 | 4 | {4,4,4} | {4,4} + 3 | 3 | {3,3,4} | {3,4} 3 | 4 | {3,4,4} | {3,4} + 3 | 4 | {4,4,4} | {4,4} + 3 | 4 | {4,4,4} | {4,4} 3 | 4 | {4,4,5} | {4,5} 3 | 5 | {4,5} | {4} - 4 | 0 | {0,0,1} | {0,1} - 4 | 0 | {0,0,0} | {0,0} 4 | 0 | {0,0} | {0} 4 | 0 | {0,0,0} | {0,0} + 4 | 0 | {0,0,0} | {0,0} + 4 | 0 | {0,0,1} | {0,1} 4 | 1 | {0,1,2} | {0,2} - 4 | 2 | {2,2,3} | {2,3} - 4 | 2 | {2,2,2} | {2,2} 4 | 2 | {1,2,2} | {1,2} - 4 | 3 | {3,3,4} | {3,4} - 4 | 3 | {3,3,3} | {3,3} - 4 | 3 | {3,3,3} | {3,3} - 4 | 3 | {3,3,3} | {3,3} - 4 | 3 | {3,3,3} | {3,3} + 4 | 2 | {2,2,2} | {2,2} + 4 | 2 | {2,2,3} | {2,3} 4 | 3 | {2,3,3} | {2,3} + 4 | 3 | {3,3,3} | {3,3} + 4 | 3 | {3,3,3} | {3,3} + 4 | 3 | {3,3,3} | {3,3} + 4 | 3 | {3,3,3} | {3,3} + 4 | 3 | {3,3,4} | {3,4} 4 | 4 | {3,4,4} | {3,4} 4 | 4 | {4,4,4} | {4,4} 4 | 4 | {4,4,4} | {4,4} @@ -633,34 +633,34 @@ ORDER BY 4 | 4 | {4,4,4} | {4,4} 4 | 4 | {4,4,4} | {4,4} 4 | 4 | {4,4,5} | {4,5} - 4 | 5 | {5,5} | {5} 4 | 5 | {4,5,5} | {4,5} - 5 | 0 | {0,0,1} | {0,1} + 4 | 5 | {5,5} | {5} 5 | 0 | {0,0} | {0} + 5 | 0 | {0,0,1} | {0,1} + 5 | 1 | {0,1,1} | {0,1} 5 | 1 | {1,1,1} | {1,1} 5 | 1 | {1,1,2} | {1,2} - 5 | 1 | {0,1,1} | {0,1} - 5 | 2 | {2,2,2} | {2,2} 5 | 2 | {1,2,2} | {1,2} + 5 | 2 | {2,2,2} | {2,2} + 5 | 2 | {2,2,2} | {2,2} + 5 | 2 | {2,2,2} | {2,2} + 5 | 2 | {2,2,2} | {2,2} 5 | 2 | {2,2,3} | {2,3} - 5 | 2 | {2,2,2} | {2,2} - 5 | 2 | {2,2,2} | {2,2} - 5 | 2 | {2,2,2} | {2,2} - 5 | 3 | {3,3,4} | {3,4} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} - 5 | 3 | {3,3,3} | {3,3} 5 | 3 | {2,3,3} | {2,3} - 5 | 4 | {4,4,5} | {4,5} - 5 | 4 | {4,4,4} | {4,4} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,3} | {3,3} + 5 | 3 | {3,3,4} | {3,4} 5 | 4 | {3,4,4} | {3,4} + 5 | 4 | {4,4,4} | {4,4} + 5 | 4 | {4,4,5} | {4,5} + 5 | 5 | {4,5,5} | {4,5} 5 | 5 | {5,5} | {5} 5 | 5 | {5,5,5} | {5,5} - 5 | 5 | {4,5,5} | {4,5} (66 rows) -- some tests with GROUP BY, HAVING and LIMIT diff --git a/src/test/regress/expected/window_functions_0.out b/src/test/regress/expected/window_functions_0.out index 305d2c2a1..185765ef4 100644 --- a/src/test/regress/expected/window_functions_0.out +++ b/src/test/regress/expected/window_functions_0.out @@ -422,7 +422,7 @@ FROM WHERE user_id > 2 AND user_id < 6 ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; ERROR: syntax error at or near "EXCLUDE" LINE 5: ...ANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE CU... ^ @@ -440,7 +440,7 @@ WINDOW range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING), range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; ERROR: RANGE PRECEDING is only supported with UNBOUNDED LINE 11: ..._window as (PARTITION BY user_id ORDER BY value_1 RANGE BETW... ^ @@ -458,7 +458,7 @@ WINDOW row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING), row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; ERROR: syntax error at or near "EXCLUDE" LINE 12: ...value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CU... ^ diff --git a/src/test/regress/sql/window_functions.sql b/src/test/regress/sql/window_functions.sql index 071c45519..45e37372e 100644 --- a/src/test/regress/sql/window_functions.sql +++ b/src/test/regress/sql/window_functions.sql @@ -239,7 +239,7 @@ FROM WHERE user_id > 2 AND user_id < 6 ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; -- test preceding and following on RANGE window SELECT @@ -255,7 +255,7 @@ WINDOW range_window as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING), range_window_exclude as (PARTITION BY user_id ORDER BY value_1 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; -- test preceding and following on ROW window SELECT @@ -271,7 +271,7 @@ WINDOW row_window as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING), row_window_exclude as (PARTITION BY user_id ORDER BY value_1 ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW) ORDER BY - user_id, value_1; + user_id, value_1, 3, 4; -- some tests with GROUP BY, HAVING and LIMIT SELECT From b3af5b2cc47715da9d67a3fc2c0f1c5ab6b7e15f Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 17 Apr 2019 14:43:55 +0300 Subject: [PATCH 2/3] Add order by multi_mx_modifications --- src/test/regress/expected/multi_mx_modifications.out | 4 ++-- src/test/regress/sql/multi_mx_modifications.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/regress/expected/multi_mx_modifications.out b/src/test/regress/expected/multi_mx_modifications.out index 47a2873d9..678847ba1 100644 --- a/src/test/regress/expected/multi_mx_modifications.out +++ b/src/test/regress/expected/multi_mx_modifications.out @@ -32,11 +32,11 @@ SELECT COUNT(*) FROM limit_orders_mx WHERE id = 32745; (1 row) -- and see all the inserted rows -SELECT * FROM limit_orders_mx; +SELECT * FROM limit_orders_mx ORDER BY 1; id | symbol | bidder_id | placed_at | kind | limit_price -------+--------+-----------+--------------------------+------+------------- - 32744 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69 32743 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69 + 32744 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69 32745 | AAPL | 9580 | Tue Oct 19 10:23:54 2004 | buy | 20.69 (3 rows) diff --git a/src/test/regress/sql/multi_mx_modifications.sql b/src/test/regress/sql/multi_mx_modifications.sql index 1896376a8..7de25e76f 100644 --- a/src/test/regress/sql/multi_mx_modifications.sql +++ b/src/test/regress/sql/multi_mx_modifications.sql @@ -24,7 +24,7 @@ INSERT INTO limit_orders_mx VALUES (32745, 'AAPL', 9580, '2004-10-19 10:23:54', SELECT COUNT(*) FROM limit_orders_mx WHERE id = 32745; -- and see all the inserted rows -SELECT * FROM limit_orders_mx; +SELECT * FROM limit_orders_mx ORDER BY 1; -- basic single-row INSERT with RETURNING INSERT INTO limit_orders_mx VALUES (32746, 'AAPL', 9580, '2004-10-19 10:23:54', 'buy', 20.69) RETURNING *; From 753163b4d8b0132b374f53ef70ae7d1945945762 Mon Sep 17 00:00:00 2001 From: Onder Kalaci Date: Wed, 17 Apr 2019 14:48:37 +0300 Subject: [PATCH 3/3] Be less verbose for printing worker ports in intermediate_results --- src/test/regress/expected/intermediate_results.out | 5 +++-- src/test/regress/sql/intermediate_results.sql | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/regress/expected/intermediate_results.out b/src/test/regress/expected/intermediate_results.out index 04d8f142d..51d969020 100644 --- a/src/test/regress/expected/intermediate_results.out +++ b/src/test/regress/expected/intermediate_results.out @@ -78,16 +78,17 @@ ORDER BY x; (3 rows) END; +-- don't print the worker port +\set VERBOSITY terse -- files should now be cleaned up SELECT x, x2 FROM interesting_squares JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x text, x2 int)) squares ON (x = interested_in) WHERE user_id = 'jon' ORDER BY x; WARNING: result "squares" does not exist -CONTEXT: while executing command on localhost:57638 WARNING: result "squares" does not exist -CONTEXT: while executing command on localhost:57637 ERROR: could not receive query results +\set VERBOSITY DEFAULT -- try to read the file as text, will fail because of binary encoding BEGIN; SELECT create_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,5) s'); diff --git a/src/test/regress/sql/intermediate_results.sql b/src/test/regress/sql/intermediate_results.sql index 8fd4951f6..9279ebcc9 100644 --- a/src/test/regress/sql/intermediate_results.sql +++ b/src/test/regress/sql/intermediate_results.sql @@ -38,12 +38,17 @@ JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x int, ORDER BY x; END; +-- don't print the worker port +\set VERBOSITY terse + -- files should now be cleaned up SELECT x, x2 FROM interesting_squares JOIN (SELECT * FROM read_intermediate_result('squares', 'binary') AS res (x text, x2 int)) squares ON (x = interested_in) WHERE user_id = 'jon' ORDER BY x; +\set VERBOSITY DEFAULT + -- try to read the file as text, will fail because of binary encoding BEGIN; SELECT create_intermediate_result('squares', 'SELECT s, s*s FROM generate_series(1,5) s');