溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)

發(fā)布時間:2021-09-14 17:34:35 來源:億速云 閱讀:122 作者:chen 欄目:云計算

這篇文章主要講解了“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”吧!

一、數(shù)據(jù)庫操作結(jié)果數(shù)據(jù)結(jié)構(gòu)

struct zbx_db_result

{

#if defined(HAVE_IBM_DB2)

SQLHANDLE hstmt;

SQLSMALLINT nalloc;

SQLSMALLINT ncolumn;

DB_ROW values;

DB_ROW values_cli;

SQLINTEGER *values_len;

#elif defined(HAVE_MYSQL)

       MYSQL_RES *result;

#elif defined(HAVE_ORACLE)

OCIStmt *stmthp; /* the statement handle for select operations */

int  ncolumn;

DB_ROW values;

ub4 *values_alloc;

OCILobLocator **clobs;

#elif defined(HAVE_POSTGRESQL)

PGresult *pg_result;

int row_num;

int fld_num;

int cursor;

DB_ROW values;

#elif defined(HAVE_SQLITE3)

int curow;

char **data;

int nrow;

int ncolumn;

DB_ROW values;

#endif

};

二、數(shù)據(jù)庫根據(jù)sql查詢

/******************************************************************************

 *                                                                            *

 * Function: DBselect                                                         *

 *                                                                            *

 * Purpose: execute a select statement                                        *

 *                                                                            *

 * Comments: retry until DB is up                                             *

 *                                                                            *

 ******************************************************************************/

DB_RESULT __zbx_DBselect(const char *fmt, ...)

{

va_list args;  //參數(shù)列表

DB_RESULT rc;

va_start(args, fmt);

rc = zbx_db_vselect(fmt, args);

while ((DB_RESULT)ZBX_DB_DOWN == rc)

{

DBclose();

DBconnect(ZBX_DB_CONNECT_NORMAL);

if ((DB_RESULT)ZBX_DB_DOWN == (rc = zbx_db_vselect(fmt, args)))

{

zabbix_log(LOG_LEVEL_ERR, "database is down: retrying in %d seconds", ZBX_DB_WAIT_DOWN);

connection_failure = 1;

sleep(ZBX_DB_WAIT_DOWN);

}

}

va_end(args);

return rc;

}

三、MySQL操作結(jié)果數(shù)據(jù)結(jié)構(gòu)

typedef struct st_mysql_res {

  my_ulonglong  row_count;

  MYSQL_FIELD *fields;

  MYSQL_DATA *data;

  MYSQL_ROWS *data_cursor;

  unsigned long *lengths; /* column lengths of current row */

  MYSQL *handle; /* for unbuffered reads */

  const struct st_mysql_methods *methods;

  MYSQL_ROW row; /* If unbuffered read */

  MYSQL_ROW current_row; /* buffer to current row */

  MEM_ROOT field_alloc;

  unsigned int field_count, current_field;

  my_bool eof; /* Used by mysql_fetch_row */

  /* mysql_stmt_close() had to cancel this result */

  my_bool       unbuffered_fetch_cancelled;  

  void *extension;

} MYSQL_RES;

感謝各位的閱讀,以上就是“MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對MySQL數(shù)據(jù)庫操作結(jié)果的數(shù)據(jù)結(jié)構(gòu)這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI