Changeset: c2efea211233 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/c2efea211233 Modified Files: sql/backends/monet5/rel_bin.c sql/include/sql_catalog.h sql/storage/store.c Branch: iso Log Message:
Merged with Jul2021 diffs (truncated from 112227 to 300 lines): diff --git a/clients/Tests/MAL-signatures.stable.out b/clients/Tests/MAL-signatures.stable.out --- a/clients/Tests/MAL-signatures.stable.out +++ b/clients/Tests/MAL-signatures.stable.out @@ -9207,7 +9207,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "analyze", "unsafe pattern sql.analyze(X_0:int, X_1:lng, X_2:str, X_3:str):void ", "sql_analyze;", "" ] [ "sql", "analyze", "unsafe pattern sql.analyze(X_0:int, X_1:lng, X_2:str, X_3:str, X_4:str):void ", "sql_analyze;", "" ] [ "sql", "any", "pattern sql.any(X_0:bit, X_1:bit, X_2:bit):bit ", "SQLany_cmp;", "" ] -[ "sql", "append", "pattern sql.append(X_0:int, X_1:str, X_2:str, X_3:str, X_4:lng, X_5:any):int ", "mvc_append_wrap;", "" ] +[ "sql", "append", "pattern sql.append(X_0:int, X_1:str, X_2:str, X_3:str, X_4:bat[:oid], X_5:any):int ", "mvc_append_wrap;", "" ] [ "sql", "argRecord", "pattern sql.argRecord():str ", "SQLargRecord;", "" ] [ "sql", "argRecord", "pattern sql.argRecord(X_0:any...):str ", "SQLargRecord;", "" ] [ "sql", "assert", "pattern sql.assert(X_0:bit, X_1:str):void ", "SQLassert;", "" ] @@ -9231,7 +9231,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int):bat[:any_1] ", "mvc_bind_idxbat_wrap;", "" ] [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int, X_5:int, X_6:int) (X_7:bat[:oid], X_8:bat[:any_1]) ", "mvc_bind_idxbat_wrap;", "" ] [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int, X_5:int, X_6:int):bat[:any_1] ", "mvc_bind_idxbat_wrap;", "" ] -[ "sql", "claim", "unsafe pattern sql.claim(X_0:int, X_1:str, X_2:str, X_3:lng):lng ", "mvc_claim_wrap;", "" ] +[ "sql", "claim", "unsafe pattern sql.claim(X_0:int, X_1:str, X_2:str, X_3:lng):bat[:oid] ", "mvc_claim_wrap;", "" ] [ "sql", "clear_table", "unsafe pattern sql.clear_table(X_0:str, X_1:str):lng ", "mvc_clear_table_wrap;", "" ] [ "sql", "commit", "unsafe pattern sql.commit():void ", "SQLcommit;", "" ] [ "sql", "copy_from", "unsafe pattern sql.copy_from(X_0:ptr, X_1:str, X_2:str, X_3:str, X_4:str, X_5:str, X_6:lng, X_7:lng, X_8:int, X_9:str, X_10:int, X_11:int):bat[:any]... ", "mvc_import_table_wrap;", "" ] @@ -9243,6 +9243,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "corr", "pattern sql.corr(X_0:int, X_1:int, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] [ "sql", "corr", "pattern sql.corr(X_0:lng, X_1:lng, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] [ "sql", "corr", "pattern sql.corr(X_0:sht, X_1:sht, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] +[ "sql", "count", "pattern sql.count(X_0:str, X_1:str):lng ", "SQLbasecount;", "" ] [ "sql", "count", "pattern sql.count(X_0:any_1, X_1:bit, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):lng ", "SQLcount;", "" ] [ "sql", "covariance", "pattern sql.covariance(X_0:bte, X_1:bte, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcovar_samp;", "" ] [ "sql", "covariance", "pattern sql.covariance(X_0:dbl, X_1:dbl, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcovar_samp;", "" ] diff --git a/clients/Tests/MAL-signatures.stable.out.int128 b/clients/Tests/MAL-signatures.stable.out.int128 --- a/clients/Tests/MAL-signatures.stable.out.int128 +++ b/clients/Tests/MAL-signatures.stable.out.int128 @@ -12508,7 +12508,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "analyze", "unsafe pattern sql.analyze(X_0:int, X_1:lng, X_2:str, X_3:str):void ", "sql_analyze;", "" ] [ "sql", "analyze", "unsafe pattern sql.analyze(X_0:int, X_1:lng, X_2:str, X_3:str, X_4:str):void ", "sql_analyze;", "" ] [ "sql", "any", "pattern sql.any(X_0:bit, X_1:bit, X_2:bit):bit ", "SQLany_cmp;", "" ] -[ "sql", "append", "pattern sql.append(X_0:int, X_1:str, X_2:str, X_3:str, X_4:lng, X_5:any):int ", "mvc_append_wrap;", "" ] +[ "sql", "append", "pattern sql.append(X_0:int, X_1:str, X_2:str, X_3:str, X_4:bat[:oid], X_5:any):int ", "mvc_append_wrap;", "" ] [ "sql", "argRecord", "pattern sql.argRecord():str ", "SQLargRecord;", "" ] [ "sql", "argRecord", "pattern sql.argRecord(X_0:any...):str ", "SQLargRecord;", "" ] [ "sql", "assert", "pattern sql.assert(X_0:bit, X_1:str):void ", "SQLassert;", "" ] @@ -12534,7 +12534,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int):bat[:any_1] ", "mvc_bind_idxbat_wrap;", "" ] [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int, X_5:int, X_6:int) (X_7:bat[:oid], X_8:bat[:any_1]) ", "mvc_bind_idxbat_wrap;", "" ] [ "sql", "bind_idxbat", "pattern sql.bind_idxbat(X_0:int, X_1:str, X_2:str, X_3:str, X_4:int, X_5:int, X_6:int):bat[:any_1] ", "mvc_bind_idxbat_wrap;", "" ] -[ "sql", "claim", "unsafe pattern sql.claim(X_0:int, X_1:str, X_2:str, X_3:lng):lng ", "mvc_claim_wrap;", "" ] +[ "sql", "claim", "unsafe pattern sql.claim(X_0:int, X_1:str, X_2:str, X_3:lng):bat[:oid] ", "mvc_claim_wrap;", "" ] [ "sql", "clear_table", "unsafe pattern sql.clear_table(X_0:str, X_1:str):lng ", "mvc_clear_table_wrap;", "" ] [ "sql", "commit", "unsafe pattern sql.commit():void ", "SQLcommit;", "" ] [ "sql", "copy_from", "unsafe pattern sql.copy_from(X_0:ptr, X_1:str, X_2:str, X_3:str, X_4:str, X_5:str, X_6:lng, X_7:lng, X_8:int, X_9:str, X_10:int, X_11:int):bat[:any]... ", "mvc_import_table_wrap;", "" ] @@ -12547,6 +12547,7 @@ stdout of test 'MAL-signatures` in direc [ "sql", "corr", "pattern sql.corr(X_0:int, X_1:int, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] [ "sql", "corr", "pattern sql.corr(X_0:lng, X_1:lng, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] [ "sql", "corr", "pattern sql.corr(X_0:sht, X_1:sht, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcorr;", "" ] +[ "sql", "count", "pattern sql.count(X_0:str, X_1:str):lng ", "SQLbasecount;", "" ] [ "sql", "count", "pattern sql.count(X_0:any_1, X_1:bit, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):lng ", "SQLcount;", "" ] [ "sql", "covariance", "pattern sql.covariance(X_0:bte, X_1:bte, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcovar_samp;", "" ] [ "sql", "covariance", "pattern sql.covariance(X_0:dbl, X_1:dbl, X_2:bit, X_3:bit, X_4:int, X_5:oid, X_6:oid):dbl ", "SQLcovar_samp;", "" ] 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 @@ -203,6 +203,7 @@ void BATtseqbase(BAT *b, oid o); void BATundo(BAT *b); BAT *BATunique(BAT *b, BAT *s); BAT *BATunmask(BAT *b); +gdk_return BATupdate(BAT *b, BAT *p, BAT *n, bool force) __attribute__((__warn_unused_result__)); BBPrec *BBP[N_BBPINIT]; gdk_return BBPaddfarm(const char *dirname, uint32_t rolemask, bool logerror); void BBPclear(bat bid); @@ -891,6 +892,7 @@ const char *columnRef; const char *comment_onRef; const char *commitRef; str compileString(Symbol *fcn, Client c, str s); +char *concatErrors(char *err1, const char *err2) __attribute__((__nonnull__(1, 2))) __attribute__((__returns_nonnull__)); const char *connectRef; const char *contextRef; str convertConstant(malType type, ValPtr vr); diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake --- a/cmake/monetdb-functions.cmake +++ b/cmake/monetdb-functions.cmake @@ -8,7 +8,15 @@ function(monetdb_hg_revision) # Get the current version control revision - if(EXISTS "${CMAKE_SOURCE_DIR}/.hg") + if(EXISTS "${CMAKE_SOURCE_DIR}/.hg_archival.txt") + execute_process(COMMAND "sed" "-n" "s/^node: \\([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]\\).*/\\1/p" ".hg_archival.txt" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE HG_RETURN_CODE + OUTPUT_VARIABLE HG_OUPUT_RES OUTPUT_STRIP_TRAILING_WHITESPACE) + if(HG_RETURN_CODE EQUAL 0 AND HG_OUPUT_RES) + set(MERCURIAL_ID "${HG_OUPUT_RES}" PARENT_SCOPE) + else() + message(FATAL_ERROR "Failed to find mercurial ID") + endif() + elseif(EXISTS "${CMAKE_SOURCE_DIR}/.hg") find_package(Hg) if(HG_FOUND) message("hg found: ${HG_EXECUTABLE}") diff --git a/ctest/tools/monetdbe/example_copy.c b/ctest/tools/monetdbe/example_copy.c --- a/ctest/tools/monetdbe/example_copy.c +++ b/ctest/tools/monetdbe/example_copy.c @@ -35,14 +35,14 @@ main(void) error(err) // Get working directory and construct the CSV path - if (getcwd(csv_path, sizeof(csv_path)) == NULL) { + if (getcwd(csv_path, sizeof(csv_path)) == NULL) { error("Could not get the current working directory"); - } + } strcat(csv_path, "/test.csv"); - strcpy(sql, "COPY SELECT * FROM test INTO '"); - strcat(sql, csv_path); - strcat(sql, "' USING DELIMITERS ','"); + strcpy(sql, "COPY SELECT * FROM test INTO '"); + strcat(sql, csv_path); + strcat(sql, "' USING DELIMITERS ','"); if ((err = monetdbe_query(mdbe, sql, NULL, NULL)) != NULL) error(err) @@ -54,8 +54,8 @@ main(void) memset(sql, 0, 1000); strcpy(sql, "COPY INTO test_copy FROM '"); - strcat(sql, csv_path); - strcat(sql, "' DELIMITERS ','"); + strcat(sql, csv_path); + strcat(sql, "' DELIMITERS ','"); if ((err = monetdbe_query(mdbe, sql, NULL, NULL)) != NULL) { delete_file(csv_path) @@ -74,6 +74,8 @@ main(void) delete_file(csv_path) + if ((err = monetdbe_cleanup_result(mdbe, result)) != NULL) + error(err) if (monetdbe_close(mdbe)) error("Failed to close database"); diff --git a/documentation/monetdbe/introduction.rst b/documentation/monetdbe/introduction.rst --- a/documentation/monetdbe/introduction.rst +++ b/documentation/monetdbe/introduction.rst @@ -49,7 +49,7 @@ A single library to be linked into the a . Full use of the multi-core architectures. . Seamless integration with the application. . Single user control over the resources. -. Working with :memory: databases with controlled RAM footprint. +. Working with in-memory databases with controlled RAM footprint. . Boosting your data analytics .. image:: architecture.png @@ -67,11 +67,11 @@ What to expect? --------------- The MonetDBe library supports three different storage schemes. -A light-weight scheme for small databases confined to main memory, i.e. connect(':memory:'). +A light-weight scheme for small databases confined to main memory, i.e. connect('in-memory'). The maximum footprint can be set explicitly or is derived from the host (VM) resource limits. Using a directory on your local machine is the way to go if you need persistence, but with exclusive access as it concerns ACID properties. If the application works -with :memory: or a local database then switching to a MonetDB server merely +with in-memory or a local database then switching to a MonetDB server merely requires the connect call to be provided with the access point information. The MonetDBe code is available from the development branch of MonetDB as an **alpha-release**.. diff --git a/documentation/monetdbe/monetdbe_api.rst b/documentation/monetdbe/monetdbe_api.rst --- a/documentation/monetdbe/monetdbe_api.rst +++ b/documentation/monetdbe/monetdbe_api.rst @@ -9,10 +9,10 @@ If all went well they return a NULL. Oth General considerations ---------------------- -There can be a single :memory: database or local persistent database open at a time. +There can be a single in-memory database or local persistent database open at a time. The database location should be passed as a full path. Relative paths are currently not supported. -As soon as you create a connection with another database, the content of the :memory: data store is lost. +As soon as you create a connection with another database, the content of the in-memory data store is lost. MonetDB/e can also be used as a proxy to a remote database. It is possible to have multiple such connections open. @@ -21,31 +21,33 @@ Data Types The API wraps the internal data types to those more convenient for programming directly in C. -| MonetDBe type | MonetDB internal type | -| ----------------------- | --------------------- | -| int8_t | bool| -| int8_t | int8_t| -| int16_t | int16_t| -| int32_t | int32_t| -| int64_t | int64_t| -| __int128 | int128_t| -| float | float| -| double | double| -| char * | str| -| monetdbe_data_blob | blob| -| monetdbe_data_date | date| -| monetdbe_data_time | time| -| monetdbe_data_timestamp | timestamp| -| ----------------------- | --------------------- | +======================= ===================== +MonetDBe type MonetDB internal type +======================= ===================== +int8_t bool +int8_t int8_t +int16_t int16_t +int32_t int32_t +int64_t int64_t +__int128 int128_t +float float +double double +char * str +monetdbe_data_blob blob +monetdbe_data_date date +monetdbe_data_time time +monetdbe_data_timestamp timestamp +======================= ===================== Connection and server options ----------------------------- .. c:function:: int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *options) - Initialize a monetdbe_database structure. The database of interest is denoted by an url and denote either ':memory:', /fullpath/directory, - mapi:monetdb://company.nl:50000/database. The latter refers to a MonetDB server location. - The :memory: and local path options lead to an exclusive lock on the database storage.. + Initialize a monetdbe_database structure. The database of interest is denoted by an url and denote either ``NULL``, /fullpath/directory, + mapi:monetdb://company.nl:50000/database. The latter refers to a + MonetDB server location. The value ``NULL`` denotes an in-memory database. + The ``NULL`` and local path options lead to an exclusive lock on the database storage. Opening the same database multiple times concurrently is allowed, but opening another one concurrently will throw an error for now. There may be multiple connections to multiple MonetDB servers. @@ -53,7 +55,7 @@ Connection and server options Close the database handler and release the resources for another database connection. From here on the connection can not be used anymore to pass queries and any pending result set is cleaned up. - Be aware that the content of an ':memory:' database is discarded. + Be aware that the content of an 'in-memory' database is discarded. Transaction management ---------------------- @@ -120,7 +122,7 @@ Backup and restore ------------------ .. c:function:: char* monetdbe_dump_database(monetdbe_database db, char *backupfile); - Dump a :memory: database as a collection of SQL statements on a local file + Dump a in-memory database as a collection of SQL statements on a local file .. c:function:: char* monetdbe_dump_table(monetdbe_database db, const char *schema_name, const char *table_name, const char *backupfile); @@ -128,7 +130,7 @@ Backup and restore .. c:function:: char* monetdbe_restore(monetdbe_database db, char *localfile); - [TODO] Restore a SQL dump to initialize the ':memory:' case. This is similar to loading a SQL script. + [TODO] Restore a SQL dump to initialize the 'in-memory' case. This is similar to loading a SQL script. Miscellaneous ------------- diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -972,6 +972,8 @@ gdk_export gdk_return BATdel(BAT *b, BAT gdk_export gdk_return BATreplace(BAT *b, BAT *p, BAT *n, bool force) __attribute__((__warn_unused_result__)); +gdk_export gdk_return BATupdate(BAT *b, BAT *p, BAT *n, bool force) + __attribute__((__warn_unused_result__)); /* Functions to perform a binary search on a sorted BAT. * See gdk_search.c for details. */ diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1090,8 +1090,8 @@ BATdel(BAT *b, BAT *d) * The last in this series is a BATreplace, which replaces all the * buns mentioned. */ -gdk_return -BATreplace(BAT *b, BAT *p, BAT *n, bool force) +static gdk_return +BATappend_or_update(BAT *b, BAT *p, BAT *n, bool mayappend, bool force) { lng t0 = GDKusec(); @@ -1116,12 +1116,14 @@ BATreplace(BAT *b, BAT *p, BAT *n, bool BATiter bi = bat_iterator(b); BATiter ni = bat_iterator(n); +#if 0 /* questionable: what if p point outside b, even if !mayappend? */ if (BATcount(b) == 0 || (b->tsorted && b->trevsorted && n->tsorted && n->trevsorted && ATOMcmp(b->ttype, BUNtail(bi, 0), BUNtail(ni, 0)) == 0)) { return GDK_SUCCEED; } +#endif _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list