[tracker/wip/carlosg/insert-perf: 1/13] libtracker-data: Add internal error code for failed constraints




commit 2ad29dc2c516205a1f53d29c8e132ab61a4f0194
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Nov 28 18:41:04 2020 +0100

    libtracker-data: Add internal error code for failed constraints
    
    And add the missing plumbing for TRACKER_SPARQL_ERROR_CONSTRAINT to
    be a thing.

 src/libtracker-data/tracker-db-interface-sqlite.c | 5 +++++
 src/libtracker-data/tracker-db-interface.h        | 3 ++-
 src/libtracker-sparql/tracker-error.c             | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 18a174e26..0fd28c066 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -2916,6 +2916,11 @@ execute_stmt (TrackerDBInterface  *interface,
                                             TRACKER_DB_INTERFACE_ERROR,
                                             TRACKER_DB_INTERRUPTED,
                                             "Interrupted");
+                       } else if (result == SQLITE_CONSTRAINT) {
+                               g_set_error (error,
+                                            TRACKER_DB_INTERFACE_ERROR,
+                                            TRACKER_DB_CONSTRAINT,
+                                            "Constraint would be broken");
                        } else {
                                g_set_error (error,
                                             TRACKER_DB_INTERFACE_ERROR,
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 28fe5c7e9..f415cdeca 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -64,7 +64,8 @@ typedef enum {
        TRACKER_DB_QUERY_ERROR,
        TRACKER_DB_INTERRUPTED,
        TRACKER_DB_OPEN_ERROR,
-       TRACKER_DB_NO_SPACE
+       TRACKER_DB_NO_SPACE,
+       TRACKER_DB_CONSTRAINT,
 } TrackerDBInterfaceError;
 
 typedef enum {
diff --git a/src/libtracker-sparql/tracker-error.c b/src/libtracker-sparql/tracker-error.c
index 89e42c023..849aa87db 100644
--- a/src/libtracker-sparql/tracker-error.c
+++ b/src/libtracker-sparql/tracker-error.c
@@ -87,6 +87,7 @@ _translate_internal_error (GError *error)
                        /* This should never happen as we don't call sqlite3_interrupt()
                         * anywhere, so it doesn't get its own public error code. */
                        case TRACKER_DB_INTERRUPTED: new_code = TRACKER_SPARQL_ERROR_INTERNAL; break;
+                       case TRACKER_DB_CONSTRAINT: new_code = TRACKER_SPARQL_ERROR_CONSTRAINT; break;
                        default: g_warn_if_reached ();
                }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]