pgdesign v0.26.0 /internal/splitfmt
On this page

Package splitfmt implements a sealed, length-prefixed .sqlsplit file format for carrying pre-split SQL statements without embedded-delimiter ambiguity.

#internal/splitfmt

#internal/splitfmt

Package splitfmt implements a sealed, terminal file format for carrying split SQL statements. The file extension is .sqlsplit.

The format is bare length-prefixed text:

file = count LF { entry } count = DIGIT+ ; number of statements (decimal) entry = length LF payload LF length = DIGIT+ ; byte length of payload (decimal) payload = BYTE{length} ; exactly length raw bytes LF = %x0A

Example for two statements:

2 42 CREATE TABLE foo (id integer PRIMARY KEY); 55 ALTER TABLE foo ADD CONSTRAINT fk FOREIGN KEY (...);

The format is sealed: no version header, no metadata, no extensibility. If the format ever needs to change, a new file extension is chosen.

#Encode

Go go
func Encode(statements []string) []byte

Encode encodes statements into the .sqlsplit format.

#Decode

Go go
func Decode(data []byte) ([]string, error)

Decode decodes the .sqlsplit format back to statements.

Search