mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Merge remote-tracking branch 'origin/topic/bernhard/sqlite'
* origin/topic/bernhard/sqlite: fix a few small rough edges (mostly comments that do no longer apply) fix bug in input-manager regarding enums that a writer reads without 0-terminating the string actually make sqlite work again (tests passed because the writer was not actually defined because of the define.) add sqlite distribution. fix warnings, update baselines, handle rotation add sqlite tests and fix small vector/set escaping bugs fix small bug with vectors and sets. make work with newer AsciiFormatter. start adding a different text for empty records for the sqlite writer. no, you will never guess from where I copied this file... make sqlite support more or less work for logging and input make sqlite-writer more stable. make it compile with new version of AsciiInputOutput and adapt to AsciiInputOutput - seems to work... make it compile add SQLite reader. ...adapt to new api... now the writer supports tables and vectors. basic sqlite writer seems to work.
This commit is contained in:
commit
de88645d05
28 changed files with 146709 additions and 10 deletions
60
src/logging/writers/SQLite.h
Normal file
60
src/logging/writers/SQLite.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
//
|
||||
// Log writer for SQLITE logs.
|
||||
|
||||
#ifndef LOGGING_WRITER_SQLITE_H
|
||||
#define LOGGING_WRITER_SQLITE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "../WriterBackend.h"
|
||||
#include "../../external/sqlite3.h"
|
||||
#include "../../threading/AsciiFormatter.h"
|
||||
|
||||
namespace logging { namespace writer {
|
||||
|
||||
class SQLite : public WriterBackend {
|
||||
public:
|
||||
SQLite(WriterFrontend* frontend);
|
||||
~SQLite();
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
{ return new SQLite(frontend); }
|
||||
|
||||
protected:
|
||||
virtual bool DoInit(const WriterInfo& info, int arg_num_fields,
|
||||
const threading::Field* const* arg_fields);
|
||||
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
|
||||
threading::Value** vals);
|
||||
virtual bool DoSetBuf(bool enabled) { return true; }
|
||||
virtual bool DoRotate(const char* rotated_path, double open,
|
||||
double close, bool terminating);
|
||||
virtual bool DoFlush(double network_time) { return true; }
|
||||
virtual bool DoFinish(double network_time) { return true; }
|
||||
virtual bool DoHeartbeat(double network_time, double current_time) { return true; }
|
||||
|
||||
private:
|
||||
bool checkError(int code);
|
||||
|
||||
int AddParams(threading::Value* val, int pos);
|
||||
string GetTableType(int, int);
|
||||
char* FS(const char* format, ...);
|
||||
|
||||
const threading::Field* const * fields; // raw mapping
|
||||
unsigned int num_fields;
|
||||
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *st;
|
||||
|
||||
string set_separator;
|
||||
string unset_field;
|
||||
string empty_field;
|
||||
|
||||
AsciiFormatter* io;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LOGGING_WRITER_SQLITE_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue