{"id":21418,"date":"2024-01-02T09:03:24","date_gmt":"2024-01-02T09:03:24","guid":{"rendered":"https:\/\/server.hk\/blog\/21418\/"},"modified":"2024-11-14T10:34:47","modified_gmt":"2024-11-14T02:34:47","slug":"how-to-fix-postgresql-error-code-42p03-duplicate_cursor","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21418\/","title":{"rendered":"\u5982\u4f55\u89e3\u6c7a PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor"},"content":{"rendered":"<h1 id=\"how-to-fix-postgresql-error-code-42p03-duplicate_cursor-LtxthxTUSf\">\u5982\u4f55\u89e3\u6c7a PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor<\/h1>\n<p>PostgreSQL \u662f\u4e00\u6b3e\u5f37\u5927\u7684\u958b\u6e90\u95dc\u806f\u6027\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5f0f\u4e2d\u3002\u7136\u800c\uff0c\u8207\u6240\u6709\u8edf\u4ef6\u4e00\u6a23\uff0c\u5b83\u4e5f\u53ef\u80fd\u9047\u5230\u6703\u5f71\u97ff\u6b63\u5e38\u904b\u4f5c\u7684\u932f\u8aa4\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u70ba PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u6210\u56e0\uff0c\u4e26\u63d0\u4f9b\u9010\u6b65\u6307\u5c0e\u4f86\u89e3\u6c7a\u5b83\u3002<\/p>\n<h2 id=\"understanding-the-error-LtxthxTUSf\">\u7406\u89e3\u9019\u500b\u932f\u8aa4<\/h2>\n<p>\u7576\u67e5\u8a62\u4e2d\u6aa2\u6e2c\u5230\u91cd\u8907\u7684\u6e38\u6a19\u540d\u7a31\u6642\uff0c\u5c31\u6703\u51fa\u73fe PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor\u3002\u6e38\u6a19\u662f\u4e00\u7a2e\u6578\u64da\u5eab\u5c0d\u8c61\uff0c\u4f7f\u60a8\u80fd\u5920\u6aa2\u7d22\u548c\u64cd\u4f5c\u7d50\u679c\u96c6\u4e2d\u7684\u6578\u64da\u3002\u6bcf\u500b\u6e38\u6a19\u5728\u4e00\u500b\u6703\u8a71\u4e2d\u5fc5\u9808\u64c1\u6709\u552f\u4e00\u7684\u540d\u7a31\uff0c\u5617\u8a66\u5275\u5efa\u4e00\u500b\u5df2\u5b58\u5728\u540d\u7a31\u7684\u6e38\u6a19\u5c07\u89f8\u767c\u6b64\u932f\u8aa4\u3002<\/p>\n<h2 id=\"possible-causes-LtxthxTUSf\">\u53ef\u80fd\u7684\u6210\u56e0<\/h2>\n<p>PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor \u53ef\u80fd\u7531\u5e7e\u500b\u6f5b\u5728\u6210\u56e0\u5f15\u8d77\uff1a<\/p>\n<ul>\n<li><strong>\u591a\u91cd\u6e38\u6a19\u8072\u660e\uff1a<\/strong>\u5982\u679c\u60a8\u7684\u4ee3\u78bc\u4e2d\u5b58\u5728\u591a\u500b\u64c1\u6709\u76f8\u540c\u540d\u7a31\u7684\u6e38\u6a19\u8072\u660e\uff0c\u5247\u6703\u5c0e\u81f4\u932f\u8aa4\u3002\u8acb\u6aa2\u67e5\u60a8\u7684\u4ee3\u78bc\uff0c\u78ba\u4fdd\u6bcf\u500b\u6e38\u6a19\u64c1\u6709\u552f\u4e00\u7684\u540d\u7a31\u3002<\/li>\n<li><strong>\u6e38\u6a19\u672a\u6b63\u78ba\u95dc\u9589\uff1a<\/strong>\u5982\u679c\u5728\u8072\u660e\u65b0\u6e38\u6a19\u4e4b\u524d\uff0c\u672a\u6b63\u78ba\u95dc\u9589\u540c\u540d\u6e38\u6a19\uff0c\u5247\u6703\u5c0e\u81f4\u932f\u8aa4\u3002\u5728\u4f7f\u7528\u5b8c\u6e38\u6a19\u5f8c\uff0c\u8acb\u52d9\u5fc5\u95dc\u9589\u5b83\u5011\u3002<\/li>\n<li><strong>\u4e26\u767c\u554f\u984c\uff1a<\/strong>\u5982\u679c\u591a\u500b\u6703\u8a71\u6216\u4ea4\u6613\u540c\u6642\u4f01\u5716\u5275\u5efa\u540c\u540d\u6e38\u6a19\uff0c\u5247\u6703\u51fa\u73fe\u932f\u8aa4\u3002\u9019\u7a2e\u60c5\u6cc1\u53ef\u80fd\u767c\u751f\u5728\u591a\u7528\u6236\u74b0\u5883\u4e2d\u6216\u5728\u4f7f\u7528\u9023\u63a5\u6c60\u6642\u3002<\/li>\n<\/ul>\n<h2 id=\"fixing-the-error-LtxthxTUSf\">\u4fee\u5fa9\u6b64\u932f\u8aa4<\/h2>\n<p>\u8981\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor\uff0c\u8acb\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li><strong>\u6aa2\u67e5\u60a8\u7684\u4ee3\u78bc\uff1a<\/strong>\u6aa2\u67e5\u4ee3\u78bc\u4e2d\u662f\u5426\u5b58\u5728\u4efb\u4f55\u91cd\u8907\u7684\u6e38\u6a19\u8072\u660e\u3002\u78ba\u4fdd\u6bcf\u500b\u6e38\u6a19\u64c1\u6709\u552f\u4e00\u7684\u540d\u7a31\u3002<\/li>\n<li><strong>\u6b63\u78ba\u95dc\u9589\u6e38\u6a19\uff1a<\/strong>\u5728\u4f7f\u7528\u5b8c\u6e38\u6a19\u5f8c\uff0c\u8acb\u52d9\u5fc5\u95dc\u9589\u5b83\u5011\u3002\u8acb\u4f7f\u7528 <code>CLOSE<\/code> \u8a9e\u53e5\u5728\u8072\u660e\u65b0\u6e38\u6a19\u4e4b\u524d\u95dc\u9589\u820a\u7684\u6e38\u6a19\u3002<\/li>\n<li><strong>\u4f7f\u7528\u552f\u4e00\u7684\u6e38\u6a19\u540d\u7a31\uff1a<\/strong>\u5982\u679c\u60a8\u6b63\u5728\u4f7f\u7528\u591a\u500b\u6703\u8a71\u6216\u4ea4\u6613\uff0c\u8acb\u78ba\u4fdd\u6bcf\u500b\u6e38\u6a19\u64c1\u6709\u552f\u4e00\u7684\u540d\u7a31\u3002\u8003\u616e\u4f7f\u7528\u7279\u5b9a\u65bc\u6703\u8a71\u6216\u4ea4\u6613\u7684\u540d\u7a31\uff0c\u4ee5\u907f\u514d\u885d\u7a81\u3002<\/li>\n<li><strong>\u6aa2\u67e5\u4e26\u767c\u554f\u984c\uff1a<\/strong>\u5982\u679c\u60a8\u9047\u5230\u4e26\u767c\u554f\u984c\uff0c\u8003\u616e\u5be6\u65bd\u9396\u5b9a\u6a5f\u5236\u6216\u70ba\u6bcf\u500b\u6703\u8a71\u6216\u4ea4\u6613\u4f7f\u7528\u4e0d\u540c\u7684\u6e38\u6a19\u540d\u7a31\u3002<\/li>\n<\/ol>\n<p>\u6309\u7167\u9019\u4e9b\u6b65\u9a5f\uff0c\u60a8\u61c9\u80fd\u89e3\u6c7a PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor\uff0c\u4e26\u78ba\u4fdd\u60a8\u7684 PostgreSQL \u6578\u64da\u5eab\u5e73\u7a69\u904b\u884c\u3002<\/p>\n<h2 id=\"summary-LtxthxTUSf\">\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u4e4b\uff0c\u7576\u67e5\u8a62\u4e2d\u6aa2\u6e2c\u5230\u91cd\u8907\u7684\u6e38\u6a19\u540d\u7a31\u6642\uff0c\u6703\u51fa\u73fe PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P03 &#8211; duplicate_cursor\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u8acb\u6aa2\u67e5\u4ee3\u78bc\u4e2d\u662f\u5426\u6709\u91cd\u8907\u7684\u6e38\u6a19\u8072\u660e\uff0c\u6b63\u78ba\u95dc\u9589\u6e38\u6a19\uff0c\u4f7f\u7528\u552f\u4e00\u7684\u6e38\u6a19\u540d\u7a31\uff0c\u4ee5\u53ca\u6aa2\u67e5\u4e26\u767c\u554f\u984c\u3002\u5982\u679c\u60a8\u5728\u5c0b\u627e\u53ef\u9760\u4e14\u9ad8\u6548\u80fd\u7684 VPS \u4e3b\u6a5f\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002\u4ed6\u5011\u5353\u8d8a\u7684 VPS \u4e3b\u6a5f\u670d\u52d9\uff0c\u5c07\u78ba\u4fdd\u60a8\u7684 PostgreSQL \u6578\u64da\u5eab\u53ca\u5176\u4ed6\u61c9\u7528\u7a0b\u5f0f\u7684\u5e73\u7a69\u904b\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u89e3\u6c7a PostgreSQL &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21418","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21418"}],"version-history":[{"count":2,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21418\/revisions"}],"predecessor-version":[{"id":24075,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21418\/revisions\/24075"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}