Changeset: bf346a864fe4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/bf346a864fe4 Modified Files: gdk/gdk.h gdk/gdk_hash.c Branch: qcancel Log Message:
merge default diffs (truncated from 5996 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -224,8 +224,8 @@ gdk_return BUNappend(BAT *b, const void gdk_return BUNappendmulti(BAT *b, const void *values, BUN count, bool force) __attribute__((__warn_unused_result__)); gdk_return BUNdelete(BAT *b, oid o) __attribute__((__warn_unused_result__)); BUN BUNfnd(BAT *b, const void *right); -gdk_return BUNinplace(BAT *b, BUN p, const void *right, bool force) __attribute__((__warn_unused_result__)); gdk_return BUNreplace(BAT *b, oid left, const void *right, bool force) __attribute__((__warn_unused_result__)); +gdk_return BUNreplacemulti(BAT *b, const oid *positions, const void *values, BUN count, bool force) __attribute__((__warn_unused_result__)); BAT *COLcopy(BAT *b, int tt, bool writable, role_t role); BAT *COLnew(oid hseq, int tltype, BUN capacity, role_t role) __attribute__((__warn_unused_result__)); size_t GDK_mem_maxsize; diff --git a/clients/odbc/ChangeLog b/clients/odbc/ChangeLog new file mode 100644 --- /dev/null +++ b/clients/odbc/ChangeLog @@ -0,0 +1,13 @@ +# ChangeLog file for odbc +# This file is updated with Maddlog + +* Thu Mar 25 2021 Sjoerd Mullender <sjo...@acm.org> +- The ODBC driver now only passes on information about HUGEINT columns + as HUGEINT when the application has indicated interest by querying + about the SQL_HUGEINT extension type using the SQLGetTypeInfo + function or by specifying the type in a call to SQLSetDescField. + Otherwise the driver silently translates the HUGEINT type to BIGINT. + This means that most application will see BIGINT columns when the + server produced a HUGEINT column and only give an error if the value + in the HUGEINT column didn't fit into a BIGINT. + diff --git a/clients/odbc/driver/ODBCDbc.c b/clients/odbc/driver/ODBCDbc.c --- a/clients/odbc/driver/ODBCDbc.c +++ b/clients/odbc/driver/ODBCDbc.c @@ -53,40 +53,16 @@ newODBCDbc(ODBCEnv *env) addEnvError(env, "HY001", NULL, 0); return NULL; } - assert(dbc); - dbc->Env = env; - dbc->Error = NULL; - dbc->RetrievedErrors = 0; - - dbc->dsn = NULL; - dbc->uid = NULL; - dbc->pwd = NULL; - dbc->host = NULL; - dbc->port = 0; - dbc->dbname = NULL; - - dbc->Connected = false; - dbc->has_comment = false; - dbc->sql_attr_autocommit = SQL_AUTOCOMMIT_ON; /* default is autocommit */ - dbc->sql_attr_metadata_id = SQL_FALSE; - dbc->sql_attr_connection_timeout = 0; - dbc->mid = NULL; - dbc->major = 0; - dbc->minor = 0; - dbc->patch = 0; - dbc->cachelimit = 0; - dbc->qtimeout = 0; - dbc->Mdebug = 0; - - dbc->FirstStmt = NULL; - - /* add this dbc to start of the administrative linked dbc list */ - dbc->next = env->FirstDbc; + *dbc = (ODBCDbc) { + .Env = env, + .sql_attr_autocommit = SQL_AUTOCOMMIT_ON, /* default is autocommit */ + .sql_attr_metadata_id = SQL_FALSE, + /* add this dbc to start of the administrative linked dbc list */ + .next = env->FirstDbc, + .Type = ODBC_DBC_MAGIC_NR, /* set it valid */ + }; env->FirstDbc = dbc; - - dbc->Type = ODBC_DBC_MAGIC_NR; /* set it valid */ - return dbc; } diff --git a/clients/odbc/driver/ODBCDbc.h b/clients/odbc/driver/ODBCDbc.h --- a/clients/odbc/driver/ODBCDbc.h +++ b/clients/odbc/driver/ODBCDbc.h @@ -55,6 +55,7 @@ typedef struct tODBCDRIVERDBC { char *dbname; /* Database Name or NULL */ bool Connected; /* whether we are connecte to a server */ bool has_comment; /* whether the server has sys.comments */ + bool allow_hugeint; /* whether the application deals with HUGEINT */ SQLUINTEGER sql_attr_autocommit; SQLUINTEGER sql_attr_metadata_id; SQLUINTEGER sql_attr_connection_timeout; diff --git a/clients/odbc/driver/ODBCDesc.c b/clients/odbc/driver/ODBCDesc.c --- a/clients/odbc/driver/ODBCDesc.c +++ b/clients/odbc/driver/ODBCDesc.c @@ -30,22 +30,14 @@ newODBCDesc(ODBCDbc *dbc) addDbcError(dbc, "HY001", NULL, 0); return NULL; } - assert(desc); - desc->Dbc = dbc; - desc->Error = NULL; - desc->RetrievedErrors = 0; - desc->Stmt = NULL; - desc->descRec = NULL; - desc->sql_desc_alloc_type = SQL_DESC_ALLOC_USER; - desc->sql_desc_array_size = 1; - desc->sql_desc_array_status_ptr = NULL; - desc->sql_desc_bind_offset_ptr = NULL; - desc->sql_desc_bind_type = SQL_BIND_TYPE_DEFAULT; - desc->sql_desc_count = 0; - desc->sql_desc_rows_processed_ptr = NULL; - - desc->Type = ODBC_DESC_MAGIC_NR; /* set it valid */ + *desc = (ODBCDesc) { + .Dbc = dbc, + .sql_desc_alloc_type = SQL_DESC_ALLOC_USER, + .sql_desc_array_size = 1, + .sql_desc_bind_type = SQL_BIND_TYPE_DEFAULT, + .Type = ODBC_DESC_MAGIC_NR, /* set it valid */ + }; return desc; } diff --git a/clients/odbc/driver/ODBCEnv.c b/clients/odbc/driver/ODBCEnv.c --- a/clients/odbc/driver/ODBCEnv.c +++ b/clients/odbc/driver/ODBCEnv.c @@ -48,11 +48,9 @@ newODBCEnv(void) if (env == NULL) return NULL; - env->Error = NULL; - env->RetrievedErrors = 0; - env->FirstDbc = NULL; - env->Type = ODBC_ENV_MAGIC_NR; - env->sql_attr_odbc_version = 0; + *env = (ODBCEnv) { + .Type = ODBC_ENV_MAGIC_NR, + }; return env; } diff --git a/clients/odbc/driver/ODBCError.c b/clients/odbc/driver/ODBCError.c --- a/clients/odbc/driver/ODBCError.c +++ b/clients/odbc/driver/ODBCError.c @@ -239,11 +239,12 @@ newODBCError(const char *SQLState, const return &malloc_error; } + *error = (ODBCError) { + .nativeErrorCode = nativeCode, + }; + if (SQLState) { strcpy_len(error->sqlState, SQLState, sizeof(error->sqlState)); - } else { - /* initialize it with nulls */ - memset(error->sqlState, 0, sizeof(error->sqlState)); } if (msg) { @@ -258,14 +259,9 @@ newODBCError(const char *SQLState, const /* remove trailing newlines */ len = strlen(error->message); while (len > 0 && error->message[len - 1] == '\n') { - error->message[len - 1] = 0; - len--; + error->message[--len] = 0; } - } else { - error->message = NULL; } - error->nativeErrorCode = nativeCode; - error->next = NULL; return error; } diff --git a/clients/odbc/driver/ODBCStmt.c b/clients/odbc/driver/ODBCStmt.c --- a/clients/odbc/driver/ODBCStmt.c +++ b/clients/odbc/driver/ODBCStmt.c @@ -54,46 +54,42 @@ newODBCStmt(ODBCDbc *dbc) return NULL; } - stmt->Dbc = dbc; - stmt->Error = NULL; - stmt->RetrievedErrors = 0; + *stmt = (ODBCStmt) { + .Dbc = dbc, + .Error = NULL, + .RetrievedErrors = 0, + + .State = INITED, + .hdl = mapi_new_handle(dbc->mid), + .currentRow = 0, + .startRow = 0, + .rowSetSize = 0, + .queryid = -1, + .nparams = 0, + .querytype = -1, + .rowcount = 0, - stmt->State = INITED; - stmt->hdl = mapi_new_handle(dbc->mid); + .qtimeout = dbc->qtimeout, /* inherit query timeout */ + + .cursorType = SQL_CURSOR_FORWARD_ONLY, + .cursorScrollable = SQL_NONSCROLLABLE, + .retrieveData = SQL_RD_ON, + .noScan = SQL_NOSCAN_OFF, + + .ApplRowDescr = newODBCDesc(dbc), + .ApplParamDescr = newODBCDesc(dbc), + .ImplRowDescr = newODBCDesc(dbc), + .ImplParamDescr = newODBCDesc(dbc), + + .Type = ODBC_STMT_MAGIC_NR, /* set it valid */ + }; + if (stmt->hdl == NULL) { /* Memory allocation error */ addDbcError(dbc, "HY001", NULL, 0); - free(stmt); + destroyODBCStmt(stmt); return NULL; } - assert(stmt->hdl); - - stmt->currentRow = 0; - stmt->startRow = 0; - stmt->rowSetSize = 0; - stmt->queryid = -1; - stmt->nparams = 0; - stmt->querytype = -1; - stmt->rowcount = 0; - - stmt->qtimeout = dbc->qtimeout; /* inherit query timeout */ - - /* add this stmt to the administrative linked stmt list */ - stmt->next = dbc->FirstStmt; - dbc->FirstStmt = stmt; - - stmt->cursorType = SQL_CURSOR_FORWARD_ONLY; - stmt->cursorScrollable = SQL_NONSCROLLABLE; - stmt->retrieveData = SQL_RD_ON; - stmt->noScan = SQL_NOSCAN_OFF; - - stmt->ApplRowDescr = newODBCDesc(dbc); - stmt->ApplParamDescr = newODBCDesc(dbc); - stmt->ImplRowDescr = newODBCDesc(dbc); - stmt->ImplParamDescr = newODBCDesc(dbc); - stmt->AutoApplRowDescr = stmt->ApplRowDescr; - stmt->AutoApplParamDescr = stmt->ApplParamDescr; - if (stmt->ApplRowDescr == NULL || stmt->ApplParamDescr == NULL || stmt->ImplRowDescr == NULL || stmt->ImplParamDescr == NULL) { destroyODBCStmt(stmt); @@ -106,8 +102,12 @@ newODBCStmt(ODBCDbc *dbc) stmt->ImplParamDescr->sql_desc_alloc_type = SQL_DESC_ALLOC_AUTO; stmt->ImplRowDescr->Stmt = stmt; stmt->ImplParamDescr->Stmt = stmt; + stmt->AutoApplRowDescr = stmt->ApplRowDescr; + stmt->AutoApplParamDescr = stmt->ApplParamDescr; - stmt->Type = ODBC_STMT_MAGIC_NR; /* set it valid */ + /* add this stmt to the administrative linked stmt list */ + stmt->next = dbc->FirstStmt, + dbc->FirstStmt = stmt; return stmt; } diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c --- a/clients/odbc/driver/SQLExecute.c +++ b/clients/odbc/driver/SQLExecute.c @@ -228,6 +228,8 @@ ODBCInitResult(ODBCStmt *stmt) s = mapi_get_type(hdl, i); if (s == NULL) /* shouldn't happen */ s = ""; + if (!stmt->Dbc->allow_hugeint && strcmp(s, "hugeint") == 0) + s = "bigint"; if (rec->sql_desc_type_name) free(rec->sql_desc_type_name); rec->sql_desc_type_name = (SQLCHAR *) strdup(s); diff --git a/clients/odbc/driver/SQLGetTypeInfo.c b/clients/odbc/driver/SQLGetTypeInfo.c --- a/clients/odbc/driver/SQLGetTypeInfo.c +++ b/clients/odbc/driver/SQLGetTypeInfo.c @@ -1057,7 +1057,6 @@ MNDBGetTypeInfo(ODBCStmt *stmt, case SQL_VARBINARY: case SQL_LONGVARBINARY: case SQL_BIGINT: - case SQL_HUGEINT: case SQL_TINYINT: case SQL_BIT: case SQL_WCHAR: @@ -1079,6 +1078,12 @@ MNDBGetTypeInfo(ODBCStmt *stmt, case SQL_INTERVAL_MINUTE_TO_SECOND: break; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list