* a failure of the command 'cmd' on file 'filename'
* with the message given by strerror(errno).
*/
-#define LOG_MYSQL(db, level, cmd, stmt) do { GNUNET_log_from (level, "psycstore-mysql", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, mysql_stmt_error (GNUNET_MYSQL_statement_get_stmt(stmt))); } while(0)
+#define LOG_MYSQL(db, level, cmd, stmt) \
+ do { \
+ GNUNET_log_from (level, "psycstore-mysql", \
+ _("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, __FILE__, __LINE__, \
+ mysql_stmt_error (GNUNET_MYSQL_statement_get_stmt(stmt))); \
+ } while (0)
#define LOG(kind,...) GNUNET_log_from (kind, "psycstore-mysql", __VA_ARGS__)
"psycstore-mysql", "FILENAME");
return GNUNET_SYSERR;
}
-
+
if (GNUNET_OK != GNUNET_DISK_file_test (filename))
{
if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (filename))
GNUNET_MY_query_param_end
};
- if(GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_channel", stmt);
+ "mysql exec_channel", stmt);
}
if (0 != mysql_stmt_reset (GNUNET_MYSQL_statement_get_stmt (stmt)))
transaction_begin (struct Plugin *plugin, enum Transactions transaction)
{
struct GNUNET_MYSQL_StatementHandle *stmt = plugin->transaction_begin;
-
+
struct GNUNET_MY_QueryParam params[] = {
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", stmt);
+ "mysql exexc_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared( plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_prepared", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared( plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_prepared", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_prepared", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_insert))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_insert))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
GNUNET_MY_query_param_end
};
- sql_ret = GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_update);
- switch(sql_ret)
+ sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params_update);
+ switch (sql_ret)
{
case GNUNET_OK:
ret = GNUNET_OK;
break;
+
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
{
case GNUNET_NO:
if (ret != GNUNET_OK)
- ret = GNUNET_NO;
+ ret = GNUNET_NO;
break;
+
case GNUNET_OK:
+ mp = GNUNET_malloc (sizeof (*mp) + buf_size);
- mp = GNUNET_malloc (sizeof (*mp) + buf_size);
-
mp->header.size = htons (sizeof (*mp) + buf_size);
mp->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE);
mp->hop_counter = htonl (hop_counter);
GNUNET_memcpy (&mp[1],
buf,
buf_size);
- ret = cb (cb_cls,
- mp,
- (enum GNUNET_PSYCSTORE_MessageFlags) flags);
-
+ ret = cb (cb_cls, mp, (enum GNUNET_PSYCSTORE_MessageFlags) flags);
+
GNUNET_MY_cleanup_result (results);
-
break;
+
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", stmt);
int ret = GNUNET_SYSERR;
int sql_ret;
- if(NULL == plugin->mc)
- {
- fprintf(stderr, "bla\n");
- }
-
- if(NULL == stmt)
+ // FIXME
+ if (NULL == plugin->mc || NULL == stmt || NULL == params)
{
- fprintf(stderr, "blo\n" );
- }
-
- if(NULL == params)
- {
- fprintf(stderr, "toot\n" );
+ fprintf(stderr, "%p %p %p\n", plugin->mc, stmt, params);
+ return GNUNET_SYSERR;
}
- sql_ret = GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params);
- switch(sql_ret)
+ sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params);
+ switch (sql_ret)
{
case GNUNET_NO:
if (ret != GNUNET_OK)
- ret = GNUNET_NO;
+ ret = GNUNET_NO;
break;
+
case GNUNET_YES:
ret = fragment_row (stmt, cb, cb_cls);
(*returned_fragments)++;
break;
+
default:
- LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql exec_prepared", stmt);
+ LOG_MYSQL (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "mysql exec_prepared", stmt);
}
return ret;
GNUNET_MY_query_param_end
};
- sql_ret = GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select);
- switch(sql_ret)
+ sql_ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select);
+ switch (sql_ret)
{
case GNUNET_NO:
ret = GNUNET_NO;
break;
+
case GNUNET_OK:
ret = fragment_row (stmt, cb, cb_cls);
break;
+
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
GNUNET_MY_query_param_end
};
- if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select))
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql execute prepared", stmt);
GNUNET_MY_query_param_end
};
- ret = GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params);
-
+ ret = GNUNET_MY_exec_prepared (plugin->mc, stmt, params);
if (GNUNET_OK != ret)
{
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql execute prepared", stmt);
+ "mysql exec_prepared", stmt);
return GNUNET_SYSERR;
}
GNUNET_MY_result_spec_end
};
- GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select);
-
-
- sql_ret = GNUNET_MY_extract_result (stmt,
- results);
-
- switch (sql_ret)
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
{
+ LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "mysql exec_prepared", stmt);
+ }
+ else
+ {
+ sql_ret = GNUNET_MY_extract_result (stmt, results);
+ switch (sql_ret)
+ {
case GNUNET_NO:
ret = GNUNET_NO;
break;
break;
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
- "mysql extract_result", stmt);
+ "mysql extract_result", stmt);
+ }
}
if (0 != mysql_stmt_reset (GNUNET_MYSQL_statement_get_stmt (stmt)))
do
{
- GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select);
- sql_ret = GNUNET_MY_extract_result (stmt,
- results);
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
+ {
+ LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "mysql exec_prepared", stmt);
+ break;
+ }
+ sql_ret = GNUNET_MY_extract_result (stmt, results);
switch (sql_ret)
{
case GNUNET_NO:
if (ret != GNUNET_OK)
ret = GNUNET_NO;
break;
+
case GNUNET_YES:
ret = cb (cb_cls, (const char *) name2,
value_current,
if (ret != GNUNET_YES)
sql_ret = GNUNET_NO;
break;
+
default:
LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"mysql extract_result", stmt);
do
{
- GNUNET_MY_exec_prepared (plugin->mc,
- stmt,
- params_select);
- sql_ret = GNUNET_MY_extract_result (stmt,
- results);
-
+ if (GNUNET_OK != GNUNET_MY_exec_prepared (plugin->mc, stmt, params_select))
+ {
+ LOG_MYSQL(plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
+ "mysql exec_prepared", stmt);
+ break;
+ }
+ sql_ret = GNUNET_MY_extract_result (stmt, results);
switch (sql_ret)
{
case GNUNET_NO: