1mysql_stmt_attr_set(3) MariaDB Connector/C mysql_stmt_attr_set(3)
2
3
4
5 Name
6 mysql_stmt_attr_set - Sets attribute of a statement
7
8 Synopsis
9 #include <mysql.h>
10
11 my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt,
12 enum enum_stmt_attr_type,
13 const void * attr);
14
15 Description
16 Used to modify the behavior of a prepared statement. This function may
17 be called multiple times to set several attributes. Returns zero on
18 success, non-zero on failure.
19
20 Parameters
21 • stmt - a statement handle, which was previously allocated by
22 mysql_stmt_init(3).
23
24 • enum_stmt_attr_type - the attribute that you want to set. See below.
25
26 • attr - the value to assign to the attribute
27
28 Attribute types
29 The enum_stmt_attr_type attribute can have one of the following values:
30
31 Value Type Description
32 ─────────────────────────────────────────────────────────────────────────────
33 STMT_ATTR_UP‐ my_bool * If set to 1,
34 DATE_MAX_LENGTH mysql_stmt_store_re‐
35 sult(3) will update the
36 max_length value of
37 MYSQL_FIELD structures.
38 STMT_ATTR_CURSOR_TYPE unsigned long * cursor type when
39 mysql_stmt_execute(3)
40 is invoked. Possible
41 values are CUR‐
42 SOR_TYPE_READ_ONLY or
43 default value CUR‐
44 SOR_TYPE_NO_CURSOR.
45 STMT_ATTR_PREFETCH_ROWS unsigned long * number of rows which
46 will be prefetched.
47 The default value is 1.
48 STMT_ATTR_PRE‐ unsigned int * number of parameter
49 BIND_PARAMS markers when using
50 mariadb_stmt_exe‐
51 cute_direct(3). If the
52 statement handle is
53 reused it will be reset
54 automatically to the
55 state after
56 mysql_stmt_init().
57 This option was added
58 in Connector/C 3.0
59 STMT_ATTR_ARRAY_SIZE unsigned int * number of array ele‐
60 ments. This option was
61 added in Connector/C
62 3.0 and requires Mari‐
63 aDB 10.2 or later
64
65
66
67 STMT_ATTR_ROW_SIZE size_t * specifies size of a
68 structure for row wise
69 binding. This length
70 must include space for
71 all of the bound param‐
72 eters and any padding
73 of the structure or
74 buffer to ensure that
75 when the address of a
76 bound parameter is in‐
77 cremented with the
78 specified length, the
79 result will point to
80 the beginning of the
81 same parameter in the
82 next set of parameters.
83 When using the sizeof
84 operator in ANSI C,
85 this behavior is guar‐
86 anteed. If the value
87 is zero column-wise
88 binding will be used
89 (default). This option
90 was added in Connec‐
91 tor/C 3.0 and requires
92 MariaDB 10.2 or later
93
94 Notes
95 • If you use the MYSQL_STMT_ATTR_CURSOR_TYPE option with MYSQL_CUR‐
96 SOR_TYPE_READ_ONLY, a cursor is opened for the statement when you in‐
97 voke mysql_stmt_execute(3). If there is already an open cursor from
98 a previous mysql_stmt_execute(3) call, it closes the cursor before
99 opening a new one. mysql_stmt_reset(3) also closes any open cursor
100 before preparing the statement for re-execution.
101
102 • If you open a cursor for a prepared statement it is unnecessary to
103 call mysql_stmt_store_result(3).
104
105 • mysql_stmt_free_result(3) closes any open cursor.
106
107 See Also
108 • mariadb_stmt_execute_direct(3)
109
110 • mysql_stmt_attr_get(3)
111
112
113
114Version 3.2.2 mysql_stmt_attr_set(3)