mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 索引嵌入块内容可能会导致内核崩溃 https://github.com/siyuan-note/siyuan/issues/7213
This commit is contained in:
parent
7aea03db69
commit
70e2cd3987
2 changed files with 12 additions and 4 deletions
|
|
@ -197,6 +197,10 @@ func autoIndexEmbedBlock(embedBlocks []*sql.Block) {
|
|||
for i, embedBlock := range embedBlocks {
|
||||
stmt := strings.TrimPrefix(embedBlock.Markdown, "{{")
|
||||
stmt = strings.TrimSuffix(stmt, "}}")
|
||||
if !strings.Contains(strings.ToLower(stmt), "select") {
|
||||
continue
|
||||
}
|
||||
|
||||
queryResultBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 102400)
|
||||
for _, block := range queryResultBlocks {
|
||||
embedBlock.Content += block.Content
|
||||
|
|
|
|||
|
|
@ -468,14 +468,18 @@ func selectBlocksRawStmt(stmt string, limit int) (ret []*Block) {
|
|||
defer rows.Close()
|
||||
|
||||
confLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
|
||||
var count, errCount int
|
||||
for rows.Next() {
|
||||
count++
|
||||
if block := scanBlockRows(rows); nil != block {
|
||||
ret = append(ret, block)
|
||||
if confLimit && limit < len(ret) {
|
||||
break
|
||||
}
|
||||
} else {
|
||||
logging.LogWarnf("raw sql query [%s] failed: %s", stmt, err)
|
||||
logging.LogWarnf("raw sql query [%s] failed: %s", stmt)
|
||||
errCount++
|
||||
}
|
||||
|
||||
if (confLimit && limit < count) || 7 < errCount {
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue