summaryrefslogtreecommitdiff
path: root/lib/LuaOCCI.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LuaOCCI.cc')
-rw-r--r--lib/LuaOCCI.cc88
1 files changed, 79 insertions, 9 deletions
diff --git a/lib/LuaOCCI.cc b/lib/LuaOCCI.cc
index cc0b2af..9151982 100644
--- a/lib/LuaOCCI.cc
+++ b/lib/LuaOCCI.cc
@@ -362,7 +362,7 @@ enum EncapOCCI_Statement_methods_t {
STATEMENT_GETAUTOCOMMIT,
// STATEMENT_GETBFILE,
// STATEMENT_GETBLOB,
-// STATEMENT_GETBYTES,
+ STATEMENT_GETBYTES,
STATEMENT_GETCHARSET,
// STATEMENT_GETCLOB,
STATEMENT_GETCURRENTITERATION,
@@ -383,7 +383,7 @@ enum EncapOCCI_Statement_methods_t {
// STATEMENT_GETOCISTATEMENT,
// STATEMENT_GETREF,
STATEMENT_GETRESULTSET,
-// STATEMENT_GETROWID,
+ STATEMENT_GETROWID,
STATEMENT_GETSQL,
STATEMENT_GETSTREAM,
STATEMENT_GETSTRING,
@@ -400,7 +400,7 @@ enum EncapOCCI_Statement_methods_t {
// STATEMENT_SETBFILE,
STATEMENT_SETBINARYSTREAMMODE,
// STATEMENT_SETBLOB,
-// STATEMENT_SETBYTES,
+ STATEMENT_SETBYTES,
STATEMENT_SETCHARACTERSTREAMMODE,
STATEMENT_SETCHARSET,
// STATEMENT_SETCLOB,
@@ -423,7 +423,7 @@ enum EncapOCCI_Statement_methods_t {
STATEMENT_SETPREFETCHMEMORYSIZE,
STATEMENT_SETPREFETCHROWCOUNT,
// STATEMENT_SETREF,
-// STATEMENT_SETROWID,
+ STATEMENT_SETROWID,
STATEMENT_SETSQL,
STATEMENT_SETSTRING,
// STATEMENT_SETTIMESTAMP,
@@ -442,6 +442,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = {
{ STATEMENT_EXECUTEQUERY, "executeQuery", 0, 1, { BLUA_STRING } },
{ STATEMENT_EXECUTEUPDATE, "executeUpdate", 0, 1, { BLUA_STRING } },
{ STATEMENT_GETAUTOCOMMIT, "getAutoCommit", 0, 0, { } },
+ { STATEMENT_GETBYTES, "getBytes", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_GETCHARSET, "getCharSet", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_GETCURRENTITERATION, "getCurrentIteration", 0, 0, { } },
{ STATEMENT_GETCURRENTSTREAMITERATION, "getCurrentStreamIteration", 0, 0, { } },
@@ -454,6 +455,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = {
{ STATEMENT_GETMAXITERATIONS, "getMaxIterations", 0, 0, { } },
{ STATEMENT_GETMAXPARAMSIZE, "getMaxParamSize", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_GETRESULTSET, "getResultSet", 0, 0, { } },
+ { STATEMENT_GETROWID, "getRowid", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_GETSQL, "getSQL", 0, 0, { } },
{ STATEMENT_GETSTREAM, "getStream", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_GETSTRING, "getString", 1, 1, { BLUA_NUMBER } },
@@ -465,6 +467,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = {
{ STATEMENT_REGISTEROUTPARAM, "registerOutParam", 2, 4, { BLUA_NUMBER, BLUA_NUMBER, BLUA_NUMBER, BLUA_STRING } },
{ STATEMENT_SETAUTOCOMMIT, "setAutoCommit", 1, 1, { BLUA_BOOLEAN } },
{ STATEMENT_SETBINARYSTREAMMODE, "setBinaryStreamMode", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } },
+ { STATEMENT_SETBYTES, "setBytes", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } },
{ STATEMENT_SETCHARACTERSTREAMMODE, "setCharacterStreamMode", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } },
{ STATEMENT_SETCHARSET, "setCharSet", 2, 2, { BLUA_NUMBER, BLUA_STRING } },
{ STATEMENT_SETDATABASENCHARPARAM, "setDatabaseNCHARParam", 2, 2, { BLUA_NUMBER, BLUA_BOOLEAN } },
@@ -478,6 +481,7 @@ struct lua_functypes_t EncapOCCI_Statement_methods[] = {
{ STATEMENT_SETNULL, "setNull", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } },
{ STATEMENT_SETPREFETCHMEMORYSIZE, "setPrefetchMemorySize", 1, 1, { BLUA_NUMBER } },
{ STATEMENT_SETPREFETCHROWCOUNT, "setPrefetchRowCount", 1, 1, { BLUA_NUMBER } },
+ { STATEMENT_SETROWID, "SetRowid", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } },
{ STATEMENT_SETSQL, "setSQL", 1, 1, { BLUA_STRING } },
{ STATEMENT_SETSTRING, "setString", 2, 2, { BLUA_NUMBER, BLUA_STRING } },
{ STATEMENT_SETUINT, "setUInt", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } },
@@ -499,6 +503,7 @@ class sLua_EncapOCCI_Statement : public Base {
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_EXECUTEQUERY);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_EXECUTEUPDATE);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETAUTOCOMMIT);
+ DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETBYTES);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETCHARSET);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETCURRENTITERATION);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETCURRENTSTREAMITERATION);
@@ -511,6 +516,7 @@ class sLua_EncapOCCI_Statement : public Base {
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXITERATIONS);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXPARAMSIZE);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETRESULTSET);
+ DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETROWID);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETSQL);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETSTREAM);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_GETSTRING);
@@ -522,6 +528,7 @@ class sLua_EncapOCCI_Statement : public Base {
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_REGISTEROUTPARAM);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETAUTOCOMMIT);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETBINARYSTREAMMODE);
+ DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETBYTES);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETCHARACTERSTREAMMODE);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETCHARSET);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETDATABASENCHARPARAM);
@@ -535,6 +542,7 @@ class sLua_EncapOCCI_Statement : public Base {
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETNULL);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHMEMORYSIZE);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHROWCOUNT);
+ DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETROWID);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETSQL);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETSTRING);
DECLARE_METHOD(EncapOCCI_Statement, STATEMENT_SETUINT);
@@ -557,6 +565,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) {
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_EXECUTEQUERY);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_EXECUTEUPDATE);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETAUTOCOMMIT);
+ PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETBYTES);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETCHARSET);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETCURRENTITERATION);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETCURRENTSTREAMITERATION);
@@ -569,6 +578,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) {
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXITERATIONS);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETMAXPARAMSIZE);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETRESULTSET);
+ PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETROWID);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETSQL);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETSTREAM);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_GETSTRING);
@@ -580,6 +590,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) {
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_REGISTEROUTPARAM);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETAUTOCOMMIT);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETBINARYSTREAMMODE);
+ PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETBYTES);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETCHARACTERSTREAMMODE);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETCHARSET);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETDATABASENCHARPARAM);
@@ -593,6 +604,7 @@ void LuaOCCI_Statement::pushmembers(Lua * L) {
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETNULL);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHMEMORYSIZE);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETPREFETCHROWCOUNT);
+ PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETROWID);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETSQL);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETSTRING);
PUSH_METHOD(EncapOCCI_Statement, STATEMENT_SETUINT);
@@ -682,6 +694,21 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i
L->push(stmt->getAutoCommit());
r = 1;
break;
+ case STATEMENT_GETBYTES:
+ {
+ Bytes bytes = stmt->getBytes(L->tonumber(2));
+ Buffer * b = new Buffer(true);
+ int size = bytes.length();
+ unsigned char * x = (unsigned char *) malloc(size);
+ bytes.getBytes(x, size);
+ b->write(x, size);
+ free(x);
+ LuaBuffer o(b);
+ o.pushdestruct(L);
+ L->push((lua_Number) size);
+ }
+ r = 2;
+ break;
case STATEMENT_GETCHARSET:
L->push(stmt->getCharSet(L->tonumber(2)).c_str());
r = 1;
@@ -738,6 +765,21 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i
}
r = 1;
break;
+ case STATEMENT_GETROWID:
+ {
+ Bytes bytes = stmt->getRowid(L->tonumber(2));
+ Buffer * b = new Buffer(true);
+ int size = bytes.length();
+ unsigned char * x = (unsigned char *) malloc(size);
+ bytes.getBytes(x, size);
+ b->write(x, size);
+ free(x);
+ LuaBuffer o(b);
+ o.pushdestruct(L);
+ L->push((lua_Number) size);
+ }
+ r = 2;
+ break;
case STATEMENT_GETSQL:
L->push(stmt->getSQL().c_str());
r = 1;
@@ -789,6 +831,13 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i
case STATEMENT_SETBINARYSTREAMMODE:
stmt->setBinaryStreamMode(L->tonumber(2), L->tonumber(3));
break;
+ case STATEMENT_SETBYTES:
+ {
+ Buffer * b = dynamic_cast<Buffer *>((Base *) LuaObject::getme(L, 3));
+ Bytes bytes((unsigned char *) b->GetBuffer(), b->GetSize());
+ stmt->setBytes(L->tonumber(2), bytes);
+ }
+ break;
case STATEMENT_SETCHARACTERSTREAMMODE:
stmt->setCharacterStreamMode(L->tonumber(2), L->tonumber(3));
break;
@@ -828,6 +877,13 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i
case STATEMENT_SETPREFETCHROWCOUNT:
stmt->setPrefetchRowCount(L->tonumber(2));
break;
+ case STATEMENT_SETROWID:
+ {
+ Buffer * b = dynamic_cast<Buffer *>((Base *) LuaObject::getme(L, 3));
+ Bytes bytes((unsigned char *) b->GetBuffer(), b->GetSize());
+ stmt->setRowid(L->tonumber(2), bytes);
+ }
+ break;
case STATEMENT_SETSQL:
stmt->setSQL(L->tostring(2).to_charp());
break;
@@ -859,7 +915,7 @@ enum EncapOCCI_ResultSet_methods_t {
// RESULTSET_CLOSESTREAM,
// RESULTSET_GETBFILE,
// RESULTSET_GETBLOB,
-// RESULTSET_GETBYTES,
+ RESULTSET_GETBYTES,
RESULTSET_GETCHARSET,
// RESULTSET_GETCLOB,
// RESULTSET_GETCOLUMNLISTMETADATA,
@@ -890,12 +946,8 @@ enum EncapOCCI_ResultSet_methods_t {
RESULTSET_NEXT,
RESULTSET_PRETRUNCATIONLENGTH,
RESULTSET_SETBINARYSTREAMMODE,
-// RESULTSET_SETBLOB,
-// RESULTSET_SETBYTES,
RESULTSET_SETCHARACTERSTREAMMODE,
RESULTSET_SETCHARSET,
-// RESULTSET_SETCLOB,
-// RESULTSET_SETDATE,
RESULTSET_SETDATABASENCHARPARAM,
// RESULTSET_SETDATABUFFER,
RESULTSET_SETERRORONNULL,
@@ -906,6 +958,7 @@ enum EncapOCCI_ResultSet_methods_t {
struct lua_functypes_t EncapOCCI_ResultSet_methods[] = {
{ RESULTSET_CANCEL, "cancel", 0, 0, { } },
+ { RESULTSET_GETBYTES, "getBytes", 1, 1, { BLUA_NUMBER } },
{ RESULTSET_GETCHARSET, "getCharSet", 1, 1, { BLUA_NUMBER } },
{ RESULTSET_GETCURRENTSTREAMCOLUMN, "getCurrentStreamColumn", 0, 0, { } },
{ RESULTSET_GETCURRENTSTREAMROW, "getCurrentStreamRow", 0, 0, { } },
@@ -940,6 +993,7 @@ struct lua_functypes_t EncapOCCI_ResultSet_functions[] = {
class sLua_EncapOCCI_ResultSet : public Base {
public:
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_CANCEL);
+ DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBYTES);
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCHARSET);
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCURRENTSTREAMCOLUMN);
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCURRENTSTREAMROW);
@@ -975,6 +1029,7 @@ void LuaOCCI_ResultSet::pushmembers(Lua * L) {
pushme(L, o, "OCCI_ResultSet");
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_CANCEL);
+ PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETBYTES);
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCHARSET);
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCURRENTSTREAMCOLUMN);
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_GETCURRENTSTREAMROW);
@@ -1036,6 +1091,21 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i
L->push(rset->getCharSet(L->tonumber(2)).c_str());
r = 1;
break;
+ case RESULTSET_GETBYTES:
+ {
+ Bytes bytes = rset->getBytes(L->tonumber(2));
+ Buffer * b = new Buffer(true);
+ int size = bytes.length();
+ unsigned char * x = (unsigned char *) malloc(size);
+ bytes.getBytes(x, size);
+ b->write(x, size);
+ free(x);
+ LuaBuffer o(b);
+ o.pushdestruct(L);
+ L->push((lua_Number) size);
+ }
+ r = 2;
+ break;
case RESULTSET_GETCURRENTSTREAMCOLUMN:
L->push((lua_Number) rset->getCurrentStreamColumn());
r = 1;