Get und-x-icu as collation and character type in Postgres 10 and win server 2008 - postgresql

I have successfully installed Postgres 10 in a Windows Server 2008 R2 standard, 64 bit.
I am trying to create a new database that has LC_COLLATE = 'und-x-icu' and LC_CTYPE = 'und-x-icu' with the following SQL
CREATE DATABASE hey
WITH
OWNER = postgres
ENCODING = 'UTF8'
LC_COLLATE = 'und-x-icu'
LC_CTYPE = 'und-x-icu'
TABLESPACE = pg_default
CONNECTION LIMIT = -1
TEMPLATE = template0
;
I get ERROR: invalid locale name: "und-x-icu" SQL state: 42809.
But the SELECT * FROM pg_collation; clearly shows und-x-icu.
The same SQL works on my laptop (windows 10).
I did select locale : C while installing on the server, I did not remember what I selected as a locale while installing on the laptop.
How can I make this work on win server 2008 and get und-x-icu?

The documentation does not seem to mention that restriction, but you cannot use ICU collations in CREATE DATABASE.
This may be improved in the future, but for now there is no way to have an ICU collation as the default collation.

Related

Adding COLLATION in postgres

I am migrating data from SQL Server to Postgres. Since Postgres is case-sensitive, I am trying to add case-insensitive COLLATION but it is failing with the below error -
ERROR: could not create locale "en-u-ks-primary": No such file or
directory DETAIL: The operating system could not find any locale data
for the locale name "en-u-ks-primary". SQL state: 22023
CREATE COLLATION main.case_insensitive_collation (LC_COLLATE = 'en-u-ks-primary',
LC_CTYPE = 'en-u-ks-primary'
PROVIDER = icu,
DETERMINISTIC = False
);
Checked the version of postgres -
SELECT version();
"PostgreSQL 12.5 on x86_64-pc-linux-gnu, compiled by gcc (Debian
8.3.0-6) 8.3.0, 64-bit"
Any idea on how can I fix this or get this working ?
Thanks in advance,
Neha
Your collation definition is wrong. It should be something like
CREATE COLLATION english_ci (
PROVIDER = icu,
LOCALE = 'en-u-ks-level2',
DETERMINISTIC = FALSE
);
Here is an article that has some information about that.

How to create DB with Latin9 locale

I have a new server running Postgres Linux Version 12.9 (2021-12-13), and I want to create a DB with these options:
CREATE DATABASE et_base WITH
ENCODING 'LATIN9' LC_COLLATE = 'fr_FR.iso885915#euro'
LC_CTYPE = 'fr_FR.iso885915#euro' TEMPLATE=template0.....
But I get this error message:
ERROR: invalid locale name: "fr_FR.iso885915#euro"

connecting to DB2 database:[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed

odbc.ini:
[DEFAULT]
Driver = DB2
[abc]
Driver = DB2
[dsn_test1]
DESCRIPTION = Connection to DB2
Driver = db2
odbcinst.ini:
[DB2]
Description = DB2 Driver
Driver = /home/user/sqllib/lib/libdb2.so
fileusage=1
dontdlclose=1
[ODBC]
Trace=1
TraceFile=/home/user/sqllib/trace.out
db2cli.ini
[abc]
hostname="hostname"
pwd="passwd"
port="port"
PROTOCOL=TCPIP
database="dbname"
uid="uid"
$ ./isql abc
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
while connecting from db2 driver,below error is coming:
Connection attempt for data source name "abc":
===============================================================================
ODBC Driver Manager Path: /home/user/sqllib/odbclib/lib/libodbc.so
[FAILED]: [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV
failed
Below is the snippet of odbc trace:
[ODBC][23419][1403783774.660159][SQLConnect.c][1380]Error: IM004
[ODBC][23419][1403783774.660223][SQLError.c][434]
Entry:
Connection = 0x81aaac8
SQLState = 0xffff9593
Native = 0xffff9684
Message Text = 0xffff8d93
Buffer Length = 1024
Text Len Ptr = 0xffff95bc
[ODBC][23419][1403783774.660260][SQLError.c][471]
Exit:[SQL_SUCCESS]
SQLState = IM004
Native = 0xffff9684 -> 0
Message Text = [[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed]
Googled a lot for root-cause,dint helped much,please provide some pointer to solve this.
its a 32 bit linux machine having 32 bit db driver as well.
According to this IBM Support page, an IM004 SQLState on SQLAllocHandle relates to the new security feature.
Cause
The new security features introduced in DB2® Universal Database™ (DB2
UDB) Version 8.2 prevent users from using the database unless they
belong to the Windows® groups DB2ADMNS or DB2USERS.
Answer
Add the userid (the one used to execute the application) to either the
DB2ADMNS or DB2USERS group. Please refer to the link under "Related
Information" (below) for instructions on how to accomplish this.
Alternatively, there are a number of threads (e.g. Huge problems connecting to a DB2 database) which suggest setting the DB2INSTANCE environment variable to match the instance setting in your odbc.ini file for the DSN concerned, e.g.
export DB2INSTANCE=db2inst1
isql -v FS01DB2

How to see cyrillic symbols in PostgreSQL errors?

I have a PostgreSQL on Windows 7 machine. And here my data base script:
CREATE DATABASE usersdb
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'Russian_Russia.1251'
LC_CTYPE = 'Russian_Russia.1251'
CONNECTION LIMIT = -1;
My problem in that i see unreadable error in Jetty/Tomcat:
Caused by: org.postgresql.util.PSQLException: ?????: ???????????? "test_user" ?? ?????? ???????? ??????????? (?? ??????)
I try create new db in pgAdmin but there are only LC_COLLATE = 'Russian_Russia.1251' and LC_CTYPE = 'Russian_Russia.1251' i can chose.
How can i solve this problem?
The first place to look, of course, are in the PostgreSQL logs. Those may be better handled than your Jetty/Tomcat instance.
The second question is what client encoding is set. You may want to (via jdbc):
show client_encoding;
Finally lc_messages may need to be adjusted.

character 0xe28093 of encoding "UTF8" has no equivalent in "LATIN1"

While inserting some data in a Latin1 Postgres 9.1.3 I get the error:
character 0xe28093 of encoding "UTF8" has no equivalent in "LATIN1"
The data is being inserted by a Grails application. I've tried the following with no success:
hibernate { connection.characterEncoding='utf8'}
?charSet=LATIN1 in the jdbc conn string
hibernate { connection.charSet='LATIN1'}
The database were created with:
CREATE DATABASE mydb
WITH OWNER = postgres
ENCODING = 'LATIN1'
TABLESPACE = pg_default
LC_COLLATE = 'C'
LC_CTYPE = 'C'
CONNECTION LIMIT = -1;
Any idea? Thank you in advance.
If I understand you correctly your database has been created with the encoding "LATIN1". This encoding cannot be changed after the DB has been created. The only thing you can change - as shown by your bullet points - is the encoding between your client and the PostgreSQL server. The PostgreSQL server then tries to translate between the client encoding and the database encoding.
This process of course fails if when the client transmits data which cannot be translated into the DB encoding. In your case the Unicode codepoint 2013 cannot be translated into LATIN1.
This means you have to clean all data going to the database. Fiddling with the client encodings will not help.
That is the UTF-8 encoding for the en dash symbol. The closest equivalent in the latin1 character set would be character code 150 (0x96).