mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40: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 {
|
for i, embedBlock := range embedBlocks {
|
||||||
stmt := strings.TrimPrefix(embedBlock.Markdown, "{{")
|
stmt := strings.TrimPrefix(embedBlock.Markdown, "{{")
|
||||||
stmt = strings.TrimSuffix(stmt, "}}")
|
stmt = strings.TrimSuffix(stmt, "}}")
|
||||||
|
if !strings.Contains(strings.ToLower(stmt), "select") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
queryResultBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 102400)
|
queryResultBlocks := sql.SelectBlocksRawStmtNoParse(stmt, 102400)
|
||||||
for _, block := range queryResultBlocks {
|
for _, block := range queryResultBlocks {
|
||||||
embedBlock.Content += block.Content
|
embedBlock.Content += block.Content
|
||||||
|
|
|
||||||
|
|
@ -468,14 +468,18 @@ func selectBlocksRawStmt(stmt string, limit int) (ret []*Block) {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
confLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
|
confLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
|
||||||
|
var count, errCount int
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
count++
|
||||||
if block := scanBlockRows(rows); nil != block {
|
if block := scanBlockRows(rows); nil != block {
|
||||||
ret = append(ret, block)
|
ret = append(ret, block)
|
||||||
if confLimit && limit < len(ret) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
} 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
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue