1.Dd January 24, 2024 2.Dt SQLITE3_COMPLETE 3 3.Os 4.Sh NAME 5.Nm sqlite3_complete , 6.Nm sqlite3_complete16 7.Nd determine if an SQL statement is complete 8.Sh SYNOPSIS 9.In sqlite3.h 10.Ft int 11.Fo sqlite3_complete 12.Fa "const char *sql" 13.Fc 14.Ft int 15.Fo sqlite3_complete16 16.Fa "const void *sql" 17.Fc 18.Sh DESCRIPTION 19These routines are useful during command-line input to determine if 20the currently entered text seems to form a complete SQL statement or 21if additional input is needed before sending the text into SQLite for 22parsing. 23These routines return 1 if the input string appears to be a complete 24SQL statement. 25A statement is judged to be complete if it ends with a semicolon token 26and is not a prefix of a well-formed CREATE TRIGGER statement. 27Semicolons that are embedded within string literals or quoted identifier 28names or comments are not independent tokens (they are part of the 29token in which they are embedded) and thus do not count as a statement 30terminator. 31Whitespace and comments that follow the final semicolon are ignored. 32.Pp 33These routines return 0 if the statement is incomplete. 34If a memory allocation fails, then SQLITE_NOMEM is returned. 35.Pp 36These routines do not parse the SQL statements thus will not detect 37syntactically incorrect SQL. 38.Pp 39If SQLite has not been initialized using 40.Fn sqlite3_initialize 41prior to invoking sqlite3_complete16() then sqlite3_initialize() is 42invoked automatically by sqlite3_complete16(). 43If that initialization fails, then the return value from sqlite3_complete16() 44will be non-zero regardless of whether or not the input SQL is complete. 45.Pp 46The input to 47.Fn sqlite3_complete 48must be a zero-terminated UTF-8 string. 49.Pp 50The input to 51.Fn sqlite3_complete16 52must be a zero-terminated UTF-16 string in native byte order. 53.Sh IMPLEMENTATION NOTES 54These declarations were extracted from the 55interface documentation at line 2745. 56.Bd -literal 57SQLITE_API int sqlite3_complete(const char *sql); 58SQLITE_API int sqlite3_complete16(const void *sql); 59.Ed 60.Sh SEE ALSO 61.Xr sqlite3_initialize 3 62