Fix filter path_func to allow record argument as a subset of stream's columns.

This required adding the ability for RecordVal::CoerceTo functions to
optionally allow orphaning fields.  The default is to not allow it, but
now before writing to a log, the value of the stream's columns is coerced
down, if necessary, before passing it on to the filter's path_func.

Addresses #600.
This commit is contained in:
Jon Siwek 2011-09-09 14:57:22 -05:00
parent 3a3f58d5df
commit 7ff2a3e115
6 changed files with 82 additions and 6 deletions

View file

@ -902,7 +902,13 @@ bool LogMgr::Write(EnumVal* id, RecordVal* columns)
val_list vl(3);
vl.append(id->Ref());
vl.append(filter->path_val->Ref());
vl.append(columns->Ref());
Val* rec_arg;
BroType* rt = filter->path_func->FType()->Args()->FieldType("rec");
if ( rt->Tag() == TYPE_RECORD )
rec_arg = columns->CoerceTo(rt->AsRecordType(), true);
else
rec_arg = columns->Ref();
vl.append(rec_arg);
Val* v = filter->path_func->Call(&vl);
if ( ! v->Type()->Tag() == TYPE_STRING )