diff --git a/datalink.sql b/datalink.sql index 037c245..023639a 100644 --- a/datalink.sql +++ b/datalink.sql @@ -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 @@ -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 diff --git a/test/expected/link.out b/test/expected/link.out index 0d3e32d..507fa5d 100644 --- a/test/expected/link.out +++ b/test/expected/link.out @@ -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')); @@ -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')); @@ -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')); diff --git a/test/expected/linker.out b/test/expected/linker.out index 60e84cc..5a9b5fa 100644 --- a/test/expected/linker.out +++ b/test/expected/linker.out @@ -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 diff --git a/test/expected/other.out b/test/expected/other.out index e4b41df..0fcc944 100644 --- a/test/expected/other.out +++ b/test/expected/other.out @@ -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