[suggestion]support UNICODE host variables in ECPG

From: "Nagaura, Ryohei" <nagaura(dot)ryohei(at)jp(dot)fujitsu(dot)com>
To: "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Cc: "'jingwangian(at)gmail(dot)com'" <jingwangian(at)gmail(dot)com>, "'michael(dot)paquier(at)gmail(dot)com'" <michael(dot)paquier(at)gmail(dot)com>, "'meskes(at)postgresql(dot)org'" <meskes(at)postgresql(dot)org>
Subject: [suggestion]support UNICODE host variables in ECPG
Date: 2018-12-17 08:31:41
Message-ID: EDA4195584F5064680D8130B1CA91C453A5F79@G01JPEXMBYT04
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all.

There is a demand for ECPG to support UNICODE host variables.
This topic has also appeared in thread [1].
I would like to discuss whether to support in postgres.

Do you have any opinion?

The specifications and usage described below are the same as in [1].

Requirements
============
1. support utext keyword in ECPG

The utext is used to define the Unicode host variable in ECPG application
in windows platform.

2. support UVARCHAR keyword in ECPG

The UVARCHAR is used to define the Unicode vary length host variable in
ECPG application in windows platform.

3. Saving the content of the Unicode variables into the database as
database character set or getting the content from the database into the
Unicode variables.

4. Firstly can only consider the UTF8 as database character set and UTF16
as the Unicode format for host variable. A datatype convert will be done
between the UTF8 and UTF16 by ECPG.

5. Since Unicode has big-endian and little-endian format, a environment
variable is used to identify them and do the endianness convert accordingly.

Usage
============
int main() {
EXEC SQL BEGIN DECLARE SECTION;
utext employee[20] ; /* define Unicode host variable */
UVARCHAR address[50] ; /* defin a vary length Unicode host
variable */
EXEC SQL END DECLARE SECTION;

...

EXEC SQL CREATE TABLE emp (ename char(20), address varchar(50));

/* UTF8 is the database character set */
EXEC SQL INSERT INTO emp (ename) VALUES ('Mike', '1 sydney, NSW') ;

/* Database character set converted to Unicode */
EXEC SQL SELECT ename INTO :employee FROM emp ;

/* Database character set converted to Unicode */
EXEC SQL SELECT address INTO :address FROM emp ;

wprintf(L"employee name is %s\n",employee);

wprintf(L"employee address is %s\n", address.attr);

DELETE * FROM emp;

/* Unicode converted to Database character */
EXEC SQL INSERT INTO emp (ename,address) VALUES (:employee, :address);

EXEC SQL DROP TABLE emp;
EXEC SQL DISCONNECT ALL;
}

[1]
https://www.postgresql.org/message-id/flat/CAF3%2BxMLcare1QrDzTxP-3JZyH5SXRkGzNUf-khSgPfmpQpkz%2BA%40mail.gmail.com

Best regards,
---------------------
Ryohei Nagaura

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-12-17 08:48:07 Re: ToDo: show size of partitioned table
Previous Message amul sul 2018-12-17 08:30:48 Re: ALTER INDEX ... ALTER COLUMN not present in dump