1.\"	$Id: ksql_exec.3,v 1.9 2018/04/05 15:15:34 kristaps Exp $
2.\"
3.\" Copyright (c) 2016, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: April 5 2018 $
18.Dt KSQL_EXEC 3
19.Os
20.Sh NAME
21.Nm ksql_exec
22.Nd execute a standalone statement not returning any values
23.Sh LIBRARY
24.Lb ksql
25.Sh SYNOPSIS
26.In sys/types.h
27.In stdint.h
28.In ksql.h
29.Ft enum ksqlc
30.Fo ksql_exec
31.Fa "struct ksql *sql"
32.Fa "const char *stmt"
33.Fa "size_t id"
34.Fc
35.Sh DESCRIPTION
36The
37.Nm
38function executes
39.Fa stmt
40on an open database connection
41.Fa sql .
42The
43.Fa id
44is used to identify the statement in error messages and should uniquely
45identify the statement.
46.Pp
47If a non-empty
48.Fa cfg->stmts
49structure documented in
50.Xr ksql_cfg_defaults 3
51is passed to
52.Xr ksql_alloc 3
53or
54.Xr ksql_alloc_child 3 ,
55the stored statement is looked up by
56.Fa id
57and the
58.Fa stmt
59value is ignored.
60If
61.Fa id
62is not a valid index of
63.Fa cfg->stmts.stmtsz ,
64the program is immediately terminated.
65.Pp
66This function handles a locked database (specifically,
67.Dv SQLITE_BUSY ,
68.Dv SQLITE_LOCKED ,
69or
70.Dv SQLITE_PROTOCOL )
71by sleeping for a random interval, then trying again infinitely.
72.\" .Sh CONTEXT
73.\" For section 9 functions only.
74.\" .Sh IMPLEMENTATION NOTES
75.\" Not used in OpenBSD.
76.Sh RETURN VALUES
77This function returns
78.Dv KSQL_NOTOPEN
79if the database connection has not been opeend,
80.Dv KSQL_DB
81on database errors, or
82.Dv KSQL_OK
83otherwise.
84.\" For sections 2, 3, and 9 function return values only.
85.\" .Sh ENVIRONMENT
86.\" For sections 1, 6, 7, and 8 only.
87.\" .Sh FILES
88.\" .Sh EXIT STATUS
89.\" For sections 1, 6, and 8 only.
90.\" .Sh EXAMPLES
91.\" .Sh DIAGNOSTICS
92.\" For sections 1, 4, 6, 7, 8, and 9 printf/stderr messages only.
93.\" .Sh ERRORS
94.\" For sections 2, 3, 4, and 9 errno settings only.
95.Sh SEE ALSO
96.Xr sqlite3_exec 3
97.\" .Xr foobar 1
98.\" .Sh STANDARDS
99.\" .Sh HISTORY
100.\" .Sh AUTHORS
101.\" .Sh CAVEATS
102.\" .Sh BUGS
103.\" .Sh SECURITY CONSIDERATIONS
104.\" Not used in OpenBSD.
105