feat: Replace pg_query_go with lightweight SQL parser (no CGO required)

- Remove github.com/pganalyze/pg_query_go/v6 dependency to avoid CGO requirement
- Implement lightweight SQL parser for basic SELECT, SHOW, and DDL statements
- Fix operator precedence in WHERE clause parsing (handle AND/OR before comparisons)
- Support INTEGER, FLOAT, and STRING literals in WHERE conditions
- All SQL engine tests passing with new parser
- PostgreSQL integration tests can now build without CGO

The lightweight parser handles the essential SQL features needed for the
SeaweedFS query engine while maintaining compatibility and avoiding CGO
dependencies that caused Docker build issues.
This commit is contained in:
chrislu
2025-09-03 07:11:18 -07:00
parent 88d86374ea
commit d60c542ecc
4 changed files with 206 additions and 143 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
FROM golang:1.24-alpine AS builder
# Install build dependencies including gcc for CGO (required by pg_query_go)
RUN apk add --no-cache git make gcc musl-dev
# Install git and other build dependencies
RUN apk add --no-cache git make
# Set working directory
WORKDIR /app
@@ -13,8 +13,8 @@ RUN go mod download
# Copy source code
COPY . .
# Build the weed binary with CGO enabled (required for pg_query_go)
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags "-s -w" -o weed ./weed/
# Build the weed binary without CGO
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o weed ./weed/
# Final stage - minimal runtime image
FROM alpine:latest