Skip to content

Commit

Permalink
use conversion string to timestamp only for attribute @timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatolog committed Feb 20, 2024
1 parent a67fb07 commit 15975cf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/searchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7911,7 +7911,7 @@ class CSphMatchVariant
return false;
}

static bool ConvertPlainAttr ( const SqlInsert_t & tVal, ESphAttr eTargetType, SphAttr_t & tAttr, bool bDocID, CSphString & sError )
static bool ConvertPlainAttr ( const SqlInsert_t & tVal, ESphAttr eTargetType, const CSphString * pName, SphAttr_t & tAttr, bool bDocID, CSphString & sError )
{
tAttr = 0;

Expand Down Expand Up @@ -7956,7 +7956,7 @@ class CSphMatchVariant

case SPH_ATTR_TIMESTAMP:
{
if ( tVal.m_iType==SqlInsert_t::QUOTED_STRING )
if ( pName && tVal.m_iType==SqlInsert_t::QUOTED_STRING && StrEq ( pName->cstr(), "@timestamp" ) )
tAttr = GetUTC ( tVal.m_sVal, CompatDateFormat() );
else
tAttr = ToInt(tVal);
Expand All @@ -7970,10 +7970,10 @@ class CSphMatchVariant
return true;
}

inline static bool SetAttr ( CSphMatch & tMatch, const CSphAttrLocator & tLoc, const SqlInsert_t & tVal, ESphAttr eTargetType, bool bDocID, CSphString & sError )
inline static bool SetAttr ( CSphMatch & tMatch, const CSphAttrLocator & tLoc, const CSphString * pName, const SqlInsert_t & tVal, ESphAttr eTargetType, bool bDocID, CSphString & sError )
{
SphAttr_t tAttr;
if ( ConvertPlainAttr ( tVal, eTargetType, tAttr, bDocID, sError ) )
if ( ConvertPlainAttr ( tVal, eTargetType, pName, tAttr, bDocID, sError ) )
{
tMatch.SetAttr ( tLoc, tAttr );
return true;
Expand All @@ -7988,7 +7988,7 @@ class CSphMatchVariant
tVal.m_iType = SqlInsert_t::CONST_INT;
tVal.SetValueInt(0);
CSphString sError;
SetAttr ( tMatch, tLoc, tVal, eTargetType, false, sError );
SetAttr ( tMatch, tLoc, nullptr, tVal, eTargetType, false, sError );
}
};

Expand Down Expand Up @@ -9811,7 +9811,7 @@ static bool ParseBsonDocument ( const VecTraits_T<BYTE> & dDoc, const SchemaItem
} else
{
BsonToSqlInsert ( dChild, tAttr );
CSphMatchVariant::SetAttr ( tDoc, pItem->m_tLoc, tAttr, pItem->m_eType, false, sError );
CSphMatchVariant::SetAttr ( tDoc, pItem->m_tLoc, &sName, tAttr, pItem->m_eType, false, sError );
if ( pId==pItem )
tDoc.SetAttr ( tIdLoc, (DocID_t)dChild.Int() );

Expand Down Expand Up @@ -11080,7 +11080,7 @@ void AttributeConverter_c::SetDefaultAttrValue ( int iCol )

SphAttr_t tAttr;
CSphString sError;
if ( CSphMatchVariant::ConvertPlainAttr ( tDefaultVal, tCol.m_eAttrType, tAttr, false, sError ) )
if ( CSphMatchVariant::ConvertPlainAttr ( tDefaultVal, tCol.m_eAttrType, &tCol.m_sName, tAttr, false, sError ) )
{
if ( tCol.IsColumnar() )
m_dColumnarAttrs [ m_dColumnarRemap[iCol] ] = tAttr;
Expand All @@ -11101,7 +11101,7 @@ bool AttributeConverter_c::SetAttrValue ( int iCol, const SqlInsert_t & tVal, in
return false;

SphAttr_t tAttr;
if ( CSphMatchVariant::ConvertPlainAttr ( tVal, tCol.m_eAttrType, tAttr, bDocId, sError ) )
if ( CSphMatchVariant::ConvertPlainAttr ( tVal, tCol.m_eAttrType, &tCol.m_sName, tAttr, bDocId, sError ) )
{
if ( tCol.IsColumnar() )
m_dColumnarAttrs [ m_dColumnarRemap[iCol] ] = tAttr;
Expand Down

0 comments on commit 15975cf

Please sign in to comment.