summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2008-05-12 22:20:51 +0000
committerpixel <pixel>2008-05-12 22:20:51 +0000
commit00202d6c759746dd7ff768934521fc1ede20f144 (patch)
treec67a42c05cf478107c39e77b3028f8dfa0ae3ff5
parent9e4fa0a8e01c5b3e91c71fbdc713e37a98094b25 (diff)
Fixing the setBlob method. The one from Statement shouldn't work, but the one from ResultSet should.
-rw-r--r--lib/LuaOCCI.cc38
1 files changed, 29 insertions, 9 deletions
diff --git a/lib/LuaOCCI.cc b/lib/LuaOCCI.cc
index 6e695d8..f9f48d1 100644
--- a/lib/LuaOCCI.cc
+++ b/lib/LuaOCCI.cc
@@ -492,7 +492,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_SETBLOB, "setBlob", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } },
+ { STATEMENT_SETBLOB, "setBlob", 3, 3, { BLUA_OBJECT, BLUA_NUMBER, BLUA_OBJECT } },
{ 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 } },
@@ -882,15 +882,14 @@ int sLua_EncapOCCI_Statement::EncapOCCI_Statement_proceed_unprotected(Lua * L, i
break;
case STATEMENT_SETBLOB:
{
- Blob blob;
+ rset = lua_recast<EncapOCCI_ResultSet>(L, 2)->Get();
+ Blob blob = rset->getBlob(L->tonumber(3));
+ printm(M_ERROR, "x\n");
+ blob.open(OCCI_LOB_READWRITE);
blob.setEmpty();
- strm = blob.getStream(1, 0);
-// Buffer * b = dynamic_cast<Buffer *>((Base *) LuaObject::getme(L, 3));
- Buffer * b = lua_recast<Buffer>(L, 3);
- strm->writeBuffer((char *) b->GetBuffer(), b->GetSize());
- strm->writeLastBuffer((char *) b->GetBuffer(), 0);
- blob.closeStream(strm);
- stmt->setBlob(L->tonumber(2), blob);
+ Buffer * b = lua_recast<Buffer>(L, 4);
+ blob.writeChunk(b->GetSize(), (unsigned char *) b->GetBuffer(), b->GetSize());
+ blob.close();
}
break;
case STATEMENT_SETBYTES:
@@ -1018,6 +1017,8 @@ enum EncapOCCI_ResultSet_methods_t {
RESULTSET_SETERRORONTRUNCATE,
RESULTSET_SETMAXCOLUMNSIZE,
RESULTSET_STATUS,
+
+ RESULTSET_SETBLOB,
};
struct lua_functypes_t EncapOCCI_ResultSet_methods[] = {
@@ -1049,6 +1050,8 @@ struct lua_functypes_t EncapOCCI_ResultSet_methods[] = {
{ RESULTSET_SETERRORONTRUNCATE, "setErrorOnTruncate", 2, 2, { BLUA_NUMBER, BLUA_BOOLEAN } },
{ RESULTSET_SETMAXCOLUMNSIZE, "setMaxColumnSize", 2, 2, { BLUA_NUMBER, BLUA_NUMBER } },
{ RESULTSET_STATUS, "status", 0, 0, { } },
+
+ { RESULTSET_SETBLOB, "setBlob", 2, 2, { BLUA_NUMBER, BLUA_OBJECT } },
{ -1, 0, 0, 0, 0 },
};
@@ -1087,6 +1090,8 @@ class sLua_EncapOCCI_ResultSet : public Base {
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_SETMAXCOLUMNSIZE);
DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_STATUS);
+ DECLARE_METHOD(EncapOCCI_ResultSet, RESULTSET_SETBLOB);
+
private:
static int EncapOCCI_ResultSet_proceed(Lua * L, int n, EncapOCCI_ResultSet * obj, int caller);
static int EncapOCCI_ResultSet_proceed_unprotected(Lua * L, int n, EncapOCCI_ResultSet * obj, int caller);
@@ -1124,6 +1129,8 @@ void LuaOCCI_ResultSet::pushmembers(Lua * L) {
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_SETERRORONTRUNCATE);
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_SETMAXCOLUMNSIZE);
PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_STATUS);
+
+ PUSH_METHOD(EncapOCCI_ResultSet, RESULTSET_SETBLOB);
}
void LuaOCCI_ResultSet::pushstatics(Lua * L) throw (GeneralException) {
@@ -1305,6 +1312,19 @@ int sLua_EncapOCCI_ResultSet::EncapOCCI_ResultSet_proceed_unprotected(Lua * L, i
L->push((lua_Number) rset->status());
r = 1;
break;
+
+ case RESULTSET_SETBLOB:
+ {
+ Blob blob = rset->getBlob(L->tonumber(2));
+ blob.open(OCCI_LOB_READWRITE);
+ Buffer * b = lua_recast<Buffer>(L, 3);
+ Stream * outstream = blob.getStream(1, 0);
+ outstream->writeBuffer((char *) b->GetBuffer(), b->GetSize());
+ char *c = (char *) "";
+ outstream->writeLastBuffer(c, 0);
+ blob.closeStream(outstream);
+ blob.close();
+ }
}
return r;