Opened 15 years ago

Closed 5 years ago

Last modified 5 years ago

#562 closed defect (fixed)

Problem with wchar in Linux

Reported by: rafael Owned by: haris
Priority: blocker Milestone: 3.5.0
Component: KingOracle Provider Version: 3.4.0
Severity: 2 Keywords:
Cc: External ID:

Description

Unlike Windows UTF-16 2-byte wide chars, wchar_t on Linux and OS X is 4 bytes UTF-32 (gcc/g++ and XCode).

Code like this don’t work in Linux:

Oracle manual: “To prepare the SQL statement, call OCIStmtPrepare with (utext*) string. The following example runs on Windows platforms only. You may need to change wchar_t datatypes for other platforms.

const wchar_t sqlstr[] = L"SELECT * FROM ENAME=:ename"; 
...
OCIStmt* stmthp;
sts = OCIHandleAlloc(envh, (void **)&stmthp, OCI_HTYPE_STMT, 0, NULL); 
status = OCIStmtPrepare(stmthp, errhp,(const text*)sqlstr, wcslen(sqlstr), 
                        OCI_NTV_SYNTAX, OCI_DEFAULT);

Change History (3)

comment:1 by rafael, 14 years ago

Priority: majorblocker

comment:2 by jng, 5 years ago

Resolution: fixed
Status: newclosed

In 7812:

Merged revision(s) 7766-7811 from sandbox/kgoralinux:

Get King Oracle provider working on Linux. The root cause of why this provider did not work on Linux in the past is due to:

a) wchar_t strings being garbage on Linux due to difference in platform size. Where wchar_t* strings are passed to OCI on Windows, they are now #ifdef'd (D_OCI_WIDE_STRINGS) on Linux to pass char* strings instead
b) Possibly the use of OCINlsEnvCreate and OCILogon

  • I could not find a suitable OCI reference code on Linux that demonstrated the use of these 2 APIs.
  • So taking a page out of known OCI reference code (the OGR OCI driver), the provider uses OCIEnvCreate and OCIServerAttach on Linux for OCI setup and connection.

This is backed by a new reproducible test suite that runs a basic set of provider test against an Oracle XE 11g instance. An 11g docker environment is provided to easily spin up such an environment.

Fixes #649, #562

comment:3 by jng, 5 years ago

In 7814:

Merged revision(s) 7811-7813 from trunk:
Merged revision(s) 7790-7810 from sandbox/linux64shp:

Fix up the SHP spatial index for 64-bit Linux. This makes the provider finally functional for FDO client applications like MapGuide on 64-bit Linux.

Fixes #963
........
Merged revision(s) 7766-7811 from sandbox/kgoralinux:

Get King Oracle provider working on Linux. The root cause of why this provider did not work on Linux in the past is due to:

a) wchar_t strings being garbage on Linux due to difference in platform size. Where wchar_t* strings are passed to OCI on Windows, they are now #ifdef'd (D_OCI_WIDE_STRINGS) on Linux to pass char* strings instead
b) Possibly the use of OCINlsEnvCreate and OCILogon

  • I could not find a suitable OCI reference code on Linux that demonstrated the use of these 2 APIs.
  • So taking a page out of known OCI reference code (the OGR OCI driver), the provider uses OCIEnvCreate and OCIServerAttach on Linux for OCI setup and connection.

This is backed by a new reproducible test suite that runs a basic set of provider test against an Oracle XE 11g instance. An 11g docker environment is provided to easily spin up such an environment.

Fixes #649, #562
........
Need to add TestCommon and ExpressionEngine projects to KingOracle_vs15.sln to ensure KgOraUnitTest will build in the correct configuration
........

Note: See TracTickets for help on using tickets.