src/SqlHandler.h
branchv_0
changeset 29 b0ef1e1dc9c8
parent 27 9441a517fa1f
child 33 86ceb97db7de
equal deleted inserted replaced
28:498d5d3406c3 29:b0ef1e1dc9c8
    25 #include <codecvt>
    25 #include <codecvt>
    26 #include <unistd.h>
    26 #include <unistd.h>
    27 #include <cassert>
    27 #include <cassert>
    28 #include <sys/stat.h>
    28 #include <sys/stat.h>
    29 
    29 
    30 #include <sqlite3.h>
       
    31 
       
    32 #include <relpipe/reader/typedefs.h>
    30 #include <relpipe/reader/typedefs.h>
    33 #include <relpipe/reader/TypeId.h>
    31 #include <relpipe/reader/TypeId.h>
    34 #include <relpipe/reader/handlers/RelationalReaderValueHandler.h>
    32 #include <relpipe/reader/handlers/RelationalReaderValueHandler.h>
    35 #include <relpipe/reader/handlers/AttributeMetadata.h>
    33 #include <relpipe/reader/handlers/AttributeMetadata.h>
    36 
    34 
    65 		sql->str(L"");
    63 		sql->str(L"");
    66 		sql->clear();
    64 		sql->clear();
    67 
    65 
    68 		for (wchar_t ch; *input >> ch;) {
    66 		for (wchar_t ch; *input >> ch;) {
    69 			*sql << ch;
    67 			*sql << ch;
    70 			if (ch == L';' && sqlite3_complete(convertor.to_bytes(sql->str()).c_str())) return true;
    68 			if (ch == L';' && PreparedStatement::isComplete(convertor.to_bytes(sql->str()).c_str())) return true;
    71 		}
    69 		}
    72 
    70 
    73 		string_t remainingSql = sql->str();
    71 		string_t remainingSql = sql->str();
    74 		for (wchar_t ch : remainingSql) if (ch != L' ' && ch != L'\n' && ch != L'\r' && ch != L'\t') throw SqlException(L"Unexpected EOF, missing „;“ after: „" + remainingSql + L"“");
    72 		for (wchar_t ch : remainingSql) if (ch != L' ' && ch != L'\n' && ch != L'\r' && ch != L'\t') throw SqlException(L"Unexpected EOF, missing „;“ after: „" + remainingSql + L"“");
    75 
    73