Skip to content

Commit

Permalink
response_code
Browse files Browse the repository at this point in the history
  • Loading branch information
lacanoid committed Jun 3, 2021
1 parent a3e1ca2 commit 1294ed7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions datalink.sql
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,11 @@ begin
detail = url,
hint = 'make sure referenced file actually exists';
end if;
end if; -- file link control,
if r.response_code > 0 then
link := jsonb_set(link,array['rc'],to_jsonb(r.response_code));
end if;
end if; -- file link control,

link := jsonb_set(link,array['rc'],to_jsonb(r.response_code));
link := dlpreviouscopy(link,has_token);

if lco.integrity = 'ALL' and dlurlscheme($1)='file' then
Expand Down Expand Up @@ -1118,7 +1120,7 @@ begin
raise exception 'datalink exception'
using errcode = 'HW000',
detail = format('Can''t change link control options; %s non-null values present in column "%s"',n,my_column_name),
hint = format('Perhaps you can truncate %s',my_regclass);
hint = format('Perhaps you can "truncate %s"',my_regclass);
end if;

-- update fdw options with new lco
Expand Down
6 changes: 3 additions & 3 deletions test/expected/link.out
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DETAIL: unknown file volume (prefix) in /etc/passwd
HINT: run "pg_datalinker add" to add volumes
CONTEXT: PL/pgSQL function file_link(file_path,dl_token,dl_lco,regclass,name) line 14 at RAISE
SQL statement "SELECT datalink.file_link(dlurlpathonly(link),(link->>'token')::datalink.dl_token,link_options,regclass,column_name)"
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 36 at PERFORM
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 38 at PERFORM
PL/pgSQL function dl_trigger_table() line 49 at assignment
insert into sample_datalinks4 (link)
values (dlvalue('/var/www/datalink/test1.txt','FS','Sample file datalink 2'));
Expand All @@ -38,7 +38,7 @@ DETAIL: unknown file volume (prefix) in /etc/hosts
HINT: run "pg_datalinker add" to add volumes
CONTEXT: PL/pgSQL function file_link(file_path,dl_token,dl_lco,regclass,name) line 14 at RAISE
SQL statement "SELECT datalink.file_link(dlurlpathonly(link),(link->>'token')::datalink.dl_token,link_options,regclass,column_name)"
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 36 at PERFORM
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 38 at PERFORM
PL/pgSQL function dl_trigger_table() line 49 at assignment
insert into sample_datalinks4 (link)
values (dlvalue('/var/www/datalink/test2.txt','FS','Sample file datalink 4'));
Expand Down Expand Up @@ -82,7 +82,7 @@ DETAIL: unknown file volume (prefix) in /etc/passwd
HINT: run "pg_datalinker add" to add volumes
CONTEXT: PL/pgSQL function file_link(file_path,dl_token,dl_lco,regclass,name) line 14 at RAISE
SQL statement "SELECT datalink.file_link(dlurlpathonly(link),(link->>'token')::datalink.dl_token,link_options,regclass,column_name)"
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 36 at PERFORM
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 38 at PERFORM
PL/pgSQL function dl_trigger_table() line 49 at assignment
insert into sample_datalinks5 (link)
values (dlvalue('/var/www/datalink/test1.txt','FS','Sample file datalink'));
Expand Down
2 changes: 1 addition & 1 deletion test/expected/linker.out
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ERROR: datalink exception - external file already linked
DETAIL: from sample_datalinks6.link as '/var/www/datalink/CHANGELOG.md'
CONTEXT: PL/pgSQL function file_link(file_path,dl_token,dl_lco,regclass,name) line 46 at RAISE
SQL statement "SELECT datalink.file_link(dlurlpathonly(link),(link->>'token')::datalink.dl_token,link_options,regclass,column_name)"
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 36 at PERFORM
PL/pgSQL function dl_ref(datalink,dl_lco,regclass,name) line 38 at PERFORM
PL/pgSQL function dl_trigger_table() line 49 at assignment
update sample_datalinks6 set link = link2;
NOTICE: DATALINK UNLINK:/var/www/datalink/CHANGELOG.md
Expand Down
2 changes: 1 addition & 1 deletion test/expected/other.out
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ update datalink.column_options
where table_name='sample_datalinks3' and column_name='link';
ERROR: datalink exception
DETAIL: Can't change link control options; 6 non-null values present in column "link"
HINT: Perhaps you can truncate sample_datalinks3
HINT: Perhaps you can "truncate sample_datalinks3"
CONTEXT: PL/pgSQL function modlco(regclass,name,dl_lco) line 35 at RAISE
SQL statement "SELECT datalink.modlco(regclass(old.table_name),old.column_name,my_lco)"
PL/pgSQL function dl_trigger_options() line 18 at PERFORM
Expand Down

0 comments on commit 1294ed7

Please sign in to comment.