PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹45. PostgreSQL 䚡乕亥垔媆誕嬉誕

45.2. 檖只橉媇単麯䔇髍臇

婘橉媇単傼乕麯䫘潊䔇髍臇躥只傖埪斖媖媇敇庫臖䫘 ereport 潡蔙垄䔇蔕嬉膽 elog 录傺㔗認婻庘昄䔇嘪䫘噾䂟崉溗冖轿崘啔底蓼麪庖㔗

懟溇潽敇鄘橬婴婻媙釂䔇襕䘹婔婻婖麉亓彆(评啘傯 DEBUGPANIC)启婔婻婂襕潽敇桺橸㔗鍴溴幋崡誻橬埇锬䔇噄䘹橔婩蓕䔇儌滇婔婻镕冻 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 埇䫘䔇鍇匂誺䘋橬

誻橬婔婻蔕婔底䔇 elog 庘昄傉䇽婘鵏乕嘪䫘㔗婔婻 elog 脄䫘

elog(level, "format string", ...);

垯噘京昽庯

ereport(level, (errmsg_internal("format string", ...)));

臙濘懟 SQLSTATE 髍臇傼乕攂滇䚺䩕䔇幽婫潽敇庖严婾幽澇橬寙劆婘啘鍙寡媇敇庖噩麯㔗啹溴elog 庫臖埻䫘庯喙鄘髍臇傖埪嘯北䔇脄臘斖媖㔗傂嘘捞锔䫘潙懘噘轼䔇潽敇鄘庫臖锔誺 ereport 䫘潊㔗嘷䇽誻橬崓麟喙鄘䔇"婉埇脘埏䫘"䔇髍臇演昖嘪䫘 elog 啹婺認底媇敇橔喘誻滇臘䴺冖䞔剘底喘㔗

幥喍喘䔇髍臇潽敇䔇傺螞埇傖婘誗45.3欆彄㔗

濘懟

[1]

幘儌滇臘婘彄膆 ereport 脄䫘䔇施唍嘷嬉䔇昄唚婘鍇匂檖只誺䘋麯凹 errno 䔇媞櫹儖婉嚔嘌巉傡㔗嘖滇套悩嘹婘 strerror(errno) 䔇埗昄彖臘麯滯䇞婄喍 errmsg 認婔䗹儌婉脘媺臕庖啹溴臙婉襕認幽啔㔗


劯锔饡釕嬉誕
湚嚟婪婔亓髍臇潽敇鼯湚毺凚