diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2025-11-11 18:27:03 +0100 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2025-11-11 18:27:03 +0100 |
| commit | afb8845d25eb4104150193be691d4b60a051ec82 (patch) | |
| tree | 02c3e6cb264994557d8a24958f4f493d5e9aff83 /src/main.c | |
| parent | 5e53e2acfe669fc0c0df4d39f6ffc9e45d35591a (diff) | |
Change tag checking SQL query
Also remove debug code.
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 35 |
1 files changed, 11 insertions, 24 deletions
@@ -66,36 +66,23 @@ static void ftag_help(int, char **) /* Check that the tag we are trying to create does not exist yet. If this * callback is ever called, then it already exist, this is a fatal error. */ -static int ftag_tag_check(void *, int count, char **cols, char **col_names) +static int ftag_tag_check(void *, int, char **cols, char **) { + assert(cols[0]); assert(cols[1]); - assert(cols[2]); fprintf(stderr, - "ftag tag add: error: tag %s already exists, its description is:\n", - cols[1]); - fprintf(stderr, "%s\n", cols[2]); + "ftag tag add: error: tag \"%s\" already exists, its description is:\n", + cols[0]); + fprintf(stderr, "%s\n", cols[1]); return 1; } -static int ftag_tag_last_id(void *_id, int count, char **cols, char **col_names) +static int ftag_tag_last_id(void *_id, int, char **cols, char **) { - printf("%s: count is %d\n", __func__, count); - printf("%s: ", __func__); - for (int i = 0; i < count; i++) { - printf("col_names[%d] = %s\t", i, col_names[i]); - } - printf("\n"); - printf("%s: ", __func__); - for (int i = 0; i < count; i++) { - printf("cols[%d] = %s\t", i, cols[i]); - } - printf("\n"); - - /* int *id = _id; */ - /* assert(count == 1); */ - /* assert(cols); */ - /* assert(cols[0]); */ - /* *id = atoi(cols[0]); */ + int *id = _id; + assert(cols); + assert(cols[0]); + *id = atoi(cols[0]); return 0; } @@ -120,7 +107,7 @@ static void ftag_tag_add(int argc, char **argv) memset(sql, 0, sizeof(sql)); snprintf(sql, sizeof(sql)-1, - "SELECT * FROM tags WHERE name = '%s';", new_tag_name); + "SELECT name, description FROM tags WHERE name = '%s';", new_tag_name); rc = sqlite3_exec(db, sql, ftag_tag_check, NULL, NULL); sqlite3_check(rc, db); |
