Changeset: fbc4744cffb9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fbc4744cffb9
Modified Files:
        sql/backends/monet5/sql.c
        sql/server/rel_schema.c
Branch: Nov2019
Log Message:

Use SQLSTATE macro dor error codes


diffs (170 lines):

diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -282,7 +282,7 @@ create_table_or_view(mvc *sql, char* sna
        int check = 0;
 
        if (STORE_READONLY)
-               return sql_error(sql, 06, "25006!schema statements cannot be 
executed on a readonly database.");
+               return sql_error(sql, 06, SQLSTATE(25006) "schema statements 
cannot be executed on a readonly database.");
 
        if (!s)
                return sql_message(SQLSTATE(3F000) "CREATE %s: schema '%s' 
doesn't exist", (t->query) ? "TABLE" : "VIEW", sname);
@@ -472,11 +472,11 @@ create_table_from_emit(Client cntxt, cha
        if (!sname)
                sname = "sys";
        if (!(s = mvc_bind_schema(sql, sname))) {
-               msg = sql_error(sql, 02, "3F000!CREATE TABLE: no such schema 
'%s'", sname);
+               msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: no such 
schema '%s'", sname);
                goto cleanup;
        }
        if (!(t = mvc_create_table(sql, s, tname, tt_table, 0, 
SQL_DECLARED_TABLE, CA_COMMIT, -1, 0))) {
-               msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not create 
table '%s'", tname);
+               msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: could 
not create table '%s'", tname);
                goto cleanup;
        }
 
@@ -486,13 +486,13 @@ create_table_from_emit(Client cntxt, cha
                sql_column *col = NULL;
 
                if (!tpe) {
-                       msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not 
find type for column");
+                       msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: 
could not find type for column");
                        goto cleanup;
                }
 
                col = mvc_create_column(sql, t, columns[i].name, tpe);
                if (!col) {
-                       msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not 
create column %s", columns[i].name);
+                       msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: 
could not create column %s", columns[i].name);
                        goto cleanup;
                }
        }
@@ -502,7 +502,7 @@ create_table_from_emit(Client cntxt, cha
        }
        t = mvc_bind_table(sql, s, tname);
        if (!t) {
-               msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not bind 
table %s", tname);
+               msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: could 
not bind table %s", tname);
                goto cleanup;
        }
        for(i = 0; i < ncols; i++) {
@@ -511,7 +511,7 @@ create_table_from_emit(Client cntxt, cha
 
                col = mvc_bind_column(sql,t, columns[i].name);
                if (!col) {
-                       msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not 
bind column %s", columns[i].name);
+                       msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: 
could not bind column %s", columns[i].name);
                        goto cleanup;
                }
                msg = mvc_append_column(sql->session->tr, col, b);
@@ -552,12 +552,12 @@ append_to_table_from_emit(Client cntxt, 
        if (!sname)
                sname = "sys";
        if (!(s = mvc_bind_schema(sql, sname))) {
-               msg = sql_error(sql, 02, "3F000!CREATE TABLE: no such schema 
'%s'", sname);
+               msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: no such 
schema '%s'", sname);
                goto cleanup;
        }
        t = mvc_bind_table(sql, s, tname);
        if (!t) {
-               msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not bind 
table %s", tname);
+               msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: could 
not bind table %s", tname);
                goto cleanup;
        }
        for(i = 0; i < ncols; i++) {
@@ -566,7 +566,7 @@ append_to_table_from_emit(Client cntxt, 
 
                col = mvc_bind_column(sql,t, columns[i].name);
                if (!col) {
-                       msg = sql_error(sql, 02, "3F000!CREATE TABLE: could not 
bind column %s", columns[i].name);
+                       msg = sql_error(sql, 02, SQLSTATE(3F000) "CREATE TABLE: 
could not bind column %s", columns[i].name);
                        goto cleanup;
                }
                msg = mvc_append_column(sql->session->tr, col, b);
diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c
--- a/sql/server/rel_schema.c
+++ b/sql/server/rel_schema.c
@@ -2226,12 +2226,12 @@ current_or_designated_schema(mvc *sql, c
 
        s = mvc_bind_schema(sql, name);
        if (!s) {
-               sql_error(sql, 02, "3F000!COMMENT ON:no such schema: %s", name);
+               sql_error(sql, 02, SQLSTATE(3F000) "COMMENT ON:no such schema: 
%s", name);
                return NULL;
        }
 
        if (strcmp(s->base.name, "tmp") == 0) {
-               sql_error(sql, 2, "3F000!COMMENT ON tmp object not allowed");
+               sql_error(sql, 2, SQLSTATE(3F000) "COMMENT ON tmp object not 
allowed");
                return NULL;
        }
 
@@ -2246,7 +2246,7 @@ rel_find_designated_schema(mvc *sql, sym
        assert(sym->type == type_string);
        sname = sym->data.sval;
        if (!(s = mvc_bind_schema(sql, sname))) {
-               sql_error(sql, 02, "3F000!COMMENT ON:no such schema: %s", 
sname);
+               sql_error(sql, 02, SQLSTATE(3F000) "COMMENT ON:no such schema: 
%s", sname);
                return 0;
        }
 
@@ -2273,7 +2273,7 @@ rel_find_designated_table(mvc *sql, symb
                return t->base.id;
        }
 
-       sql_error(sql, 02, "42S02!COMMENT ON:no such %s: %s.%s",
+       sql_error(sql, 02, SQLSTATE(42S02) "COMMENT ON:no such %s: %s.%s",
                want_table ? "table" : "view",
                s->base.name, tname);
        return 0;
@@ -2306,11 +2306,11 @@ rel_find_designated_column(mvc *sql, sym
        if (!(s = current_or_designated_schema(sql, sname)))
                return 0;
        if (!(t = mvc_bind_table(sql, s, tname))) {
-               sql_error(sql, 02, "42S02!COMMENT ON:no such table: %s.%s", 
s->base.name, tname);
+               sql_error(sql, 02, SQLSTATE(42S02) "COMMENT ON:no such table: 
%s.%s", s->base.name, tname);
                return 0;
        }
        if (!(c = mvc_bind_column(sql, t, cname))) {
-               sql_error(sql, 02, "42S22!COMMENT ON:no such column: %s.%s", 
tname, cname);
+               sql_error(sql, 02, SQLSTATE(42S12) "COMMENT ON:no such column: 
%s.%s", tname, cname);
                return 0;
        }
        *schema_out = s;
@@ -2335,7 +2335,7 @@ rel_find_designated_index(mvc *sql, symb
                return idx->base.id;
        }
 
-       sql_error(sql, 02, "42S12!COMMENT ON:no such index: %s.%s",
+       sql_error(sql, 02, SQLSTATE(42S12) "COMMENT ON:no such index: %s.%s",
                s->base.name, iname);
        return 0;
 }
@@ -2360,7 +2360,7 @@ rel_find_designated_sequence(mvc *sql, s
                return seq->base.id;
        }
 
-       sql_error(sql, 02, "42000!COMMENT ON:no such sequence: %s.%s",
+       sql_error(sql, 02, SQLSTATE(42000) "COMMENT ON:no such sequence: %s.%s",
                s->base.name, seqname);
        return 0;
 }
@@ -2399,7 +2399,7 @@ rel_find_designated_routine(mvc *sql, sy
        }
 
        if (sql->errstr[0] == '\0')
-               sql_error(sql, 02, "42000!COMMENT ON:no such routine: %s.%s", 
s->base.name, fname);
+               sql_error(sql, 02, SQLSTATE(42000) "COMMENT ON:no such routine: 
%s.%s", s->base.name, fname);
        return 0;
 }
 
@@ -2426,7 +2426,7 @@ rel_find_designated_object(mvc *sql, sym
        case SQL_ROUTINE:
                return rel_find_designated_routine(sql, sym, schema_out);
        default:
-               sql_error(sql, 2, "42000!COMMENT ON %s is not supported", 
token2string(sym->token));
+               sql_error(sql, 2, SQLSTATE(42000) "COMMENT ON %s is not 
supported", token2string(sym->token));
                return 0;
        }
 }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to