diff options
author | tomsmeding <hallo@tomsmeding.nl> | 2015-05-23 18:49:59 +0200 |
---|---|---|
committer | tomsmeding <hallo@tomsmeding.nl> | 2015-05-23 18:49:59 +0200 |
commit | 91140dcb42f441f8883b204fdfea367c133def9e (patch) | |
tree | e22aee085d61b4af4590e24bf5a8e58c6a7f3f49 | |
parent | 059a8baa815f0b50d11546ad26b854572ef52182 (diff) |
Bugfixing
-rw-r--r-- | engine.cpp | 14 | ||||
-rw-r--r-- | enginedata.cpp | 10 |
2 files changed, 19 insertions, 5 deletions
@@ -46,7 +46,7 @@ int main(int argc,char **argv){ row.items[0].rh_int32=UINT_MAX; row.items[1].rh_uint32=UINT_MAX; row.items[2].rh_bytes=new unsigned char[10]; - strcpy((char*)row.items[2].rh_bytes,"hallo daar"); + memcpy((char*)row.items[2].rh_bytes,"hallo daar",10); InsertQuery iqu(move(row)); iqu.tablename="hoi"; @@ -56,12 +56,20 @@ int main(int argc,char **argv){ cout<<"Insert, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; for(const Row &r : res.rows)cout<<"- "<<r<<endl; + iqu.row.items[0].rh_int32=42; + memcpy((char*)iqu.row.items[2].rh_bytes,"doei!\0\0\0\0",10); + + res=iqu.execute(tables); + + cout<<"Insert, Result: "<<res.res<<": (msg=\""<<res.msg<<"\")"<<endl; + for(const Row &r : res.rows)cout<<"- "<<r<<endl; + cout<<"hoitb has "<<hoitb->rows.size()<<" row"<<(hoitb->rows.size()==1?"":"s")<<'.'<<endl; FindQuery fqu; fqu.tablename="hoi"; - RowItem ri; ri.rh_int32=-1; - fqu.where.emplace_back(0,ri); + RowItem ri; ri.rh_uint32=UINT_MAX; + fqu.where.emplace_back(1,ri); res=fqu.execute(tables); diff --git a/enginedata.cpp b/enginedata.cpp index fb60521..5cc357f 100644 --- a/enginedata.cpp +++ b/enginedata.cpp @@ -17,8 +17,14 @@ Row::Row(Row &&other):nc(other.nc),table(other.table),items(other.items){ //move other.items=nullptr; } Row::Row(const Row &other):nc(other.nc),table(other.table){ //copy constr - items=new RowItem[table->nc]; - memcpy(items,other.items,table->nc*sizeof(RowItem)); + items=new RowItem[nc]; + memcpy(items,other.items,nc*sizeof(RowItem)); + for(int i=0;i<nc;i++){ + if(table->header[i].type==RH_BYTES){ + items[i].rh_bytes=new unsigned char[table->header[i].arg]; + memcpy(items[i].rh_bytes,other.items[i].rh_bytes,table->header[i].arg); + } + } } ostream& operator<<(ostream &os,const Row &r){ os<<'['; |