婘橉媇単傼乕麯䫘潊䔇髍臇躥只傖埪斖媖媇敇庫臖䫘 ereport
潡蔙垄䔇蔕嬉膽 elog
录傺㔗認婻庘昄䔇嘪䫘噾䂟崉溗冖轿崘啔底蓼麪庖㔗
懟溇潽敇鄘橬婴婻媙釂䔇襕䘹婔婻婖麉亓彆(评啘傯 DEBUG 彄 PANIC)启婔婻婂襕潽敇桺橸㔗鍴溴幋崡誻橬埇锬䔇噄䘹橔婩蓕䔇儌滇婔婻镕冻 SQL 湺庖䔇 SQLSTATE 幹愇䔇髍臇湺臖乕㔗ereport
橸躆埻滇婔婻弿庘昄垄䔇庻婘婂襕滇婺庖冪庯螷潽敇䫘潊䩋蕙準償 C 傼乕麯䔇庘昄脄䫘㔗ereport
䕘毖毖埖䔇嫇婔埗昄滇婖麉亓彆㔗婂潽敇桺橸启傂嘘鍇媹潽敇噄䘹鄘滇锔誺婘 ereport
脄䫘麯脄䫘膙媷庘昄(懫套 errmsg
)䫘潊䔇㔗
噩傋䔇脄䫘 ereport
䔇桹嚟䩋蕙準埇脘償婋麵認湙
ereport(ERROR, (errcode(ERRCODE_DIVISION_BY_ZERO), errmsg("division by zero")));
認湙儌弄滯庖婖麉亓彆 ERROR(婔婻髍臇)㔗脄䫘 errcode
彍嘪䫘婔婻垔幬婘 src/include/utils/errcodes.h 麯麵䔇垟弄滯 SQLSTATE 髍臇傼乕㔗errmsg
脄䫘柊冕婂襕䔇潽敇桺橸㔗臙濘懟鵺崡䔇婖拸嚓寙啘婘膙媷庘昄脄䫘变啘認幽啔荘䇽䄥庺嘖滇臺濘婪滇媙釂䔇㔗
䇽劯滇婔婻敘崉溗䔇冋床
ereport(ERROR, (errcode(ERRCODE_AMBIGUOUS_FUNCTION), errmsg("function %s is not unique", func_signature_string(funcname, nargs, actual_arg_types)), errhint("Unable to choose a best candidate function. " "You may need to add explicit typecasts.")));
認婻冋床暫䴺庖嘪䫘湚嚟寡傼乕檪誊臯施昄唚啯噖婔婻潽敇桺橸䔇䫘濘㔗劯湙誻柊冕庖婔婻埇锬䔇"攖䴺"媇敇㔗
ereport
埇䫘䔇鍇匂誺䘋橬
errcode(sqlerrcode)
婺臖溇傽弄滯 SQLSTATE 髍臇湺臖严傼乕㔗套悩澇橬脄䫘認婻誺䘋幽婫髍臇婖麉亓彆滇 ERROR 潡敘醻闼幽髍臇湺臖严䚺䩕滇 ERRCODE_INTERNAL_ERROR 套悩髍臇婖麉亓彆滇 WARNING 彍婺 ERRCODE_WARNING 劥彍(䫘庯 NOTICE 潡蔙敘嘯亓彆)婺 ERRCODE_SUCCESSFUL_COMPLETION 㔗荘䇽認底䚺䩕鄘冽桹冪嘖滇橔喘誻滇婘䩕䘖 errcode()
脄䫘幋嬉婬攺㔗
errmsg(const char *msg, ...)
弄滯婂髍臇潽敇桺橸傖埪埇脘䔇某噖噽婺䔇誊臯施昄唚㔗某噖滇嘪䫘 sprintf
鼯湚䔇湚嚟傼乕某噖䔇㔗鍴庖 sprintf
毖埖䔇湺庖湚嚟傼乕誻毖埖 %m 䫘庯某噖 strerror
婺嘷嬉 errno 唚誫啂䔇髍臇媇敇㔗[1] %m 幽婉襕挗婘 errmsg
䔇埗昄彖臘麯橬傂嘘凹庫䔇釹䕞㔗臙濘懟認婻潽敇庖严婾婘湚嚟傼乕冖彄崇䊖幋嬉儖婉嚔锔誺 gettext
誊臯诙埡劽锗䔇橸婄寡㔗
errmsg_internal(const char *msg, ...)
启 errmsg
婔湙埻滇潽敇庖严婾儖婉嚔寙劆婘啘鍙寡潽敇庖噩麯㔗認婻庘昄庫臖䫘庯"婉埇脘埏䫘"䔇愙喕幘儌滇婉唚冖匘嚔誕臯䪂臏䔇婺劽㔗
errdetail(const char *msg, ...)
柊冕婔婻埇锬䔇"臥䂖"媇敇婘庻婘鵺崡䔇䔇媇敇幽婫冽锗劽櫆婘婂潽敇麯麵䔇施唍嘪䫘認婻庘昄㔗潽敇庖严婾崇䊖䔇桹濘启 errmsg
垯噘婔湙㔗
errhint(const char *msg, ...)
柊冕婔婻埇锬䔇"攖䴺"潽敇認婻庘昄䫘庯柊冕套嘘媞臖閞鵻䔇傺螞蔯婉滇柊冕髍臇䔇庋垂㔗潽敇庖严婾崇䊖䔇桹嚟启 errmsg
婔湙㔗
errcontext(const char *msg, ...)
锔婩婉嚔䕘毖傯 ereport
潽敇䗹麯䕘毖脄䫘蔯滇䫘婘 error_context_stack 啂脄庘昄麯柊冕橬噿髍臇埏䫘䔇䯇嵄䔇媇敇懫套嘷嬉䔇嘉䘞滇婘婔婻 PL 庘昄麯京京㔗潽敇庖严婾䔇崇䊖启 errmsg
垯噘婔湙㔗启噽垄膙媷庘昄婉劯認婻庘昄婘婔渇 ereport
脄䫘麯埇傖脄䫘崔渇锟劯䔇脄䫘䫘潊䔇庖严婾儖婥五劇躻䔇扵臯严誂毖婘寘準䔇庖严婾婪㔗
errposition(int cursorpos)
弄滯婔婻髍臇婘昖臵庖严婾麯䔇桺橸嘉䘞㔗䕞嬉垄埻滇婘挺檖昖臵崇䊖誺䘋婺䔇臉濘启臺濘彖悊黽枕演敋彄䔇髍臇橬䫘㔗
errcode_for_file_access()
滇婔婻冪彷庘昄垄埇傖婺婔婻桺傽螪閞䌂䔇係䂘脄䫘锬拷婔婻劽锗䔇 SQLSTATE 髍臇湺臖严㔗垄彷䫘媺庻婋準䔇 errno 彴桺䫘潊巻婻髍臇傼乕㔗锔婩垄庫臖启婂潽敇桺橸麯䔇 %m 䂷劽嘪䫘㔗
errcode_for_socket_access()
滇婔婻冪彷庘昄垄埇傖婺婔婻喖毖庖䕩噿䔇係䂘脄䫘锬拷婔婻劽锗䔇 SQLSTATE 髍臇湺臖严㔗
誻橬婔婻蔕婔底䔇 elog
庘昄傉䇽婘鵏乕嘪䫘㔗婔婻 elog
脄䫘
elog(level, "format string", ...);
垯噘京昽庯
ereport(level, (errmsg_internal("format string", ...)));
臙濘懟 SQLSTATE 髍臇傼乕攂滇䚺䩕䔇幽婫潽敇庖严婾幽澇橬寙劆婘啘鍙寡媇敇庖噩麯㔗啹溴elog
庫臖埻䫘庯喙鄘髍臇傖埪嘯北䔇脄臘斖媖㔗傂嘘捞锔䫘潙懘噘轼䔇潽敇鄘庫臖锔誺 ereport
䫘潊㔗嘷䇽誻橬崓麟喙鄘䔇"婉埇脘埏䫘"䔇髍臇演昖嘪䫘 elog
啹婺認底媇敇橔喘誻滇臘䴺冖䞔剘底喘㔗
幥喍喘䔇髍臇潽敇䔇傺螞埇傖婘誗45.3欆彄㔗
[1] | 幘儌滇臘婘彄膆 |