3 * Copyright (C) 2008, 2010 Jukka-Pekka Iivonen
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jukka-Pekka Iivonen <jp0409@jippii.fi>
23 [CCode (lower_case_cprefix = "mysql_", cheader_filename = "mysql/mysql.h")]
25 [CCode (cname = "unsigned long", cprefix = "CLIENT_", has_type_id = false)]
26 public enum ClientFlag {
45 SSL_VERIFY_SERVER_CERT,
49 [CCode (cname = "enum_mysql_set_option", cprefix = "MYSQL_OPTION_", has_type_id = false)]
50 public enum SetOption {
55 [CCode (cname = "mysql_option", cprefix = "MYSQL_", has_type_id = false)]
67 SHARED_MEMORY_BASE_NAME,
71 OPT_USE_REMOTE_CONNECTION,
72 OPT_USE_EMBEDDED_CONNECTION,
76 REPORT_DATA_TRUNCATION,
78 OPT_SSL_VERIFY_SERVER_CERT
81 [CCode (cname = "enum enum_field_types", cprefix = "MYSQL_TYPE_", has_type_id = false)]
82 public enum FieldType {
112 [CCode (cname = "guint", has_type_id = false)]
113 public enum FieldFlag {
114 [CCode (cname = "NOT_NULL_FLAG")]
116 [CCode (cname = "PRI_KEY_FLAG")]
118 [CCode (cname = "UNIQUE_FLAG")]
120 [CCode (cname = "MULTIPLE_KEY_FLAG")]
122 [CCode (cname = "BLOB_FLAG")]
124 [CCode (cname = "UNSIGNED_FLAG")]
126 [CCode (cname = "ZEROFILL_FLAG")]
128 [CCode (cname = "BINARY_FLAG")]
130 [CCode (cname = "ENUM_FLAG")]
132 [CCode (cname = "AUTO_INCREMENT_FLAG")]
134 [CCode (cname = "TIMESTAMP_FLAG")]
136 [CCode (cname = "SET_FLAG")]
138 [CCode (cname = "NO_DEFAULT_VALUE_FLAG")]
140 [CCode (cname = "ON_UPDATE_NOW_FLAG")]
142 [CCode (cname = "NUM_FLAG")]
144 [CCode (cname = "PART_KEY_FLAG")]
146 [CCode (cname = "GROUP_FLAG")]
148 [CCode (cname = "UNIQUE_FLAG")]
150 [CCode (cname = "BINCMP_FLAG")]
152 [CCode (cname = "GET_FIXED_FIELDS_FLAG")]
154 [CCode (cname = "FIELD_IN_PART_FUNC_FLAG")]
156 [CCode (cname = "FIELD_IN_ADD_INDEX")]
158 [CCode (cname = "FIELD_IS_RENAMED")]
162 [CCode (cname = "enum_cursor_type", cprefix = "CURSOR_TYPE_")]
163 public enum CursorType {
171 [CCode (free_function = "mysql_close", cname = "MYSQL", cprefix = "mysql_")]
172 public class Database {
173 [CCode (cname = "mysql_init")]
174 public Database (Database? mysql = null);
176 public ulong affected_rows ();
177 public bool autocommit (bool mode);
178 public bool change_user (string username, string passwd, string? dbname = null);
179 public unowned string character_set_name ();
180 public bool commit ();
181 public int dump_debug_info ();
182 public uint errno ();
183 public unowned string error ();
184 public unowned string get_host_info ();
185 public uint get_proto_info ();
186 public unowned string get_server_info ();
187 public ulong get_server_version ();
188 public unowned string get_ssl_cipher ();
189 public unowned string info ();
190 public ulong insert_id ();
191 public int kill (ulong pid);
192 public Result? list_dbs (string? wild = null);
193 public Result? list_fields (string table, string? wild = null);
194 public Result? list_processes ();
195 public Result? list_tables (string? wild = null);
196 public bool more_results ();
197 public int next_result ();
198 public int options (Option option, string arg);
200 public int query (string stmt_str);
201 public bool real_connect (string? host = null, string? username = null, string? passwd = null, string? dbname = null, uint port = 0, string? unix_socket = null, ClientFlag client_flag = 0);
202 public ulong real_escape_string (string to, string from, ulong length);
203 public int real_query (string query, ulong len);
204 public int reload ();
205 public bool rollback ();
206 public int select_db (string dbname);
207 public int set_character_set (string csname);
208 public void set_local_infile_default ();
209 public int set_server_option (SetOption option);
210 public unowned string sqlstate ();
211 public int shutdown (int shutdown_level);
212 public bool ssl_set (string key, string cert, string ca, string capath, string cipher);
213 public unowned string stat ();
214 public Result? store_result ();
215 public ulong thread_id ();
216 public Result? use_result ();
217 public uint warning_count ();
221 [CCode (free_function = "mysql_free_result", cname = "MYSQL_RES", cprefix = "mysql_")]
222 public class Result {
224 public Field* fetch_field ();
225 public Field* fetch_field_direct (uint field_nbr);
227 [CCode (cname = "mysql_fetch_fields", array_length = false)]
228 public unowned Field[] _fetch_fields ();
229 [CCode (cname = "_vala_mysql_fetch_fields")]
230 public unowned Field[] fetch_fields () {
231 unowned Field[] fields = this._fetch_fields ();
232 fields.length = (int) this.num_fields ();
236 [CCode (cname = "mysql_fetch_lengths", array_length = false)]
237 public unowned ulong[] _fetch_lengths ();
238 [CCode (cname = "_vala_mysql_fetch_lengths")]
239 public unowned ulong[] fetch_lengths () {
240 unowned ulong[] lengths = this._fetch_lengths ();
241 lengths.length = (int) this.num_fields ();
245 [CCode (cname = "mysql_fetch_row", array_length = false)]
246 public unowned string[]? _fetch_row ();
247 [CCode (cname = "_vala_mysql_fetch_row")]
248 public unowned string[]? fetch_row () {
249 unowned string[]? row = this._fetch_row ();
250 row.length = (int) this.num_fields ();
254 public uint fetch_count ();
255 public uint num_fields ();
256 public uint num_rows ();
258 public bool data_seek (ulong offset);
260 [CCode (cname = "MYSQL_FIELD")]
261 public struct Field {
262 public unowned string name;
263 public unowned string org_name;
264 public unowned string table;
265 public unowned string org_table;
266 public unowned string db;
267 public unowned string catalog;
268 public unowned string def;
270 public ulong max_length;
271 public uint name_length;
272 public uint org_name_length;
273 public uint table_length;
274 public uint org_table_length;
275 public uint db_length;
276 public uint catalog_length;
277 public uint def_length;
279 public uint decimals;
280 public uint charsetnr;
281 public FieldType type;
282 public void *extension;
285 public unowned string get_client_info ();
286 public ulong get_client_version ();
287 public void debug (string msg);
288 public ulong hex_string (string to, string from, ulong length);
289 public void library_end ();
290 public int library_init ([CCode (array_length_pos = 0.1)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? groups = null);
291 public void server_end ();
292 public int server_init ([CCode (array_length_pos = 0.1)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? groups = null);
293 public void thread_end ();
294 public bool thread_init ();
295 public uint thread_safe ();