Add function to get the async status for a mysql connection
This will allow for php code to better verify the async state of the mysql connection and aid in debugging. This diff adds mysql_async_status as well as associated constants.
Esse commit está contido em:
@@ -25,6 +25,37 @@ CPP
|
||||
// 'note' => additional note about this constant's schema
|
||||
// )
|
||||
|
||||
DefineConstant(
|
||||
array(
|
||||
'name' => "ASYNC_OP_INVALID",
|
||||
'type' => Int64,
|
||||
));
|
||||
|
||||
DefineConstant(
|
||||
array(
|
||||
'name' => "ASYNC_OP_UNSET",
|
||||
'type' => Int64,
|
||||
));
|
||||
|
||||
DefineConstant(
|
||||
array(
|
||||
'name' => "ASYNC_OP_CONNECT",
|
||||
'type' => Int64,
|
||||
));
|
||||
|
||||
DefineConstant(
|
||||
array(
|
||||
'name' => "ASYNC_OP_QUERY",
|
||||
'type' => Int64,
|
||||
));
|
||||
|
||||
DefineConstant(
|
||||
array(
|
||||
'name' => "ASYNC_OP_FETCH_ROW",
|
||||
'type' => Int64,
|
||||
));
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Functions
|
||||
//
|
||||
@@ -264,6 +295,24 @@ DefineFunction(
|
||||
),
|
||||
));
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "mysql_async_status",
|
||||
'desc' => "Returns the async operation status for a given mysql connection. For non-async connections, this returns ASYNC_OP_INVALID. For an async connection, this can be either ASYNC_OP_UNSET (no pending async operation), ASYNC_OP_QUERY (async query pending), ASYNC_OP_FETCH_ROW (async row fetching pending), or ASYNC_OP_CONNECT (async connection pending). Returns -1 if the supplied connection itself is invalid.",
|
||||
'flags' => HasDocComment,
|
||||
'return' => array(
|
||||
'type' => Int64,
|
||||
'desc' => "Returns the async operation number for this mysql connection.",
|
||||
),
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "link_identifier",
|
||||
'type' => Variant,
|
||||
'desc' => "The MySQL connection.",
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "mysql_pconnect",
|
||||
|
||||
@@ -1250,6 +1250,13 @@ static Variant php_mysql_fetch_hash(CVarRef result, int result_type) {
|
||||
libmysqlclient; for now, protect with an ifdef. Once open sourced,
|
||||
the client will be detectable via its own ifdef. */
|
||||
#ifdef FACEBOOK
|
||||
|
||||
const int64_t k_ASYNC_OP_INVALID = 0;
|
||||
const int64_t k_ASYNC_OP_UNSET = ASYNC_OP_UNSET;
|
||||
const int64_t k_ASYNC_OP_CONNECT = ASYNC_OP_CONNECT;
|
||||
const int64_t k_ASYNC_OP_QUERY = ASYNC_OP_QUERY;
|
||||
const int64_t k_ASYNC_OP_FETCH_ROW = ASYNC_OP_FETCH_ROW;
|
||||
|
||||
bool MySQL::async_connect(CStrRef host, int port, CStrRef socket,
|
||||
CStrRef username, CStrRef password,
|
||||
CStrRef database) {
|
||||
@@ -1505,7 +1512,24 @@ Variant f_mysql_async_wait_actionable(CVarRef items, double timeout) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
int64_t f_mysql_async_status(CVarRef link_identifier) {
|
||||
MySQL *mySQL = MySQL::Get(link_identifier);
|
||||
if (!mySQL || !mySQL->get()) {
|
||||
raise_warning("supplied argument is not a valid MySQL-Link resource");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return mySQL->get()->async_op_status;
|
||||
}
|
||||
|
||||
#else // FACEBOOK
|
||||
|
||||
// Bogus values for non-facebook libmysqlclients.
|
||||
const int64_t k_ASYNC_OP_INVALID = 0;
|
||||
const int64_t k_ASYNC_OP_UNSET = -1;
|
||||
const int64_t k_ASYNC_OP_CONNECT = -2;
|
||||
const int64_t k_ASYNC_OP_QUERY = -3;
|
||||
const int64_t k_ASYNC_OP_FETCH_ROW = -4;
|
||||
|
||||
Variant f_mysql_async_connect_start(CStrRef server,
|
||||
CStrRef username,
|
||||
@@ -1538,6 +1562,10 @@ Variant f_mysql_async_wait_actionable(CVarRef items, double timeout) {
|
||||
throw NotImplementedException(__func__);
|
||||
}
|
||||
|
||||
int64_t f_mysql_async_status(CVarRef link_identifier) {
|
||||
throw NotImplementedException(__func__);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Variant f_mysql_fetch_row(CVarRef result) {
|
||||
|
||||
@@ -435,6 +435,39 @@ TypedValue* fg_mysql_async_wait_actionable(HPHP::VM::ActRec *ar) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
long HPHP::f_mysql_async_status(HPHP::Variant const&)
|
||||
_ZN4HPHP20f_mysql_async_statusERKNS_7VariantE
|
||||
|
||||
(return value) => rax
|
||||
link_identifier => rdi
|
||||
*/
|
||||
|
||||
long fh_mysql_async_status(TypedValue* link_identifier) asm("_ZN4HPHP20f_mysql_async_statusERKNS_7VariantE");
|
||||
|
||||
TypedValue* fg_mysql_async_status(HPHP::VM::ActRec *ar) {
|
||||
TypedValue rv;
|
||||
int64_t count = ar->numArgs();
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
if (count == 1LL) {
|
||||
rv.m_type = KindOfInt64;
|
||||
rv.m_data.num = (int64_t)fh_mysql_async_status((args-0));
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
throw_wrong_arguments_nr("mysql_async_status", count, 1, 1, 1);
|
||||
}
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
return &ar->m_r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
HPHP::Variant HPHP::f_mysql_pconnect(HPHP::String const&, HPHP::String const&, HPHP::String const&, int, int, int)
|
||||
_ZN4HPHP16f_mysql_pconnectERKNS_6StringES2_S2_iii
|
||||
|
||||
@@ -113,6 +113,16 @@ timeout => xmm0
|
||||
|
||||
TypedValue* fh_mysql_async_wait_actionable(TypedValue* _rv, TypedValue* items, double timeout) asm("_ZN4HPHP29f_mysql_async_wait_actionableERKNS_7VariantEd");
|
||||
|
||||
/*
|
||||
long HPHP::f_mysql_async_status(HPHP::Variant const&)
|
||||
_ZN4HPHP20f_mysql_async_statusERKNS_7VariantE
|
||||
|
||||
(return value) => rax
|
||||
link_identifier => rdi
|
||||
*/
|
||||
|
||||
long fh_mysql_async_status(TypedValue* link_identifier) asm("_ZN4HPHP20f_mysql_async_statusERKNS_7VariantE");
|
||||
|
||||
/*
|
||||
HPHP::Variant HPHP::f_mysql_pconnect(HPHP::String const&, HPHP::String const&, HPHP::String const&, int, int, int)
|
||||
_ZN4HPHP16f_mysql_pconnectERKNS_6StringES2_S2_iii
|
||||
|
||||
@@ -262,6 +262,7 @@ Variant f_mysql_async_query_result(CVarRef link_identifier);
|
||||
bool f_mysql_async_query_completed(CVarRef result);
|
||||
Variant f_mysql_async_fetch_array(CVarRef result, int result_type = 1);
|
||||
Variant f_mysql_async_wait_actionable(CVarRef items, double timeout);
|
||||
int64_t f_mysql_async_status(CVarRef link_identifier);
|
||||
|
||||
String f_mysql_escape_string(CStrRef unescaped_string);
|
||||
|
||||
@@ -366,6 +367,12 @@ Variant f_mysql_field_type(CVarRef result, int field = 0);
|
||||
Variant f_mysql_field_flags(CVarRef result, int field = 0);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
extern const int64_t k_ASYNC_OP_INVALID;
|
||||
extern const int64_t k_ASYNC_OP_UNSET;
|
||||
extern const int64_t k_ASYNC_OP_CONNECT;
|
||||
extern const int64_t k_ASYNC_OP_QUERY;
|
||||
extern const int64_t k_ASYNC_OP_FETCH_ROW;
|
||||
|
||||
}
|
||||
|
||||
#endif // __EXT_MYSQL_H__
|
||||
|
||||
@@ -1483,6 +1483,7 @@ TypedValue* fg_mysql_async_query_result(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_async_query_completed(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_async_fetch_array(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_async_wait_actionable(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_async_status(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_pconnect(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_connect_with_db(VM::ActRec *ar);
|
||||
TypedValue* fg_mysql_pconnect_with_db(VM::ActRec *ar);
|
||||
@@ -3057,7 +3058,7 @@ TypedValue* tg_9XMLWriter_endDTD(VM::ActRec *ar);
|
||||
TypedValue* tg_9XMLWriter_flush(VM::ActRec *ar);
|
||||
TypedValue* tg_9XMLWriter_outputMemory(VM::ActRec *ar);
|
||||
|
||||
const long long hhbc_ext_funcs_count = 2203;
|
||||
const long long hhbc_ext_funcs_count = 2204;
|
||||
const HhbcExtFuncInfo hhbc_ext_funcs[] = {
|
||||
{ "apache_note", fg_apache_note, (void *)&fh_apache_note },
|
||||
{ "apache_request_headers", fg_apache_request_headers, (void *)&fh_apache_request_headers },
|
||||
@@ -4519,6 +4520,7 @@ const HhbcExtFuncInfo hhbc_ext_funcs[] = {
|
||||
{ "mysql_async_query_completed", fg_mysql_async_query_completed, (void *)&fh_mysql_async_query_completed },
|
||||
{ "mysql_async_fetch_array", fg_mysql_async_fetch_array, (void *)&fh_mysql_async_fetch_array },
|
||||
{ "mysql_async_wait_actionable", fg_mysql_async_wait_actionable, (void *)&fh_mysql_async_wait_actionable },
|
||||
{ "mysql_async_status", fg_mysql_async_status, (void *)&fh_mysql_async_status },
|
||||
{ "mysql_pconnect", fg_mysql_pconnect, (void *)&fh_mysql_pconnect },
|
||||
{ "mysql_connect_with_db", fg_mysql_connect_with_db, (void *)&fh_mysql_connect_with_db },
|
||||
{ "mysql_pconnect_with_db", fg_mysql_pconnect_with_db, (void *)&fh_mysql_pconnect_with_db },
|
||||
|
||||
@@ -9934,6 +9934,12 @@ const char *g_class_map[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "mysql_async_status", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/function.mysql-async-status.php\n * )\n *\n * Returns the async operation status for a given mysql connection. For\n * non-async connections, this returns ASYNC_OP_INVALID. For an async\n * connection, this can be either ASYNC_OP_UNSET (no pending async\n * operation), ASYNC_OP_QUERY (async query pending), ASYNC_OP_FETCH_ROW\n * (async row fetching pending), or ASYNC_OP_CONNECT (async connection\n * pending). Returns -1 if the supplied connection itself is invalid.\n *\n * @link_identifier\n * mixed The MySQL connection.\n *\n * @return int Returns the async operation number for this mysql\n * connection.\n */",
|
||||
(const char *)0xa /* KindOfInt64 */, (const char *)0x2000, "link_identifier", "", (const char *)0xffffffff /* KindOfUnknown: $t: Variant */, "", (const char *)0, "", (const char *)0, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006040, "mysql_pconnect", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/function.mysql-pconnect.php )\n *\n * Establishes a persistent connection to a MySQL server.\n *\n * mysql_pconnect() acts very much like mysql_connect() with two major\n * differences.\n *\n * First, when connecting, the function would first try to find a\n * (persistent) link that's already open with the same host, username and\n * password. If one is found, an identifier for it will be returned instead\n * of opening a new connection.\n *\n * Second, the connection to the SQL server will not be closed when the\n * execution of the script ends. Instead, the link will remain open for\n * future use (mysql_close() will not close links established by\n * mysql_pconnect()).\n *\n * This type of link is therefore called 'persistent'.\n *\n * @server string The MySQL server. It can also include a port number.\n * e.g. \"hostname:port\" or a path to a local socket\n * e.g. \":/path/to/socket\" for the localhost.\n *\n * If the PHP directive mysql.default_host is\n * undefined (default), then the default value is\n * 'localhost:3306'\n * @username string The username. Default value is the name of the user\n * that owns the server process.\n * @password string The password. Default value is an empty password.\n * @client_flags\n * int The client_flags parameter can be a combination of\n * the following constants: 128 (enable LOAD DATA LOCAL\n * handling), MYSQL_CLIENT_SSL, MYSQL_CLIENT_COMPRESS,\n * MYSQL_CLIENT_IGNORE_SPACE or\n * MYSQL_CLIENT_INTERACTIVE.\n * @connect_timeout_ms\n * int (HipHop specific) How many milli-seconds to wait for\n * connection.\n * @query_timeout_ms\n * int (HipHop specific) How many milli-seconds to wait for\n * query.\n *\n * @return mixed Returns a MySQL persistent link identifier on\n * success, or FALSE on failure.\n */",
|
||||
(const char *)0xffffffff /* KindOfUnknown: $t: Variant */, (const char *)0x2000, "server", "", (const char *)0x14 /* KindOfString */, "N;", (const char *)2, "null", (const char *)4, NULL,
|
||||
@@ -19515,6 +19521,11 @@ const char *g_class_map[] = {
|
||||
"JSON_FB_LOOSE", (const char *)&k_JSON_FB_LOOSE, (const char *)0xc /* KindOfInt64 */,
|
||||
"JSON_FB_UNLIMITED", (const char *)&k_JSON_FB_UNLIMITED, (const char *)0xc /* KindOfInt64 */,
|
||||
"JSON_FB_EXTRA_ESCAPES", (const char *)&k_JSON_FB_EXTRA_ESCAPES, (const char *)0xc /* KindOfInt64 */,
|
||||
"ASYNC_OP_INVALID", (const char *)&k_ASYNC_OP_INVALID, (const char *)0xc /* KindOfInt64 */,
|
||||
"ASYNC_OP_UNSET", (const char *)&k_ASYNC_OP_UNSET, (const char *)0xc /* KindOfInt64 */,
|
||||
"ASYNC_OP_CONNECT", (const char *)&k_ASYNC_OP_CONNECT, (const char *)0xc /* KindOfInt64 */,
|
||||
"ASYNC_OP_QUERY", (const char *)&k_ASYNC_OP_QUERY, (const char *)0xc /* KindOfInt64 */,
|
||||
"ASYNC_OP_FETCH_ROW", (const char *)&k_ASYNC_OP_FETCH_ROW, (const char *)0xc /* KindOfInt64 */,
|
||||
"PHP_ROUND_HALF_UP", (const char *)&k_PHP_ROUND_HALF_UP, (const char *)0xc /* KindOfInt64 */,
|
||||
"PHP_ROUND_HALF_DOWN", (const char *)&k_PHP_ROUND_HALF_DOWN, (const char *)0xc /* KindOfInt64 */,
|
||||
"PHP_ROUND_HALF_EVEN", (const char *)&k_PHP_ROUND_HALF_EVEN, (const char *)0xc /* KindOfInt64 */,
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário