| 1 | module mysql |
| 2 | |
| 3 | @[typedef] |
| 4 | pub struct C.MYSQL { |
| 5 | } |
| 6 | |
| 7 | @[typedef] |
| 8 | pub struct C.MYSQL_RES { |
| 9 | } |
| 10 | |
| 11 | @[typedef] |
| 12 | pub struct C.MYSQL_FIELD { |
| 13 | name &u8 // Name of column |
| 14 | org_name &u8 // Original column name, if an alias |
| 15 | table &u8 // Table of column if column was a field |
| 16 | org_table &u8 // Org table name, if table was an alias |
| 17 | db &u8 // Name of the database that the field comes from |
| 18 | catalog &u8 // Catalog for table |
| 19 | def &u8 // Default value (set by `mysql_list_fields`) |
| 20 | length int // Width of column (create length) |
| 21 | max_length int // Max width for selected set |
| 22 | name_length u32 |
| 23 | org_name_length u32 |
| 24 | table_length u32 |
| 25 | org_table_length u32 |
| 26 | db_length u32 |
| 27 | catalog_length u32 |
| 28 | def_length u32 |
| 29 | flags u32 // Bit-flags that describe the field |
| 30 | decimals u32 // Number of decimals in field |
| 31 | charsetnr u32 // Character set |
| 32 | type int // Type of field. See enums.v for types |
| 33 | } |
| 34 | |
| 35 | // C.mysql_init allocates or initializes a MYSQL object suitable for `mysql_real_connect()`. |
| 36 | fn C.mysql_init(mysql &C.MYSQL) &C.MYSQL |
| 37 | |
| 38 | // C.mysql_thread_init initializes thread-local client state for threads using the MySQL C API. |
| 39 | fn C.mysql_thread_init() bool |
| 40 | |
| 41 | // C.mysql_thread_end finalizes thread-local client state for threads using the MySQL C API. |
| 42 | fn C.mysql_thread_end() |
| 43 | |
| 44 | // C.mysql_real_connect attempts to establish a connection to a MySQL server running on `host`. |
| 45 | fn C.mysql_real_connect(mysql &C.MYSQL, host &char, user &char, passwd &char, db &char, port u32, unix_socket &char, |
| 46 | client_flag ConnectionFlag) &C.MYSQL |
| 47 | |
| 48 | // C.mysql_query executes the SQL statement pointed to by the null-terminated string `stmt_str`. |
| 49 | fn C.mysql_query(mysql &C.MYSQL, const_q charptr) i32 |
| 50 | |
| 51 | // C.mysql_use_result initiates a result set retrieval but does not actually read |
| 52 | // the result set into the client like `mysql_store_result()` does. |
| 53 | fn C.mysql_use_result(mysql &C.MYSQL) |
| 54 | |
| 55 | // C.mysql_real_query executes the SQL statement pointed to by `stmt_str`, |
| 56 | // a string length bytes long. |
| 57 | fn C.mysql_real_query(mysql &C.MYSQL, q &u8, len u32) i32 |
| 58 | |
| 59 | // C.mysql_select_db causes the database specified by `db` to become |
| 60 | // the default (current) database on the connection specified by mysql. |
| 61 | fn C.mysql_select_db(mysql &C.MYSQL, db &u8) i32 |
| 62 | |
| 63 | // C.mysql_change_user changes the user and causes the database specified by `db` to become |
| 64 | // the default (current) database on the connection specified by `mysql`. |
| 65 | fn C.mysql_change_user(mysql &C.MYSQL, user &u8, password &u8, db &u8) bool |
| 66 | |
| 67 | // C.mysql_affected_rows returns the number of rows changed, deleted, |
| 68 | // or inserted by the last statement if it was an `UPDATE`, `DELETE`, or `INSERT`. |
| 69 | fn C.mysql_affected_rows(mysql &C.MYSQL) u64 |
| 70 | |
| 71 | // C.mysql_options sets extra connect options and affects behavior for a connection. |
| 72 | fn C.mysql_options(mysql &C.MYSQL, option i32, arg voidptr) i32 |
| 73 | |
| 74 | // C.mysql_get_option returns the current value of an option settable using `mysql_options()`. |
| 75 | fn C.mysql_get_option(mysql &C.MYSQL, option i32, arg voidptr) i32 |
| 76 | |
| 77 | // C.mysql_list_tables returns a result set consisting of table names in the current database |
| 78 | // that match the simple regular expression specified by the `wild` parameter. |
| 79 | // `wild` may contain the wildcard characters `%` or `_`, |
| 80 | // or may be a `NULL` pointer to match all tables. |
| 81 | fn C.mysql_list_tables(mysql &C.MYSQL, wild &u8) &C.MYSQL_RES |
| 82 | |
| 83 | // C.mysql_num_fields returns the number of columns in a result set. |
| 84 | fn C.mysql_num_fields(res &C.MYSQL_RES) i32 |
| 85 | |
| 86 | // C.mysql_num_rows returns the number of rows in the result set. |
| 87 | fn C.mysql_num_rows(res &C.MYSQL_RES) u64 |
| 88 | |
| 89 | // C.mysql_autocommit sets autocommit mode on if `mode` is 1, off if `mode` is 0. |
| 90 | fn C.mysql_autocommit(mysql &C.MYSQL, mode bool) i32 |
| 91 | |
| 92 | // C.mysql_commit commits the current transaction. |
| 93 | fn C.mysql_commit(mysql &C.MYSQL) i32 |
| 94 | |
| 95 | // C.mysql_rollback rollback the current transaction. |
| 96 | fn C.mysql_rollback(mysql &C.MYSQL) i32 |
| 97 | |
| 98 | // C.mysql_refresh flush tables or caches, or resets replication server information. |
| 99 | fn C.mysql_refresh(mysql &C.MYSQL, options u32) i32 |
| 100 | |
| 101 | // C.mysql_reset_connection resets the connection to clear the session state. |
| 102 | fn C.mysql_reset_connection(mysql &C.MYSQL) i32 |
| 103 | |
| 104 | // C.mysql_ping checks whether the connection to the server is working. |
| 105 | // Returns zero if the connection to the server is active. Nonzero if an error occurred. |
| 106 | fn C.mysql_ping(mysql &C.MYSQL) i32 |
| 107 | |
| 108 | // C.mysql_store_result reads the entire result of a query to the client, |
| 109 | // allocates a `MYSQL_RES` structure, and places the result into this structure. |
| 110 | // It is a synchronous function. |
| 111 | fn C.mysql_store_result(mysql &C.MYSQL) &C.MYSQL_RES |
| 112 | |
| 113 | // C.mysql_fetch_row retrieves the next row of a result set. |
| 114 | fn C.mysql_fetch_row(res &C.MYSQL_RES) &charptr |
| 115 | |
| 116 | // C.mysql_fetch_fields returns an array of all `MYSQL_FIELD` structures for a result set. |
| 117 | // Each structure provides the field definition for one column of the result set. |
| 118 | fn C.mysql_fetch_fields(res &C.MYSQL_RES) &C.MYSQL_FIELD |
| 119 | |
| 120 | // C.mysql_free_result frees the memory allocated for a result set by `mysql_store_result()`, |
| 121 | // `mysql_use_result()`, `mysql_list_dbs()`, and so forth. |
| 122 | fn C.mysql_free_result(res &C.MYSQL_RES) |
| 123 | |
| 124 | // C.mysql_real_escape_string creates a legal SQL string for use in an SQL statement. |
| 125 | fn C.mysql_real_escape_string(mysql &C.MYSQL, to &u8, from &u8, len u64) u64 |
| 126 | |
| 127 | // C.mysql_close closes a previously opened connection. |
| 128 | fn C.mysql_close(sock &C.MYSQL) |
| 129 | |
| 130 | // C.mysql_info retrieves a string providing information about the most recently executed statement. |
| 131 | fn C.mysql_info(mysql &C.MYSQL) &u8 |
| 132 | |
| 133 | // C.mysql_get_host_info returns a string describing the type of connection in use, |
| 134 | // including the server host name. |
| 135 | fn C.mysql_get_host_info(mysql &C.MYSQL) &u8 |
| 136 | |
| 137 | // C.mysql_get_server_info returns a string that represents |
| 138 | // the MySQL server version (for example, "8.0.33"). |
| 139 | fn C.mysql_get_server_info(mysql &C.MYSQL) &u8 |
| 140 | |
| 141 | // C.mysql_get_server_version returns an integer that represents the MySQL server version. |
| 142 | // The value has the format `XYYZZ` where `X` is the major version, |
| 143 | // `YY` is the release level (or minor version), |
| 144 | // and `ZZ` is the sub-version within the release level: |
| 145 | // `major_version*10000 + release_level*100 + sub_version` |
| 146 | // For example, "8.0.33" is returned as 80033. |
| 147 | fn C.mysql_get_server_version(mysql &C.MYSQL) u64 |
| 148 | |
| 149 | // C.mysql_get_client_version returns an integer that represents the MySQL client library version. |
| 150 | // The value has the format `XYYZZ` where `X` is the major version, |
| 151 | // `YY` is the release level (or minor version), |
| 152 | // and `ZZ` is the sub-version within the release level: |
| 153 | // `major_version*10000 + release_level*100 + sub_version` |
| 154 | // For example, "8.0.33" is returned as 80033. |
| 155 | fn C.mysql_get_client_version() u64 |
| 156 | |
| 157 | // C.mysql_get_client_info returns a string that represents |
| 158 | // the MySQL client library version (for example, "8.0.33"). |
| 159 | fn C.mysql_get_client_info() &u8 |
| 160 | |
| 161 | // C.mysql_error returns a null-terminated string containing the error message |
| 162 | // for the most recently invoked API function that failed. |
| 163 | fn C.mysql_error(mysql &C.MYSQL) &u8 |
| 164 | |
| 165 | // C.mysql_errno returns the error code for the most recently invoked API function that can succeed or fail. |
| 166 | fn C.mysql_errno(mysql &C.MYSQL) i32 |
| 167 | |
| 168 | // C.mysql_dump_debug_info instructs the server to write debugging information to the error log. |
| 169 | fn C.mysql_dump_debug_info(mysql &C.MYSQL) i32 |
| 170 | |
| 171 | // C.mysql_debug does a `DBUG_PUSH` with the given string. |
| 172 | fn C.mysql_debug(debug &u8) |
| 173 | |