const char sig[3] = {0x7f, 'D', 'W'};
-const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables", "Database not selected", "Parser fail"};
+const char* dw_errors[] = {"Success", "Used already", "File open fail", "Invalid signature", "Invalid version", "Parser returned NULL", "Cannot call non-method", "Unknown method", "Insufficient arguments", "Too many arguments", "Not used", "Too many tables", "Database not selected", "Parser fail", "Type mismatch"};
#ifdef M_I86
#define BUFSIZE 128
}
return errnum;
}
+
+char* dataworks_database_get_using_table(struct dataworks_db* db) { return db->name; }
#include <string.h>
#include <stdlib.h>
-const char* dataworks_version = "0.1.1";
+const char* dataworks_version = "0.1.2";
const char* dataworks_compile_date = __DATE__;
const char* dataworks_copyright = "Copyright (c) Crabware 2024\n"
" pnsk-lab 2024\n"
*
*/
DW_ERR_PARSER_FAIL,
+
+ /**
+ * @~english
+ * @brief Type mispatch
+ *
+ */
+ DW_ERR_EXEC_TYPE_MISMATCH,
};
/**
*/
void dataworks_database_set_table_count(struct dataworks_db* db, const char* table, uint64_t count);
+/**
+ * @~english
+ * @brief Get the using table name.
+ * @param db Database
+ *
+ */
+char* dataworks_database_get_using_table(struct dataworks_db* db);
+
#ifdef __cplusplus
}
#endif
newnode->string = __dw_strdup(dataworks_get_version());
used = true;
}
- if(node->nodes != NULL) {
+ if(node->nodes != NULL && !__dw_strcaseequ(node->ident, "insert")) {
for(i = 0; node->nodes[i] != NULL; i++) {
struct Node* r = parser_process(db, node->nodes[i], false);
if(r->errnum != DW_ERR_SUCCESS) {
newnode->errnum = DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS;
}
} else if(__dw_strcaseequ(node->ident, "insert")) {
+ for(i = 0; node->nodes[i] != NULL; i++)
+ ;
+
+ char** list = dataworks_database_get_table_fields(db, dataworks_database_get_using_table(db));
+
+ int count;
+ for(count = 0; list[count] != NULL; count++) free(list[count]);
+ free(list);
+
+ if(i < count) {
+ newnode->errnum = DW_ERR_EXEC_INSUFFICIENT_ARGUMENTS;
+ } else if(i > count) {
+ newnode->errnum = DW_ERR_EXEC_TOO_MANY_ARGUMENTS;
+ } else {
+ struct Node** arr = malloc(sizeof(*arr) * (i + 1));
+ for(i = 0; node->nodes[i] != NULL; i++) {
+ struct Node* r = parser_process(db, node->nodes[i], false);
+ arr[i] = r;
+ }
+ arr[i] = NULL;
+
+ for(i = 0; arr[i] != NULL; i++) {
+ __dw_free_node(arr[i]);
+ }
+ free(arr);
+ }
} else if(!used) {
newnode->errnum = DW_ERR_EXEC_UNKNOWN_METHOD;
}
# $Id$
pkgname='dataworks'
-pkgver='0.1.1'
+pkgver='0.1.2'
pkgdesc='Database System'
arch=('i686' 'x86_64')
license=('BSD')
-pkgrel='40'
+pkgrel='2'
makedepends=('byacc')
-source=('dataworks::svn+http://sw.nishi.boats/svn/nishi-dataworks/trunk#revision=418')
+source=('dataworks::svn+http://sw.nishi.boats/svn/nishi-dataworks/trunk#revision=437')
sha256sums=('SKIP')
build() {