Changeset: 6e2f27fa0a11 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6e2f27fa0a11 Removed Files: ctest/tools/embedded/CMakeLists.txt ctest/tools/embedded/backup.c ctest/tools/embedded/example1.c ctest/tools/embedded/example2.c ctest/tools/embedded/example_append.c ctest/tools/embedded/example_blob.c ctest/tools/embedded/example_connections.c ctest/tools/embedded/example_decimals.c ctest/tools/embedded/example_temporal.c ctest/tools/embedded/mapi.c ctest/tools/embedded/mapi.h tools/embedded/CMakeLists.txt tools/embedded/monetdb_embedded.c tools/embedded/monetdb_embedded.h Modified Files: tools/CMakeLists.txt Branch: default Log Message:
remove old embedded code diffs (truncated from 2974 to 300 lines): diff --git a/ctest/tools/embedded/CMakeLists.txt b/ctest/tools/embedded/CMakeLists.txt deleted file mode 100644 --- a/ctest/tools/embedded/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -#[[ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. -#]] - -add_executable(example1 example1.c) -target_link_libraries(example1 - PRIVATE - monetdb_config_header - embedded) -add_test(run_example1 example1) - -add_executable(example2 example2.c) -target_link_libraries(example2 - PRIVATE - monetdb_config_header - embedded) -add_test(run_example2 example2) - -add_executable(example_temporal example_temporal.c) -target_link_libraries(example_temporal - PRIVATE - monetdb_config_header - embedded) -add_test(run_example_temporal example_temporal) - -add_executable(example_decimals example_decimals.c) -target_link_libraries(example_decimals - PRIVATE - monetdb_config_header - embedded) -add_test(run_example_decimals example_decimals) - -add_executable(example_blob example_blob.c) -target_link_libraries(example_blob - PRIVATE - monetdb_config_header - embedded) -add_test(run_example_blob example_blob) - -add_executable(example_append example_append.c) -target_link_libraries(example_append - PRIVATE - monetdb_config_header - embedded) -add_test(run_example_append example_append) - -add_executable(backup backup.c mapi.h mapi.c ../../../clients/mapiclient/dump.c) -target_include_directories(backup PUBLIC .) -target_link_libraries(backup - PRIVATE - monetdb_config_header - embedded - stream - matomic) -add_test(run_backup backup) - -add_executable(example_connections example_connections.c) -target_link_libraries(example_connections - PRIVATE - monetdb_config_header - embedded) -add_test(run_example_connections example_connections) - diff --git a/ctest/tools/embedded/backup.c b/ctest/tools/embedded/backup.c deleted file mode 100644 --- a/ctest/tools/embedded/backup.c +++ /dev/null @@ -1,47 +0,0 @@ - -#include "monetdb_config.h" -#include "stream.h" -#include "mstring.h" -#include <unistd.h> -#include <string.h> -#include <ctype.h> -#include "mapi.h" -#include <monetdb_embedded.h> - -extern int dump_database(Mapi mid, stream *toConsole, bool describe, bool useInserts); - -#define error(msg) {fprintf(stderr, "Failure: %s\n", msg); return -1;} - -int -main(void) -{ - char* err = NULL; - Mapi mid = (Mapi)malloc(sizeof(struct MapiStruct)); - - if ((mid->msg = monetdb_open(&mid->mdbe, NULL)) != NULL) - error(mid->msg); - - if ((err = monetdb_query(mid->mdbe, "CREATE TABLE test (b bool, t tinyint, s smallint, x integer, l bigint, " -#ifdef HAVE_HGE - "h hugeint, " -#else - "h bigint, " -#endif - "f float, d double, y string)", NULL, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mid->mdbe, "INSERT INTO test VALUES (TRUE, 42, 42, 42, 42, 42, 42.42, 42.42, 'Hello'), (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'World')", NULL, NULL)) != NULL) - error(err) - - /* open file stream */ - stream *fd = open_wastream("/tmp/backup"); - - if (dump_database(mid, fd, 0, 0)) { - if (mid->msg) - error(mid->msg) - fprintf(stderr, "database backup failed\n"); - } - close_stream(fd); - - if ((mid->msg = monetdb_close(mid->mdbe)) != NULL) - error(mid->msg); -} diff --git a/ctest/tools/embedded/example1.c b/ctest/tools/embedded/example1.c deleted file mode 100644 --- a/ctest/tools/embedded/example1.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. - */ - -#include "monetdb_embedded.h" -#include <stdlib.h> -#include <stdio.h> -#include <inttypes.h> - -#define error(msg) {fprintf(stderr, "Failure: %s\n", msg); return -1;} - -int -main(void) -{ - char* err = NULL; - monetdb_database mdbe = NULL; - monetdb_result* result = NULL; - - // second argument is a string for the db directory or NULL for in-memory mode - if ((err = monetdb_open(&mdbe, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "CREATE TABLE test (x integer, y string)", NULL, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "INSERT INTO test VALUES (42, 'Hello'), (NULL, 'World')", NULL, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "SELECT x, y FROM test; ", &result, NULL)) != NULL) - error(err) - - fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); - for (int64_t r = 0; r < result->nrows; r++) { - for (size_t c = 0; c < result->ncols; c++) { - monetdb_column* rcol; - if ((err = monetdb_result_fetch(result, &rcol, c)) != NULL) - error(err) - switch (rcol->type) { - case monetdb_int32_t: { - monetdb_column_int32_t * col = (monetdb_column_int32_t *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%d", col->data[r]); - } - break; - } - case monetdb_str: { - monetdb_column_str * col = (monetdb_column_str *) rcol; - if (col->is_null(col->data[r])) { - printf("NULL"); - } else { - printf("%s", (char*) col->data[r]); - } - break; - } - default: { - printf("UNKNOWN"); - } - } - - if (c + 1 < result->ncols) { - printf(", "); - } - } - printf("\n"); - } - - if ((err = monetdb_cleanup_result(mdbe, result)) != NULL) - error(err) - if ((err = monetdb_close(mdbe)) != NULL) - error(err) - return 0; -} diff --git a/ctest/tools/embedded/example2.c b/ctest/tools/embedded/example2.c deleted file mode 100644 --- a/ctest/tools/embedded/example2.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. - */ - -#include "monetdb_embedded.h" -#include <stdlib.h> -#include <stdio.h> -#include <inttypes.h> - -#define error(msg) {fprintf(stderr, "Failure: %s\n", msg); return -1;} - -int -main(void) -{ - char* err = NULL; - monetdb_database mdbe = NULL; - monetdb_result* result = NULL; - - // second argument is a string for the db directory or NULL for in-memory mode - if ((err = monetdb_open(&mdbe, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "CREATE TABLE test (b bool, t tinyint, s smallint, x integer, l bigint, " -#ifdef HAVE_HGE - "h hugeint, " -#else - "h bigint, " -#endif - "f float, d double, y string)", NULL, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "INSERT INTO test VALUES (TRUE, 42, 42, 42, 42, 42, 42.42, 42.42, 'Hello'), (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'World')", NULL, NULL)) != NULL) - error(err) - if ((err = monetdb_query(mdbe, "SELECT b, t, s, x, l, h, f, d, y FROM test; ", &result, NULL)) != NULL) - error(err) - - fprintf(stdout, "Query result with %zu cols and %"PRId64" rows\n", result->ncols, result->nrows); - for (int64_t r = 0; r < result->nrows; r++) { - for (size_t c = 0; c < result->ncols; c++) { - monetdb_column* rcol; - if ((err = monetdb_result_fetch(result, &rcol, c)) != NULL) - error(err) - switch (rcol->type) { - case monetdb_bool: { - monetdb_column_bool * col = (monetdb_column_bool *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%c", col->data[r]?'T':'F'); - } - break; - } - case monetdb_int8_t: { - monetdb_column_int8_t * col = (monetdb_column_int8_t *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%d", col->data[r]); - } - break; - } - case monetdb_int16_t: { - monetdb_column_int16_t * col = (monetdb_column_int16_t *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%d", col->data[r]); - } - break; - } - case monetdb_int32_t: { - monetdb_column_int32_t * col = (monetdb_column_int32_t *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%d", col->data[r]); - } - break; - } - case monetdb_int64_t: { - monetdb_column_int64_t * col = (monetdb_column_int64_t *) rcol; - if (col->data[r] == col->null_value) { - printf("NULL"); - } else { - printf("%" PRId64, col->data[r]); - } - break; - } -#ifdef HAVE_HGE _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
