You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// UsageStringjson = PgQueryWrapper.parse("SELECT * FROM users");
ParseResulttree = PgQueryWrapper.parseTree("SELECT * FROM users");
List<String> stmts = PgQueryWrapper.split("SELECT 1; SELECT 2;");
Low-level API: PgQueryLibInterface
Method
Description
Must Free
pg_query_parse(input)
Parse → JSON
pg_query_free_parse_result
pg_query_parse_opts(input, opts)
Parse with options
pg_query_free_parse_result
pg_query_parse_protobuf(input)
Parse → Protobuf
pg_query_free_protobuf_parse_result
pg_query_parse_protobuf_opts(input, opts)
Parse with options
pg_query_free_protobuf_parse_result
pg_query_split_with_scanner(input)
Split (lexer)
pg_query_free_split_result
pg_query_split_with_parser(input)
Split (parser)
pg_query_free_split_result
Build Commands
# Full build with Docker (recommended)
docker build -t libpg-query-builder .
mvn clean package -Pdownload -PbuildLibDocker -DskipTests
# Local build (may have glibc issues)
mvn clean package -Pdownload -PbuildLib -DskipTests
# Regenerate protobuf classes
mvn generate-sources -Pdownload -PgenerateProtobuf
# Run tests
mvn test# Deploy to private repo
mvn deploy -DskipTests
Maven Profiles
Profile
Phase
Description
download
initialize
Download libpg_query source from GitHub
buildLib
generate-sources
Build .so locally with system gcc
buildLibDocker
generate-sources
Build .so in Docker (Debian 10, glibc 2.28)
generateProtobuf
generate-sources
Generate Java from pg_query.proto
Dependencies
Dependency
Version
Scope
net.java.dev.jna:jna
5.18.1
compile
com.google.protobuf:protobuf-java
3.21.12
compile
org.junit.jupiter:junit-jupiter-engine
5.9.0
test
Class Loading Behavior
Dependency only (no method call)
└── PgQueryWrapper class NOT loaded
└── PgQueryLibInterface NOT loaded
└── Native.load() NOT called
└── libpg_query.so NOT loaded
└── ✓ Safe, no JVM risk
Method call: PgQueryWrapper.parse()
└── PgQueryWrapper class loaded
└── POINTER_SIZE = Native.POINTER_SIZE (safe, JNA constant)
└── PgQueryLibInterface.INSTANCE accessed
└── Native.load(libpg_query.so) called
└── Native library loaded
└── ⚠ Potential JVM crash risk