ascii 152字符(“?”)上的PostgreSQL上层函数
发布时间:2020-12-13 15:52:56 所属栏目:百科 来源:网络整理
导读:在 Windows 7平台上,使用PostgreSQL版本9.3.9,使用PgAdmin作为客户端,在包含例如的列上选择上部的结果“???”,返回null.如果存储三个值,例如, "ada""john""mole" "???" 除了包含“???”的行外,它们都以大写形式返回;这一行 什么都没有回来,null … 数据库编
在
Windows 7平台上,使用PostgreSQL版本9.3.9,使用PgAdmin作为客户端,在包含例如的列上选择上部的结果“???”,返回null.如果存储三个值,例如,
"ada" "john" "mole" "???" 除了包含“???”的行外,它们都以大写形式返回;这一行 数据库编码方案是UTF8 / UNICODE.设置“client_encoding”具有相同的值UNICODE. 这是数据库中的设置问题,操作系统问题还是错误 的结果: select thecol,upper(thecol),upper(thecol) is null,convert_to(thecol,'UTF8'),current_setting('server_encoding') from thetable where ... 是: "Apps";"APPS";f;"Apps";"UTF8" "All";"ALL";f;"All";"UTF8" "Test";"TEST";f;"Test";"UTF8" "???";"";f;"303277303277303277";"UTF8" pg_settings的lc_部分是: "lc_collate";"Swedish_Sweden.1252";"Shows the collation order locale." "lc_ctype";"Swedish_Sweden.1252";"Shows the character classification and case conversion locale." "lc_messages";"Swedish_Sweden.1252";"Sets the language in which messages are displayed." "lc_monetary";"Swedish_Sweden.1252";"Sets the locale for formatting monetary amounts." "lc_numeric";"Swedish_Sweden.1252";"Sets the locale for formatting numbers." select * from pg_database的输出是: "template1";10;6;"Swedish_Sweden.1252";"Swedish_Sweden.1252";t;t;-1;12130;668;1??;1663;"{=c/postgres,postgres=CTc/postgres}" "template0";10;6;"Swedish_Sweden.1252";"Swedish_Sweden.1252";t;f;-1;12130;668;1??;1663;"{=c/postgres,postgres=CTc/postgres}" "postgres";10;6;"Swedish_Sweden.1252";"Swedish_Sweden.1252";f;t;-1;12130;668;1;??1663;"" 对于9.4.4版本,实际的create database语句是: CREATE DATABASE postgres WITH OWNER = postgres ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'Swedish_Sweden.1252' LC_CTYPE = 'Swedish_Sweden.1252' CONNECTION LIMIT = -1; 解决方法
我的猜测是上层函数使用数据库的LC_CTYPE设置.带有DIAERESIS(U 00FF)的LATIN SMALL LETTER Y的大写字母是LATIN CAPITAL LETTER Y WITH DIAERESIS'(U 0178),它不是Windows 1252代码页的一部分.
如果首先将字符串转换为Unicode格式,则upper函数可能会按预期工作: SELECT upper(convert_to(thecol,'UTF8')) ... 您应该为LC_CTYPE和LC_COLLATE使用不同的值.在Linux上,您将使用sv_SE.UTF-8. 不过,我认为这是Postgres中的一个错误.如果大写版本无法在目标字符集中表示,最好保留?. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |