<commit_before>#include <sqlite3.h>
#include <stdio.h>

static sqlite3 *db;

int _mqtt_db_create_tables(void);

int mqtt_db_open(const char *filename)
{
	if(sqlite3_open(filename, &db) != SQLITE_OK){
		fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
		return 1;
	}

	return _mqtt_db_create_tables();
}

int mqtt_db_close(void)
{
	sqlite3_close(db);
	db = NULL;

	return 0;
}

int _mqtt_db_create_tables(void)
{
	int rc;
	char *errmsg = NULL;

	rc = sqlite3_exec(db,
		"CREATE TABLE IF NOT EXISTS clients("
		"id TEXT, "
		"will INTEGER, will_retain INTEGER, will_qos "
		"will_topic TEXT, will_message TEXT)",
		NULL, NULL, &errmsg);

	if(errmsg) sqlite3_free(errmsg);

	if(rc == SQLITE_OK){
		return 0;
	}else{
		return 1;
	}
}


<commit_msg>Create db table for subscriptions.<commit_after>#include <sqlite3.h>
#include <stdio.h>

static sqlite3 *db;

int _mqtt_db_create_tables(void);

int mqtt_db_open(const char *filename)
{
	if(sqlite3_open(filename, &db) != SQLITE_OK){
		fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
		return 1;
	}

	return _mqtt_db_create_tables();
}

int mqtt_db_close(void)
{
	sqlite3_close(db);
	db = NULL;

	return 0;
}

int _mqtt_db_create_tables(void)
{
	int rc = 0;
	char *errmsg = NULL;

	if(sqlite3_exec(db,
		"CREATE TABLE IF NOT EXISTS clients("
		"id TEXT, "
		"will INTEGER, will_retain INTEGER, will_qos "
		"will_topic TEXT, will_message TEXT)",
		NULL, NULL, &errmsg) != SQLITE_OK){

		rc = 1;
	}

	if(errmsg) sqlite3_free(errmsg);

	if(sqlite3_exec(db,
		"CREATE TABLE IF NOT EXISTS subs("
		"client_id TEXT, sub TEXT, qos INTEGER)",
		NULL, NULL, &errmsg) != SQLITE_OK){

		rc = 1;
	}

	if(errmsg) sqlite3_free(errmsg);

	return rc;
}



{'fraction_non_alphanumeric': 0.1378698224852071, 'fraction_numerical': 0.014792899408284023, 'mean_word_length': 4.617940199335548, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1308757', 'n_tokens_mistral': 783, 'n_tokens_neox': 714, 'n_words': 161}