List:General Discussion« Previous MessageNext Message »
From:Michael Pawlowsky Date:December 4 2009 11:06pm
Subject:mysql_real_query causing segmentation fault for binary select
View as plain text  
I am trying top run these 2 SELECT queries using mysql_real_query in MySQL-C.

The only difference between them is changing the first hex value from 41 to 01.

It if is 41, the query runs fine. When I change it to 01 I get the following segmentation

segfault at 0 ip 0000000000402be6 sp 00007fff01e5bee0 error 4 in apnsd[400000+7000]

SELECT `id` FROM `apns`.`tblTokens` WHERE `token_id` =
0x01A161E6CEAC902311B2357792F6076A3CEA85FA9B0B071A77289FC450D7092E LIMIT 1
SELECT `id` FROM `apns`.`tblTokens` WHERE `token_id` =
0x41A161E6CEAC902311B2357792F6076A3CEA85FA9B0B071A77289FC450D7092E LIMIT 1

token_id is defines as:  binary(32)
I also tried it a char(32) with the same results

Any insight on why this is happening?


  /* Connect to database */
   if (!mysql_real_connect(conn, db_host,
         db_user, db_password, db_name, 0, NULL, 0)) {

			 /* log an error */
   			syslog(LOG_ERR,"Unable to connect to DB. Error: %s", mysql_error(conn));

			/* Can't connect to DB... Bailing out */
   if (mysql_real_query(conn, "SELECT `id` FROM `apns`.`tblTokens` WHERE `token_id` =
0x01A161E6CEAC902311B2357792F6076A3CEA85FA9B0B071A77289FC450D7092E LIMIT 1", 129)) {
			 /* log an error */
   			syslog(LOG_ERR,"Failed to SELECT, Error: %s", mysql_error(conn));
	                syslog(LOG_ERR, "Query: %s", query);

			/* Failed to select from DB... Bailing out */



mysql_real_query causing segmentation fault for binary selectMichael Pawlowsky5 Dec