mirror of https://github.com/citusdata/citus.git
Update test to use citus_is_coordinator()
with a wrapper to make it a stable function and ensure part of the query is executed on coordinator. Thanks @onurctirtir for the test/tip.pull/7914/head
parent
b201eee280
commit
2e61a9d552
|
@ -814,40 +814,31 @@ SELECT * FROM app_analytics_events ORDER BY id;
|
||||||
DROP TABLE app_analytics_events;
|
DROP TABLE app_analytics_events;
|
||||||
-- test function call in UPDATE SET
|
-- test function call in UPDATE SET
|
||||||
-- https://github.com/citusdata/citus/issues/7676
|
-- https://github.com/citusdata/citus/issues/7676
|
||||||
CREATE TABLE test_ref_multiexpr (
|
CREATE FUNCTION citus_is_coordinator_stable() returns bool as $$
|
||||||
id bigint primary key
|
select citus_is_coordinator();
|
||||||
, col_int integer
|
$$ language sql stable;
|
||||||
, col_bool bool
|
CREATE TABLE bool_test (
|
||||||
, col_text text
|
id bigint primary key,
|
||||||
, col_timestamp timestamp
|
col_bool bool
|
||||||
);
|
);
|
||||||
SELECT create_reference_table('test_ref_multiexpr');
|
SELECT create_reference_table('bool_test');
|
||||||
create_reference_table
|
create_reference_table
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
/* TODO how to ensure in test that 'now()' is correctly pre-executed */
|
INSERT INTO bool_test values (1, true);
|
||||||
INSERT INTO test_ref_multiexpr VALUES (1, 1, true, 'one', now());
|
UPDATE bool_test
|
||||||
UPDATE test_ref_multiexpr
|
SET (col_bool)
|
||||||
SET (col_timestamp)
|
= (SELECT citus_is_coordinator_stable())
|
||||||
= (SELECT now())
|
RETURNING id, col_bool;
|
||||||
RETURNING id, col_int, col_bool;
|
id | col_bool
|
||||||
id | col_int | col_bool
|
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
1 | 1 | t
|
1 | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
UPDATE test_ref_multiexpr
|
DROP TABLE bool_test;
|
||||||
SET (col_bool, col_timestamp)
|
DROP FUNCTION citus_is_coordinator_stable();
|
||||||
= (SELECT true, now())
|
|
||||||
RETURNING id, col_int, col_bool;
|
|
||||||
id | col_int | col_bool
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
1 | 1 | t
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
DROP TABLE test_ref_multiexpr;
|
|
||||||
-- Test multi-row insert with serial in a non-partition column
|
-- Test multi-row insert with serial in a non-partition column
|
||||||
CREATE TABLE app_analytics_events (id int, app_id serial, name text);
|
CREATE TABLE app_analytics_events (id int, app_id serial, name text);
|
||||||
SELECT create_distributed_table('app_analytics_events', 'id');
|
SELECT create_distributed_table('app_analytics_events', 'id');
|
||||||
|
|
|
@ -507,29 +507,25 @@ DROP TABLE app_analytics_events;
|
||||||
|
|
||||||
-- test function call in UPDATE SET
|
-- test function call in UPDATE SET
|
||||||
-- https://github.com/citusdata/citus/issues/7676
|
-- https://github.com/citusdata/citus/issues/7676
|
||||||
CREATE TABLE test_ref_multiexpr (
|
CREATE FUNCTION citus_is_coordinator_stable() returns bool as $$
|
||||||
id bigint primary key
|
select citus_is_coordinator();
|
||||||
, col_int integer
|
$$ language sql stable;
|
||||||
, col_bool bool
|
|
||||||
, col_text text
|
CREATE TABLE bool_test (
|
||||||
, col_timestamp timestamp
|
id bigint primary key,
|
||||||
|
col_bool bool
|
||||||
);
|
);
|
||||||
SELECT create_reference_table('test_ref_multiexpr');
|
SELECT create_reference_table('bool_test');
|
||||||
|
|
||||||
/* TODO how to ensure in test that 'now()' is correctly pre-executed */
|
INSERT INTO bool_test values (1, true);
|
||||||
INSERT INTO test_ref_multiexpr VALUES (1, 1, true, 'one', now());
|
|
||||||
|
|
||||||
UPDATE test_ref_multiexpr
|
UPDATE bool_test
|
||||||
SET (col_timestamp)
|
SET (col_bool)
|
||||||
= (SELECT now())
|
= (SELECT citus_is_coordinator_stable())
|
||||||
RETURNING id, col_int, col_bool;
|
RETURNING id, col_bool;
|
||||||
|
|
||||||
UPDATE test_ref_multiexpr
|
DROP TABLE bool_test;
|
||||||
SET (col_bool, col_timestamp)
|
DROP FUNCTION citus_is_coordinator_stable();
|
||||||
= (SELECT true, now())
|
|
||||||
RETURNING id, col_int, col_bool;
|
|
||||||
|
|
||||||
DROP TABLE test_ref_multiexpr;
|
|
||||||
|
|
||||||
-- Test multi-row insert with serial in a non-partition column
|
-- Test multi-row insert with serial in a non-partition column
|
||||||
CREATE TABLE app_analytics_events (id int, app_id serial, name text);
|
CREATE TABLE app_analytics_events (id int, app_id serial, name text);
|
||||||
|
|
Loading…
Reference in New Issue