Skip to content

Commit a076cb2

Browse files
Increase maximum SQLite variables count to 32766 (#11696) (#11783)
* Increase maximum SQLite variables count to 32766 (#11696) per https://www.sqlite.org/limits.html Co-authored-by: techknowlogick <[email protected]> (cherry picked from commit a5aa5c5) * Fix missing CGO_EXTRA_FLAGS build arg for docker Co-authored-by: techknowlogick <[email protected]>
1 parent 530ae65 commit a076cb2

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ENV GOPROXY ${GOPROXY:-direct}
99
ARG GITEA_VERSION
1010
ARG TAGS="sqlite sqlite_unlock_notify"
1111
ENV TAGS "bindata $TAGS"
12+
ARG CGO_EXTRA_CFLAGS
1213

1314
#Build deps
1415
RUN apk --no-cache add build-base git nodejs npm

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ MIN_NODE_VERSION := 010013000
3333
ifeq ($(HAS_GO), GO)
3434
GOPATH ?= $(shell $(GO) env GOPATH)
3535
export PATH := $(GOPATH)/bin:$(PATH)
36+
37+
CGO_EXTRA_CFLAGS := -DSQLITE_MAX_VARIABLE_NUMBER=32766
38+
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
3639
endif
3740

3841

@@ -499,7 +502,7 @@ check: test
499502

500503
.PHONY: install $(TAGS_PREREQ)
501504
install: $(wildcard *.go)
502-
$(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
505+
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) install -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
503506

504507
.PHONY: build
505508
build: frontend backend
@@ -515,7 +518,7 @@ generate: $(TAGS_PREREQ)
515518
CC= GOOS= GOARCH= $(GO) generate -mod=vendor -tags '$(TAGS)' $(GO_PACKAGES)
516519

517520
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
518-
$(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
521+
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
519522

520523
.PHONY: release
521524
release: frontend generate release-windows release-linux release-darwin release-copy release-compress release-sources release-check
@@ -528,7 +531,7 @@ release-windows: | $(DIST_DIRS)
528531
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
529532
$(GO) get -u src.techknowlogick.com/xgo; \
530533
fi
531-
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
534+
CGO_CFLAGS="$(CGO_CFLAGS)" GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out gitea-$(VERSION) .
532535
ifeq ($(CI),drone)
533536
cp /build/* $(DIST)/binaries
534537
endif
@@ -538,7 +541,7 @@ release-linux: | $(DIST_DIRS)
538541
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
539542
$(GO) get -u src.techknowlogick.com/xgo; \
540543
fi
541-
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
544+
CGO_CFLAGS="$(CGO_CFLAGS)" GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out gitea-$(VERSION) .
542545
ifeq ($(CI),drone)
543546
cp /build/* $(DIST)/binaries
544547
endif
@@ -548,7 +551,7 @@ release-darwin: | $(DIST_DIRS)
548551
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
549552
$(GO) get -u src.techknowlogick.com/xgo; \
550553
fi
551-
GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
554+
CGO_CFLAGS="$(CGO_CFLAGS)" GO111MODULE=off xgo -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out gitea-$(VERSION) .
552555
ifeq ($(CI),drone)
553556
cp /build/* $(DIST)/binaries
554557
endif

docker/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ docker:
1111

1212
.PHONY: docker-build
1313
docker-build:
14-
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" LDFLAGS="$(LDFLAGS)" webhippie/golang:edge make clean build
14+
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" LDFLAGS="$(LDFLAGS)" CGO_EXTRA_CFLAGS="$(CGO_EXTRA_CFLAGS)" webhippie/golang:edge make clean build

models/issue.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ var (
7676
const issueTasksRegexpStr = `(^\s*[-*]\s\[[\sxX]\]\s.)|(\n\s*[-*]\s\[[\sxX]\]\s.)`
7777
const issueTasksDoneRegexpStr = `(^\s*[-*]\s\[[xX]\]\s.)|(\n\s*[-*]\s\[[xX]\]\s.)`
7878
const issueMaxDupIndexAttempts = 3
79-
const maxIssueIDs = 950
8079

8180
func init() {
8281
issueTasksPat = regexp.MustCompile(issueTasksRegexpStr)
@@ -1114,9 +1113,6 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
11141113
}
11151114

11161115
if len(opts.IssueIDs) > 0 {
1117-
if len(opts.IssueIDs) > maxIssueIDs {
1118-
opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
1119-
}
11201116
sess.In("issue.id", opts.IssueIDs)
11211117
}
11221118

@@ -1360,9 +1356,6 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats,
13601356
Where("issue.repo_id = ?", opts.RepoID)
13611357

13621358
if len(opts.IssueIDs) > 0 {
1363-
if len(opts.IssueIDs) > maxIssueIDs {
1364-
opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
1365-
}
13661359
sess.In("issue.id", opts.IssueIDs)
13671360
}
13681361

@@ -1446,9 +1439,6 @@ func GetUserIssueStats(opts UserIssueStatsOptions) (*IssueStats, error) {
14461439
cond = cond.And(builder.In("issue.repo_id", opts.RepoIDs))
14471440
}
14481441
if len(opts.IssueIDs) > 0 {
1449-
if len(opts.IssueIDs) > maxIssueIDs {
1450-
opts.IssueIDs = opts.IssueIDs[:maxIssueIDs]
1451-
}
14521442
cond = cond.And(builder.In("issue.id", opts.IssueIDs))
14531443
}
14541444

0 commit comments

Comments
 (0)