-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path002-runner.sql
45 lines (37 loc) · 1.41 KB
/
002-runner.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
begin;
set search_path=meta_meta;
CREATE FUNCTION exec(text) RETURNS text AS $$
BEGIN
-- raise notice 'exec: %', $1;
EXECUTE $1;
RETURN $1;
END
$$ LANGUAGE plpgsql;
-- all components except downcasts for every entity
select exec(component_statement(e.name, c.name))
from pg_entity e, pg_entity_component c
where c.position < 30
order by e.name, c.position;
-- downcasts to schema_id for everything that has a schema_name
select exec(component_statement(e.name, c.name))
from pg_entity e, pg_entity_component c
where c.position in (30,31) and 'schema_name' = any(constructor_arg_names)
order by e.name, c.position;
-- downcasts to relation_id for everything that has a relation_name
select exec(component_statement(e.name, c.name))
from pg_entity e, pg_entity_component c
where c.position in(32,33) and 'relation_name' = any(constructor_arg_names)
order by e.name, c.position;
-- downcasts to column_id for everything that has a column_name
select exec(component_statement(e.name, c.name))
from pg_entity e, pg_entity_component c
where c.position in(34,35) and 'column_name' = any(constructor_arg_names)
order by e.name, c.position;
/*
field_id cast to row_id
select e.name as entity_name, c.name as component_name, exec(component_statement(e.name, c.name))
from pg_entity e, pg_entity_component c
where c.position in(26,27) and 'column_name' = any(constructor_arg_names)
order by e.name, c.position;
*/
commit;