mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
fix small bug with vectors and sets.
On a first glance - this kind of seems to work. On mac-os you need a newer than the system-installed sqlite - the hanging problem only occurs with that one...
This commit is contained in:
parent
5d12765886
commit
a251a1c39a
3 changed files with 13 additions and 7 deletions
|
@ -27,7 +27,7 @@ public:
|
||||||
static ReaderBackend* Instantiate(ReaderFrontend* frontend) { return new SQLite(frontend); }
|
static ReaderBackend* Instantiate(ReaderFrontend* frontend) { return new SQLite(frontend); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool DoInit(const ReaderInfo& info, int arg_num_fields, const threading::Field* const* fields);
|
virtual bool DoInit(const ReaderInfo& info, int arg_num_fields, const threading::Field* const* arg_fields);
|
||||||
|
|
||||||
virtual void DoClose();
|
virtual void DoClose();
|
||||||
|
|
||||||
|
|
|
@ -109,14 +109,17 @@ bool SQLite::checkError( int code )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQLite::DoInit(const WriterInfo& info, int num_fields,
|
bool SQLite::DoInit(const WriterInfo& info, int arg_num_fields,
|
||||||
const Field* const * fields)
|
const Field* const * arg_fields)
|
||||||
{
|
{
|
||||||
if ( sqlite3_threadsafe() == 0 )
|
if ( sqlite3_threadsafe() == 0 )
|
||||||
{
|
{
|
||||||
Error("SQLite reports that it is not threadsafe. Bro needs a threadsafe version of SQLite. Aborting");
|
Error("SQLite reports that it is not threadsafe. Bro needs a threadsafe version of SQLite. Aborting");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_fields = arg_num_fields;
|
||||||
|
fields = arg_fields;
|
||||||
|
|
||||||
string fullpath(info.path);
|
string fullpath(info.path);
|
||||||
fullpath.append(".sqlite");
|
fullpath.append(".sqlite");
|
||||||
|
@ -300,7 +303,7 @@ int SQLite::AddParams(Value* val, int pos)
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc.AddRaw(set_separator);
|
desc.AddRaw(set_separator);
|
||||||
|
|
||||||
io->Describe(&desc, val->val.set_val.vals[j], NULL);
|
io->Describe(&desc, val->val.set_val.vals[j], fields[pos]->name);
|
||||||
// yes, giving NULL here is not really really pretty....
|
// yes, giving NULL here is not really really pretty....
|
||||||
// it works however, because tables cannot contain tables...
|
// it works however, because tables cannot contain tables...
|
||||||
// or vectors.
|
// or vectors.
|
||||||
|
@ -320,7 +323,7 @@ int SQLite::AddParams(Value* val, int pos)
|
||||||
if ( j > 0 )
|
if ( j > 0 )
|
||||||
desc.AddRaw(set_separator);
|
desc.AddRaw(set_separator);
|
||||||
|
|
||||||
io->Describe(&desc, val->val.vector_val.vals[j], NULL);
|
io->Describe(&desc, val->val.vector_val.vals[j], fields[pos]->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.RemoveEscapeSequence(set_separator);
|
desc.RemoveEscapeSequence(set_separator);
|
||||||
|
|
|
@ -25,8 +25,8 @@ public:
|
||||||
{ return new SQLite(frontend); }
|
{ return new SQLite(frontend); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool DoInit(const WriterInfo& info, int num_fields,
|
virtual bool DoInit(const WriterInfo& info, int arg_num_fields,
|
||||||
const threading::Field* const* fields);
|
const threading::Field* const* arg_fields);
|
||||||
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
|
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
|
||||||
threading::Value** vals);
|
threading::Value** vals);
|
||||||
virtual bool DoSetBuf(bool enabled) { return true; }
|
virtual bool DoSetBuf(bool enabled) { return true; }
|
||||||
|
@ -43,6 +43,9 @@ private:
|
||||||
string GetTableType(int, int);
|
string GetTableType(int, int);
|
||||||
char* FS(const char* format, ...);
|
char* FS(const char* format, ...);
|
||||||
|
|
||||||
|
const threading::Field* const * fields; // raw mapping
|
||||||
|
unsigned int num_fields;
|
||||||
|
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
sqlite3_stmt *st;
|
sqlite3_stmt *st;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue