|
|
@ -142,15 +142,19 @@ func (n *Node) handleRawQuery(c net.Conn) bool { |
|
|
|
respType = ph.RespTypeShowSchema |
|
|
|
resp, err = n.showSchema(x) |
|
|
|
|
|
|
|
case ph.UpsertStmt: |
|
|
|
case ph.UpsertIntoStmt: |
|
|
|
filePath, err = n.getFile(c) |
|
|
|
if err != nil { |
|
|
|
break |
|
|
|
return n.writeErr(c, err) |
|
|
|
} |
|
|
|
respType = ph.RespTypeUpsert |
|
|
|
respType = ph.RespTypeUpsertInto |
|
|
|
resp, err = n.upsert(x, filePath) |
|
|
|
_ = os.Remove(filePath) |
|
|
|
|
|
|
|
case ph.DeleteFromStmt: |
|
|
|
respType = ph.RespTypeDeleteFrom |
|
|
|
resp, err = n.delete(x) |
|
|
|
|
|
|
|
default: |
|
|
|
err = errors.Unexpected.WithMsg("Query wasn't understood.") |
|
|
|
} |
|
|
@ -243,7 +247,7 @@ func (n *Node) showSchema(stmt ph.ShowSchemaStmt) (interface{}, error) { |
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func (n *Node) upsert( |
|
|
|
stmt ph.UpsertStmt, |
|
|
|
stmt ph.UpsertIntoStmt, |
|
|
|
localPath string, |
|
|
|
) ( |
|
|
|
interface{}, |
|
|
@ -259,9 +263,16 @@ func (n *Node) upsert( |
|
|
|
schema, |
|
|
|
stmt.Day, |
|
|
|
localPath) |
|
|
|
return ph.UpsertResult{ |
|
|
|
return ph.UpsertIntoResult{ |
|
|
|
Dataset: stmt.Dataset, |
|
|
|
TableName: stmt.TableName, |
|
|
|
Day: stmt.Day, |
|
|
|
}, err |
|
|
|
} |
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
func (n *Node) delete(stmt ph.DeleteFromStmt) (interface{}, error) { |
|
|
|
_, err := n.store.SegmentDelete(stmt.Dataset, stmt.TableName, stmt.Day) |
|
|
|
return ph.DeleteFromResult(stmt), err |
|
|
|
} |