Home » U++ Library support » U++ SQL » Oracle8: UTF8 charset Patch
Oracle8: UTF8 charset Patch [message #26793] |
Fri, 28 May 2010 13:59 |
|
Hello all,
I propose to apply this Oracle patch for use UTF-8 (AL32UTF8) or UTF8 charset encoding, acording by this documentation. I read legal documentation but without success.
Ok, the patch is (with long raw patch):
Index: uppsrc/Oracle/Oci8.cpp
===================================================================
--- uppsrc/Oracle/Oci8.cpp (revision 2421)
+++ uppsrc/Oracle/Oci8.cpp (working copy)
@@ -69,7 +69,7 @@
struct Item {
T_OCI8& oci8;
int type;
- int16 len;
+ int len;
sb2 ind;
ub2 rl;
ub2 rc;
@@ -142,6 +142,7 @@
void SetParam(int i, Date d);
void SetParam(int i, Time d);
void SetParam(int i, Sql& refcursor);
+ void SetRawParam(int i, const String& s);
void AddColumn(int type, int len);
void GetColumn(int i, String& s) const;
@@ -296,6 +297,13 @@
PrepareParam(i, r.GetOraType(), r.GetMaxLen(), 0, r.GetType());
}
+void OCI8Connection::SetRawParam(int i, const String& s) {
+ int l = s.GetLength();
+ Item& p = PrepareParam(i, SQLT_LBI, l, 0, VOID_V);
+ memcpy(p.Data(), s, l);
+ p.ind = l ? 0 : -1;
+}
+
class Oracle8RefCursorStub : public SqlSource {
public:
Oracle8RefCursorStub(SqlConnection *cn) : cn(cn) {}
@@ -320,6 +328,9 @@
SetParam(i, String());
else
switch(q.GetType()) {
+ case SQLRAW_V:
+ SetRawParam(i, SqlRaw(q));
+ break;
case STRING_V:
case WSTRING_V:
SetParam(i, String(q));
@@ -842,21 +853,36 @@
| OCI_THREADED
#endif
;
- if(oci8.OCIEnvCreate) {
- if(oci8.OCIEnvCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0)) {
- OCIInitError(*this, "OCIEnvCreate");
- return false;
- }
+
+ // ILUPASCU(tojocky): try to put utf8 charset
+ bool v_without_NLS = true;
+
+ if(oci8.OCIEnvNlsCreate) {
+ if((v_without_NLS)&&(oci8.OCIEnvNlsCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0, OCI_NLS_NCHARSET_ID_UT8, OCI_NLS_NCHARSET_ID_UT8))){
+ LLOG("OCI8: error on initialization utf8 NLS");
+ v_without_NLS = true;
+ }else v_without_NLS = false;
+ if((v_without_NLS)&&(oci8.OCIEnvNlsCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0, OCI_NLS_NCHARSET_ID_AL32UT8, OCI_NLS_NCHARSET_ID_AL32UT8))){
+ LLOG("OCI8: error on initialization utf8 NLS");
+ v_without_NLS = true;
+ }else v_without_NLS = false;
}
- else {
- if(oci8.OCIInitialize(accessmode, 0, 0, 0, 0)) {
- OCIInitError(*this, "OCIInitialize");
- return false;
+ if(v_without_NLS){
+ if(oci8.OCIEnvCreate){
+ if(oci8.OCIEnvCreate(&envhp, accessmode, 0, 0, 0, 0, 0, 0)) {
+ OCIInitError(*this, "OCIEnvCreate");
+ return false;
+ }
+ } else {
+ if(oci8.OCIInitialize(accessmode, 0, 0, 0, 0)) {
+ OCIInitError(*this, "OCIInitialize");
+ return false;
+ }
+ if(oci8.OCIEnvInit(&envhp, OCI_DEFAULT, 0, 0)) {
+ OCIInitError(*this, "OCIEnvInit");
+ return false;
+ }
}
- if(oci8.OCIEnvInit(&envhp, OCI_DEFAULT, 0, 0)) {
- OCIInitError(*this, "OCIEnvInit");
- return false;
- }
}
if(!AllocOciHandle(&errhp, OCI_HTYPE_ERROR)) {
OCIInitError(*this, "OCI_HTYPE_ERROR");
Index: uppsrc/Oracle/Oci8.dli
===================================================================
--- uppsrc/Oracle/Oci8.dli (revision 2421)
+++ uppsrc/Oracle/Oci8.dli (working copy)
@@ -18,6 +18,19 @@
FN(sword, OCIEnvInit, (UPP::OCIEnv **envp, ub4 mode, size_t xtramem_sz, dvoid **usrmempp))
+FN0(sword, OCIEnvNlsCreate, (OCIEnv **envp, ub4 mode, const dvoid *ctxp, \
+ const dvoid *(*malocfp)(dvoid *ctxp, size_t size), \
+ const dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize), \
+ const void (*mfreexp)(dvoid *ctxp, dvoid *memptr), \
+ size_t xtramem_sz, dvoid **usrmempp, ub2 charset, ub2 ncharset))
+
+FN0(sword, OCINlsEnvironmentVariableGet, (dvoid *val, size_t size, ub2 item,\
+ ub2 charset, size_t *rsize))
+
+FN0(ub2, OCINlsCharSetNameToId, (dvoid *hndl, const OraText *name))
+
+FN0(sword, OCINlsCharSetIdToName, (dvoid *hndl, OraText *buf, size_t buflen, ub2 id))
+
FN0(sword, OCIEnvCreate, (OCIEnv **envp, ub4 mode, const dvoid *ctxp, \
const dvoid *(*malocfp)(dvoid *ctxp, size_t size), \
const dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize), \
Index: uppsrc/Oracle/OciCommon.h
===================================================================
--- uppsrc/Oracle/OciCommon.h (revision 2421)
+++ uppsrc/Oracle/OciCommon.h (working copy)
@@ -36,6 +36,9 @@
// The following *TWO* are only valid for OCICreateEnvironment call
OCI_NO_UCB = 0x40, // No user callback called during init
OCI_NO_MUTEX = 0x80, // the environment handle will not be
+ // NLS
+ OCI_NLS_NCHARSET_ID_UT8 = 871, /* AL32UTF8 charset id */
+ OCI_NLS_NCHARSET_ID_AL32UT8 = 873, /* AL32UTF8 charset id */
// protected by a mutex internally
OCI_SHARED_EXT = 0x100, // Used for shared forms
OCI_CACHE = 0x200, // used by iCache
I hope to be helpful!
[Updated on: Fri, 28 May 2010 19:16] Report message to a moderator
|
|
|
|
|
Oracle8: UTF8 charset Patch
By: tojocky on Fri, 28 May 2010 13:59
|
|
|
Re: Oracle8: UTF8 charset Patch
By: mirek on Fri, 28 May 2010 14:54
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Fri, 28 May 2010 19:15
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Fri, 28 May 2010 22:19
|
|
|
Re: Oracle8: UTF8 charset Patch
By: mirek on Sun, 30 May 2010 21:15
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Mon, 31 May 2010 08:27
|
|
|
Re: Oracle8: UTF8 charset Patch
By: rylek on Tue, 13 July 2010 01:20
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Tue, 13 July 2010 08:36
|
|
|
Re: Oracle8: UTF8 charset Patch
By: rylek on Wed, 14 July 2010 01:39
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Wed, 14 July 2010 08:56
|
|
|
Re: Oracle8: UTF8 charset Patch
By: rylek on Wed, 21 July 2010 22:48
|
|
|
Re: Oracle8: UTF8 charset Patch
By: mirek on Wed, 21 July 2010 23:49
|
|
|
Re: Oracle8: UTF8 charset Patch
By: tojocky on Mon, 26 July 2010 18:04
|
Goto Forum:
Current Time: Wed May 01 14:02:01 CEST 2024
Total time taken to generate the page: 0.03216 seconds
|