Example #1
0
__declspec(dllexport) const void * WINAPI sqlite3_column_database_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen)
{
  const void *pval = sqlite3_column_database_name16(stmt, iCol);
  *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0;
  return pval;
}
Example #2
0
static void DoTestStatement()
	{
	int err, val;
	sqlite_int64 val64;
	double dblval;
	const unsigned char* textval;
	const unsigned short* textval16;
	const unsigned char* blob;
	const char *coltype, *colname;
	const unsigned short *coltype16, *colname16;
	sqlite3* db;

	TEST(TheDb != 0);
	TEST(TheStmt != 0);
	
	val = sqlite3_column_count(TheStmt);
	TEST2(val, 5);
	
	db = sqlite3_db_handle(TheStmt);
	TEST2((unsigned int)db, (unsigned int)TheDb);
	
	err = sqlite3_step(TheStmt);
	TEST2(err, SQLITE_ROW);
	
#ifdef SQLITE_ENABLE_COLUMN_METADATA
	sqlite3_column_database_name(TheStmt, 0);
	sqlite3_column_database_name16(TheStmt, 1);
	sqlite3_column_table_name(TheStmt, 2);
	sqlite3_column_table_name16(TheStmt, 3);
	sqlite3_column_origin_name(TheStmt, 4);
	sqlite3_column_origin_name16(TheStmt, 0);
#endif	

	coltype = sqlite3_column_decltype(TheStmt, 0);
	TEST2(strcmp(coltype, "INTEGER"), 0);
	
	coltype16 = (const unsigned short*)sqlite3_column_decltype16(TheStmt, 2);
	TEST2(wcscmp(coltype16, L"REAL"), 0);

	colname = sqlite3_column_name(TheStmt, 1);
	TEST2(strcmp(colname, "F2"), 0);
	
	colname16 = (const unsigned short *)sqlite3_column_name16(TheStmt, 4);
	TEST2(wcscmp(colname16, L"F5"), 0);

	val = sqlite3_column_int(TheStmt, 0);
	TEST2(val, 1);
	
	val64 = sqlite3_column_int64(TheStmt, 1);
	TEST64(val64, 1234567891234LL);
	
	dblval = sqlite3_column_double(TheStmt, 2);
	TEST(dabs(dblval - 56.12) < 0.00001);

	textval = sqlite3_column_text(TheStmt, 3);
	TEST2(strcmp((const char*)textval, "TEXT"), 0);

	textval16 = sqlite3_column_text16(TheStmt, 3);
	TEST2(wcscmp(textval16, L"TEXT"), 0);

	blob = (const unsigned char*)sqlite3_column_blob(TheStmt, 4);
	TEST2(memcmp(blob, "123456", 6), 0);

	err = sqlite3_step(TheStmt);
	TEST2(err, SQLITE_DONE);
	}