MCPcopy Create free account
hub / github.com/MariaDB/server / PrepareSQL

Method PrepareSQL

storage/connect/myconn.cpp:611–644  ·  view source on GitHub ↗

/ Prepare the SQL statement used to insert into a MySQL table. */ /

Source from the content-addressed store, hash-verified

609/* Prepare the SQL statement used to insert into a MySQL table. */
610/***********************************************************************/
611int MYSQLC::PrepareSQL(PGLOBAL g, const char *stmt)
612 {
613 if (!m_DB) {
614 strcpy(g->Message, "MySQL not connected");
615 return -4;
616 } else if (m_Stmt)
617 return -1; // should not append
618
619#if defined(ALPHA)
620 if (!(m_Stmt = mysql_prepare(m_DB, stmt, strlen(stmt)))) {
621
622 snprintf(g->Message, sizeof(g->Message), "mysql_prepare failed: %s [%s]",
623 mysql_error(m_DB), stmt);
624 return -1;
625 } // endif m_Stmt
626
627 // Return the parameter count from the statement
628 return mysql_param_count(m_Stmt);
629#else // !ALPHA
630 if (!(m_Stmt = mysql_stmt_init(m_DB))) {
631 strcpy(g->Message, "mysql_stmt_init(), out of memory");
632 return -2;
633 } // endif m_Stmt
634
635 if (mysql_stmt_prepare(m_Stmt, stmt, strlen(stmt))) {
636 snprintf(g->Message, sizeof(g->Message), "mysql_stmt_prepare() failed: (%d) %s",
637 mysql_stmt_errno(m_Stmt), mysql_stmt_error(m_Stmt));
638 return -3;
639 } // endif prepare
640
641 // Return the parameter count from the statement
642 return mysql_stmt_param_count(m_Stmt);
643#endif // !ALPHA
644 } // end of PrepareSQL
645
646/***********************************************************************/
647/* Bind the parameter buffers. */

Callers 4

OpenDBMethod · 0.45
MakeInsertMethod · 0.45
OpenDBMethod · 0.45
OpenDBMethod · 0.45

Calls 5

mysql_errorFunction · 0.85
mysql_stmt_prepareFunction · 0.85
mysql_stmt_errnoFunction · 0.85
mysql_stmt_errorFunction · 0.85
mysql_stmt_param_countFunction · 0.85

Tested by

no test coverage detected