橸誗柟誄潽敇敕㔗傖埪懟䓉潽敇䌂傋䔇臺懟(懟䓉媇敇䔇庖䇞臘䯄䂖誗婘誗44.4麯)㔗啹誂毖䔇䪽攕婉劯庻婘庹䓉婉劯䔇床剟螞劇媘㔕昖臵㔕庘昄脄䫘㔕COPY 㔕䂷溘㔗誻橬䫘庯锔䘖巉庫启变傴埡潽䔇䬹枪媇敇認底䬹枪媇敇埇脘婘劇媘黽枕誺劯䔇傂嘘施閘库䫘㔗
襕嚔哋婔婻嚔臺嬉䆇欷嚔婔婻婯橉媇単䔇誂毖幽婫埏锕婔婻劇媘潽敇㔗認婻潽敇寙拸䫘潙劉傖埪䫘潙婯橕婯幋誂毖䔇昄扞康垄誻湺臖襕嘪䫘䔇䬹垔䔇剟螞䬽橸㔗埥崡劇媘媇敇埇傖寙拸䫘庯誊臯施埗昄䔇鵺崡螆䘞㔗橉媇単䇽劯儌嘪䫘認底媇敇傖埪垄䔇陉䘞桺傽䔇喙垹(懫套 pg_hba.conf)傖彴桺認婻誂毖滇劥埇傖毖埖傖埪驔襕傔幽湙䔇鵺崡䔇螴臕(套悩驔襕)㔗
䇽劯橉媇単儌埏锕劽锗䔇螴臕臙挗媇敇嬉䆇媙釂䫘劽锗䔇螴臕巉庫媇敇準巉庫(懫套婔婻埼傴)㔗䊖螺婪螾認湙䔇螴臕臙挗/巉庫冻䯇埇脘驔襕崔渇誺傼嘖滇䕞嬉䔇螴臕桹濘鄘婉驔襕轙誺婔渇䔇臙挗启巉庫㔗橬底桹濘彍湹橸婉驔襕嬉䆇䔇巉庫啹溴儌澇橬螴臕臙挗埏䫘㔗
螴臕变橘䔇䂷溘襕幽滇傖橉媇単䔇拐䂺誂毖(ErrorResponse)䂷溘襕幽滇傖螴臕潊媘(AuthenticationOk)䂷溘䔇㔗
認婻黽枕準躻橉媇単埇脘潽敇滇
誂毖臙挗赆拐䂺㔗䇽劯橉媇単鷸婪噿閺誂毖㔗
螴臕庴扵潊媘垯潊㔗
䯄婘嬉䆇媙釂婯橉媇単誕臯婔渇 KerberosV5 螴臕凹臺(婘認麯澇橬柟誄Kerberos 蓇评䔇婔鄘彖)㔗套悩凹臺潊媘橉媇単巉庫婔婻 AuthenticationOk(螴臕潊媘)媇敇劥彍垄巉庫婔婻 ErrorResponse(髍臇巉庫)㔗
䯄婘嬉䆇媙釂滯桺嘵嚟埏锕婔婻寙劆埼傴䔇 PasswordMessage(橻媹凖埼傴)寙㔗套悩認滇溼䇞䔇埼傴橉媇単䫘婔婻 AuthenticationOk 寙巉庫劥彍垄巉庫婔婻 ErrorResponse 寙㔗
䯄婘嬉䆇媙釂埏锕婔婻 PasswordMessage 寙臖寙寙劆䫘 crypt(3)媹凖䔇埼傴媹凖施嘪䫘庖婘 AuthenticationCryptPassword 潽敇麯弄滯䔇 2 庖誗䕊侐㔗套悩認滇溼䇞埼傴橉媇単䫘婔婻 AuthenticationOk 巉庫劥彍垄䫘婔婻 ErrorResponse 巉庫㔗
䯄婘嬉䆇媙釂埏锕婔婻寙劆䫘 MD5 媹凖䔇埼傴䔇 PasswordMessage 媹凖施嘪䫘庖婘 AuthenticationMD5Password 潽敇麯弄滯䔇 4 庖严䕊侐㔗套悩認滇溼䇞埼傴橉媇単䫘婔婻 AuthenticationOk 巉庫劥彍垄䫘婔婻 ErrorResponse 巉庫㔗
認婻巉庫埻凹闼底櫇毕 SCM 媇傂潽敇䔇橸婄 Unix 嘘誂毖庺䯄㔗嬉䆇媙釂埏庺婔溇 SCM 媇傂潽敇䇽劯埏锕婔婻昄扞庖誗㔗昄扞庖誗䔇喙垹幽婉嚔赆濘懟垄䔇嘩䫘埻滇䇞媺橉媇単京写庖轿崘阪䔇施閘準毖埖媇傂媇敇㔗套悩媇傂滇埇傖毖埖䔇闼幽橉媇単䫘 AuthenticationOk 巉庫劥彍䫘 ErrorResponse 巉庫㔗
套悩嬉䆇婉櫇毕橉媇単襕挗䔇螴臕桹嚟闼幽垄庫臖鷸婪噿閺誂毖㔗
婘櫽彄 AuthenticationOk 寙幋劯嬉䆇媙釂京写準躻劯䆇䔇敘崔潽敇㔗婘認婻黽枕嚔劇媘婔婻劯䆇誕䘋蔯嬉䆇埻滇婔婻懘噘轼䔇䩋䄺閹䔇㔗劇媘儺臘傉䇽橬埇脘崌蘖 (ErrorResponse)嘖滇锔婩愙喕婋劯䆇儖埏锕婔底 ParameterStatus 潽敇㔕BackendKeyData 㔕傖埪橔劯 ReadyForQuery 㔗
婘認婻黽枕劯䆇儖儺臘庫䫘傂嘘婘劇媘潽敇麯䂍庺鵺崡䔇誊臯施埗昄螆䘞㔗套悩潊媘認底唚儖潊婺嚔臺䚺䩕㔗髍臇儖凚躘 ErrorResponse 幽锔庺㔗
認婻黽枕準躻劯䆇䔇埇脘潽敇滇
認婻潽敇柊冕庖凖鐖(secret-key)昄扞嬉䆇套悩愿襕婘䘉劯埏庺埡潽䔇臙挗彍媙釂媺庻認婻昄扞㔗嬉䆇婉庫臖巉庫認婻媇敇嘖滇庫臖䂓䂺冥劸京写 ReadyForQuery 潽敇㔗
認婻潽敇只臬嬉䆇橬噿劯䆇埗昄䔇嘷嬉(彺哋寡)螆䘞懫套 client_encoding 潡 DateStyle 京㔗嬉䆇埇傖媘䘖認底媇敇潡蔙螄嘘噽螆䘞䫘庯儖準嘪䫘埗黙誗44.2.6诙埡敘崔䂖誗㔗嬉䆇婉庫臖巉庫認底媇敇蔯滇庫臖䂓䂺冥劸 ReadyForQuery 潽敇㔗
劯䆇劇媘潊媘嬉䆇䯄婘埇傖埏庺变傴㔗
劯䆇劇媘崌蘖㔗婘埏锕垯認婻潽敇幋劯誂毖赆噿閺㔗
埏庺庖婔婻躥只媇敇㔗嬉䆇庫臖滆䴺認婻媇敇幽婫䂓䂺京写 ReadyForQuery 潡 ErrorResponse 㔗
劯䆇婘懟婻昖臵冻䯇劯鄘嚔埏庺婔婻䕩劯䔇 ReadyForQuery 潽敇㔗嬉䆇埇傖劽䊖婄螴婺 ReadyForQuery 滇婔婻昖臵冻䯇䔇嚔哋(蔯 BackendKeyData 臘滯劇媘黽枕䔇潊媘垯潊)潡蔙螴婺 ReadyForQuery 滇劇媘黽枕启懟婻锟劯昖臵冻䯇䔇䂷溘噙嘷滇闼䓉愙喕埡喿庯嬉䆇䔇䚡乕驔襕㔗
婔婻昖臵冻䯇滇䫌嬉䆇埏锕婔溇 Query 潽敇䂍劯䆇誕臯彺哋寡䔇㔗認溇潽敇寙劆婔婻䫘桺橸庖严婾臘膆䔇 SQL 变傴(潡蔙婔底变傴)㔗劯䆇湹扞昖臵变傴庖严婾䔇喙垹埏锕婔溇潡蔙敘崔溇巉庫潽敇䂍嬉䆇幽婫橔劯滇婔溇 ReadyForQuery 巉庫媇敇㔗ReadyForQuery 锔䘖嬉䆇垄埇傖垬噘婄埏锕桄变傴庖㔗垂鍙婪嬉䆇婉媙婘埏锕噽垄变傴幋嬉京写 ReadyForQuery 嘖滇認湙婔準嬉䆇媙釂蘘蘼寺彖斷噽埏庺䔇变傴崌蘖蔯䘉劯埏庺䔇变傴潊媘䔇愙喕㔗
傯劯䆇準䔇埇脘䔇潽敇滇
婔婻 SQL 变傴溼婩䂷溘㔗
劯䆇噾䂟庖崺喘傯嬉䆇拙蘺昄扞彄婔婻臘麯麵寂㔗埽蓕誗44.2.5㔗
劯䆇噾䂟庖崺喘傯婔婻臘麯拙蘺昄扞彄嬉䆇麯麵寂㔗埽蓕誗44.2.5㔗
臘䴺婺庖巉庫婔婻 SELECT, FETCH 京䔇昖臵儖襕誫啂婔婻臯㔗認溇潽敇䔇喙垹柟誄庖認臯䔇庖枕婄匔㔗認溇潽敇劯麵儖虘五懟婻誫啂䂍嬉䆇䔇臯婔婻䔇 DataRow 潽敇㔗
SELECT, FETCH 京昖臵誫啂䔇䂷悩镖婺䔇婔臯㔗
臖彆庖婔婻䷺䔇昖臵庖严婾㔗
庺髍庖㔗
昖臵庖严婾䔇崇䊖垯潊㔗埏锕婔婻䋸䆋䔇潽敇準湺臖認婻滇啹婺昖臵庖严婾埇脘寙劆崔婻 SQL 变傴㔗CommandComplete 埻滇湺螄婔溇 SQL 变傴崇䊖垯懘蔯婉滇昘婻庖严婾㔗ReadyForQuery 攂嚔赆埏锕婉䞇滇崇䊖潊媘䂷溘誻滇库䫘髍臇㔗
埏锕庖婔婻婯昖臵橬噿䔇躥只媇敇㔗濘懟媇敇滇鍇媹婘噽垄巉庫婪䔇幘儌滇臘,劯䆇儖䂓䂺崇䊖臖变傴㔗
SELECT (潡噽垄誫啂䂷悩镖䔇昖臵懫套 EXPLAIN 潡 SHOW)昖臵䔇巉庫媇敇锔婩寙劆 RowDescription 镽婻潡蔙崔婻 DataRow 潽敇傖埪橔劯䔇 CommandComplete 㔗傯嬉䆇準啂䔇 COPY 脄䫘誗44.2.5 麯柊彄䔇䬹枪䔇剟螞㔗欔橬噽垄昖臵䌂傋锔婩埻䫘潊婔婻 CommandComplete 潽敇㔗
啹婺昖臵庖严婾埇脘寙劆苖幾婻昖臵(䫘彖埙彖锫)欔傖婘劯䆇垯潊昖臵庖严婾䔇崇䊖幋嬉埇脘橬喘庹婻認湙䔇巉庫废彖㔗套悩昘婻庖严婾噾䂟崇䊖垯劯䆇噾䂟庖崺喘毖埖桄昖臵庖严婾䔇施唍彍埏庺 ReadyForQuery 潽敇㔗
套悩櫽彄婔婻垯噘䷺(鍴庖䷺䍘幋崡澇橬喙垹)䔇昖臵庖严婾闼幽巉庫滇婔溇 EmptyQueryResponse 劯麵虘五 ReadyForQuery 㔗
婘庺䯄髍臇䔇施唍埏庺婔婻 ErrorResponse 潽敇劯麵虘五 ReadyForQuery 㔗昖臵庖严婾䔇欔橬劯䂓䔇崇䊖鄘赆 ErrorResponse 婺溵(剿嘪麯麵誻橬昖臵幘認幽幾)㔗臙濘懟認底庋愙埇脘婘崇䊖婔婻昖臵库䫘䔇潽敇废彖䔇婺锫埏䫘㔗
婘䞔剘昖臵昇嚟演䘵庺準䔇昄唚䔇湚嚟攂滇桺橸䔇鍴麂䂍庺䔇变傴滇婔婻傯婔婻弄滯庖 BINARY 锬釹䔇橩湺婪 FETCH 㔗婘認䓉愙喕婋演䘵庺準䔇昄唚滇庯誕彽湚嚟䔇㔗婘 RowDescription 潽敇麯䂍庺䔇湚嚟傼乕只臬䫘庖闼䓉湚嚟㔗
嬉䆇婘京写噽垄䌂傋䔇潽敇施媙釂庖崺毖櫽 ErrorResponse 启 NoticeResponse 潽敇㔗埗黙誗44.2.6劯䆇啹婺崡鄘䔇施閘埇脘䫘潊䔇潽敇㔗
傺螞䔇桹濘滇檪嬉䆇傼乕喍潊䪽攕橺䔇鼯湚垄埇傖婘傂嘘施彂毖埖傂嘘橬懟幬䔇媇敇蔯婉滇喍潊啺螆潽敇䔇庖䇞废彖䔇傼乕㔗
欷匘䔇昖臵剟螞檪婪麵柟誄䔇䞔剘剟螞彖輗潊苖幾婻準黴㔗庖崺䔇準黴埇傖崔渇崉䫘傖柊醻昽䯺㔗埥崡誻埇傖诙冖鵺崡䔇䬹攓懫套檪昄扞唚嘩婺䋸䆋䔇埗昄柊冕䔇埇脘攓蔯婉滇檪垄傸䕘毖某噖婔婻昖臵庖严婾㔗
婘欷匘䔇剟螞麯嬉䆇饡噽埏锕婔婻 Parse 潽敇垄寙劆婔婻桺橸昖臵庖严婾埥崡誻橬婔底橬噿埗昄剹嘉严䔇昄扞䌂傋䔇媇敇傖埪婔婻橔䂽鵇崺臺埖凹茇䔇劉庖(婔婻䷺庖严婾锬拷橻变劉䔇鵇崺臺埖)㔗巉庫襕幽滇婔婻 ParseComplete 襕幽滇 ErrorResponse 㔗埗昄昄扞䌂傋埇傖䫘 OID 準弄滯套悩澇橬䂍庺闼幽彖悊単儖臘商䫘垄凹傻方䌂傋䔇庖严婾婩麟䔇桹濘準毘凚噽昄扞䌂傋㔗
㔊濘懟㔏婔婻埗昄昄扞䌂傋埇傖锔誺螆䘞婺镽潡蔙螷埗昄䌂傋 OID 䔇昄䕞懫昖臵庖严婾麯䔇埗昄严埙($n)䔇昄䕞儏䔇桹濘婉庽弄滯㔗埥崡婔婻䬹冋滇埗昄䔇䌂傋埇傖弄滯婺 void(幘儌滇嚻䌂傋 void 䔇 OID)㔗認滇婺庖噕螩䫘庯昊底庘昄埗昄䔇埗昄严埙垂鍙婪滇 OUT 埗昄㔗锔婩愙喕婋澇橬傔幽䯇嵄嚔䫘彄 void 埗昄嘖滇套悩婘庘昄䔇埗昄彖臘麯庺䯄庖認幽婔婻埗昄严埙闼幽垄垂鍙婪嚔赆媘䘖㔗懫套婔婻償認湙䔇庘昄脄䫘 foo($1,$2,$3,$4) 套悩 $3 启 $4 弄滯婺䌂傋滇 void 闼幽認婻庘昄脄䫘埇傖对陉婔婻婥橬婴婻 IN 启婴婻 OUT 埗昄䔇庘昄㔗
㔊濘懟㔏婘婔婻 Parse 潽敇麯寙劆䔇昖臵庖严婾婉脘寙劆轙誺婔婻 SQL 臺埖劥彍儌嚔檖只婔婻臺濘髍臇㔗認婻鍊彽婘䞔剘昖臵剟螞婺幽婉庻婘嘖滇垄庻婘庯欷匘䔇剟螞婺啹婺噕螩鵇崺臺埖潡蔙噖埼寙劆崔婻变傴儖凚躘剟螞誺庥婄崉溗㔗
套悩潊媘录傺庖婔婻变劉䔇庖崺喘臺埖凹茇闼幽垄儖毕䂺彄嘷嬉嚔臺䂷溘鍴麂滯䇞役鍴㔗婔婻橻变劉䔇鵇崺臺埖埻毕䂺彄婋婔婻弄滯橻变劉䔇臺埖婺䕞湺䔇 Parse 臺埖埏庺婺溵(臙濘懟婔婻䞔剘䔇昖臵潽敇幘役鍴橻变劉臺埖)㔗变劉䔇臺埖媙釂滯䇞婄噿閺䇽劯欉脘䫘婔婻 Parse 潽敇麉桄垔幬嘖滇橻变劉䔇臺埖幽婉襕挗認婻媘嘩㔗变劉䔇鵇崺臺埖幘埇傖婘 SQL 变傴亓录傺启螪閞桹濘滇嘪䫘 PREPARE 启 EXECUTE
埻襕鵇崺臺埖誻庻婘闼幽儌埇傖嘪䫘 Bind 潽敇冽垹滷婄嘪幋誕噖欓臯䪽攕㔗Bind 潽敇䂍庺溊鵇崺臺埖䔇劉庖(䷺庖严婾臘䴺橻变劉䔇鵇崺臺埖)䕞湺噖埼䔇劉庖(䷺庖严婾臘䴺橻变劉䔇噖埼)傖埪䫘庯闼底婘鵇崺臺埖婺庺䯄䔇欔橬埗昄剹嘉严䔇昄唚㔗柊冕䔇埗昄镖媙釂对陉闼底鵇崺臺埖驔襕䔇婩薪㔗套悩嘹婘 Parse 潽敇麯弄滯傂嘘 void 埗昄闼幽婘 Bind 潽敇麯䂍垄傸嚹锐 NULL 唚㔗Bind 誻弄滯䫘庯昖臵誫啂䔇傂嘘昄扞䔇湚嚟湚嚟埇傖婔渇弄滯幘埇傖懟婻庖枕誕臯弄滯㔗巉庫襕幽滇 BindComplete 襕幽滇 ErrorResponse 㔗
㔊濘懟㔏膷庺䔇湚嚟滇桺橸誻滇庯誕彽滇䫌 Bind 麯䂍庺䔇湚嚟傼乕喿垔䔇婉䞇䫘䔇滇傔幽 SQL 变傴㔗婘嘪䫘欷匘䔇昖臵剟螞䔇施唍橩湺弄滯麯䔇 BINARY 匂攓滇方噿䔇㔗
凹噾变劉鵇崺臺埖凹茇䔇昖臵蓇彐埏䫘婘櫽彄 Parse 潽敇䔇施唍㔗套悩婔婻昖臵嚔婥五婉劯埗昄麉崉欓臯闼幽埏锕剘婻婥五埗昄寡䔇昖臵䔇 Parse 潽敇劯麵虘五崔婻 Bind 启 Execute 潽敇嚔冽橬婞媷㔗認湙儖镪噉婘懟渇欓臯䔇施唍麉桄蓇彐臖昖臵㔗
套悩 Parse 潽敇澇橬垔幬埗昄闼幽橻变劉䔇鵇崺臺埖冽埇脘躻庯 Parse 崇䊖䔇施唍蓇彐㔗嘖滇套悩橬埗昄闼幽昖臵蓇彐儌嚔毘誘彄臖臺埖䔇丸婔婻 Bind 潽敇㔗蓇彐単婘凹臖昖臵誕臯蓇彐䔇施唍儖蔄荏婘 Bind 潽敇麯柊冕䔇垂鍙埗昄唚㔗
㔊濘懟㔏婺婔婻埗昄寡庖䔇昖臵䫘潊䔇昖臵蓇彐埇脘懫䫘垂鍙埗昄敪扵劯䔇昖臵䫘潊䔇昖臵蓇彐昽䯺噞底㔗婘䂍婔婻蕋庽庖橬劉鵇崺臺埖凹茇䔇埗昄寡昖臵誕臯蓇彐䔇施唍昖臵蓇彐単方濘嘺庯垂鍙埗昄唚啔喿亡(懫套䘵嚘锬拷攓)㔗婘嘪䫘方劉臺埖䔇施唍镪噉庖認婻嚔體啹婺䕘彄埗昄唚埇䫘䔇施唍欉誕臯蓇彐㔗套悩櫽彄嚘䫘方劉䔇鵇崺臺埖䔇丸庯婻潡蔙滇傖劯䔇 Bind 潽敇劯施澇橬幾潬䔇 Parse 潽敇闼幽認婻昖臵儌婉嚔赆蓇彐㔗婘丸婔婻 Bind 潽敇麯嘪䫘䔇埗昄唚埇脘䫘潊婔婻埻凹欔橬埇脘䔇埗昄唚婺䔇婔償鄘彖橬昽䔇蓇彐㔗襕婺婔喖媇䔇埗昄镖嚺彽臖昖臵䔇麉桄蓇彐襕埏锕埥崡婔婻 Parse 檪敪扵臖方劉鵇崺臺埖凹茇敪扵毬㔗
套悩潊媘录傺庖婔婻变劉䔇鵇崺臺埖凹茇闼幽垄儖毕䂺彄嘷嬉嚔臺䂷溘鍴麂滯䇞役鍴㔗婔婻橻变劉䔇鵇崺臺埖埻毕䂺彄婋婔婻弄滯橻变劉䔇臺埖婺䕞湺䔇 Parse 臺埖埏庺婺溵(臙濘懟婔婻䞔剘䔇昖臵潽敇幘役鍴橻变劉臺埖)㔗变劉䔇臺埖媙釂滯䇞婄噿閺䇽劯欉脘䫘婔婻 Parse 潽敇麉桄垔幬嘖滇橻变劉䔇臺埖幽婉襕挗認婻媘嘩㔗变劉䔇鵇崺臺埖幘埇傖婘 SQL 变傴亓录傺启螪閞桹濘滇嘪䫘 DECLARE CURSOR 启 FETCH
埻襕庻婘婔婻噖埼闼幽儌埇傖䫘婔婻 Execute 潽敇欓臯垄㔗Execute 潽敇弄滯噖埼䔇劉庖(䷺庖严婾臘䴺橻变劉噖埼)启婔婻橔崓䔇䂷悩臯螇昄(镽臘䴺"檷埡欔橬臯")㔗䂷悩臯螇昄埻凹寙劆誫啂䂷悩镖䔇噖埼橬懟幬婘噽垄愙喕婋臖变傴攂滇欓臯彄䂷溘蔯臯螇昄嚔赆媘䘖㔗Execute 埇脘䔇巉庫启闼底锔誺䞔剘昖臵剟螞埏庺䔇昖臵婔湙埻婉誺 Execute 婉嚔凚躘劯䆇埏庺 ReadyForQuery 潡蔙 RowDescription 㔗
套悩 Execute 婘婔婻噖埼䔇欓臯垯潊幋嬉䂽溵(啹婺膆彄庖婔婻麂镽䔇䂷悩臯螇昄)垄儖埏锕婔婻 PortalSuspended 潽敇認婻潽敇䔇庺䯄只臬嬉䆇庫臖婘劯婔婻噖埼婪埏庺埥崡婔婻 Execute 傖垯潊淉嘩㔗婘噖埼䔇欓臯垯潊幋嬉婉嚔埏庺臘䴺溊 SQL 变傴䂷溘䔇 CommandComplete 潽敇㔗啹溴 Execute 黽枕攂滇䫌婋彖潽敇幋婔庺䯄湺媖五䂷溘䔇CommandComplete 㔕EmptyQueryResponse(套悩噖埼滇傯婔婻䷺庖严婾录傺庺準䔇)㔕ErrorResponse 㔕PortalSuspended 㔗
懟婻欷匘昖臵潽敇废彖垯潊劯嬉䆇鄘庫臖埏庺婔溇 Sync 潽敇㔗認婻方埗昄䔇潽敇凚躘劯䆇噿閺嘷嬉庋媇┫┫套悩嘷嬉庋媇婉滇婘婔婻 BEGIN/COMMIT 庋媇庖婺䔇臺("噿閺"䔇懟攺儌滇婘澇橬髍臇䔇愙喕婋柊庴潡蔙滇橬髍臇䔇愙喕婋啂悔)㔗䇽劯巉庫婔溇 ReadyForQuery 潽敇㔗Sync 䔇䕞䔇滇柊冕婔婻髍臇敵崉䔇麉桄劯準䔇䗹㔗套悩婘崇䊖傂嘘欷匘昖臵潽敇䔇施唍冥敋彄傂嘘髍臇闼幽劯䆇埏庺 ErrorResponse 䇽劯臂埡幽檕嚄潽敇䕘彄婔婻 sync 䔇彄準䇽劯埏庺 ReadyForQuery 幽婫誫啂彄溼婩䔇潽敇崇䊖婺㔗嘖滇襕濘懟套悩溼婘 崇䊖 Sync 䔇施唍埏䫘庖髍臇闼幽婉嚔媘䘖傂嘘婩薪 ┫認湙儌媺臕庖婺懟婻 Sync 埏庺婔婻幽婫埻滇婔婻䔇 ReadyForQuery 㔗
㔊濘懟㔏 Sync 幽婉凚躘婔婻䫘 BEGIN 欷嚔䔇庋媇庖噿閺㔗埇傖冥敋彄認䓉愙喕啹婺 ReadyForQuery 潽敇寙劆庋媇䪽攕媇敇㔗
鍴庖認底嘺橸䔇媙釂䔇淉嘩幋崡婘欷匘昖臵剟螞麯誻橬庹䓉埇锬䔇淉嘩埇傖嘪䫘㔗
Describe 潽敇(噖埼埻嘷)弄滯婔婻䯄橬䔇噖埼䔇劉庖(潡蔙婔婻橻变劉噖埼儌滇䷺庖严婾)㔗巉庫滇婔婻 RowDescription 潽敇垄柟誄庖欓臯噖埼儖襕誫啂䔇臯潡蔙滇婔婻 NoData 潽敇(套悩噖埼幽婉寙劆嚔誫啂臯䔇昖臵)潡蔙滇婔婻 ErrorResponse(套悩澇橬認婻噖埼)㔗
Describe 潽敇(臺埖埻嘷)弄滯婔婻䯄橬䔇鵇崺臺埖䔇劉庖(套悩滇婔婻橻变劉䔇鵇崺臺埖彍滇婔婻䷺庖严婾)㔗巉庫滇婔婻柟誄臖臺埖驔襕䔇埗昄䔇 ParameterDescription 潽敇劯麵虘五婔婻柟誄臺埖橔䂽欓臯劯誫啂䔇臯䔇 RowDescription 潽敇(潡蔙滇 NoData 潽敇套悩臖臺埖婉誫啂臯)㔗套悩澇橬認湙䔇鵇崺臺埖彍誫啂 ErrorResponse 㔗臙濘懟啹婺誻澇橬埏庺 Bind 欔傖劯䆇誻婉䘖長䫘庯誫啂庖枕䔇湚嚟婘認䓉愙喕婋RowDescription 潽敇麯麵䔇湚嚟傼乕庖枕儖滇镽㔗
㔊柊䴺㔏婘崓崔昄愙喕婋嬉䆇婘埏庺 Execute 幋嬉庫臖埏庺昊䓉 Describe 䔇埻嘷傖媺臕垄䘖長套嘘蓼悊垄儖冖彄䔇䂷悩㔗
Close 潽敇噿閺婔婻䯄橬䔇鵇崺臺埖潡蔙噖埼幽婫麪櫆蕇溊㔗凹婔婻婉庻婘䔇臺埖潡蔙噖埼劉庖埏庺 Close 婉滇婔婻髍臇㔗巉庫锔婩滇 CloseComplete 嘖套悩婘麪櫆蕇溊䔇施唍埏䫘庖婔底啄锆幘埇傖滇 ErrorResponse 㔗臙濘懟噿閺婔婻庖崺喘婄臺埖锊劆婄噿閺傂嘘傯臖臺埖悇锹庺準婄欷嚔䔇噖埼㔗
Flush 潽敇幽婉凚躘傂嘘䬹垔䔇膷庺䔇䫘潊嘖滇嚺彽劯䆇埏锕傂嘘誻婘垄䔇膷庺䚷喾寺婺啩䘍䔇昄扞㔗Flush 媙釂婘鍴 Sync 崡䔇傂嘘欷匘昖臵变傴劯麵埏庺(套悩嬉䆇婯橕婘埏庺敘崔䔇变傴幋嬉演昖臖变傴䔇䂷悩䔇臺)㔗套悩婉 Flush 劯䆇誫啂䔇潽敇儖䂇劽潊橔償埇脘䔇昄扞寙婻昄傖废儏䘏䂩蘘艙㔗
㔊濘懟㔏䞔剘昖臵潽敇崓楗京庯婔係彖嘪䫘橻变劉䔇鵇崺臺埖启方埗昄䔇噖埼凹茇䔇 Parse 㔕Bind 㔕噖埼 Describe 㔕Execute 㔕Close 㔕Sync 㔗婔婻寺彆滇垄嚔婘昖臵庖严婾婺毖埖崔婻 SQL 臺埖幽婘嚔臺婺婺懟婻臺埖躻媘欓臯䂏垔/柟誄/欓臯废彖㔗埥崡婔婻寺彆滇垄婉嚔誫啂 ParseComplete 㔕Bindcomplete 㔕CloseComplete 㔕NoData 潽敇㔗
庘昄脄䫘床剟螞噕螩垵潙䆇臙挗婔婻凹庻婘庯昄扞康 pg_proc 係䂘臘婺䔇傂懟庘昄䔇䕘毖脄䫘㔗垵潙䆇媙釂婘臖庘昄婪橬欓臯䔇溄鍊㔗
㔊濘懟㔏庘昄脄䫘床剟螞滇婔婻镖䘍䔇䬹攓婘桄傼乕麯埇脘橔喘镪噉䫘垄㔗䌂嚚䔇䂷悩埇傖锔誺螆䘞婔婻 SELECT function($1, ...) 鵇崺臺埖诙冖㔗認湙庘昄脄䫘冻䯇儌埇傖䫘 Bind/Execute 傼敪㔗
婔婻庘昄脄䫘冻䯇滇䫌嬉䆇劏劯䆇埏锕婔溇 FunctionCall 潽敇彺哋寡䔇㔗䇽劯劯䆇湹扞庘昄脄䫘䔇䂷悩埏锕婔溇潡蔙敘崔巉庫潽敇幽婫婘橔劯滇婔溇 ReadyForQuery 巉庫潽敇㔗ReadyForQuery 锔䘖嬉䆇垄埇傖垬噘婄埏锕婔溇桄䔇昖臵潡蔙庘昄脄䫘庖㔗
傯劯䆇準䔇埇脘䔇巉庫媇敇滇
埏䫘庖婔婻髍臇㔗
庘昄脄䫘垯潊幽婫婘潽敇婺誫啂婔婻䂷悩㔗臙濘懟庘昄脄䫘剟螞埻脘崇䊖剘婻湺麟䂷悩婉脘崇䊖臯䌂傋潡蔙䂷悩镖㔗
庘昄脄䫘崇䊖垯潊㔗ReadyForQuery 儖攂滇赆埏锕婉䞇滇潊媘垯潊崇䊖誻滇埏䫘婔婻髍臇㔗
埏庺庖婔溇橬噿臖庘昄脄䫘䔇躥只媇敇㔗锔䘖滇鍇媹婘噽垄巉庫婪䔇幘儌滇臘劯䆇儖䂓䂺崇䊖变傴㔗
COPY 变傴噕螩婘橉媇単启垵潙䆇幋閘醻锘䔇崓欹麟昄扞嚹膷㔗拙蘺噖启拙蘺庺淉嘩懟婻鄘檪誂毖彺扵彄婔婻䋸䆋䔇床剟螞婺幽婫毕䂺彄淉嘩䂷溘㔗
拙蘺噖昇嚟(昄扞嚹膷彄橉媇単)滇婘劯䆇欓臯婔婻 COPY FROM STDIN 臺埖䔇施唍彺哋寡䔇㔗劯䆇埏锕婔婻 CopyInResponse 潽敇䂍嬉䆇㔗嬉䆇庫臖埏锕镽溇潡蔙敘崔 CopyData 潽敇嘵潊婔婻膷庺昄扞䔇敕㔗潽敇䔇膹䘯启臯䔇膹䘯澇橬傂嘘䕩噿攓襕挗儘䞇锔婩闼儌滇劽䊖䔇膹䘯锬拷㔗嬉䆇埇傖锔誺埏锕婔婻 CopyDone 潽敇準䂽溵拙蘺噖淉嘩(噕螩潊媘䂽溵)幘埇傖埏庺婔婻 CopyFail 潽敇(垄儖凚躘 COPY 臺埖婥五髍臇崌蘖)㔗䇽劯劯䆇儌敵崉啂垄婘 COPY 嚔哋幋嬉䔇变傴崇䊖昇嚟埇脘滇䞔剘昖臵剟螞幘埇脘滇欷匘昖臵剟螞㔗䇽劯垄嚔埏锕 CommandComplete(套悩潊媘)潡蔙 ErrorResponse(套悩崌蘖)㔗
套悩婘拙蘺噖昇嚟婋劯䆇演敋彄庖髍臇(寙拸毖埖毖櫽彄 CopyFiail 潽敇潡蔙滇傂嘘鍴庖 CopyData 潡蔙 CopyDone 幋崡䔇嬉䆇潽敇)闼幽劯䆇儖埏庺婔婻 ErrorResponse 潽敇㔗套悩 COPY 变傴滇锔誺婔婻欷匘䔇昖臵潽敇埏庺䔇闼幽劯䆇傯䯄婘嚔哋儖檕嚄嬉䆇潽敇䕘彄婔婻 Sync 潽敇彄崓䇽劯垄儖埏庺 ReadyForQuery 幽婫誫啂彄溼婩䔇崇䊖婺㔗套悩 COPY 变傴滇婘婔婻䞔剘昖臵潽敇麯埏庺䔇闼幽臖潽敇嬷嘍鄘彖赆婵嚄䇽劯埏庺 ReadyForQuery 潽敇㔗婉䞇滇巻䓉愙喕傂嘘嬉䆇埏庺䔇 CopyData, CopyDone, CopyFail 潽敇鄘儖赆䞔剘婄檕嚄㔗
劯䆇儖嚔媘䘖拙蘺噖昇嚟施毖櫽彄䔇 Flush 启 Sync 潽敇㔗櫽彄傂嘘噽垄寙劆嚔凚躘拙蘺噖䪽攕锔庺(套嬉欔誄)髍臇䔇麂拙蘺媇敇䌂傋㔗Flush 启 Sync 䔇冋崡滇婺庖桹冪垵潙䆇康婘欓臯 Execute 潽敇劯哋䂽埏锕 Flush 潡 Sync 蔯婉演昖欔欓臯䔇变傴滇劥滇婔婻 COPY FROM STDIN 变傴㔗
拙蘺庺昇嚟(昄扞傯橉媇単埏庺)滇婘劯䆇欓臯婔婻 COPY TO STDOUT 臺埖䔇施唍彺哋寡䔇㔗劯䆇埏庺婔婻 CopyOutResponse 潽敇䂍嬉䆇劯麵虘五镽潡蔙崔婻 CopyData 潽敇(攂滇懟臯婔婻)䇽劯虘五 CopyDone 㔗䇽劯劯䆇啂锔彄垄婘 COPY 嚔哋幋嬉䔇变傴崇䊖昇嚟䇽劯埏锕 CommandComplete 㔗嬉䆇婉脘锔庺嚹膷(鍴麂滇噿閺誂毖潡蔙埏庺婔婻 Cancel 臙挗)嘖滇垄埇傖檕嚄婉驔襕䔇 CopyData 启 CopyDone 潽敇㔗
婘拙蘺庺昇嚟婺套悩劯䆇演敋彄髍臇闼幽垄儖埏庺婔婻 ErrorResponse 潽敇幽婫啂彄溼婩䔇崇䊖㔗嬉䆇庫臖檪櫽彄 ErrorResponse(潡蔙垂鍙婪鍴庖 CopyData 潡蔙 CopyDone 幋崡䔇傂嘘潽敇䌂傋)嘷嘩䂽溵拙蘺庺昇嚟䔇湺媖㔗
CopyInResponse 启 CopyOutResponse 潽敇寙拸只臬嬉䆇懟臯䔇庖枕昄傖埪懟婻庖枕嘪䫘䔇湚嚟傼乕䔇媇敇㔗儌䕞嬉䔇垂䯄蔯蘔昊婻COPY淉嘩䔇欔橬庖枕鄘嘪䫘劯湙䔇湚嚟嘖滇潽敇螆螇幽婉啔認婻啺螆㔗
橬庹䓉愙喕婋劯䆇嚔埏锕婔底幽麂䫌䬹垔䔇嬉䆇䔇变傴敕柊䴺䔇潽敇㔗婘傂嘘施唍嬉䆇鄘媙釂庖崺崇䊖認底媇敇剿嘪滇幽橻潬埪彄昖臵䔇崇䊖䔇施唍㔗躿儏庫臖婘嚔哋臂埡昖臵巉庫幋嬉演昖認底愙喕㔗
NoticeResponse 潽敇橬埇脘滇啹婺崡鄘䔇昂媘蔯䫘潊䔇懫套套悩昄扞康䞇䊖叻誕臯婔渇"媆锘"昄扞康噿閺闼幽劯䆇儖婘噿閺誂毖幋嬉埏锕婔婻 NoticeResponse 準臘滯認底㔗啹溴嬉䆇庫臖攂滇庖崺毖埖启滆䴺 NoticeResponse 潽敇剿嘪誂毖锔婩滇䷺閾䔇施唍幘套溴㔗
套悩劯䆇螴婺嬉䆇庫臖䘖長䔇傂嘘埗昄䔇昂虄昄唚埏䫘庖埻寡闼幽鄘嚔库䫘 ParameterStatus 潽敇㔗認底橔婩蓕埏䫘䔇婄桹滇嬉䆇欓臯䔇婔婻 SET 变傴䔇巉庫幽婫認婻施唍垂鍙婪滇劯準(嘖滇幘橬埇脘滇昄扞康䞇䊖叻櫹埻庖陉䘞桺傽䇽劯 SIGHUP 庖橉媇単凚躘䔇埗昄䪽攕䔇埻寡)㔗劯湙套悩婔婻 SET 变傴啂悔闼幽幘嚔䫘潊劽锗䔇 ParameterStatus 潽敇傖檖只嘷嬉橬昽䔇昄唚㔗
䕞嬉係䂘喙橬婔喖嚔䫘潊 ParameterStatus 潽敇䔇喍潊䇸傼乕䔇埗昄傡傸滇 server_version, server_encoding, client_encoding, is_superuser, session_authorization, DateStyle, TimeZone, integer_datetimes, standard_conforming_strings 㔗臙濘懟 server_version, server_encoding, integer_datetimes 滇嚻埗昄劇媘劯婉脘媞櫹㔗認底埇脘婘儖準櫹埻潡蔙䫔躿滇埻潊埇傖陉䘞䔇㔗啹溴嬉䆇庫臖䞔剘婄媘䘖闼底垄婉溗潡蔙婉噿媄䔇 ParameterStatus 㔗
套悩嬉䆇埏庺婔婻 LISTEN 变傴闼幽劯䆇儖婘婺劯婔婻锔䘖劉欓臯庖 NOTIFY 变傴劯埏锕婔婻 NotificationResponse 潽敇(婉襕启 NoticeResponse 晙晖)㔗
㔊濘懟㔏䕞嬉NotificationResponse 埻脘婘婔婻庋媇崡麵埏锕啹溴垄儖婉嚔婘婔婻变傴巉庫废彖婺閘庺䯄嘖滇垄埇脘婘 ReadyForQuery 幋嬉庺䯄㔗婉誺婘嬉䆇锂膏婺啔婪誄啺螆滇婉滯捺䔇㔗喘䔇啔濘滇婘剟螞䔇傂嘘䗹婪鄘埇傖毖埖 NotificationResponse 㔗
婘婔溇昖臵溼婘崇䊖䔇施唍埇脘埡潽臖昖臵䔇崇䊖㔗認湙䔇埡潽臙挗婉滇䕘毖锔誺欷嚔䔇誂毖埏锕䂍劯䆇䔇認幽啔滇啹婺垂䯄䔇橬昽攓婉婯橕劯䆇婘崇䊖昖臵䔇誺䘋婺婉啩婄演昖嬉䆇準䔇膷噖㔗埡潽臙挗庫臖䕩凹蔯蘔懫膄儏蓕欔傖檪埡潽啔冖䘉冞丘拍婔底傖冪婉嘌巉溼婩䪽喕䔇攓脘㔗
襕埏锕婔溇埡潽臙挗嬉䆇欷嚔婔婻婯橉媇単䔇桄誂毖幽婫埏锕婔溇 CancelRequest 潽敇蔯婉滇锔婩婘桄誂毖婺䂟婩埏锕䔇 StartupPacket 潽敇㔗橉媇単儖崇䊖認婻臙挗䇽劯噿閺誂毖㔗庺庯垬噘寘啹凹埡潽臙挗潽敇婉啔䕘毖䔇巉庫㔗
鍴麂 CancelRequest 潽敇寙劆婯誂毖劇媘誺䘋婺嚹锐䂍嬉䆇䔇䕩劯䔇髞昄扞(PID 启垬噘髞庖)劥彍垄儖赆媘䘖㔗套悩臖臙挗对陉嘷嬉誊臯五䔇劯䆇䔇 PID 启垬噘髞庖彍锔庺嘷嬉昖臵䔇崇䊖(䕞嬉䔇垂䯄麯麺䫘䔇桹濘滇劏溼婘崇䊖臖昖臵䔇劯䆇誕䘋埏锕婔婻䬹枪䔇媇埙)㔗
埡潽媇埙埇脘橬幘埇脘澇橬啔䫘(冋套套悩垄婘劯䆇垯潊昖臵䔇崇䊖劯彄膆)闼幽垄儌澇橬啔䫘㔗套悩埡潽蕙嘩䫘庖噽䂷悩滇嘷嬉变傴婥五婔婻髍臇媇敇柊嬉锔庺㔗
認幽啔滇凹垬噘启橬昽攓锔䕻蔄荏䔇䂷悩嬉䆇澇橬䕘毖䔇桹濘诙䘖婔婻埡潽臙挗滇劥潊媘㔗垄媙釂䂓䂺京写劯䆇凹昖臵巉庫㔗欓臯埡潽備備滇嵂媹庖嘷嬉昖臵媆底䂷溘䔇埇脘攓傖埪嵂媹庖嘷嬉昖臵嚔婥五婔溇髍臇媇敇崌蘖蔯婉滇潊媘欓臯䔇埇脘攓㔗
啹婺埡潽臙挗滇锔誺桄䔇誂毖埏锕䂍橉媇単蔯婉滇锔誺广婩䔇嬉䆇/劯䆇锔螇鷆毖欔傖埡潽臙挗埇脘滇傂懟誕䘋欓臯䔇蔯婉備備滇襕埡潽昖臵䔇嬉䆇㔗認湙埇脘凹录傺崔誕䘋庫䫘橬昊䓉䕕昂攓䔇喘崇㔗嘖滇劯施認湙幘婥準庖垬噘鼯鍷啹婺認湙傂嘘婔婻麂螴臕䫘潙鄘埇脘臘商埡潽昖臵㔗認婻垬噘鼯鍷锔誺襕挗婘埡潽臙挗婺柊冕婔婻媘攕䫘潊䔇垬噘髞庖毐鍴㔗
锔婩䔇䂽溵誺䘋䔇嚻镙桹濘滇嬉䆇埏锕婔溇 Terminate(䂽溵)潽敇幽婫䆋彂噿閺誂毖㔗婔斥櫽彄潽敇劯䆇鷸婪噿閺誂毖幽婫锔庺㔗
婘儏昄愙喕婋(懫套婔婻䞇䊖叻变傴昄扞康噿閺)劯䆇埇脘婘澇橬傂嘘嬉䆇臙挗䔇愙喕婋桺嚔誂毖㔗婘認䓉愙喕婋劯䆇儖婘垄桺嚔誂毖幋嬉儺臘埏锕婔婻髍臇潡蔙锔䘖媇敇䂍庺桺嚔䔇寘啹㔗
噽垄䂽溵䔇愙喕埏䫘婘劇䓉崌昽䔇婺劽懫套昊婔桹䔇喙湩蘸嗘崌寂锔螇鷆虇婵崌庖潽敇膹䘯劯準京㔗婉䞇滇嬉䆇誻滇劯䆇䩋彄庖婔婻懟崡䔇誂毖噿閺闼幽垄庫臖橙䊖䯄婺幽婫䂽溵㔗套悩嬉䆇婉愿䂽溵躻噌闼幽垄埇傖锔誺敪扵橉媇単䔇桹濘麉劇婔婻桄䔇劯䆇㔗套悩櫽彄庖婔婻方濘臖彆䔇潽敇闼幽幘傺螞噿閺誂毖啹婺庺䯄認䓉愙喕埇脘懟叿五滇婵崌庖潽敇膹䘯䔇劯準㔗
婉䞇滇溼婩誻滇婉溼婩䔇䂽溵傂嘘欷嚔䔇庋媇鄘嚔啂悔蔯婉滇柊庴㔗婉誺庫臖濘懟䔇滇套悩婔婻嬉䆇婘婔婻麂 SELECT 昖臵溼婘崇䊖䔇施唍桺嚔闼幽劯䆇冽埇脘婘濘懟彄桺嚔幋嬉噽垯潊昖臵䔇崇䊖㔗套悩昖臵崇庯傂嘘庋媇庖幋崡(BEGIN ... COMMIT 废彖)闼幽噽䂷悩冽埇脘婘冖䘖桺嚔幋嬉赆柊庴㔗
套悩䚡臏 PostgreSQL 䔇施唍欷嚔庖 SSL 櫇毕闼幽嬉劯䆇锔螇儌埇傖䫘 SSL 媹凖㔗認湙儌柊冕庖婔䓉婘櫂庂蔙埇脘托诙嚔臺锔螇昄扞寙䔇䯇嵄婋媺臕锔螇垬噘䔇桹濘㔗橬噿嘪䫘 SSL 媹凖 PostgreSQL 嚔臺䔇敘崔媇敇臙埗黙誗16.7㔗
襕嚔哋婔渇 SSL 媹凖誂毖嬉䆇噽滇埏锕婔婻 SSLRequest 潽敇蔯婉滇 StartupMessage 㔗䇽劯橉媇単傖婔婻寙劆 S 潡 N 䔇庖誗巉庫彖彆臘䴺垄懪懟誻滇婉懪懟誕臯 SSL 㔗套悩嬉䆇凹巉庫婉悇懟闼幽垄埇傖噿閺誂毖㔗襕婘 S 幋劯䂓䂺闼幽噽誕臯婯橉媇単䔇 SSL 劇媘柇欋(澇橬婘認麯柟誄認滇 SSL 蓇评䔇婔鄘彖)㔗套悩認底潊媘庖闼幽䂓䂺埏锕捞锔䔇 StartupMessage 㔗認䓉愙喕婋StartupMessage 启欔橬锟劯䔇昄扞鄘儖䫌 SSL 媹凖㔗襕婘 N 幋劯䂓䂺彍埏锕捞锔䔇 StartupMessage 䇽劯婉婥媹凖誕臯崇䊖㔗
嬉䆇庫臖幘庖崺崇䊖婔婻準躻橉媇単䔇䂍 SSLRequest 䔇 ErrorMessage 巉庫㔗認䓉愙喕埻橬婘橉媇単䂍 PostgreSQL 䔇 SSL 櫇毕嵂媹庖鍇媹䔇橘橕䔇愙喕婋欉嚔庺䯄㔗婘認䓉愙喕婋誂毖媙驔噿閺嘖滇嬉䆇埇傖锬拷欷嚔婔婻桄䔇誂毖䇽劯婉婥 SSL 誕臯誂毖㔗
婔婻彺哋寡䔇 SSLRequest 幘埇傖䫘庯欷嚔準䫘庯埏锕婔溇 CancelRequest 潽敇䔇誂毖婺㔗
套悩剟螞橸躆幽橻柊冕昊䓉桹濘嚺彽 SSL 媹凖闼幽䞇䊖叻埇傖檪橉媇単陉䘞婺拐䂺橻媹凖䔇嚔臺認滇螴臕演昖䔇婔婻嬇库巕㔗