{"id":179054,"date":"2024-11-08T22:37:19","date_gmt":"2024-11-08T14:37:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/179054\/"},"modified":"2024-11-08T22:37:20","modified_gmt":"2024-11-08T14:37:20","slug":"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9-postgresql-%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc%ef%bc%9a42p18-indeterminate_datatype%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/179054\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P18 &#8211; indeterminate_datatype\uff1f"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9-postgresql-%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc%ef%bc%9a42p18-indeterminate_datatype-aceRLoTMVu\">\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a42P18 &#8211; indeterminate_datatype<\/h1>\n<p>\u5728\u4f7f\u7528 PostgreSQL \u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u932f\u8aa4\u4ee3\u78bc 42P18\uff0c\u8a72\u932f\u8aa4\u901a\u5e38\u8207\u300cindeterminate_datatype\u300d\u6709\u95dc\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u51fa\u73fe\u5728\u4f7f\u7528\u4e0d\u78ba\u5b9a\u985e\u578b\u7684\u6578\u64da\u6642\uff0c\u7279\u5225\u662f\u5728\u6d89\u53ca\u5230\u6578\u64da\u985e\u578b\u7684\u6bd4\u8f03\u6216\u6392\u5e8f\u6642\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u53ca\u5176\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<h2 id=\"%e9%8c%af%e8%aa%a4%e5%8e%9f%e5%9b%a0-aceRLoTMVu\">\u932f\u8aa4\u539f\u56e0<\/h2>\n<p>PostgreSQL \u4e2d\u7684\u300cindeterminate_datatype\u300d\u6307\u7684\u662f\u67d0\u4e9b\u6578\u64da\u985e\u578b\u5728\u9032\u884c\u6bd4\u8f03\u6642\u7121\u6cd5\u78ba\u5b9a\u5176\u9806\u5e8f\u6216\u7b49\u50f9\u6027\u3002\u9019\u901a\u5e38\u767c\u751f\u5728\u4ee5\u4e0b\u60c5\u6cc1\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u4e86\u4e0d\u652f\u6301\u6392\u5e8f\u7684\u6578\u64da\u985e\u578b\uff0c\u4f8b\u5982\u67d0\u4e9b\u81ea\u5b9a\u7fa9\u985e\u578b\u3002<\/li>\n<li>\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528\u4e86\u4e0d\u660e\u78ba\u7684\u6bd4\u8f03\u904b\u7b97\u7b26\u3002<\/li>\n<li>\u5728\u4f7f\u7528\u805a\u5408\u51fd\u6578\u6216\u7a97\u53e3\u51fd\u6578\u6642\uff0c\u672a\u80fd\u6b63\u78ba\u6307\u5b9a\u6578\u64da\u985e\u578b\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff0c\u7576\u4f60\u5617\u8a66\u5728\u4e00\u500b\u5305\u542b\u81ea\u5b9a\u7fa9\u6578\u64da\u985e\u578b\u7684\u8868\u4e2d\u9032\u884c\u6392\u5e8f\u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u9019\u500b\u932f\u8aa4\u3002PostgreSQL \u9700\u8981\u80fd\u5920\u78ba\u5b9a\u5982\u4f55\u6bd4\u8f03\u9019\u4e9b\u6578\u64da\u985e\u578b\uff0c\u4f46\u5982\u679c\u6c92\u6709\u63d0\u4f9b\u76f8\u61c9\u7684\u6bd4\u8f03\u51fd\u6578\uff0c\u5c31\u6703\u5c0e\u81f4\u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-aceRLoTMVu\">\u89e3\u6c7a\u65b9\u6848<\/h2>\n<p>\u8981\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc 42P18\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u63a1\u53d6\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b-aceRLoTMVu\">1. \u6aa2\u67e5\u6578\u64da\u985e\u578b<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u4f60\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528\u7684\u6578\u64da\u985e\u578b\u3002\u78ba\u4fdd\u6240\u6709\u7684\u6578\u64da\u985e\u578b\u90fd\u662f\u53ef\u6bd4\u8f03\u7684\u3002\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u81ea\u5b9a\u7fa9\u6578\u64da\u985e\u578b\uff0c\u5247\u9700\u8981\u70ba\u9019\u4e9b\u985e\u578b\u5b9a\u7fa9\u6bd4\u8f03\u51fd\u6578\u3002<\/p>\n<pre><code>CREATE FUNCTION custom_type_compare(a custom_type, b custom_type) RETURNS integer AS $$\nBEGIN\n    -- \u6bd4\u8f03\u908f\u8f2f\nEND;\n$$ LANGUAGE plpgsql;\n\nCREATE OPERATOR &lt; ( \n    LEFTARG = custom_type, \n    RIGHTARG = custom_type, \n    PROCEDURE = custom_type_compare \n);\n<\/code><\/pre>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8%e6%98%8e%e7%a2%ba%e7%9a%84%e6%af%94%e8%bc%83%e9%81%8b%e7%ae%97%e7%ac%a6-aceRLoTMVu\">2. \u4f7f\u7528\u660e\u78ba\u7684\u6bd4\u8f03\u904b\u7b97\u7b26<\/h3>\n<p>\u5728\u67e5\u8a62\u4e2d\uff0c\u4f7f\u7528\u660e\u78ba\u7684\u6bd4\u8f03\u904b\u7b97\u7b26\u4f86\u907f\u514d\u4e0d\u78ba\u5b9a\u6027\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u300c=\u300d\u800c\u4e0d\u662f\u300c==\u300d\u4f86\u9032\u884c\u6bd4\u8f03\uff0c\u9019\u6a23\u53ef\u4ee5\u5e6b\u52a9 PostgreSQL \u78ba\u5b9a\u5982\u4f55\u8655\u7406\u6578\u64da\u3002<\/p>\n<h3 id=\"3-%e6%aa%a2%e6%9f%a5%e8%81%9a%e5%90%88%e5%87%bd%e6%95%b8-aceRLoTMVu\">3. \u6aa2\u67e5\u805a\u5408\u51fd\u6578<\/h3>\n<p>\u5982\u679c\u932f\u8aa4\u767c\u751f\u5728\u4f7f\u7528\u805a\u5408\u51fd\u6578\u7684\u4e0a\u4e0b\u6587\u4e2d\uff0c\u8acb\u6aa2\u67e5\u4f60\u662f\u5426\u6b63\u78ba\u6307\u5b9a\u4e86\u6578\u64da\u985e\u578b\u3002\u78ba\u4fdd\u5728\u4f7f\u7528\u805a\u5408\u51fd\u6578\u6642\uff0c\u6240\u6709\u53c3\u6578\u7684\u6578\u64da\u985e\u578b\u90fd\u662f\u660e\u78ba\u7684\u3002<\/p>\n<pre><code>SELECT custom_aggregate_function(column_name::custom_type) FROM your_table;<\/code><\/pre>\n<h3 id=\"4-%e6%9b%b4%e6%96%b0-postgresql-%e7%89%88%e6%9c%ac-aceRLoTMVu\">4. \u66f4\u65b0 PostgreSQL \u7248\u672c<\/h3>\n<p>\u6709\u6642\u5019\uff0c\u932f\u8aa4\u53ef\u80fd\u662f\u7531\u65bc PostgreSQL \u7684\u67d0\u4e9b\u7248\u672c\u4e2d\u7684 bug \u5f15\u8d77\u7684\u3002\u6aa2\u67e5\u662f\u5426\u6709\u53ef\u7528\u7684\u66f4\u65b0\uff0c\u4e26\u8003\u616e\u5347\u7d1a\u5230\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u7372\u5f97\u66f4\u597d\u7684\u7a69\u5b9a\u6027\u548c\u529f\u80fd\u652f\u6301\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-aceRLoTMVu\">\u7e3d\u7d50<\/h2>\n<p>PostgreSQL \u932f\u8aa4\u4ee3\u78bc 42P18 &#8211; indeterminate_datatype \u901a\u5e38\u662f\u7531\u65bc\u4e0d\u78ba\u5b9a\u7684\u6578\u64da\u985e\u578b\u6bd4\u8f03\u5f15\u8d77\u7684\u3002\u901a\u904e\u6aa2\u67e5\u6578\u64da\u985e\u578b\u3001\u4f7f\u7528\u660e\u78ba\u7684\u6bd4\u8f03\u904b\u7b97\u7b26\u3001\u6aa2\u67e5\u805a\u5408\u51fd\u6578\u4ee5\u53ca\u66f4\u65b0 PostgreSQL \u7248\u672c\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u6c7a\u9019\u500b\u554f\u984c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\u7684\u7528\u6236\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u662f\u81f3\u95dc\u91cd\u8981\u7684\uff0c\u9019\u6a23\u53ef\u4ee5\u78ba\u4fdd\u4f60\u7684\u61c9\u7528\u7a0b\u5e8f\u5728\u6700\u4f73\u74b0\u5883\u4e2d\u904b\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc 42P18 &#8211; indeterminate_datatype\uff0c\u89e3\u6c7a\u6578\u64da\u985e\u578b\u4e0d\u78ba\u5b9a\u6027\u554f\u984c\uff0c\u63d0\u5347\u6578\u64da\u5eab\u6027\u80fd\u3002<\/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-179054","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179054","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=179054"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179054\/revisions"}],"predecessor-version":[{"id":179055,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/179054\/revisions\/179055"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=179054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=179054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=179054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}