Commit c4f89093 authored by haoyuz3's avatar haoyuz3
Browse files

add func.sql

parent 14c5c308
create or replace function add_provtuple(
tablename regclass
)
returns void
as $$
declare
curid integer := 0;
tupleid text;
_ctid tid;
begin
EXECUTE format('alter table %s add column if not exists provtuple varchar(20)', tablename);
for _ctid in execute 'select ctid from ' || tablename for update
loop
tupleid = 'tuple ' || curid;
EXECUTE format('update %s
set provtuple = ''%s''
where ctid = $1', tablename, tupleid)
using _ctid;
curid = curid + 1;
end loop;
end; $$
language plpgsql;
select student.name from student join regu on student.name = regu.name;
provenance formula | name | provsql-token
(student.t1 ⊗ regu.t1) ⊕ (student.t1 ⊗ regu.t2) | jhon | 004c4f1a-67d8-5aa5-b5e3-c2aee1b834d7
(student.t2 ⊗ regu.t3) | mike | c3374551-4f71-586b-90d6-67f592592433
(student.t3 ⊗ regu.t4) ⊕ (student.t3 ⊗ regu.t5) | jack | acf08ab2-1a50-527e-9823-b2ea0ecc2ccb
(student.t1 ⊗ regu.t1) ⊕ (student.t1 ⊗ regu.t2) | jhon | ee800acf-8736-55d9-80ef-5de98f255cbf
(student.t2 ⊗ regu.t3) | mike | a857d9c0-f900-5b25-925c-c8ea0c3f85cc
(student.t3 ⊗ regu.t4) ⊕ (student.t3 ⊗ regu.t5) | jack | a39d5b90-95b6-5dd0-84e6-4ce63870fe33
---------------------------
select student.name from student join (select name from regu) as r on student.name = r.name;
provenance formula | name | provsql-token
(student.t1 ⊗ regu.t1) ⊕ (student.t1 ⊗ regu.t2) | jhon | 35e40191-71ae-5948-bb7b-b506ec569f19
(student.t2 ⊗ regu.t3) | mike | 7efa0002-9d56-5f40-979d-01bef85ad75e
(student.t3 ⊗ regu.t4) ⊕ (student.t3 ⊗ regu.t5) | jack | 8a693cc2-3ebf-5d3d-970a-21094986eaa7
(student.t1 ⊗ regu.t1) ⊕ (student.t1 ⊗ regu.t2) | jhon | 00f6a7b7-7d26-5bb8-b4c2-ec21bd400253
(student.t2 ⊗ regu.t3) | mike | 62c92b62-f4c1-5d79-a1a4-206818c5c902
(student.t3 ⊗ regu.t4) ⊕ (student.t3 ⊗ regu.t5) | jack | 5f8152f4-7722-538b-8d8b-92bb80a44af0
---------------------------
#!/bin/sh
git add .
git commit -m "debug"
git push
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment