Changeset: d4e2354d9215 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d4e2354d9215
Modified Files:
sql/backends/monet5/sql_cat.c
sql/storage/bat/bat_storage.c
sql/storage/store.c
Branch: Jan2022
Log Message:
Use strcmp instead of comparing pointers
diffs (100 lines):
diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -84,7 +84,7 @@ rel_check_tables(mvc *sql, sql_table *nt
if (nc->null != mc->null)
throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER
%s: to be added table column NULL check doesn't match %s definition", errtable,
errtable);
if (isRangePartitionTable(nt) || isListPartitionTable(nt)) {
- if ((!nc->def && mc->def) || (nc->def && !mc->def) ||
(nc->def && mc->def && strcmp(nc->def, mc->def) != 0))
+ if ((nc->def || mc->def) && (!nc->def || !mc->def ||
strcmp(nc->def, mc->def) != 0))
throw(SQL,"sql.rel_check_tables",SQLSTATE(3F000) "ALTER %s: to be added table
column DEFAULT value doesn't match %s definition", errtable, errtable);
}
}
@@ -1129,7 +1129,6 @@ alter_table(Client cntxt, mvc *sql, char
}
for (n = ol_first_node(t->columns); n; n = n->next) {
-
/* null or default value changes */
sql_column *c = n->data;
@@ -1180,7 +1179,7 @@ alter_table(Client cntxt, mvc *sql, char
throw(SQL,"sql.alter_table",
SQLSTATE(40002) "ALTER TABLE: NOT NULL constraint violated for column %s.%s",
c->t->base.name, c->base.name);
}
}
- if (c->def != nc->def) {
+ if ((c->def || nc->def) && (!c->def || !nc->def ||
strcmp(c->def, nc->def) != 0)) {
switch (mvc_default(sql, nc, c->def)) {
case -1:
throw(SQL,"sql.alter_table",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -1192,7 +1191,7 @@ alter_table(Client cntxt, mvc *sql, char
}
}
- if (c->storage_type != nc->storage_type) {
+ if ((c->storage_type || nc->storage_type) && (!c->storage_type
|| !nc->storage_type || strcmp(c->storage_type, nc->storage_type) != 0)) {
if (c->t->access == TABLE_WRITABLE)
throw(SQL,"sql.alter_table", SQLSTATE(40002)
"ALTER TABLE: SET STORAGE for column %s.%s only allowed on READ or INSERT ONLY
tables", c->t->base.name, c->base.name);
switch (mvc_storage(sql, nc, c->storage_type)) {
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -2515,20 +2515,18 @@ create_col(sql_trans *tr, sql_column *c)
if (!isNew(c) && !isTempTable(c->t)){
bat->cs.ts = tr->ts;
- if (c->storage_type) {
- if (strcmp(c->storage_type, "DICT")==0) {
- ok=load_cs(tr, &bat->cs, type, c->base.id);
-
- if (ok == LOG_OK) {
- sqlstore *store = tr->store;
- int bid =
logger_find_bat(store->logger, -c->base.id);
- if (!bid)
- return LOG_ERR;
- bat->cs.ebid = temp_dup(bid);
- bat->cs.st = ST_DICT;
- }
- return ok;
+ if (c->storage_type && strcmp(c->storage_type, "DICT") == 0) {
+ ok=load_cs(tr, &bat->cs, type, c->base.id);
+
+ if (ok == LOG_OK) {
+ sqlstore *store = tr->store;
+ int bid = logger_find_bat(store->logger,
-c->base.id);
+ if (!bid)
+ return LOG_ERR;
+ bat->cs.ebid = temp_dup(bid);
+ bat->cs.st = ST_DICT;
}
+ return ok;
}
return load_cs(tr, &bat->cs, type, c->base.id);
} else if (bat && bat->cs.bid && !isTempTable(c->t)) {
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -6103,10 +6103,7 @@ sql_trans_alter_default(sql_trans *tr, s
int res = LOG_OK;
sqlstore *store = tr->store;
- if (!col->def && !val)
- return res; /* no change */
-
- if (!col->def || !val || strcmp(col->def, val) != 0) {
+ if ((col->def || val) && (!col->def || !val || strcmp(col->def, val) !=
0)) {
void *p = val ? val : (void *) ATOMnilptr(TYPE_str);
sql_schema *syss = find_sql_schema(tr,
isGlobal(col->t)?"sys":"tmp");
sql_table *syscolumn = find_sql_table(tr, syss, "_columns");
@@ -6140,10 +6137,7 @@ sql_trans_alter_storage(sql_trans *tr, s
int res = LOG_OK;
sqlstore *store = tr->store;
- if (!col->storage_type && !storage)
- return res; /* no change */
-
- if (!col->storage_type || !storage || strcmp(col->storage_type,
storage) != 0) {
+ if ((col->storage_type || storage) && (!col->storage_type || !storage
|| strcmp(col->storage_type, storage) != 0)) {
void *p = storage ? storage : (void *) ATOMnilptr(TYPE_str);
sql_schema *syss = find_sql_schema(tr,
isGlobal(col->t)?"sys":"tmp");
sql_table *syscolumn = find_sql_table(tr, syss, "_columns");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list