套悩嘹襕嘪䫘昊䓉誺䘋臺蘔闼幽嘹媙釂檪垄"垬輙"彄襕嘪䫘垄䔇昄扞康麯㔗婉誺闼底垬輙彄昄扞康 template1 麯䔇誺䘋臺蘔嚔躻媘婘锟劯录傺䔇昄扞康婺垬輙㔗啹溴昄扞康䞇䊖叻埇傖喿垔巻婻昄扞康埇傖嘪䫘巻䓉臺蘔傖埪喿垔䚺䩕施埇傖嘪䫘巻底臺蘔㔗
凹庯闼底锟五湺庖䬽橸埏婄䔇臺蘔埻驔襕嘪䫘 CREATE LANGUAGE language_name 檪臺蘔垬輙彄嘷嬉昄扞康婺剿埇㔗埥崡幘埇傖嘪䫘 createlang 䘋废婘 shell 变傴臯婪垬輙臺蘔㔗懫套襕儖 PL/pgSQL 垬輙彄 template1 昄扞康婺埇傖嘪䫘
createlang plpgsql template1
婋麵柟誄䔇欋噖垬輙桹濘埻锗䫘庯闼底 CREATE LANGUAGE 誻婉䘖長䔇臺蘔㔗
欋噖垬輙誺䘋臺蘔
婔婻誺䘋臺蘔滇毬啕婻準黴垬輙彄昄扞康麯麵寂䔇認底傂媇媙釂䫌昄扞康轙亓䫘潙欓臯㔗凹庯 CREATE LANGUAGE 噾䘖䔇臺蘔丸庯启丸婬準埇傖媘䘖啹婺垄傸嚔婘驔襕䔇施唍躻媘欓臯㔗
媙釂䚡臏启垬輙臖臺蘔崇䊖単䔇噌庆凹茇幽垬輙彄婔婻劽锗䔇康䕞嘘婺㔗桹濘启垬輙䫘潙垔幬䔇 C 庘昄䔇桹濘(誗33.9.6)婔湙㔗锔婩臺蘔崇䊖単驔襕崡鄘康柊冕垂鍙䔇嚘淯套悩滇認湙闼幽認底康幘媙釂垬輙㔗
崇䊖単媙釂嘪䫘婋麵䔇变傴弄滯
CREATE FUNCTION handler_function_name() RETURNS language_handler AS 'path-to-shared-object' LANGUAGE C;
language_handler 䔇誫啂䌂傋只臬昄扞康係䂘臖庘昄幽婉誫啂傂嘘噾垔幬䔇 SQL 昄扞䌂傋幽婫婉脘婘 SQL 臺埖婺赆䕘毖嘪䫘㔗
埇锬準黴㔗臺蘔崇䊖単埇傖柊冕婔婻"黯臕単"庘昄認婻庘昄演昖庘昄䔇垔幬滇劥溼䇞蔯婉嚔垂鍙欓臯垄㔗套悩庻婘黯臕単庘昄闼幽䫌 CREATE FUNCTION 脄䫘㔗套悩婔婻黯臕単庘昄䫌崇䊖単柊冕闼幽䫘婋麵䔇变傴弄滯
CREATE FUNCTION validator_function_name(oid) RETURNS void AS 'path-to-shared-object' LANGUAGE C;
PL 媙釂䫘婋麵变傴垔幬
CREATE [TRUSTED] [PROCEDURAL] LANGUAGE language-name HANDLER handler_function_name [VALIDATOR validator_function_name] ;
埇锬䔇噿髞庖 TRUSTED 弄滯婔婻澇橬轙亓䫘潙溄鍊䔇捞锔昄扞康䫘潙脘劥嘪䫘認䓉臺蘔录傺庘昄启蓥埏単誺䘋㔗啹婺 PL 庘昄婘昄扞康劯䆇喙鄘欓臯欔傖 TRUSTED 湺媖庫臖埻滇䫘庯闼底婉噕螩螪閞昄扞康橉媇単喙鄘潡桺傽係䂘䔇臺蘔㔗PL/pgSQL, PL/Tcl, PL/Perl 臺蘔鄘滇埇媇䔇㔗PL/TclU, PL/PerlU, PL/PythonU 鄘赆螆螇潊柊冕方鍊䔇媘脘啹溴婉庫臖湺螄婺埇媇㔗
冋36-1滆䴺庖套嘘欋噖垬輙 PL/pgSQL 臺蘔㔗
冋36-1. 欋噖垬輙 PL/pgSQL
婋麵䔇变傴只臬昄扞康彄闼麯欉脘欆彄䫘庯 PL/pgSQL 臺蘔䔇脄䫘崇䊖単庘昄䔇噌庆凹茇㔗
CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler AS '$libdir/plpgsql' LANGUAGE C;
PL/pgSQL 橬婔婻黯臕単庘昄欔傖誻襕弄滯垄
CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS '$libdir/plpgsql' LANGUAGE C;
婋麵䔇变傴
CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler VALIDATOR plpgsql_validator;
弄滯庖嬉麵欔垔幬䔇庘昄庫臖赆闼底脄䫘臺蘔匂攓滇 plpgsql 䔇庘昄潡蓥埏単誺䘋嘪䫘㔗
婘䚺䩕䔇 PostgreSQL 垬輙麯PL/pgSQL 臺蘔䔇崇䊖単滇彽嘩幽垬輙彄"library"䕞嘘婺寂䔇㔗套悩陉䘞庖 Tcl 櫇毕闼幽 PL/Tcl 启 PL/TclU 䔇崇䊖単幘鄘赆䚡臏幽垬輙彄劯婔婻嘉䘞㔗䌂嚚䔇誻橬 PL/Perl 启 PL/PerlU 傖埪 PL/PythonU 㔗