{"id":96766,"date":"2024-10-20T12:11:17","date_gmt":"2024-10-20T04:11:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/96766\/"},"modified":"2024-10-20T12:11:18","modified_gmt":"2024-10-20T04:11:18","slug":"postgresql-22p03-invalid_binary_representation-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/96766\/","title":{"rendered":"PostgreSQL 22P03: invalid_binary_representation \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"postgresql-22p03-invalid_binary_representation-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9-%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-wkeggkIqcK\">PostgreSQL 22P03: invalid_binary_representation \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406<\/h1>\n<p>\u5728\u4f7f\u7528 PostgreSQL \u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u300c22P03: invalid_binary_representation\u300d\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8207\u6578\u64da\u985e\u578b\u7684\u8f49\u63db\u6709\u95dc\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u4e8c\u9032\u5236\u6578\u64da\u6642\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u3001\u89e3\u6c7a\u65b9\u6848\u4ee5\u53ca\u5982\u4f55\u9032\u884c\u9060\u7a0b\u8655\u7406\u3002<\/p>\n<h2 id=\"%e9%8c%af%e8%aa%a4%e5%8e%9f%e5%9b%a0-wkeggkIqcK\">\u932f\u8aa4\u539f\u56e0<\/h2>\n<p>PostgreSQL \u7684\u300c22P03: invalid_binary_representation\u300d\u932f\u8aa4\u901a\u5e38\u767c\u751f\u5728\u4ee5\u4e0b\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\uff1a<\/strong>\u7576\u5617\u8a66\u5c07\u4e00\u500b\u4e0d\u7b26\u5408\u9810\u671f\u683c\u5f0f\u7684\u4e8c\u9032\u5236\u6578\u64da\u8f49\u63db\u70ba\u5176\u4ed6\u6578\u64da\u985e\u578b\u6642\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u6b64\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u5c07\u4e00\u500b\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6574\u6578\u6642\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u5305\u542b\u975e\u6578\u5b57\u5b57\u7b26\uff0c\u5c31\u6703\u51fa\u73fe\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u6578\u64da\u640d\u58de\uff1a<\/strong>\u5982\u679c\u6578\u64da\u5728\u5b58\u5132\u6216\u50b3\u8f38\u904e\u7a0b\u4e2d\u640d\u58de\uff0cPostgreSQL \u5728\u8b80\u53d6\u9019\u4e9b\u6578\u64da\u6642\u4e5f\u53ef\u80fd\u6703\u5831\u544a\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u4e0d\u6b63\u78ba\u7684\u51fd\u6578\u4f7f\u7528\uff1a<\/strong>\u4f7f\u7528\u4e0d\u6b63\u78ba\u7684\u51fd\u6578\u6216\u65b9\u6cd5\u4f86\u8655\u7406\u4e8c\u9032\u5236\u6578\u64da\uff0c\u53ef\u80fd\u6703\u5c0e\u81f4\u7121\u6cd5\u6b63\u78ba\u89e3\u6790\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%95%85%e9%9a%9c%e4%bf%ae%e5%be%a9%e6%ad%a5%e9%a9%9f-wkeggkIqcK\">\u6545\u969c\u4fee\u5fa9\u6b65\u9a5f<\/h2>\n<p>\u7576\u9047\u5230\u300c22P03: invalid_binary_representation\u300d\u932f\u8aa4\u6642\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u9032\u884c\u6545\u969c\u6392\u9664\u548c\u4fee\u5fa9\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-wkeggkIqcK\">1. \u6aa2\u67e5\u6578\u64da\u985e\u578b<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u5c0e\u81f4\u932f\u8aa4\u7684\u6578\u64da\u985e\u578b\u3002\u78ba\u4fdd\u6578\u64da\u7684\u683c\u5f0f\u8207\u9810\u671f\u7684\u6578\u64da\u985e\u578b\u76f8\u7b26\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5c07\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6574\u6578\uff0c\u8acb\u78ba\u4fdd\u5b57\u7b26\u4e32\u53ea\u5305\u542b\u6578\u5b57\u3002<\/p>\n<pre><code>SELECT CAST('123' AS INTEGER);  -- \u6b63\u78ba\nSELECT CAST('123abc' AS INTEGER);  -- \u932f\u8aa4\uff0c\u6703\u5c0e\u81f4 22P03\n<\/code><\/pre>\n<h3 id=\"2-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e5%ae%8c%e6%95%b4%e6%80%a7-wkeggkIqcK\">2. \u6aa2\u67e5\u6578\u64da\u5b8c\u6574\u6027<\/h3>\n<p>\u5982\u679c\u6578\u64da\u4f86\u81ea\u5916\u90e8\u4f86\u6e90\uff0c\u8acb\u6aa2\u67e5\u6578\u64da\u7684\u5b8c\u6574\u6027\u3002\u53ef\u4ee5\u4f7f\u7528 SQL \u67e5\u8a62\u4f86\u6aa2\u67e5\u6578\u64da\u662f\u5426\u7b26\u5408\u9810\u671f\u683c\u5f0f\u3002<\/p>\n<pre><code>SELECT * FROM your_table WHERE your_column IS NOT NULL AND your_column !~ '^[0-9]+$';\n<\/code><\/pre>\n<h3 id=\"3-%e4%bd%bf%e7%94%a8%e6%ad%a3%e7%a2%ba%e7%9a%84%e5%87%bd%e6%95%b8-wkeggkIqcK\">3. \u4f7f\u7528\u6b63\u78ba\u7684\u51fd\u6578<\/h3>\n<p>\u78ba\u4fdd\u4f7f\u7528\u6b63\u78ba\u7684\u51fd\u6578\u4f86\u8655\u7406\u4e8c\u9032\u5236\u6578\u64da\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>decode()<\/code> \u51fd\u6578\u4f86\u5c07\u5341\u516d\u9032\u5236\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u4e8c\u9032\u5236\u6578\u64da\u3002<\/p>\n<pre><code>SELECT decode('48656c6c6f', 'hex');  -- \u5c07\u5341\u516d\u9032\u5236\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u4e8c\u9032\u5236\n<\/code><\/pre>\n<h2 id=\"%e9%81%a0%e7%a8%8b%e8%99%95%e7%90%86-wkeggkIqcK\">\u9060\u7a0b\u8655\u7406<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u9060\u7a0b\u8655\u7406 PostgreSQL \u6578\u64da\u5eab\u4ee5\u89e3\u6c7a\u6b64\u932f\u8aa4\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5efa\u8b70\uff1a<\/p>\n<ul>\n<li><strong>\u4f7f\u7528 SSH \u9023\u63a5\uff1a<\/strong>\u901a\u904e SSH \u9023\u63a5\u5230\u6578\u64da\u5eab\u4f3a\u670d\u5668\uff0c\u4e26\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u9032\u884c\u6545\u969c\u6392\u9664\u3002<\/li>\n<li><strong>\u4f7f\u7528 pgAdmin\uff1a<\/strong>\u5982\u679c\u4f60\u4f7f\u7528 pgAdmin \u7b49\u5716\u5f62\u754c\u9762\u5de5\u5177\uff0c\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u6aa2\u67e5\u548c\u4fee\u5fa9\u6578\u64da\u3002<\/li>\n<li><strong>\u65e5\u8a8c\u6a94\u6848\u6aa2\u67e5\uff1a<\/strong>\u6aa2\u67e5 PostgreSQL \u7684\u65e5\u8a8c\u6a94\u6848\uff0c\u4ee5\u7372\u53d6\u66f4\u591a\u932f\u8aa4\u4fe1\u606f\uff0c\u9019\u6709\u52a9\u65bc\u5b9a\u4f4d\u554f\u984c\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-wkeggkIqcK\">\u7e3d\u7d50<\/h2>\n<p>PostgreSQL \u7684\u300c22P03: invalid_binary_representation\u300d\u932f\u8aa4\u901a\u5e38\u8207\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\u6216\u6578\u64da\u640d\u58de\u6709\u95dc\u3002\u901a\u904e\u6aa2\u67e5\u6578\u64da\u985e\u578b\u3001\u6578\u64da\u5b8c\u6574\u6027\u4ee5\u53ca\u4f7f\u7528\u6b63\u78ba\u7684\u51fd\u6578\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u6b64\u554f\u984c\u3002\u5728\u9700\u8981\u6642\uff0c\u9060\u7a0b\u8655\u7406\u4e5f\u80fd\u5e6b\u52a9\u5feb\u901f\u5b9a\u4f4d\u548c\u4fee\u5fa9\u6545\u969c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a> \u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to troubleshoot and fix the PostgreSQL 22P03: invalid_binary_representation error with remote handling solutions.<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-96766","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96766","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=96766"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96766\/revisions"}],"predecessor-version":[{"id":96767,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/96766\/revisions\/96767"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=96766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=96766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=96766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}