ReactOS 0.4.16-dev-329-g9223134
db.c File Reference
#include <stdio.h>
#include <windows.h>
#include <objidl.h>
#include <msi.h>
#include <msidefs.h>
#include <msiquery.h>
#include "wine/test.h"
#include "utils.h"
Include dependency graph for db.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define check_record(rec, ...)   check_record_(__LINE__, rec, __VA_ARGS__)
 
#define add_component_entry(hdb, values)
 
#define add_custom_action_entry(hdb, values)
 
#define add_feature_components_entry(hdb, values)
 
#define add_std_dlls_entry(hdb, values)
 
#define add_binary_entry(hdb, values)
 
#define MY_NVIEWS   4000 /* Largest installer I've seen uses < 2000 */
 

Functions

static void WINAPIV check_record_ (int line, MSIHANDLE rec, UINT count,...)
 
static void test_msidatabase (void)
 
static UINT do_query (MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
 
static UINT run_queryW (MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query)
 
static UINT create_component_table (MSIHANDLE hdb)
 
static UINT create_custom_action_table (MSIHANDLE hdb)
 
static UINT create_directory_table (MSIHANDLE hdb)
 
static UINT create_feature_components_table (MSIHANDLE hdb)
 
static UINT create_std_dlls_table (MSIHANDLE hdb)
 
static UINT create_binary_table (MSIHANDLE hdb)
 
static UINT add_entry (const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
 
static void test_msiinsert (void)
 
static void test_msidecomposedesc (void)
 
static UINT try_query_param (MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec)
 
static UINT try_query (MSIHANDLE hdb, LPCSTR szQuery)
 
static UINT try_insert_query (MSIHANDLE hdb, LPCSTR szQuery)
 
static void test_msibadqueries (void)
 
static void test_viewmodify (void)
 
static MSIHANDLE create_db (void)
 
static void test_getcolinfo (void)
 
static MSIHANDLE get_column_info (MSIHANDLE hdb, const char *query, MSICOLINFO type)
 
static UINT get_columns_table_type (MSIHANDLE hdb, const char *table, UINT field)
 
static void test_viewgetcolumninfo (void)
 
static void test_msiexport (void)
 
static void test_longstrings (void)
 
static void test_streamtable (void)
 
static void test_binary (void)
 
static void test_where_not_in_selected (void)
 
static void test_where (void)
 
static void write_file (const CHAR *filename, const char *data, int data_size)
 
static UINT add_table_to_db (MSIHANDLE hdb, LPCSTR table_data)
 
static void test_suminfo_import (void)
 
static void test_msiimport (void)
 
static void test_binary_import (void)
 
static void test_markers (void)
 
static void test_handle_limit (void)
 
static void generate_transform (void)
 
static void generate_transform_manual (void)
 
static UINT set_summary_info (MSIHANDLE hdb)
 
static MSIHANDLE create_package_db (const WCHAR *filename)
 
static UINT package_from_db (MSIHANDLE hdb, MSIHANDLE *handle)
 
static void test_try_transform (void)
 
static void test_join (void)
 
static void test_temporary_table (void)
 
static void test_alter (void)
 
static void test_integers (void)
 
static void test_update (void)
 
static void test_special_tables (void)
 
static void test_tables_order (void)
 
static void test_rows_order (void)
 
static void test_collation (void)
 
static void test_select_markers (void)
 
static void test_viewmodify_update (void)
 
static void test_viewmodify_assign (void)
 
static void test_stringtable (void)
 
static void test_viewmodify_delete (void)
 
static void enum_stream_names (IStorage *stg)
 
static void test_defaultdatabase (void)
 
static void test_order (void)
 
static void test_viewmodify_delete_temporary (void)
 
static void test_deleterow (void)
 
static void test_quotes (void)
 
static void test_carriagereturn (void)
 
static void test_noquotes (void)
 
static void read_file_data (LPCSTR filename, LPSTR buffer)
 
static void test_forcecodepage (void)
 
static void test_viewmodify_refresh (void)
 
static void test_where_viewmodify (void)
 
static BOOL create_storage (LPCSTR name)
 
static void test_storages_table (void)
 
static void test_dbtopackage (void)
 
static void test_droptable (void)
 
static void test_dbmerge (void)
 
static void test_select_with_tablenames (void)
 
static void test_insertorder (void)
 
static void test_columnorder (void)
 
static void test_createtable (void)
 
static void test_embedded_nulls (void)
 
static void test_select_column_names (void)
 
static void test_primary_keys (void)
 
static void test_viewmodify_merge (void)
 
static void test_viewmodify_insert (void)
 
static void test_view_get_error (void)
 
static void test_viewfetch_wraparound (void)
 
 START_TEST (db)
 

Variables

static const charmsifile = "winetest-db.msi"
 
static const charmsifile2 = "winetst2-db.msi"
 
static const charmstfile = "winetst-db.mst"
 
static const WCHAR msifileW [] = L"winetest-db.msi"
 
static const WCHAR msifile2W [] = L"winetst2-db.msi"
 
static const CHAR test_data []
 
static const CHAR two_primary []
 
static const CHAR endlines1 []
 
static const CHAR endlines2 []
 
static const CHAR suminfo []
 
static const CHAR bin_import_dat []
 
static const WCHAR name1 [] = { 0x4840, 0x3a8a, 0x481b, 0 }
 
static const WCHAR name2 [] = { 0x4840, 0x3b3f, 0x43f2, 0x4438, 0x45b1, 0 }
 
static const WCHAR name3 [] = { 0x4840, 0x3f7f, 0x4164, 0x422f, 0x4836, 0 }
 
static const WCHAR name4 [] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }
 
static const WCHAR name5 [] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }
 
static const WCHAR name6 [] = { 0x4840, 0x3e16, 0x4818, 0}
 
static const WCHAR name7 [] = { 0x4840, 0x3c8b, 0x3a97, 0x409b, 0 }
 
static const WCHAR name8 [] = { 0x3c8b, 0x3a97, 0x409b, 0x387e, 0 }
 
static const WCHAR name9 [] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }
 
static const WCHAR data1 []
 
static const WCHAR data2 []
 
static const WCHAR data3 []
 
static const char data4 []
 
static const WCHAR data5 []
 
static const WCHAR data6 []
 
static const WCHAR data7 []
 
static const char data8 []
 
static const WCHAR data9 []
 
struct {
   LPCWSTR   name
 
   const void *   data
 
   DWORD   size
 
table_transform_data []
 
static const charjoin_res_first [][2]
 
static const charjoin_res_second [][2]
 
static const charjoin_res_third [][2]
 
static const charjoin_res_fourth [][2]
 
static const charjoin_res_fifth [][2]
 
static const charjoin_res_sixth [][2]
 
static const charjoin_res_seventh [][2]
 
static const charjoin_res_eighth [][4]
 
static const charjoin_res_ninth [][6]
 
static const WCHAR data10 []
 
static const WCHAR data11 []
 
static const char data12 []
 
static const WCHAR data13 []
 
static const WCHAR _Tables [] = {0x4840, 0x3f7f, 0x4164, 0x422f, 0x4836, 0}
 
static const WCHAR _StringData [] = {0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0}
 
static const WCHAR _StringPool [] = {0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0}
 
static const WCHAR data14 []
 
struct {
   LPCWSTR   name
 
   const void *   data
 
   DWORD   size
 
database_table_data []
 
static const CHAR import_dat []
 
static const UINT ordervals [6][3]
 

Macro Definition Documentation

◆ add_binary_entry

#define add_binary_entry (   hdb,
  values 
)
Value:
add_entry(__FILE__, __LINE__, "Binary", hdb, values, \
"INSERT INTO `Binary` (`Name`, `Data`) VALUES( %s )")
static UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
Definition: db.c:305
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 335 of file db.c.

◆ add_component_entry

#define add_component_entry (   hdb,
  values 
)
Value:
add_entry(__FILE__, __LINE__, "Component", hdb, values, \
"INSERT INTO `Component` " \
"(`Component`, `ComponentId`, `Directory_`, " \
"`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")

Definition at line 319 of file db.c.

◆ add_custom_action_entry

#define add_custom_action_entry (   hdb,
  values 
)
Value:
add_entry(__FILE__, __LINE__, "CustomAction", hdb, values, \
"INSERT INTO `CustomAction` " \
"(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")

Definition at line 324 of file db.c.

◆ add_feature_components_entry

#define add_feature_components_entry (   hdb,
  values 
)
Value:
add_entry(__FILE__, __LINE__, "FeatureComponents", hdb, values, \
"INSERT INTO `FeatureComponents` " \
"(`Feature_`, `Component_`) VALUES( %s )")

Definition at line 328 of file db.c.

◆ add_std_dlls_entry

#define add_std_dlls_entry (   hdb,
  values 
)
Value:
add_entry(__FILE__, __LINE__, "StdDlls", hdb, values, \
"INSERT INTO `StdDlls` (`File`, `Binary_`) VALUES( %s )")

Definition at line 332 of file db.c.

◆ check_record

#define check_record (   rec,
  ... 
)    check_record_(__LINE__, rec, __VA_ARGS__)

Definition at line 63 of file db.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file db.c.

◆ MY_NVIEWS

#define MY_NVIEWS   4000 /* Largest installer I've seen uses < 2000 */

Definition at line 2703 of file db.c.

Function Documentation

◆ add_entry()

static UINT add_entry ( const char file,
int  line,
const char type,
MSIHANDLE  hdb,
const char values,
const char insert 
)
inlinestatic

Definition at line 305 of file db.c.

306{
307 char *query;
308 UINT sz, r;
309
310 sz = strlen(values) + strlen(insert) + 1;
311 query = malloc(sz);
313 r = run_query(hdb, 0, query);
314 free(query);
315 ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r);
316 return r;
317}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok_(x1, x2)
Definition: atltest.h:61
static int run_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL recurse)
Definition: query.c:311
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int UINT
Definition: ndis.h:50
Definition: fci.c:127
Definition: parser.c:49
static int insert
Definition: xmllint.c:138

◆ add_table_to_db()

static UINT add_table_to_db ( MSIHANDLE  hdb,
LPCSTR  table_data 
)
static

Definition at line 2194 of file db.c.

2195{
2196 UINT r;
2197
2198 write_file("temp_file", table_data, (lstrlenA(table_data) - 1) * sizeof(char));
2199 r = MsiDatabaseImportA(hdb, CURR_DIR, "temp_file");
2200 DeleteFileA("temp_file");
2201
2202 return r;
2203}
static char CURR_DIR[MAX_PATH]
static void write_file(const CHAR *filename, const char *data, int data_size)
Definition: db.c:2184
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
UINT WINAPI MsiDatabaseImportA(MSIHANDLE handle, const char *szFolder, const char *szFilename)
Definition: database.c:863
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145

Referenced by test_msiimport(), and test_suminfo_import().

◆ check_record_()

static void WINAPIV check_record_ ( int  line,
MSIHANDLE  rec,
UINT  count,
  ... 
)
static

Definition at line 40 of file db.c.

41{
43 UINT i;
44
45 ok_(__FILE__, line)(count == MsiRecordGetFieldCount(rec),
46 "expected %u fields, got %u\n", count, MsiRecordGetFieldCount(rec));
47
49
50 for (i = 1; i <= count; ++i)
51 {
52 const char *expect = va_arg(args, const char *);
53 char buffer[200] = "x";
54 DWORD sz = sizeof(buffer);
55 UINT r = MsiRecordGetStringA(rec, i, buffer, &sz);
56 ok_(__FILE__, line)(r == ERROR_SUCCESS, "field %u: got unexpected error %u\n", i, r);
57 ok_(__FILE__, line)(!strcmp(buffer, expect),
58 "field %u: expected \"%s\", got \"%s\"\n", i, expect, buffer);
59 }
60
61 va_end(args);
62}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, char *szValue, DWORD *pcchValue)
Definition: record.c:403
UINT WINAPI MsiRecordGetFieldCount(MSIHANDLE handle)
Definition: record.c:113
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define args
Definition: format.c:66
Definition: match.c:390

◆ create_binary_table()

static UINT create_binary_table ( MSIHANDLE  hdb)
static

Definition at line 294 of file db.c.

295{
296 UINT r = run_query( hdb, 0,
297 "CREATE TABLE `Binary` ( "
298 "`Name` CHAR(72) NOT NULL, "
299 "`Data` CHAR(72) NOT NULL "
300 "PRIMARY KEY `Name` )" );
301 ok(r == ERROR_SUCCESS, "Failed to create Binary table: %u\n", r);
302 return r;
303}
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_join().

◆ create_component_table()

static UINT create_component_table ( MSIHANDLE  hdb)
static

Definition at line 232 of file db.c.

233{
234 UINT r = run_query( hdb, 0,
235 "CREATE TABLE `Component` ( "
236 "`Component` CHAR(72) NOT NULL, "
237 "`ComponentId` CHAR(38), "
238 "`Directory_` CHAR(72) NOT NULL, "
239 "`Attributes` SHORT NOT NULL, "
240 "`Condition` CHAR(255), "
241 "`KeyPath` CHAR(72) "
242 "PRIMARY KEY `Component`)" );
243 ok(r == ERROR_SUCCESS, "Failed to create Component table: %u\n", r);
244 return r;
245}

Referenced by test_join().

◆ create_custom_action_table()

static UINT create_custom_action_table ( MSIHANDLE  hdb)
static

Definition at line 247 of file db.c.

248{
249 UINT r = run_query( hdb, 0,
250 "CREATE TABLE `CustomAction` ( "
251 "`Action` CHAR(72) NOT NULL, "
252 "`Type` SHORT NOT NULL, "
253 "`Source` CHAR(72), "
254 "`Target` CHAR(255) "
255 "PRIMARY KEY `Action`)" );
256 ok(r == ERROR_SUCCESS, "Failed to create CustomAction table: %u\n", r);
257 return r;
258}

Referenced by test_dbtopackage().

◆ create_db()

static MSIHANDLE create_db ( void  )
static

Definition at line 1148 of file db.c.

1149{
1150 MSIHANDLE hdb = 0;
1151 UINT res;
1152
1154
1155 /* create an empty database */
1157 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
1158 if( res != ERROR_SUCCESS )
1159 return hdb;
1160
1161 res = MsiDatabaseCommit( hdb );
1162 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
1163
1164 return hdb;
1165}
static const WCHAR msifileW[]
Definition: db.c:37
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:298
GLuint res
Definition: glext.h:9613
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:962
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
unsigned long MSIHANDLE
Definition: winemsi.idl:27

Referenced by test_alter(), test_columnorder(), test_createtable(), test_getcolinfo(), test_handle_limit(), test_insertorder(), test_join(), test_markers(), test_order(), test_primary_keys(), test_select_markers(), test_select_with_tablenames(), test_storages_table(), test_streamtable(), test_temporary_table(), test_view_get_error(), test_viewgetcolumninfo(), test_viewmodify_insert(), test_viewmodify_merge(), test_where(), and test_where_not_in_selected().

◆ create_directory_table()

static UINT create_directory_table ( MSIHANDLE  hdb)
static

Definition at line 260 of file db.c.

261{
262 UINT r = run_query( hdb, 0,
263 "CREATE TABLE `Directory` ( "
264 "`Directory` CHAR(255) NOT NULL, "
265 "`Directory_Parent` CHAR(255), "
266 "`DefaultDir` CHAR(255) NOT NULL "
267 "PRIMARY KEY `Directory`)" );
268 ok(r == ERROR_SUCCESS, "Failed to create Directory table: %u\n", r);
269 return r;
270}

Referenced by create_package_db(), and test_dbtopackage().

◆ create_feature_components_table()

static UINT create_feature_components_table ( MSIHANDLE  hdb)
static

Definition at line 272 of file db.c.

273{
274 UINT r = run_query( hdb, 0,
275 "CREATE TABLE `FeatureComponents` ( "
276 "`Feature_` CHAR(38) NOT NULL, "
277 "`Component_` CHAR(72) NOT NULL "
278 "PRIMARY KEY `Feature_`, `Component_` )" );
279 ok(r == ERROR_SUCCESS, "Failed to create FeatureComponents table: %u\n", r);
280 return r;
281}

Referenced by test_join().

◆ create_package_db()

static MSIHANDLE create_package_db ( const WCHAR filename)
static

Definition at line 3002 of file db.c.

3003{
3004 MSIHANDLE hdb = 0;
3005 UINT res;
3006
3008
3009 /* create an empty database */
3011 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
3012 if( res != ERROR_SUCCESS )
3013 return hdb;
3014
3015 res = MsiDatabaseCommit( hdb );
3016 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
3017
3018 res = set_summary_info(hdb);
3019 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3020
3022
3023 return hdb;
3024}
static UINT set_summary_info(MSIHANDLE hdb)
Definition: db.c:2958
static UINT create_directory_table(MSIHANDLE hdb)
Definition: db.c:260
const char * filename
Definition: ioapi.h:137

◆ create_std_dlls_table()

static UINT create_std_dlls_table ( MSIHANDLE  hdb)
static

Definition at line 283 of file db.c.

284{
285 UINT r = run_query( hdb, 0,
286 "CREATE TABLE `StdDlls` ( "
287 "`File` CHAR(255) NOT NULL, "
288 "`Binary_` CHAR(72) NOT NULL "
289 "PRIMARY KEY `File` )" );
290 ok(r == ERROR_SUCCESS, "Failed to create StdDlls table: %u\n", r);
291 return r;
292}

Referenced by test_join().

◆ create_storage()

static BOOL create_storage ( LPCSTR  name)
static

Definition at line 7044 of file db.c.

7045{
7047 IStorage *stg;
7048 IStream *stm;
7049 HRESULT hr;
7050 DWORD count;
7051 BOOL res = FALSE;
7052
7056 if (FAILED(hr))
7057 return FALSE;
7058
7059 hr = IStorage_CreateStream(stg, nameW, STGM_WRITE | STGM_SHARE_EXCLUSIVE,
7060 0, 0, &stm);
7061 if (FAILED(hr))
7062 goto done;
7063
7064 hr = IStream_Write(stm, "stgdata", 8, &count);
7065 if (SUCCEEDED(hr))
7066 res = TRUE;
7067
7068done:
7069 IStream_Release(stm);
7070 IStorage_Release(stg);
7071
7072 return res;
7073}
static const WCHAR nameW[]
Definition: main.c:49
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8636
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define STGM_CREATE
Definition: objbase.h:926
#define STGM_DIRECT
Definition: objbase.h:914
#define STGM_READWRITE
Definition: objbase.h:919
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
#define STGM_WRITE
Definition: objbase.h:918
HRESULT hr
Definition: shlfolder.c:183
Definition: name.c:39
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ do_query()

static UINT do_query ( MSIHANDLE  hdb,
const char query,
MSIHANDLE phrec 
)
static

Definition at line 191 of file db.c.

192{
193 MSIHANDLE hview = 0;
194 UINT r, ret;
195
196 if (phrec)
197 *phrec = 0;
198
199 /* open a select query */
200 r = MsiDatabaseOpenViewA(hdb, query, &hview);
201 if (r != ERROR_SUCCESS)
202 return r;
203 r = MsiViewExecute(hview, 0);
204 if (r != ERROR_SUCCESS)
205 return r;
206 ret = MsiViewFetch(hview, phrec);
207 r = MsiViewClose(hview);
208 if (r != ERROR_SUCCESS)
209 return r;
210 r = MsiCloseHandle(hview);
211 if (r != ERROR_SUCCESS)
212 return r;
213 return ret;
214}
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:269
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:469
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:518
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, const char *szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:404
int ret

Referenced by test_alter(), test_binary(), test_binary_import(), test_columnorder(), test_dbmerge(), test_droptable(), test_embedded_nulls(), test_integers(), test_msiimport(), test_msiinsert(), test_temporary_table(), test_try_transform(), and test_where().

◆ enum_stream_names()

static void enum_stream_names ( IStorage stg)
static

Definition at line 5845 of file db.c.

5846{
5847 IEnumSTATSTG *stgenum = NULL;
5848 IStream *stm;
5849 HRESULT hr;
5850 STATSTG stat;
5851 ULONG n, count;
5854 DWORD sz;
5855
5856 memset(check, 'a', MAX_PATH);
5857
5858 hr = IStorage_EnumElements(stg, 0, NULL, 0, &stgenum);
5859 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5860
5861 n = 0;
5862 while(TRUE)
5863 {
5864 count = 0;
5865 hr = IEnumSTATSTG_Next(stgenum, 1, &stat, &count);
5866 if(FAILED(hr) || !count)
5867 break;
5868
5869 ok(!lstrcmpW(stat.pwcsName, database_table_data[n].name),
5870 "Expected table %lu name to match\n", n);
5871
5872 stm = NULL;
5873 hr = IStorage_OpenStream(stg, stat.pwcsName, NULL,
5874 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm);
5875 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5876 ok(stm != NULL, "Expected non-NULL stream\n");
5877
5878 CoTaskMemFree(stat.pwcsName);
5879
5880 sz = MAX_PATH;
5881 memset(data, 'a', MAX_PATH);
5882 hr = IStream_Read(stm, data, sz, &count);
5883 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5884
5886 "Expected %lu, got %lu\n", database_table_data[n].size, count);
5887
5889 ok(!memcmp(data, check, MAX_PATH), "data should not be changed\n");
5890 else
5892 "Expected table %lu data to match\n", n);
5893
5894 IStream_Release(stm);
5895 n++;
5896 }
5897
5898 ok(n == 3, "Expected 3, got %lu\n", n);
5899
5900 IEnumSTATSTG_Release(stgenum);
5901}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define stat
Definition: acwin.h:99
static const struct @1685 database_table_data[]
#define NULL
Definition: types.h:112
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
#define check(expected, result)
Definition: dplayx.c:32
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLdouble n
Definition: glext.h:7729
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define S_OK
Definition: intsafe.h:52
#define STGM_READ
Definition: objbase.h:917
#define memset(x, y, z)
Definition: compat.h:39
Definition: stat.h:55
uint32_t ULONG
Definition: typedefs.h:59
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_defaultdatabase().

◆ generate_transform()

static void generate_transform ( void  )
static

Definition at line 2743 of file db.c.

2744{
2745 MSIHANDLE hdb1, hdb2, hrec;
2746 LPCSTR query;
2747 UINT r;
2748
2749 /* start with two identical databases */
2751
2753 ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2754
2755 r = MsiDatabaseCommit( hdb1 );
2756 ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
2757
2759 ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2760
2761 /* the transform between two identical database should be empty */
2762 r = MsiDatabaseGenerateTransformA(hdb1, hdb2, NULL, 0, 0);
2763 todo_wine {
2764 ok( r == ERROR_NO_DATA, "return code %d, should be ERROR_NO_DATA\n", r );
2765 }
2766
2767 query = "CREATE TABLE `AAR` ( `BAR` SHORT NOT NULL, `CAR` CHAR(255) PRIMARY KEY `CAR`)";
2768 r = run_query(hdb1, 0, query);
2769 ok(r == ERROR_SUCCESS, "failed to add table\n");
2770
2771 query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 1, 'vw' )";
2772 r = run_query(hdb1, 0, query);
2773 ok(r == ERROR_SUCCESS, "failed to add row 1\n");
2774
2775 query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 2, 'bmw' )";
2776 r = run_query(hdb1, 0, query);
2777 ok(r == ERROR_SUCCESS, "failed to add row 2\n");
2778
2779 query = "UPDATE `MOO` SET `OOO` = 'c' WHERE `NOO` = 1";
2780 r = run_query(hdb1, 0, query);
2781 ok(r == ERROR_SUCCESS, "failed to modify row\n");
2782
2783 query = "DELETE FROM `MOO` WHERE `NOO` = 3";
2784 r = run_query(hdb1, 0, query);
2785 ok(r == ERROR_SUCCESS, "failed to delete row\n");
2786
2787 hrec = MsiCreateRecord(2);
2788 r = MsiRecordSetInteger(hrec, 1, 1);
2789 ok(r == ERROR_SUCCESS, "failed to set integer\n");
2790
2791 write_file("testdata.bin", "naengmyon", 9);
2792 r = MsiRecordSetStreamA(hrec, 2, "testdata.bin");
2793 ok(r == ERROR_SUCCESS, "failed to set stream\n");
2794
2795 query = "INSERT INTO `BINARY` ( `ID`, `BLOB` ) VALUES ( ?, ? )";
2796 r = run_query(hdb1, hrec, query);
2797 ok(r == ERROR_SUCCESS, "failed to add row with blob\n");
2798
2799 MsiCloseHandle(hrec);
2800
2801 query = "ALTER TABLE `MOO` ADD `COW` INTEGER";
2802 r = run_query(hdb1, 0, query);
2803 ok(r == ERROR_SUCCESS, "failed to add column\n");
2804
2805 query = "ALTER TABLE `MOO` ADD `PIG` INTEGER";
2806 r = run_query(hdb1, 0, query);
2807 ok(r == ERROR_SUCCESS, "failed to add column\n");
2808
2809 query = "UPDATE `MOO` SET `PIG` = 5 WHERE `NOO` = 1";
2810 r = run_query(hdb1, 0, query);
2811 ok(r == ERROR_SUCCESS, "failed to modify row\n");
2812
2813 query = "CREATE TABLE `Property` ( `Property` CHAR(72) NOT NULL, "
2814 "`Value` CHAR(0) PRIMARY KEY `Property`)";
2815 r = run_query(hdb1, 0, query);
2816 ok(r == ERROR_SUCCESS, "failed to add property table\n");
2817
2818 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2819 r = run_query(hdb1, 0, query);
2820 ok(r == ERROR_SUCCESS, "failed to add property\n");
2821
2822 /* database needs to be committed */
2823 MsiDatabaseCommit(hdb1);
2824
2825 r = MsiDatabaseGenerateTransformA(hdb1, hdb2, mstfile, 0, 0);
2826 ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r );
2827
2828 MsiCloseHandle( hdb1 );
2829 MsiCloseHandle( hdb2 );
2830
2831 DeleteFileA("testdata.bin");
2832}
static const WCHAR msifile2W[]
Definition: db.c:38
static const char * msifile2
Definition: db.c:35
static const char * msifile
Definition: db.c:34
static const char * mstfile
Definition: db.c:36
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
MSIHANDLE WINAPI MsiCreateRecord(UINT cParams)
Definition: record.c:92
UINT WINAPI MsiRecordSetInteger(MSIHANDLE handle, UINT iField, int iVal)
Definition: record.c:303
UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, UINT iField, const char *szFilename)
Definition: record.c:724
#define todo_wine
Definition: custom.c:89
UINT WINAPI MsiDatabaseGenerateTransformA(MSIHANDLE hdb, MSIHANDLE hdbref, const char *szTransformFile, int iReserved1, int iReserved2)
Definition: msiquery.c:948
#define MSIDBOPEN_TRANSACT
Definition: msiquery.h:67
#define MSIDBOPEN_READONLY
Definition: msiquery.h:66
#define ERROR_NO_DATA
Definition: winerror.h:284
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by test_try_transform().

◆ generate_transform_manual()

static void generate_transform_manual ( void  )
static

Definition at line 2917 of file db.c.

2918{
2919 IStorage *stg = NULL;
2920 IStream *stm;
2921 WCHAR name[0x20];
2922 HRESULT r;
2923 DWORD i, count;
2925
2926 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
2927
2928 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
2929
2930 r = StgCreateDocfile(name, mode, 0, &stg);
2931 ok(r == S_OK, "failed to create storage\n");
2932 if (!stg)
2933 return;
2934
2935 r = IStorage_SetClass( stg, &CLSID_MsiTransform );
2936 ok(r == S_OK, "failed to set storage type\n");
2937
2938 for (i=0; i<ARRAY_SIZE(table_transform_data); i++)
2939 {
2940 r = IStorage_CreateStream( stg, table_transform_data[i].name,
2941 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
2942 if (FAILED(r))
2943 {
2944 ok(0, "failed to create stream %#lx\n", r);
2945 continue;
2946 }
2947
2948 r = IStream_Write( stm, table_transform_data[i].data,
2951 ok(0, "failed to write stream\n");
2952 IStream_Release(stm);
2953 }
2954
2955 IStorage_Release(stg);
2956}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct @1684 table_transform_data[]
GLenum mode
Definition: glext.h:6217

Referenced by test_try_transform().

◆ get_column_info()

static MSIHANDLE get_column_info ( MSIHANDLE  hdb,
const char query,
MSICOLINFO  type 
)
static

Definition at line 1219 of file db.c.

1220{
1221 MSIHANDLE hview = 0, rec = 0;
1222 UINT r;
1223
1224 r = MsiDatabaseOpenViewA(hdb, query, &hview);
1225 if( r != ERROR_SUCCESS )
1226 return r;
1227
1228 r = MsiViewExecute(hview, 0);
1229 if( r == ERROR_SUCCESS )
1230 {
1231 MsiViewGetColumnInfo( hview, type, &rec );
1232 }
1233 MsiViewClose(hview);
1234 MsiCloseHandle(hview);
1235 return rec;
1236}
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
Definition: msiquery.c:641

Referenced by test_storages_table(), test_streamtable(), and test_viewgetcolumninfo().

◆ get_columns_table_type()

static UINT get_columns_table_type ( MSIHANDLE  hdb,
const char table,
UINT  field 
)
static

Definition at line 1238 of file db.c.

1239{
1240 MSIHANDLE hview = 0, rec = 0;
1241 UINT r, type = 0;
1242 char query[0x100];
1243
1244 sprintf(query, "select * from `_Columns` where `Table` = '%s'", table );
1245
1246 r = MsiDatabaseOpenViewA(hdb, query, &hview);
1247 if( r != ERROR_SUCCESS )
1248 return r;
1249
1250 r = MsiViewExecute(hview, 0);
1251 if( r == ERROR_SUCCESS )
1252 {
1253 while (1)
1254 {
1255 r = MsiViewFetch( hview, &rec );
1256 if( r != ERROR_SUCCESS)
1257 break;
1258 r = MsiRecordGetInteger( rec, 2 );
1259 if (r == field)
1260 type = MsiRecordGetInteger( rec, 4 );
1261 MsiCloseHandle( rec );
1262 }
1263 }
1264 MsiViewClose(hview);
1265 MsiCloseHandle(hview);
1266 return type;
1267}
int WINAPI MsiRecordGetInteger(MSIHANDLE handle, UINT iField)
Definition: record.c:237
Definition: parser.c:44

Referenced by test_viewgetcolumninfo().

◆ package_from_db()

static UINT package_from_db ( MSIHANDLE  hdb,
MSIHANDLE handle 
)
static

Definition at line 3026 of file db.c.

3027{
3028 UINT res;
3029 CHAR szPackage[12];
3030 MSIHANDLE hPackage;
3031
3032 sprintf(szPackage, "#%lu", hdb);
3033 res = MsiOpenPackageA(szPackage, &hPackage);
3034 if (res != ERROR_SUCCESS)
3035 return res;
3036
3037 res = MsiCloseHandle(hdb);
3038 if (res != ERROR_SUCCESS)
3039 {
3040 MsiCloseHandle(hPackage);
3041 return res;
3042 }
3043
3044 *handle = hPackage;
3045 return ERROR_SUCCESS;
3046}
UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
Definition: package.c:1664
char CHAR
Definition: xmlstorage.h:175

Referenced by test_try_transform().

◆ read_file_data()

static void read_file_data ( LPCSTR  filename,
LPSTR  buffer 
)
static

Definition at line 6753 of file db.c.

6754{
6755 HANDLE file;
6756 DWORD read;
6757
6762}
#define read
Definition: acwin.h:96
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define ZeroMemory
Definition: winbase.h:1737

Referenced by test_embedded_nulls(), and test_forcecodepage().

◆ run_queryW()

static UINT run_queryW ( MSIHANDLE  hdb,
MSIHANDLE  hrec,
const WCHAR query 
)
static

Definition at line 216 of file db.c.

217{
218 MSIHANDLE hview = 0;
219 UINT r;
220
221 r = MsiDatabaseOpenViewW(hdb, query, &hview);
222 if( r != ERROR_SUCCESS )
223 return r;
224
225 r = MsiViewExecute(hview, hrec);
226 if( r == ERROR_SUCCESS )
227 r = MsiViewClose(hview);
228 MsiCloseHandle(hview);
229 return r;
230}
UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, LPCWSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:236

Referenced by test_collation().

◆ set_summary_info()

static UINT set_summary_info ( MSIHANDLE  hdb)
static

Definition at line 2958 of file db.c.

2959{
2960 UINT res;
2962
2963 /* build summary info */
2965 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
2966
2968 "Installation Database");
2969 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2970
2972 "Installation Database");
2973 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2974
2976 "Wine Hackers");
2977 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2978
2980 ";1033,2057");
2981 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2982
2984 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
2985 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2986
2988 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2989
2991 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
2992
2994 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
2995
2997 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
2998
2999 return res;
3000}
static const CHAR suminfo[]
Definition: db.c:2166
@ VT_LPSTR
Definition: compat.h:2324
@ VT_I4
Definition: compat.h:2298
UINT WINAPI MsiSummaryInfoSetPropertyA(MSIHANDLE handle, UINT uiProperty, UINT uiDataType, INT iValue, FILETIME *pftValue, const char *szValue)
Definition: suminfo.c:942
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, const char *szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
Definition: suminfo.c:589
UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE handle)
Definition: suminfo.c:1227

Referenced by create_package_db(), and test_dbtopackage().

◆ START_TEST()

START_TEST ( db  )

Definition at line 9368 of file db.c.

9369{
9380 test_binary();
9382 test_where();
9385 test_markers();
9388 test_join();
9390 test_alter();
9391 test_integers();
9392 test_update();
9402 test_order();
9405 test_quotes();
9407 test_noquotes();
9414 test_dbmerge();
9428}
static void test_quotes(void)
Definition: db.c:6355
static void test_viewgetcolumninfo(void)
Definition: db.c:1269
static void test_deleterow(void)
Definition: db.c:6295
static void test_msiimport(void)
Definition: db.c:2328
static void test_integers(void)
Definition: db.c:4125
static void test_defaultdatabase(void)
Definition: db.c:5903
static void test_viewfetch_wraparound(void)
Definition: db.c:9286
static void test_update(void)
Definition: db.c:4234
static void test_getcolinfo(void)
Definition: db.c:1167
static void test_collation(void)
Definition: db.c:4755
static void test_temporary_table(void)
Definition: db.c:3818
static void test_noquotes(void)
Definition: db.c:6616
static void test_msiinsert(void)
Definition: db.c:338
static void test_handle_limit(void)
Definition: db.c:2704
static void test_viewmodify_delete_temporary(void)
Definition: db.c:6179
static void test_try_transform(void)
Definition: db.c:3048
static void test_where_viewmodify(void)
Definition: db.c:6943
static void test_binary_import(void)
Definition: db.c:2468
static void test_msidatabase(void)
Definition: db.c:65
static void test_viewmodify_update(void)
Definition: db.c:4980
static void test_suminfo_import(void)
Definition: db.c:2205
static void test_storages_table(void)
Definition: db.c:7075
static void test_primary_keys(void)
Definition: db.c:8771
static void test_viewmodify_delete(void)
Definition: db.c:5741
static void test_markers(void)
Definition: db.c:2519
static void test_select_markers(void)
Definition: db.c:4893
static void test_select_with_tablenames(void)
Definition: db.c:8046
static void test_binary(void)
Definition: db.c:1813
static void test_order(void)
Definition: db.c:5930
static void test_special_tables(void)
Definition: db.c:4503
static void test_viewmodify_insert(void)
Definition: db.c:9007
static void test_viewmodify_assign(void)
Definition: db.c:5238
static void test_tables_order(void)
Definition: db.c:4541
static void test_join(void)
Definition: db.c:3374
static void test_createtable(void)
Definition: db.c:8441
static void test_viewmodify_merge(void)
Definition: db.c:8810
static void test_columnorder(void)
Definition: db.c:8266
static void test_select_column_names(void)
Definition: db.c:8604
static void test_forcecodepage(void)
Definition: db.c:6764
static void test_stringtable(void)
Definition: db.c:5536
static void test_viewmodify_refresh(void)
Definition: db.c:6834
static void test_droptable(void)
Definition: db.c:7320
static void test_streamtable(void)
Definition: db.c:1490
static void test_where(void)
Definition: db.c:2019
static void test_rows_order(void)
Definition: db.c:4649
static void test_msidecomposedesc(void)
Definition: db.c:496
static void test_carriagereturn(void)
Definition: db.c:6447
static void test_msiexport(void)
Definition: db.c:1357
static void test_insertorder(void)
Definition: db.c:8130
static void test_msibadqueries(void)
Definition: db.c:632
static void test_longstrings(void)
Definition: db.c:1432
static void test_where_not_in_selected(void)
Definition: db.c:1927
static void test_dbtopackage(void)
Definition: db.c:7194
static void test_viewmodify(void)
Definition: db.c:851
static void test_view_get_error(void)
Definition: db.c:9171
static void test_embedded_nulls(void)
Definition: db.c:8539
static void test_dbmerge(void)
Definition: db.c:7490
static void test_alter(void)
Definition: db.c:3928

◆ test_alter()

static void test_alter ( void  )
static

Definition at line 3928 of file db.c.

3929{
3930 MSICONDITION cond;
3931 MSIHANDLE hdb = 0, rec;
3932 const char *query;
3933 UINT r;
3934
3935 hdb = create_db();
3936 ok( hdb, "failed to create db\n");
3937
3938 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`)";
3939 r = run_query(hdb, 0, query);
3940 ok(r == ERROR_SUCCESS, "failed to add table\n");
3941
3942 query = "SELECT * FROM `T`";
3943 r = run_query(hdb, 0, query);
3944 ok(r == ERROR_BAD_QUERY_SYNTAX, "expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
3945
3946 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`) HOLD";
3947 r = run_query(hdb, 0, query);
3948 ok(r == ERROR_SUCCESS, "failed to add table\n");
3949
3950 query = "SELECT * FROM `T`";
3951 r = run_query(hdb, 0, query);
3952 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", r);
3953
3954 cond = MsiDatabaseIsTablePersistentA(hdb, "T");
3955 ok( cond == MSICONDITION_FALSE, "wrong return condition\n");
3956
3957 query = "ALTER TABLE `T` HOLD";
3958 r = run_query(hdb, 0, query);
3959 ok(r == ERROR_SUCCESS, "failed to hold table %d\n", r);
3960
3961 query = "ALTER TABLE `T` FREE";
3962 r = run_query(hdb, 0, query);
3963 ok(r == ERROR_SUCCESS, "failed to free table\n");
3964
3965 query = "ALTER TABLE `T` FREE";
3966 r = run_query(hdb, 0, query);
3967 ok(r == ERROR_SUCCESS, "failed to free table\n");
3968
3969 query = "ALTER TABLE `T` FREE";
3970 r = run_query(hdb, 0, query);
3971 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to free table\n");
3972
3973 query = "ALTER TABLE `T` HOLD";
3974 r = run_query(hdb, 0, query);
3975 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to hold table %d\n", r);
3976
3977 /* table T is removed */
3978 query = "SELECT * FROM `T`";
3979 r = run_query(hdb, 0, query);
3980 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
3981
3982 /* create the table again */
3983 query = "CREATE TABLE `U` ( `A` INTEGER, `B` INTEGER PRIMARY KEY `B`)";
3984 r = run_query(hdb, 0, query);
3985 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3986
3987 /* up the ref count */
3988 query = "ALTER TABLE `U` HOLD";
3989 r = run_query(hdb, 0, query);
3990 ok(r == ERROR_SUCCESS, "failed to free table\n");
3991
3992 /* add column, no data type */
3993 query = "ALTER TABLE `U` ADD `C`";
3994 r = run_query(hdb, 0, query);
3995 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
3996
3997 query = "ALTER TABLE `U` ADD `C` INTEGER";
3998 r = run_query(hdb, 0, query);
3999 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4000
4001 query = "SELECT * FROM `_Columns` WHERE `Table` = 'U' AND `Name` = 'C'";
4002 r = do_query(hdb, query, &rec);
4003 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4004
4005 /* add column C again */
4006 query = "ALTER TABLE `U` ADD `C` INTEGER";
4007 r = run_query(hdb, 0, query);
4008 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4009
4010 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY";
4011 r = run_query(hdb, 0, query);
4012 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4013
4014 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 1, 2, 3, 4 )";
4015 r = run_query(hdb, 0, query);
4016 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4017
4018 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY HOLD";
4019 r = run_query(hdb, 0, query);
4020 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4021
4022 query = "SELECT * FROM `_Columns` WHERE `Table` = 'U' AND `Name` = 'D'";
4023 r = do_query(hdb, query, &rec);
4024 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
4025
4026 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 5, 6, 7, 8 )";
4027 r = run_query(hdb, 0, query);
4028 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4029
4030 query = "SELECT * FROM `U` WHERE `D` = 8";
4031 r = run_query(hdb, 0, query);
4032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4033
4034 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY FREE";
4035 r = run_query(hdb, 0, query);
4036 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4037
4038 query = "ALTER COLUMN `D` FREE";
4039 r = run_query(hdb, 0, query);
4040 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4041
4042 /* drop the ref count */
4043 query = "ALTER TABLE `U` FREE";
4044 r = run_query(hdb, 0, query);
4045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4046
4047 /* table is not empty */
4048 query = "SELECT * FROM `U`";
4049 r = run_query(hdb, 0, query);
4050 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4051
4052 /* column D is removed */
4053 query = "SELECT * FROM `U` WHERE `D` = 8";
4054 r = run_query(hdb, 0, query);
4055 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4056
4057 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 9, 10, 11, 12 )";
4058 r = run_query(hdb, 0, query);
4059 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4060
4061 /* add the column again */
4062 query = "ALTER TABLE `U` ADD `E` INTEGER TEMPORARY HOLD";
4063 r = run_query(hdb, 0, query);
4064 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4065
4066 /* up the ref count */
4067 query = "ALTER TABLE `U` HOLD";
4068 r = run_query(hdb, 0, query);
4069 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4070
4071 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 13, 14, 15, 16 )";
4072 r = run_query(hdb, 0, query);
4073 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4074
4075 query = "SELECT * FROM `U` WHERE `E` = 16";
4076 r = run_query(hdb, 0, query);
4077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4078
4079 /* drop the ref count */
4080 query = "ALTER TABLE `U` FREE";
4081 r = run_query(hdb, 0, query);
4082 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4083
4084 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 17, 18, 19, 20 )";
4085 r = run_query(hdb, 0, query);
4086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4087
4088 query = "SELECT * FROM `U` WHERE `E` = 20";
4089 r = run_query(hdb, 0, query);
4090 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4091
4092 /* drop the ref count */
4093 query = "ALTER TABLE `U` FREE";
4094 r = run_query(hdb, 0, query);
4095 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4096
4097 /* table still exists */
4098 query = "SELECT * FROM `U`";
4099 r = run_query(hdb, 0, query);
4100 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4101
4102 /* col E is removed */
4103 query = "SELECT * FROM `U` WHERE `E` = 20";
4104 r = run_query(hdb, 0, query);
4105 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4106
4107 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 20, 21, 22, 23 )";
4108 r = run_query(hdb, 0, query);
4109 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4110
4111 /* drop the ref count once more */
4112 query = "ALTER TABLE `U` FREE";
4113 r = run_query(hdb, 0, query);
4114 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4115
4116 /* table still exists */
4117 query = "SELECT * FROM `U`";
4118 r = run_query(hdb, 0, query);
4119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4120
4121 MsiCloseHandle( hdb );
4123}
static MSIHANDLE create_db(void)
Definition: db.c:1148
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
Definition: db.c:191
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
MSICONDITION WINAPI MsiDatabaseIsTablePersistentA(MSIHANDLE hDatabase, const char *szTableName)
Definition: msiquery.c:1146
@ MSICONDITION_FALSE
Definition: msiquery.h:26
int MSICONDITION
Definition: winemsi.idl:29
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by START_TEST().

◆ test_binary()

static void test_binary ( void  )
static

Definition at line 1813 of file db.c.

1814{
1815 MSIHANDLE hdb = 0, rec;
1816 char file[MAX_PATH];
1817 char buf[MAX_PATH];
1818 DWORD size;
1819 LPCSTR query;
1820 UINT r;
1821
1822 /* insert a file into the Binary table */
1824 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1825
1826 query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1827 r = run_query( hdb, 0, query );
1828 ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1829
1830 create_file( "test.txt", 0 );
1831 rec = MsiCreateRecord( 1 );
1832 r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1833 ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r);
1834 DeleteFileA( "test.txt" );
1835
1836 /* try a name that exceeds maximum OLE stream name length */
1837 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'encryption.dll.CB4E6205_F99A_4C51_ADD4_184506EFAB87', 10000, ? )";
1838 r = run_query( hdb, rec, query );
1839 ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1840
1841 r = MsiCloseHandle( rec );
1842 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1843
1844 r = MsiDatabaseCommit( hdb );
1845 ok( r == ERROR_FUNCTION_FAILED , "got %u\n", r );
1846
1847 r = MsiCloseHandle( hdb );
1848 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1849
1851 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1852
1853 query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1854 r = run_query( hdb, 0, query );
1855 ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1856
1857 create_file( "test.txt", 0 );
1858 rec = MsiCreateRecord( 1 );
1859 r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1860 ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r );
1861 DeleteFileA( "test.txt" );
1862
1863 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1864 r = run_query( hdb, rec, query );
1865 ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1866
1867 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1868 r = run_query( hdb, rec, query );
1869 ok( r == ERROR_FUNCTION_FAILED, "got %u\n", r );
1870
1871 r = MsiCloseHandle( rec );
1872 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1873
1874 r = MsiDatabaseCommit( hdb );
1875 ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
1876
1877 r = MsiCloseHandle( hdb );
1878 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1879
1880 /* read file from the Stream table */
1882 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1883
1884 query = "SELECT * FROM `_Streams`";
1885 r = do_query( hdb, query, &rec );
1886 ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1887
1888 size = MAX_PATH;
1889 r = MsiRecordGetStringA( rec, 1, file, &size );
1890 ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1891 ok( !lstrcmpA(file, "Binary.filename1.1"), "Expected 'Binary.filename1.1', got %s\n", file );
1892
1893 size = MAX_PATH;
1894 memset( buf, 0, MAX_PATH );
1895 r = MsiRecordReadStream( rec, 2, buf, &size );
1896 ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1897 ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got %s\n", buf );
1898
1899 r = MsiCloseHandle( rec );
1900 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1901
1902 /* read file from the Binary table */
1903 query = "SELECT * FROM `Binary`";
1904 r = do_query( hdb, query, &rec );
1905 ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1906
1907 size = MAX_PATH;
1908 r = MsiRecordGetStringA( rec, 1, file, &size );
1909 ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1910 ok( !lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file );
1911
1912 size = MAX_PATH;
1913 memset( buf, 0, MAX_PATH );
1914 r = MsiRecordReadStream( rec, 3, buf, &size );
1915 ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1916 ok( !lstrcmpA(buf, "test.txt"), "Expected 'test.txt', got %s\n", buf );
1917
1918 r = MsiCloseHandle( rec );
1919 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1920
1921 r = MsiCloseHandle( hdb );
1922 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1923
1925}
DWORD size
Definition: db.c:2903
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4195
UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, UINT iField, char *buf, DWORD *sz)
Definition: record.c:819
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define create_file(name, size)
Definition: asmcache.c:813
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985

Referenced by START_TEST().

◆ test_binary_import()

static void test_binary_import ( void  )
static

Definition at line 2468 of file db.c.

2469{
2470 MSIHANDLE hdb = 0, rec;
2471 char file[MAX_PATH];
2472 char buf[MAX_PATH];
2473 char path[MAX_PATH];
2474 DWORD size;
2475 LPCSTR query;
2476 UINT r;
2477
2478 /* create files to import */
2479 write_file("bin_import.idt", bin_import_dat,
2480 (sizeof(bin_import_dat) - 1) * sizeof(char));
2481 CreateDirectoryA("bin_import", NULL);
2482 create_file_data("bin_import/filename1.ibd", "just some words", 15);
2483
2484 /* import files into database */
2486 ok( r == ERROR_SUCCESS , "Failed to open database\n");
2487
2489 r = MsiDatabaseImportA(hdb, path, "bin_import.idt");
2490 ok(r == ERROR_SUCCESS , "Failed to import Binary table\n");
2491
2492 /* read file from the Binary table */
2493 query = "SELECT * FROM `Binary`";
2494 r = do_query(hdb, query, &rec);
2495 ok(r == ERROR_SUCCESS, "SELECT query failed: %d\n", r);
2496
2497 size = MAX_PATH;
2498 r = MsiRecordGetStringA(rec, 1, file, &size);
2499 ok(r == ERROR_SUCCESS, "Failed to get string: %d\n", r);
2500 ok(!lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file);
2501
2502 size = MAX_PATH;
2503 memset(buf, 0, MAX_PATH);
2504 r = MsiRecordReadStream(rec, 2, buf, &size);
2505 ok(r == ERROR_SUCCESS, "Failed to get stream: %d\n", r);
2506 ok(!lstrcmpA(buf, "just some words"), "Expected 'just some words', got %s\n", buf);
2507
2508 r = MsiCloseHandle(rec);
2509 ok(r == ERROR_SUCCESS , "Failed to close record handle\n");
2510
2511 r = MsiCloseHandle(hdb);
2512 ok(r == ERROR_SUCCESS , "Failed to close database\n");
2513
2514 DeleteFileA("bin_import/filename1.ibd");
2515 RemoveDirectoryA("bin_import");
2516 DeleteFileA("bin_import.idt");
2517}
static const CHAR bin_import_dat[]
Definition: db.c:2463
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
Definition: asmcache.c:795

Referenced by START_TEST().

◆ test_carriagereturn()

static void test_carriagereturn ( void  )
static

Definition at line 6447 of file db.c.

6448{
6449 MSIHANDLE hdb, hview, hrec;
6450 const char *query;
6451 UINT r;
6452
6454
6456 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6457
6458 query = "CREATE TABLE `Table`\r ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6459 r = run_query(hdb, 0, query);
6461 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6462
6463 query = "CREATE TABLE `Table` \r( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6464 r = run_query(hdb, 0, query);
6466 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6467
6468 query = "CREATE\r TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6469 r = run_query(hdb, 0, query);
6471 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6472
6473 query = "CREATE TABLE\r `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6474 r = run_query(hdb, 0, query);
6476 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6477
6478 query = "CREATE TABLE `Table` (\r `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6479 r = run_query(hdb, 0, query);
6481 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6482
6483 query = "CREATE TABLE `Table` ( `A`\r CHAR(72) NOT NULL PRIMARY KEY `A` )";
6484 r = run_query(hdb, 0, query);
6486 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6487
6488 query = "CREATE TABLE `Table` ( `A` CHAR(72)\r NOT NULL PRIMARY KEY `A` )";
6489 r = run_query(hdb, 0, query);
6491 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6492
6493 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT\r NULL PRIMARY KEY `A` )";
6494 r = run_query(hdb, 0, query);
6496 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6497
6498 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT \rNULL PRIMARY KEY `A` )";
6499 r = run_query(hdb, 0, query);
6501 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6502
6503 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL\r PRIMARY KEY `A` )";
6504 r = run_query(hdb, 0, query);
6506 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6507
6508 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL \rPRIMARY KEY `A` )";
6509 r = run_query(hdb, 0, query);
6511 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6512
6513 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY\r KEY `A` )";
6514 r = run_query(hdb, 0, query);
6516 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6517
6518 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY \rKEY `A` )";
6519 r = run_query(hdb, 0, query);
6521 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6522
6523 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY\r `A` )";
6524 r = run_query(hdb, 0, query);
6526 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6527
6528 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A`\r )";
6529 r = run_query(hdb, 0, query);
6531 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6532
6533 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )\r";
6534 r = run_query(hdb, 0, query);
6536 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6537
6538 query = "CREATE TABLE `\rOne` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6539 r = run_query(hdb, 0, query);
6540 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6541
6542 query = "CREATE TABLE `Tw\ro` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6543 r = run_query(hdb, 0, query);
6544 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6545
6546 query = "CREATE TABLE `Three\r` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6547 r = run_query(hdb, 0, query);
6548 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6549
6550 query = "CREATE TABLE `Four` ( `A\r` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6551 r = run_query(hdb, 0, query);
6553 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6554
6555 query = "CREATE TABLE `Four` ( `\rA` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6556 r = run_query(hdb, 0, query);
6558 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6559
6560 query = "CREATE TABLE `Four` ( `A` CHAR(72\r) NOT NULL PRIMARY KEY `A` )";
6561 r = run_query(hdb, 0, query);
6563 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6564
6565 query = "CREATE TABLE `Four` ( `A` CHAR(\r72) NOT NULL PRIMARY KEY `A` )";
6566 r = run_query(hdb, 0, query);
6568 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6569
6570 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `\rA` )";
6571 r = run_query(hdb, 0, query);
6573 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6574
6575 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6576 r = run_query(hdb, 0, query);
6578 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6579
6580 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6581 r = run_query(hdb, 0, query);
6583 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6584
6585 query = "SELECT `Name` FROM `_Tables`";
6586 r = MsiDatabaseOpenViewA(hdb, query, &hview);
6587 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6588 r = MsiViewExecute(hview, 0);
6589 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6590
6591 r = MsiViewFetch(hview, &hrec);
6592 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6593 check_record(hrec, 1, "\rOne");
6594 MsiCloseHandle(hrec);
6595
6596 r = MsiViewFetch(hview, &hrec);
6597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6598 check_record(hrec, 1, "Tw\ro");
6599 MsiCloseHandle(hrec);
6600
6601 r = MsiViewFetch(hview, &hrec);
6602 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6603 check_record(hrec, 1, "Three\r");
6604 MsiCloseHandle(hrec);
6605
6606 r = MsiViewFetch(hview, &hrec);
6607 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6608
6609 MsiViewClose(hview);
6610 MsiCloseHandle(hview);
6611
6612 MsiCloseHandle(hdb);
6614}
#define check_record(rec,...)
Definition: db.c:63

Referenced by START_TEST().

◆ test_collation()

static void test_collation ( void  )
static

Definition at line 4755 of file db.c.

4756{
4757 const char *query;
4758 MSIHANDLE hdb = 0, hview = 0, hrec = 0;
4759 UINT r;
4760 char buffer[100];
4761 WCHAR bufferW[100];
4762 DWORD sz;
4763
4765 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
4766
4767 query = "CREATE TABLE `bar` ( "
4768 "`foo` LONGCHAR NOT NULL, "
4769 "`baz` LONGCHAR NOT NULL "
4770 "PRIMARY KEY `foo` )";
4771 r = run_query(hdb, 0, query);
4772 ok(r == ERROR_SUCCESS, "failed to create table\n");
4773
4774 r = run_query(hdb, 0, query);
4775 ok(r == ERROR_BAD_QUERY_SYNTAX, "wrong error %u\n", r);
4776
4777 r = run_query(hdb, 0, "INSERT INTO `bar` "
4778 "( `foo`, `baz` ) VALUES ( '\2', 'A' )");
4779 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4780
4781 r = run_query(hdb, 0, "INSERT INTO `bar` "
4782 "( `foo`, `baz` ) VALUES ( '\1', 'B' )");
4783 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4784
4785 r = run_queryW(hdb, 0, L"INSERT INTO `bar` (`foo`,`baz`) VALUES ('a\x30a','C')");
4786 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4787
4788 r = run_queryW(hdb, 0, L"INSERT INTO `bar` (`foo`,`baz`) VALUES ('\xe5','D')");
4789 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4790
4791 r = run_queryW(hdb, 0, L"CREATE TABLE `baz` ( `a\x30a` LONGCHAR NOT NULL, `\xe5` LONGCHAR NOT NULL PRIMARY KEY `a\x30a`)");
4792 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4793
4794 r = run_queryW(hdb, 0, L"CREATE TABLE `a\x30a` ( `foo` LONGCHAR NOT NULL PRIMARY KEY `foo`)");
4795 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4796
4797 r = run_queryW(hdb, 0, L"CREATE TABLE `\xe5` ( `foo` LONGCHAR NOT NULL PRIMARY KEY `foo`)");
4798 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4799
4800 query = "SELECT * FROM `bar`";
4801 r = MsiDatabaseOpenViewA(hdb, query, &hview);
4802 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4803 r = MsiViewExecute(hview, 0);
4804 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4805
4806 r = MsiViewFetch(hview, &hrec);
4807 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4808 sz = sizeof(buffer);
4809 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
4810 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4811 ok(!lstrcmpA(buffer, "\2"), "Expected \\2, got '%s'\n", buffer);
4812 sz = sizeof(buffer);
4813 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
4814 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4815 ok(!lstrcmpA(buffer, "A"), "Expected A, got '%s'\n", buffer);
4816 MsiCloseHandle(hrec);
4817
4818 r = MsiViewFetch(hview, &hrec);
4819 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4820 sz = sizeof(buffer);
4821 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
4822 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4823 ok(!lstrcmpA(buffer, "\1"), "Expected \\1, got '%s'\n", buffer);
4824 sz = sizeof(buffer);
4825 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
4826 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4827 ok(!lstrcmpA(buffer, "B"), "Expected B, got '%s'\n", buffer);
4828 MsiCloseHandle(hrec);
4829
4830 r = MsiViewFetch(hview, &hrec);
4831 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4832 sz = ARRAY_SIZE(bufferW);
4833 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4835 ok(!memcmp(bufferW, L"a\x30a", sizeof(L"a\x30a")),
4836 "Expected %s, got %s\n", wine_dbgstr_w(L"a\x30a"), wine_dbgstr_w(bufferW));
4837 sz = ARRAY_SIZE(bufferW);
4838 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4840 ok(!lstrcmpW(bufferW, L"C"), "Expected C, got %s\n", wine_dbgstr_w(bufferW));
4841 MsiCloseHandle(hrec);
4842
4843 r = MsiViewFetch(hview, &hrec);
4844 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4845 sz = ARRAY_SIZE(bufferW);
4846 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4848 ok(!memcmp(bufferW, L"\xe5", sizeof(L"\xe5")),
4849 "Expected %s, got %s\n", wine_dbgstr_w(L"\xe5"), wine_dbgstr_w(bufferW));
4850 sz = ARRAY_SIZE(bufferW);
4851 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4852 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4853 ok(!lstrcmpW(bufferW, L"D"), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
4854 MsiCloseHandle(hrec);
4855
4856 r = MsiViewClose(hview);
4857 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4858 r = MsiCloseHandle(hview);
4859 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4860
4861 r = MsiDatabaseOpenViewW(hdb, L"SELECT * FROM `bar` WHERE `foo` ='\xe5'", &hview);
4862 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4863 r = MsiViewExecute(hview, 0);
4864 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4865
4866 r = MsiViewFetch(hview, &hrec);
4867 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4868 sz = ARRAY_SIZE(bufferW);
4869 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4871 ok(!memcmp(bufferW, L"\xe5", sizeof(L"\xe5")),
4872 "Expected %s, got %s\n", wine_dbgstr_w(L"\xe5"), wine_dbgstr_w(bufferW));
4873 sz = ARRAY_SIZE(bufferW);
4874 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4875 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4876 ok(!lstrcmpW(bufferW, L"D"), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
4877 MsiCloseHandle(hrec);
4878
4879 r = MsiViewFetch(hview, &hrec);
4880 ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
4881
4882 r = MsiViewClose(hview);
4883 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4884 r = MsiCloseHandle(hview);
4885 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4886
4887 r = MsiCloseHandle(hdb);
4888 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4889
4891}
static UINT run_queryW(MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query)
Definition: db.c:216
UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, UINT iField, WCHAR *szValue, DWORD *pcchValue)
Definition: record.c:482
#define wine_dbgstr_w
Definition: kernel32.h:34
#define L(x)
Definition: ntvdm.h:50

Referenced by START_TEST().

◆ test_columnorder()

static void test_columnorder ( void  )
static

Definition at line 8266 of file db.c.

8267{
8268 MSIHANDLE hdb, view, rec;
8269 LPCSTR query;
8270 UINT r;
8271
8272 hdb = create_db();
8273 ok(hdb, "failed to create db\n");
8274
8275 /* Each column is a slot:
8276 * ---------------------
8277 * | B | C | A | E | D |
8278 * ---------------------
8279 *
8280 * When a column is selected as a primary key,
8281 * the column occupying the nth primary key slot is swapped
8282 * with the current position of the primary key in question:
8283 *
8284 * set primary key `D`
8285 * --------------------- ---------------------
8286 * | B | C | A | E | D | -> | D | C | A | E | B |
8287 * --------------------- ---------------------
8288 *
8289 * set primary key `E`
8290 * --------------------- ---------------------
8291 * | D | C | A | E | B | -> | D | E | A | C | B |
8292 * --------------------- ---------------------
8293 */
8294
8295 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
8296 "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
8297 "PRIMARY KEY `D`, `E`)";
8298 r = run_query(hdb, 0, query);
8299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8300
8301 query = "SELECT * FROM `T`";
8302 r = MsiDatabaseOpenViewA(hdb, query, &view);
8303 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8304
8306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8307 check_record(rec, 5, "s255", "I2", "S255", "i2", "i2");
8308 MsiCloseHandle(rec);
8309
8311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8312 check_record(rec, 5, "D", "E", "A", "C", "B");
8313 MsiCloseHandle(rec);
8314
8317
8318 query = "INSERT INTO `T` ( `B`, `C`, `A`, `E`, `D` ) "
8319 "VALUES ( 1, 2, 'a', 3, 'bc' )";
8320 r = run_query(hdb, 0, query);
8321 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8322
8323 query = "SELECT * FROM `T`";
8324 r = do_query(hdb, query, &rec);
8325 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8326 check_record(rec, 5, "bc", "3", "a", "2", "1");
8327 MsiCloseHandle(rec);
8328
8329 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'T'";
8330 r = MsiDatabaseOpenViewA(hdb, query, &view);
8331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8332 r = MsiViewExecute(view, 0);
8333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8334
8335 r = MsiViewFetch(view, &rec);
8336 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8337 check_record(rec, 3, "T", "1", "D");
8338 MsiCloseHandle(rec);
8339
8340 r = MsiViewFetch(view, &rec);
8341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8342 check_record(rec, 3, "T", "2", "E");
8343 MsiCloseHandle(rec);
8344
8345 r = MsiViewFetch(view, &rec);
8346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8347 check_record(rec, 3, "T", "3", "A");
8348 MsiCloseHandle(rec);
8349
8350 r = MsiViewFetch(view, &rec);
8351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8352 check_record(rec, 3, "T", "4", "C");
8353 MsiCloseHandle(rec);
8354
8355 r = MsiViewFetch(view, &rec);
8356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8357 check_record(rec, 3, "T", "5", "B");
8358 MsiCloseHandle(rec);
8359
8360 r = MsiViewFetch(view, &rec);
8361 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8362
8365
8366 query = "CREATE TABLE `Z` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
8367 "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
8368 "PRIMARY KEY `C`, `A`, `D`)";
8369 r = run_query(hdb, 0, query);
8370 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8371
8372 query = "SELECT * FROM `Z`";
8373 r = MsiDatabaseOpenViewA(hdb, query, &view);
8374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8375
8377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8378 check_record(rec, 5, "i2", "S255", "s255", "I2", "i2");
8379 MsiCloseHandle(rec);
8380
8382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8383 check_record(rec, 5, "C", "A", "D", "E", "B");
8384 MsiCloseHandle(rec);
8385
8388
8389 query = "INSERT INTO `Z` ( `B`, `C`, `A`, `E`, `D` ) "
8390 "VALUES ( 1, 2, 'a', 3, 'bc' )";
8391 r = run_query(hdb, 0, query);
8392 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8393
8394 query = "SELECT * FROM `Z`";
8395 r = do_query(hdb, query, &rec);
8396 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8397 check_record(rec, 5, "2", "a", "bc", "3", "1");
8398 MsiCloseHandle(rec);
8399
8400 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'T'";
8401 r = MsiDatabaseOpenViewA(hdb, query, &view);
8402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8403 r = MsiViewExecute(view, 0);
8404 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405
8406 r = MsiViewFetch(view, &rec);
8407 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8408 check_record(rec, 3, "T", "1", "D");
8409 MsiCloseHandle(rec);
8410
8411 r = MsiViewFetch(view, &rec);
8412 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8413 check_record(rec, 3, "T", "2", "E");
8414 MsiCloseHandle(rec);
8415
8416 r = MsiViewFetch(view, &rec);
8417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8418 check_record(rec, 3, "T", "3", "A");
8419 MsiCloseHandle(rec);
8420
8421 r = MsiViewFetch(view, &rec);
8422 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8423 check_record(rec, 3, "T", "4", "C");
8424 MsiCloseHandle(rec);
8425
8426 r = MsiViewFetch(view, &rec);
8427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8428 check_record(rec, 3, "T", "5", "B");
8429 MsiCloseHandle(rec);
8430
8431 r = MsiViewFetch(view, &rec);
8432 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8433
8436
8437 MsiCloseHandle(hdb);
8439}
@ MSICOLINFO_NAMES
Definition: msiquery.h:36
@ MSICOLINFO_TYPES
Definition: msiquery.h:37

Referenced by START_TEST().

◆ test_createtable()

static void test_createtable ( void  )
static

Definition at line 8441 of file db.c.

8442{
8443 MSIHANDLE hdb, htab = 0, hrec = 0;
8444 LPCSTR query;
8445 UINT res;
8446 DWORD size;
8447 char buffer[0x20];
8448
8449 hdb = create_db();
8450 ok(hdb, "failed to create db\n");
8451
8452 query = "CREATE TABLE `blah` (`foo` CHAR(72) NOT NULL PRIMARY KEY `foo`)";
8453 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8454 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8455 if(res == ERROR_SUCCESS )
8456 {
8457 res = MsiViewExecute( htab, hrec );
8458 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8459
8460 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8461 todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8462
8463 size = sizeof(buffer);
8464 res = MsiRecordGetStringA(hrec, 1, buffer, &size );
8465 todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8466 MsiCloseHandle( hrec );
8467
8468 res = MsiViewClose( htab );
8469 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8470
8471 res = MsiCloseHandle( htab );
8472 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8473 }
8474
8475 query = "CREATE TABLE `a` (`b` INT PRIMARY KEY `b`)";
8476 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8477 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8478 if(res == ERROR_SUCCESS )
8479 {
8480 res = MsiViewExecute( htab, 0 );
8481 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8482
8483 res = MsiViewClose( htab );
8484 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8485
8486 res = MsiCloseHandle( htab );
8487 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8488
8489 query = "SELECT * FROM `a`";
8490 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8491 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8492
8493 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8494 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8495 check_record(hrec, 1, "b");
8496 MsiCloseHandle( hrec );
8497
8498 res = MsiViewClose( htab );
8499 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8500
8501 res = MsiCloseHandle( htab );
8502 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8503
8504 res = MsiDatabaseCommit(hdb);
8505 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8506
8507 res = MsiCloseHandle(hdb);
8508 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8509
8511 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8512
8513 query = "SELECT * FROM `a`";
8514 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8515 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8516
8517 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8518 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8519 check_record(hrec, 1, "b");
8520 res = MsiCloseHandle( hrec );
8521 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8522
8523 res = MsiViewClose( htab );
8524 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8525
8526 res = MsiCloseHandle( htab );
8527 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8528 }
8529
8530 res = MsiDatabaseCommit(hdb);
8531 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8532
8533 res = MsiCloseHandle(hdb);
8534 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8535
8537}

Referenced by START_TEST().

◆ test_dbmerge()

static void test_dbmerge ( void  )
static

Definition at line 7490 of file db.c.

7491{
7492 MSIHANDLE hdb, href, hview, hrec;
7493 CHAR buf[MAX_PATH];
7494 LPCSTR query;
7495 DWORD size;
7496 UINT r;
7497
7499 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7500
7501 r = MsiOpenDatabaseW(L"refdb.msi", MSIDBOPEN_CREATE, &href);
7502 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7503
7504 /* hDatabase is invalid */
7505 r = MsiDatabaseMergeA(0, href, "MergeErrors");
7507 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
7508
7509 /* hDatabaseMerge is invalid */
7510 r = MsiDatabaseMergeA(hdb, 0, "MergeErrors");
7512 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
7513
7514 /* szTableName is NULL */
7515 r = MsiDatabaseMergeA(hdb, href, NULL);
7516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7517
7518 /* szTableName is empty */
7519 r = MsiDatabaseMergeA(hdb, href, "");
7520 ok(r == ERROR_INVALID_TABLE, "Expected ERROR_INVALID_TABLE, got %d\n", r);
7521
7522 /* both DBs empty, szTableName is valid */
7523 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7524 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7525
7526 query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
7527 r = run_query(hdb, 0, query);
7528 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7529
7530 query = "CREATE TABLE `One` ( `A` CHAR(72) PRIMARY KEY `A` )";
7531 r = run_query(href, 0, query);
7532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7533
7534 /* column types don't match */
7535 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7537 "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
7538
7539 /* nothing in MergeErrors */
7540 query = "SELECT * FROM `MergeErrors`";
7541 r = do_query(hdb, query, &hrec);
7543 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7544
7545 query = "DROP TABLE `One`";
7546 r = run_query(hdb, 0, query);
7547 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7548
7549 query = "DROP TABLE `One`";
7550 r = run_query(href, 0, query);
7551 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7552
7553 query = "CREATE TABLE `One` ( "
7554 "`A` CHAR(72), "
7555 "`B` CHAR(56), "
7556 "`C` CHAR(64) LOCALIZABLE, "
7557 "`D` LONGCHAR, "
7558 "`E` CHAR(72) NOT NULL, "
7559 "`F` CHAR(56) NOT NULL, "
7560 "`G` CHAR(64) NOT NULL LOCALIZABLE, "
7561 "`H` LONGCHAR NOT NULL "
7562 "PRIMARY KEY `A` )";
7563 r = run_query(hdb, 0, query);
7564 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7565
7566 query = "CREATE TABLE `One` ( "
7567 "`A` CHAR(64), "
7568 "`B` CHAR(64), "
7569 "`C` CHAR(64), "
7570 "`D` CHAR(64), "
7571 "`E` CHAR(64) NOT NULL, "
7572 "`F` CHAR(64) NOT NULL, "
7573 "`G` CHAR(64) NOT NULL, "
7574 "`H` CHAR(64) NOT NULL "
7575 "PRIMARY KEY `A` )";
7576 r = run_query(href, 0, query);
7577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7578
7579 /* column string types don't match exactly */
7580 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7581 ok(r == ERROR_SUCCESS,
7582 "Expected ERROR_SUCCESS, got %d\n", r);
7583
7584 /* nothing in MergeErrors */
7585 query = "SELECT * FROM `MergeErrors`";
7586 r = do_query(hdb, query, &hrec);
7588 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7589
7590 query = "DROP TABLE `One`";
7591 r = run_query(hdb, 0, query);
7592 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7593
7594 query = "DROP TABLE `One`";
7595 r = run_query(href, 0, query);
7596 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7597
7598 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7599 r = run_query(hdb, 0, query);
7600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7601
7602 query = "CREATE TABLE `One` ( `A` INT, `C` INT PRIMARY KEY `A` )";
7603 r = run_query(href, 0, query);
7604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7605
7606 /* column names don't match */
7607 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7609 "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
7610
7611 /* nothing in MergeErrors */
7612 query = "SELECT * FROM `MergeErrors`";
7613 r = do_query(hdb, query, &hrec);
7615 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7616
7617 query = "DROP TABLE `One`";
7618 r = run_query(hdb, 0, query);
7619 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7620
7621 query = "DROP TABLE `One`";
7622 r = run_query(href, 0, query);
7623 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7624
7625 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7626 r = run_query(hdb, 0, query);
7627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7628
7629 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `B` )";
7630 r = run_query(href, 0, query);
7631 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7632
7633 /* primary keys don't match */
7634 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7636 "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
7637
7638 /* nothing in MergeErrors */
7639 query = "SELECT * FROM `MergeErrors`";
7640 r = do_query(hdb, query, &hrec);
7642 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7643
7644 query = "DROP TABLE `One`";
7645 r = run_query(hdb, 0, query);
7646 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7647
7648 query = "DROP TABLE `One`";
7649 r = run_query(href, 0, query);
7650 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7651
7652 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7653 r = run_query(hdb, 0, query);
7654 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7655
7656 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A`, `B` )";
7657 r = run_query(href, 0, query);
7658 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7659
7660 /* number of primary keys doesn't match */
7661 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7663 "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
7664
7665 /* nothing in MergeErrors */
7666 query = "SELECT * FROM `MergeErrors`";
7667 r = do_query(hdb, query, &hrec);
7669 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7670
7671 query = "DROP TABLE `One`";
7672 r = run_query(hdb, 0, query);
7673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7674
7675 query = "DROP TABLE `One`";
7676 r = run_query(href, 0, query);
7677 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7678
7679 query = "CREATE TABLE `One` ( `A` INT, `B` INT, `C` INT PRIMARY KEY `A` )";
7680 r = run_query(hdb, 0, query);
7681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7682
7683 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7684 r = run_query(href, 0, query);
7685 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7686
7687 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 2 )";
7688 r = run_query(href, 0, query);
7689 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7690
7691 /* number of columns doesn't match */
7692 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7694
7695 query = "SELECT * FROM `One`";
7696 r = do_query(hdb, query, &hrec);
7697 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7698
7699 r = MsiRecordGetInteger(hrec, 1);
7700 ok(r == 1, "Expected 1, got %d\n", r);
7701
7702 r = MsiRecordGetInteger(hrec, 2);
7703 ok(r == 2, "Expected 2, got %d\n", r);
7704
7705 r = MsiRecordGetInteger(hrec, 3);
7706 ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
7707
7708 MsiCloseHandle(hrec);
7709
7710 /* nothing in MergeErrors */
7711 query = "SELECT * FROM `MergeErrors`";
7712 r = do_query(hdb, query, &hrec);
7714 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7715
7716 query = "DROP TABLE `One`";
7717 r = run_query(hdb, 0, query);
7718 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7719
7720 query = "DROP TABLE `One`";
7721 r = run_query(href, 0, query);
7722 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7723
7724 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7725 r = run_query(hdb, 0, query);
7726 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7727
7728 query = "CREATE TABLE `One` ( `A` INT, `B` INT, `C` INT PRIMARY KEY `A` )";
7729 r = run_query(href, 0, query);
7730 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7731
7732 query = "INSERT INTO `One` ( `A`, `B`, `C` ) VALUES ( 1, 2, 3 )";
7733 r = run_query(href, 0, query);
7734 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7735
7736 /* number of columns doesn't match */
7737 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7738 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7739
7740 query = "SELECT * FROM `One`";
7741 r = do_query(hdb, query, &hrec);
7742 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7743
7744 r = MsiRecordGetInteger(hrec, 1);
7745 ok(r == 1, "Expected 1, got %d\n", r);
7746
7747 r = MsiRecordGetInteger(hrec, 2);
7748 ok(r == 2, "Expected 2, got %d\n", r);
7749
7750 r = MsiRecordGetInteger(hrec, 3);
7751 ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
7752
7753 MsiCloseHandle(hrec);
7754
7755 /* nothing in MergeErrors */
7756 query = "SELECT * FROM `MergeErrors`";
7757 r = do_query(hdb, query, &hrec);
7759 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7760
7761 query = "DROP TABLE `One`";
7762 r = run_query(hdb, 0, query);
7763 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7764
7765 query = "DROP TABLE `One`";
7766 r = run_query(href, 0, query);
7767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7768
7769 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7770 r = run_query(hdb, 0, query);
7771 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7772
7773 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 1 )";
7774 r = run_query(hdb, 0, query);
7775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7776
7777 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 2, 2 )";
7778 r = run_query(hdb, 0, query);
7779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7780
7781 query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
7782 r = run_query(href, 0, query);
7783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7784
7785 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 2 )";
7786 r = run_query(href, 0, query);
7787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7788
7789 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 2, 3 )";
7790 r = run_query(href, 0, query);
7791 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7792
7793 /* primary keys match, rows do not */
7794 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7796 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
7797
7798 /* nothing in MergeErrors */
7799 query = "SELECT * FROM `MergeErrors`";
7800 r = do_query(hdb, query, &hrec);
7801 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7802 check_record(hrec, 2, "One", "2");
7803 MsiCloseHandle(hrec);
7804
7805 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `MergeErrors`", &hview);
7806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7807
7808 r = MsiViewGetColumnInfo(hview, MSICOLINFO_NAMES, &hrec);
7809 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7810 check_record(hrec, 2, "Table", "NumRowMergeConflicts");
7811 MsiCloseHandle(hrec);
7812
7813 r = MsiViewGetColumnInfo(hview, MSICOLINFO_TYPES, &hrec);
7814 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7815 check_record(hrec, 2, "s255", "i2");
7816 MsiCloseHandle(hrec);
7817
7818 MsiViewClose(hview);
7819 MsiCloseHandle(hview);
7820
7821 query = "DROP TABLE `MergeErrors`";
7822 r = run_query(hdb, 0, query);
7823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7824
7825 query = "DROP TABLE `One`";
7826 r = run_query(hdb, 0, query);
7827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7828
7829 query = "DROP TABLE `One`";
7830 r = run_query(href, 0, query);
7831 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7832
7833 query = "CREATE TABLE `One` ( `A` INT, `B` CHAR(72) PRIMARY KEY `A` )";
7834 r = run_query(href, 0, query);
7835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7836
7837 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 'hi' )";
7838 r = run_query(href, 0, query);
7839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7840
7841 /* table from merged database is not in target database */
7842 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7843 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7844
7845 query = "SELECT * FROM `One`";
7846 r = do_query(hdb, query, &hrec);
7847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7848 check_record(hrec, 2, "1", "hi");
7849 MsiCloseHandle(hrec);
7850
7851 /* nothing in MergeErrors */
7852 query = "SELECT * FROM `MergeErrors`";
7853 r = do_query(hdb, query, &hrec);
7855 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7856
7857 query = "DROP TABLE `One`";
7858 r = run_query(hdb, 0, query);
7859 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7860
7861 query = "DROP TABLE `One`";
7862 r = run_query(href, 0, query);
7863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7864
7865 query = "CREATE TABLE `One` ( "
7866 "`A` CHAR(72), `B` INT PRIMARY KEY `A` )";
7867 r = run_query(hdb, 0, query);
7868 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7869
7870 query = "CREATE TABLE `One` ( "
7871 "`A` CHAR(72), `B` INT PRIMARY KEY `A` )";
7872 r = run_query(href, 0, query);
7873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7874
7875 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 'hi', 1 )";
7876 r = run_query(href, 0, query);
7877 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7878
7879 /* primary key is string */
7880 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7881 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7882
7883 query = "SELECT * FROM `One`";
7884 r = do_query(hdb, query, &hrec);
7885 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7886 check_record(hrec, 2, "hi", "1");
7887 MsiCloseHandle(hrec);
7888
7889 /* nothing in MergeErrors */
7890 query = "SELECT * FROM `MergeErrors`";
7891 r = do_query(hdb, query, &hrec);
7893 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7894
7895 create_file_data("codepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0);
7896
7898 r = MsiDatabaseImportA(hdb, buf, "codepage.idt");
7899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7900
7901 query = "DROP TABLE `One`";
7902 r = run_query(hdb, 0, query);
7903 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7904
7905 query = "DROP TABLE `One`";
7906 r = run_query(href, 0, query);
7907 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7908
7909 query = "CREATE TABLE `One` ( "
7910 "`A` INT, `B` CHAR(72) LOCALIZABLE PRIMARY KEY `A` )";
7911 r = run_query(hdb, 0, query);
7912 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7913
7914 query = "CREATE TABLE `One` ( "
7915 "`A` INT, `B` CHAR(72) LOCALIZABLE PRIMARY KEY `A` )";
7916 r = run_query(href, 0, query);
7917 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7918
7919 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 'hi' )";
7920 r = run_query(href, 0, query);
7921 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7922
7923 /* code page does not match */
7924 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7925 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7926
7927 query = "SELECT * FROM `One`";
7928 r = do_query(hdb, query, &hrec);
7929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7930 check_record(hrec, 2, "1", "hi");
7931 MsiCloseHandle(hrec);
7932
7933 /* nothing in MergeErrors */
7934 query = "SELECT * FROM `MergeErrors`";
7935 r = do_query(hdb, query, &hrec);
7937 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7938
7939 query = "DROP TABLE `One`";
7940 r = run_query(hdb, 0, query);
7941 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7942
7943 query = "DROP TABLE `One`";
7944 r = run_query(href, 0, query);
7945 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7946
7947 query = "CREATE TABLE `One` ( `A` INT, `B` OBJECT PRIMARY KEY `A` )";
7948 r = run_query(hdb, 0, query);
7949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7950
7951 query = "CREATE TABLE `One` ( `A` INT, `B` OBJECT PRIMARY KEY `A` )";
7952 r = run_query(href, 0, query);
7953 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7954
7955 create_file("binary.dat", 0);
7956 hrec = MsiCreateRecord(1);
7957 MsiRecordSetStreamA(hrec, 1, "binary.dat");
7958
7959 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, ? )";
7960 r = run_query(href, hrec, query);
7961 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7962
7963 MsiCloseHandle(hrec);
7964
7965 /* binary data to merge */
7966 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
7967 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7968
7969 query = "SELECT * FROM `One`";
7970 r = do_query(hdb, query, &hrec);
7971 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7972
7973 r = MsiRecordGetInteger(hrec, 1);
7974 ok(r == 1, "Expected 1, got %d\n", r);
7975
7976 size = MAX_PATH;
7978 r = MsiRecordReadStream(hrec, 2, buf, &size);
7979 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7980 ok(!lstrcmpA(buf, "binary.dat"), "Expected \"binary.dat\", got \"%s\"\n", buf);
7981
7982 MsiCloseHandle(hrec);
7983
7984 /* nothing in MergeErrors */
7985 query = "SELECT * FROM `MergeErrors`";
7986 r = do_query(hdb, query, &hrec);
7988 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7989
7990 query = "DROP TABLE `One`";
7991 r = run_query(hdb, 0, query);
7992 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7993
7994 query = "DROP TABLE `One`";
7995 r = run_query(href, 0, query);
7996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7997
7998 query = "CREATE TABLE `One` ( `A` INT, `B` CHAR(72) PRIMARY KEY `A` )";
7999 r = run_query(hdb, 0, query);
8000 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8001 r = run_query(href, 0, query);
8002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8003
8004 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 'foo' )";
8005 r = run_query(href, 0, query);
8006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8007
8008 query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 2, 'bar' )";
8009 r = run_query(href, 0, query);
8010 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8011
8012 r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8013 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8014
8015 query = "SELECT * FROM `One`";
8016 r = MsiDatabaseOpenViewA(hdb, query, &hview);
8017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8018 r = MsiViewExecute(hview, 0);
8019 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8020
8021 r = MsiViewFetch(hview, &hrec);
8022 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8023 check_record(hrec, 2, "1", "foo");
8024 MsiCloseHandle(hrec);
8025
8026 r = MsiViewFetch(hview, &hrec);
8027 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8028 check_record(hrec, 2, "2", "bar");
8029 MsiCloseHandle(hrec);
8030
8031 r = MsiViewFetch(hview, &hrec);
8033 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8034
8035 MsiViewClose(hview);
8036 MsiCloseHandle(hview);
8037
8038 MsiCloseHandle(hdb);
8039 MsiCloseHandle(href);
8041 DeleteFileW(L"refdb.msi");
8042 DeleteFileA("codepage.idt");
8043 DeleteFileA("binary.dat");
8044}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
UINT WINAPI MsiDatabaseMergeA(MSIHANDLE hDatabase, MSIHANDLE hDatabaseMerge, const char *szTableName)
Definition: database.c:1222
#define MSI_NULL_INTEGER
Definition: msiquery.h:32
#define ERROR_INVALID_TABLE
Definition: winerror.h:986
#define ERROR_DATATYPE_MISMATCH
Definition: winerror.h:987

Referenced by START_TEST().

◆ test_dbtopackage()

static void test_dbtopackage ( void  )
static

Definition at line 7194 of file db.c.

7195{
7196 MSIHANDLE hdb, hpkg;
7197 CHAR package[12], buf[MAX_PATH];
7198 DWORD size;
7199 UINT r;
7200
7201 /* create an empty database, transact mode */
7203 ok(r == ERROR_SUCCESS, "Failed to create database\n");
7204
7205 set_summary_info(hdb);
7206
7208
7210 add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
7211
7212 sprintf(package, "#%lu", hdb);
7213 r = MsiOpenPackageA(package, &hpkg);
7215 {
7216 skip("Not enough rights to perform tests\n");
7217 goto error;
7218 }
7219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7220
7221 /* property is not set yet */
7222 size = MAX_PATH;
7223 lstrcpyA(buf, "kiwi");
7224 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7225 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7226 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7227 ok(size == 0, "Expected 0, got %lu\n", size);
7228
7229 /* run the custom action to set the property */
7230 r = MsiDoActionA(hpkg, "SetProp");
7231 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7232
7233 /* property is now set */
7234 size = MAX_PATH;
7235 lstrcpyA(buf, "kiwi");
7236 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7237 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7238 ok(!lstrcmpA(buf, "grape"), "Expected \"grape\", got \"%s\"\n", buf);
7239 ok(size == 5, "Expected 5, got %lu\n", size);
7240
7241 MsiCloseHandle(hpkg);
7242
7243 /* reset the package */
7244 r = MsiOpenPackageA(package, &hpkg);
7245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7246
7247 /* property is not set anymore */
7248 size = MAX_PATH;
7249 lstrcpyA(buf, "kiwi");
7250 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7252 todo_wine
7253 {
7254 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7255 ok(size == 0, "Expected 0, got %lu\n", size);
7256 }
7257
7258 MsiCloseHandle(hdb);
7259 MsiCloseHandle(hpkg);
7260
7261 /* create an empty database, direct mode */
7263 ok(r == ERROR_SUCCESS, "Failed to create database\n");
7264
7265 set_summary_info(hdb);
7266
7268
7270 add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
7271
7272 sprintf(package, "#%lu", hdb);
7273 r = MsiOpenPackageA(package, &hpkg);
7274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7275
7276 /* property is not set yet */
7277 size = MAX_PATH;
7278 lstrcpyA(buf, "kiwi");
7279 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7281 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7282 ok(size == 0, "Expected 0, got %lu\n", size);
7283
7284 /* run the custom action to set the property */
7285 r = MsiDoActionA(hpkg, "SetProp");
7286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7287
7288 /* property is now set */
7289 size = MAX_PATH;
7290 lstrcpyA(buf, "kiwi");
7291 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7292 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7293 ok(!lstrcmpA(buf, "grape"), "Expected \"grape\", got \"%s\"\n", buf);
7294 ok(size == 5, "Expected 5, got %lu\n", size);
7295
7296 MsiCloseHandle(hpkg);
7297
7298 /* reset the package */
7299 r = MsiOpenPackageA(package, &hpkg);
7300 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7301
7302 /* property is not set anymore */
7303 size = MAX_PATH;
7304 lstrcpyA(buf, "kiwi");
7305 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7307 todo_wine
7308 {
7309 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7310 ok(size == 0, "Expected 0, got %lu\n", size);
7311 }
7312
7313 MsiCloseHandle(hpkg);
7314
7315error:
7316 MsiCloseHandle(hdb);
7318}
#define skip(...)
Definition: atltest.h:64
static UINT create_custom_action_table(MSIHANDLE hdb)
Definition: db.c:247
#define add_custom_action_entry(hdb, values)
Definition: db.c:324
UINT WINAPI MsiDoActionA(MSIHANDLE hInstall, LPCSTR szAction)
Definition: install.c:45
UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz)
Definition: package.c:2313
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define error(str)
Definition: mkdosfs.c:1605
#define MSIDBOPEN_CREATEDIRECT
Definition: msiquery.h:70
#define ERROR_INSTALL_PACKAGE_REJECTED
Definition: winerror.h:983

Referenced by START_TEST().

◆ test_defaultdatabase()

static void test_defaultdatabase ( void  )
static

Definition at line 5903 of file db.c.

5904{
5905 UINT r;
5906 HRESULT hr;
5907 MSIHANDLE hdb;
5908 IStorage *stg = NULL;
5909
5911
5913 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5914
5915 r = MsiDatabaseCommit(hdb);
5916 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5917
5918 MsiCloseHandle(hdb);
5919
5921 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5922 ok(stg != NULL, "Expected non-NULL stg\n");
5923
5924 enum_stream_names(stg);
5925
5926 IStorage_Release(stg);
5928}
static void enum_stream_names(IStorage *stg)
Definition: db.c:5845
HRESULT WINAPI StgOpenStorage(const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8755
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:922

Referenced by START_TEST().

◆ test_deleterow()

static void test_deleterow ( void  )
static

Definition at line 6295 of file db.c.

6296{
6297 MSIHANDLE hdb, hview, hrec;
6298 const char *query;
6299 UINT r;
6300
6302
6304 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6305
6306 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6307 r = run_query(hdb, 0, query);
6308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6309
6310 query = "INSERT INTO `Table` (`A`) VALUES ('one')";
6311 r = run_query(hdb, 0, query);
6312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6313
6314 query = "INSERT INTO `Table` (`A`) VALUES ('two')";
6315 r = run_query(hdb, 0, query);
6316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6317
6318 query = "DELETE FROM `Table` WHERE `A` = 'one'";
6319 r = run_query(hdb, 0, query);
6320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6321
6322 r = MsiDatabaseCommit(hdb);
6323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6324
6325 MsiCloseHandle(hdb);
6326
6328 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6329
6330 query = "SELECT * FROM `Table`";
6331 r = MsiDatabaseOpenViewA(hdb, query, &hview);
6332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6333 r = MsiViewExecute(hview, 0);
6334 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6335
6336 r = MsiViewFetch(hview, &hrec);
6337 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6338 check_record(hrec, 1, "two");
6339 MsiCloseHandle(hrec);
6340
6341 r = MsiViewFetch(hview, &hrec);
6342 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6343
6344 MsiViewClose(hview);
6345 MsiCloseHandle(hview);
6346 MsiCloseHandle(hdb);
6348}

Referenced by START_TEST().

◆ test_droptable()

static void test_droptable ( void  )
static

Definition at line 7320 of file db.c.

7321{
7322 MSIHANDLE hdb, hview, hrec;
7323 LPCSTR query;
7324 UINT r;
7325
7327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7328
7329 query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
7330 r = run_query(hdb, 0, query);
7331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7332
7333 query = "SELECT * FROM `One`";
7334 r = do_query(hdb, query, &hrec);
7335 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7336
7337 query = "SELECT `Name` FROM `_Tables` WHERE `Name` = 'One'";
7338 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7340 r = MsiViewExecute(hview, 0);
7341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7342
7343 r = MsiViewFetch(hview, &hrec);
7344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7345 check_record(hrec, 1, "One");
7346 MsiCloseHandle(hrec);
7347
7348 MsiViewClose(hview);
7349 MsiCloseHandle(hview);
7350
7351 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'One'";
7352 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7354 r = MsiViewExecute(hview, 0);
7355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7356
7357 r = MsiViewFetch(hview, &hrec);
7358 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7359 check_record(hrec, 3, "One", "1", "A");
7360 MsiCloseHandle(hrec);
7361
7362 r = MsiViewFetch(hview, &hrec);
7364 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7365
7366 MsiViewClose(hview);
7367 MsiCloseHandle(hview);
7368
7369 query = "DROP `One`";
7370 r = run_query(hdb, 0, query);
7372 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7373
7374 query = "DROP TABLE";
7375 r = run_query(hdb, 0, query);
7377 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7378
7379 query = "DROP TABLE `One`";
7380 hview = 0;
7381 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7383 r = MsiViewExecute(hview, 0);
7384 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7385
7386 r = MsiViewFetch(hview, &hrec);
7388 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
7389
7390 MsiViewClose(hview);
7391 MsiCloseHandle(hview);
7392
7393 query = "SELECT * FROM `IDontExist`";
7394 r = do_query(hdb, query, &hrec);
7396 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7397
7398 query = "SELECT * FROM `One`";
7399 r = do_query(hdb, query, &hrec);
7401 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7402
7403 query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
7404 r = run_query(hdb, 0, query);
7405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7406
7407 query = "DROP TABLE One";
7408 r = run_query(hdb, 0, query);
7409 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7410
7411 query = "SELECT * FROM `One`";
7412 r = do_query(hdb, query, &hrec);
7414 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7415
7416 query = "SELECT * FROM `_Tables` WHERE `Name` = 'One'";
7417 r = do_query(hdb, query, &hrec);
7418 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7419
7420 query = "SELECT * FROM `_Columns` WHERE `Table` = 'One'";
7421 r = do_query(hdb, query, &hrec);
7422 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7423
7424 query = "CREATE TABLE `One` ( `B` INT, `C` INT PRIMARY KEY `B` )";
7425 r = run_query(hdb, 0, query);
7426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7427
7428 query = "SELECT * FROM `One`";
7429 r = do_query(hdb, query, &hrec);
7430 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7431
7432 query = "SELECT `Name` FROM `_Tables` WHERE `Name` = 'One'";
7433 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7434 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7435 r = MsiViewExecute(hview, 0);
7436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7437
7438 r = MsiViewFetch(hview, &hrec);
7439 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7440 check_record(hrec, 1, "One");
7441 MsiCloseHandle(hrec);
7442
7443 MsiViewClose(hview);
7444 MsiCloseHandle(hview);
7445
7446 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'One'";
7447 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7448 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7449 r = MsiViewExecute(hview, 0);
7450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7451
7452 r = MsiViewFetch(hview, &hrec);
7453 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7454 check_record(hrec, 3, "One", "1", "B");
7455 MsiCloseHandle(hrec);
7456
7457 r = MsiViewFetch(hview, &hrec);
7458 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7459 check_record(hrec, 3, "One", "2", "C");
7460 MsiCloseHandle(hrec);
7461
7462 r = MsiViewFetch(hview, &hrec);
7464 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7465
7466 MsiViewClose(hview);
7467 MsiCloseHandle(hview);
7468
7469 query = "DROP TABLE One";
7470 r = run_query(hdb, 0, query);
7471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7472
7473 query = "SELECT * FROM `One`";
7474 r = do_query(hdb, query, &hrec);
7476 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7477
7478 query = "SELECT * FROM `_Tables` WHERE `Name` = 'One'";
7479 r = do_query(hdb, query, &hrec);
7480 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7481
7482 query = "SELECT * FROM `_Columns` WHERE `Table` = 'One'";
7483 r = do_query(hdb, query, &hrec);
7484 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7485
7486 MsiCloseHandle(hdb);
7488}

Referenced by START_TEST().

◆ test_embedded_nulls()

static void test_embedded_nulls ( void  )
static

Definition at line 8539 of file db.c.

8540{
8541 static const char control_table[] =
8542 "Dialog\tText\n"
8543 "s72\tL0\n"
8544 "Control\tDialog\n"
8545 "LicenseAgreementDlg\ttext\x11\x19text\0text";
8546 static const char export_expected[] =
8547 "Dialog\tText\r\n"
8548 "s72\tL0\r\n"
8549 "Control\tDialog\r\n"
8550 "LicenseAgreementDlg\ttext\x11\x19text\x19text";
8551 /* newlines have alternate representation in idt files */
8552 static const char control_table2[] =
8553 "Dialog\tText\n"
8554 "s72\tL0\n"
8555 "Control\tDialog\n"
8556 "LicenseAgreementDlg\ttext\x11\x19te\nxt\0text";
8557 char data[1024];
8558 UINT r;
8559 DWORD sz;
8560 MSIHANDLE hdb, hrec;
8561 char buffer[32];
8562
8564 ok( r == ERROR_SUCCESS, "failed to open database %u\n", r );
8565
8567 write_file( "temp_file", control_table, sizeof(control_table) );
8568 r = MsiDatabaseImportA( hdb, CURR_DIR, "temp_file" );
8569 ok( r == ERROR_SUCCESS, "failed to import table %u\n", r );
8570 DeleteFileA( "temp_file" );
8571
8572 r = do_query( hdb, "SELECT `Text` FROM `Control` WHERE `Dialog` = 'LicenseAgreementDlg'", &hrec );
8573 ok( r == ERROR_SUCCESS, "query failed %u\n", r );
8574
8575 buffer[0] = 0;
8576 sz = sizeof(buffer);
8577 r = MsiRecordGetStringA( hrec, 1, buffer, &sz );
8578 ok( r == ERROR_SUCCESS, "failed to get string %u\n", r );
8579 ok( !memcmp( "text\r\ntext\ntext", buffer, sizeof("text\r\ntext\ntext") - 1 ), "wrong buffer contents \"%s\"\n", buffer );
8580
8581 r = MsiDatabaseExportA( hdb, "Control", CURR_DIR, "temp_file1");
8582 ok( r == ERROR_SUCCESS, "failed to export table %u\n", r );
8583 read_file_data( "temp_file1", data );
8584 ok( !memcmp( data, export_expected, sizeof(export_expected) - 1), "expected: \"%s\" got: \"%s\"\n", export_expected, data );
8585 DeleteFileA( "temp_file1" );
8586
8587 MsiCloseHandle( hrec );
8588 MsiCloseHandle( hdb );
8590
8592 ok( r == ERROR_SUCCESS, "failed to open database %u\n", r );
8593
8595 write_file( "temp_file", control_table2, sizeof(control_table2) );
8596 r = MsiDatabaseImportA( hdb, CURR_DIR, "temp_file" );
8597 ok( r == ERROR_FUNCTION_FAILED, "failed to import table %u\n", r );
8598 DeleteFileA( "temp_file" );
8599
8600 MsiCloseHandle( hdb );
8602}
static void read_file_data(LPCSTR filename, LPSTR buffer)
Definition: db.c:6753
UINT WINAPI MsiDatabaseExportA(MSIHANDLE handle, const char *szTable, const char *szFolder, const char *szFilename)
Definition: database.c:1184

Referenced by START_TEST().

◆ test_forcecodepage()

static void test_forcecodepage ( void  )
static

Definition at line 6764 of file db.c.

6765{
6766 MSIHANDLE hdb;
6767 const char *query;
6768 char buffer[MAX_PATH];
6769 UINT r;
6770
6773
6775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6776
6777 query = "SELECT * FROM `_ForceCodepage`";
6778 r = run_query(hdb, 0, query);
6779 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6780
6781 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6782 r = run_query(hdb, 0, query);
6783 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6784
6785 query = "SELECT * FROM `_ForceCodepage`";
6786 r = run_query(hdb, 0, query);
6787 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6788
6789 r = MsiDatabaseCommit(hdb);
6790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6791
6792 query = "SELECT * FROM `_ForceCodepage`";
6793 r = run_query(hdb, 0, query);
6794 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6795
6796 MsiCloseHandle(hdb);
6797
6799 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6800
6801 query = "SELECT * FROM `_ForceCodepage`";
6802 r = run_query(hdb, 0, query);
6803 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6804
6805 r = MsiDatabaseExportA(hdb, "_ForceCodepage", CURR_DIR, "forcecodepage.idt");
6806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6807
6808 read_file_data("forcecodepage.idt", buffer);
6809 ok(!lstrcmpA(buffer, "\r\n\r\n0\t_ForceCodepage\r\n"),
6810 "Expected \"\r\n\r\n0\t_ForceCodepage\r\n\", got \"%s\"\n", buffer);
6811
6812 create_file_data("forcecodepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0);
6813
6814 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
6815 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6816
6817 r = MsiDatabaseExportA(hdb, "_ForceCodepage", CURR_DIR, "forcecodepage.idt");
6818 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6819
6820 read_file_data("forcecodepage.idt", buffer);
6821 ok(!lstrcmpA(buffer, "\r\n\r\n850\t_ForceCodepage\r\n"),
6822 "Expected \"\r\n\r\n850\t_ForceCodepage\r\n\", got \"%s\"\n", buffer);
6823
6824 create_file_data("forcecodepage.idt", "\r\n\r\n9999\t_ForceCodepage\r\n", 0);
6825
6826 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
6827 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
6828
6829 MsiCloseHandle(hdb);
6831 DeleteFileA("forcecodepage.idt");
6832}
#define MSIDBOPEN_DIRECT
Definition: msiquery.h:68

Referenced by START_TEST().

◆ test_getcolinfo()

static void test_getcolinfo ( void  )
static

Definition at line 1167 of file db.c.

1168{
1169 MSIHANDLE hdb, hview = 0, rec = 0;
1170 UINT r;
1171
1172 /* create an empty db */
1173 hdb = create_db();
1174 ok( hdb, "failed to create db\n");
1175
1176 /* tables should be present */
1177 r = MsiDatabaseOpenViewA(hdb, "select Name from _Tables", &hview);
1178 ok( r == ERROR_SUCCESS, "failed to open query\n");
1179
1180 r = MsiViewExecute(hview, 0);
1181 ok( r == ERROR_SUCCESS, "failed to execute query\n");
1182
1183 /* check that NAMES works */
1184 rec = 0;
1185 r = MsiViewGetColumnInfo( hview, MSICOLINFO_NAMES, &rec );
1186 ok( r == ERROR_SUCCESS, "failed to get names\n");
1187 check_record(rec, 1, "Name");
1188 r = MsiCloseHandle( rec );
1189 ok( r == ERROR_SUCCESS, "failed to close record handle\n");
1190
1191 /* check that TYPES works */
1192 rec = 0;
1193 r = MsiViewGetColumnInfo( hview, MSICOLINFO_TYPES, &rec );
1194 ok( r == ERROR_SUCCESS, "failed to get names\n");
1195 check_record(rec, 1, "s64");
1196 r = MsiCloseHandle( rec );
1197 ok( r == ERROR_SUCCESS, "failed to close record handle\n");
1198
1199 /* check that invalid values fail */
1200 rec = 0;
1201 r = MsiViewGetColumnInfo( hview, 100, &rec );
1202 ok( r == ERROR_INVALID_PARAMETER, "wrong error code\n");
1203 ok( rec == 0, "returned a record\n");
1204
1206 ok( r == ERROR_INVALID_PARAMETER, "wrong error code\n");
1207
1209 ok( r == ERROR_INVALID_HANDLE, "wrong error code\n");
1210
1211 r = MsiViewClose(hview);
1212 ok( r == ERROR_SUCCESS, "failed to close view\n");
1213 r = MsiCloseHandle(hview);
1214 ok( r == ERROR_SUCCESS, "failed to close view handle\n");
1215 r = MsiCloseHandle(hdb);
1216 ok( r == ERROR_SUCCESS, "failed to close database\n");
1217}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101

Referenced by START_TEST().

◆ test_handle_limit()

static void test_handle_limit ( void  )
static

Definition at line 2704 of file db.c.

2705{
2706 int i;
2707 MSIHANDLE hdb;
2708 MSIHANDLE hviews[MY_NVIEWS];
2709 UINT r;
2710
2711 /* create an empty db */
2712 hdb = create_db();
2713 ok( hdb, "failed to create db\n");
2714
2715 memset(hviews, 0, sizeof(hviews));
2716
2717 for (i=0; i<MY_NVIEWS; i++) {
2718 static char szQueryBuf[256] = "SELECT * from `_Tables`";
2719 hviews[i] = 0xdeadbeeb;
2720 r = MsiDatabaseOpenViewA(hdb, szQueryBuf, &hviews[i]);
2721 if( r != ERROR_SUCCESS || hviews[i] == 0xdeadbeeb ||
2722 hviews[i] == 0 || (i && (hviews[i] == hviews[i-1])))
2723 break;
2724 }
2725
2726 ok( i == MY_NVIEWS, "problem opening views\n");
2727
2728 for (i=0; i<MY_NVIEWS; i++) {
2729 if (hviews[i] != 0 && hviews[i] != 0xdeadbeeb) {
2730 MsiViewClose(hviews[i]);
2731 r = MsiCloseHandle(hviews[i]);
2732 if (r != ERROR_SUCCESS)
2733 break;
2734 }
2735 }
2736
2737 ok( i == MY_NVIEWS, "problem closing views\n");
2738
2739 r = MsiCloseHandle(hdb);
2740 ok( r == ERROR_SUCCESS, "failed to close database\n");
2741}
#define MY_NVIEWS
Definition: db.c:2703

Referenced by START_TEST().

◆ test_insertorder()

static void test_insertorder ( void  )
static

Definition at line 8130 of file db.c.

8131{
8132 MSIHANDLE hdb, view, rec;
8133 LPCSTR query;
8134 UINT r;
8135 int i;
8136
8137 hdb = create_db();
8138 ok(hdb, "failed to create db\n");
8139
8140 query = "CREATE TABLE `T` ( `A` SHORT, `B` SHORT, `C` SHORT PRIMARY KEY `A`)";
8141 r = run_query(hdb, 0, query);
8142 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8143
8144 query = "INSERT INTO `T` ( `A`, `B`, `C` ) VALUES ( 1, 2, 3 )";
8145 r = run_query(hdb, 0, query);
8146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8147
8148 query = "INSERT INTO `T` ( `B`, `C`, `A` ) VALUES ( 4, 5, 6 )";
8149 r = run_query(hdb, 0, query);
8150 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8151
8152 query = "INSERT INTO `T` ( `C`, `A`, `B` ) VALUES ( 7, 8, 9 )";
8153 r = run_query(hdb, 0, query);
8154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8155
8156 query = "INSERT INTO `T` ( `A`, `B` ) VALUES ( 10, 11 )";
8157 r = run_query(hdb, 0, query);
8158 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8159
8160 query = "INSERT INTO `T` ( `B`, `C` ) VALUES ( 12, 13 )";
8161 r = run_query(hdb, 0, query);
8162 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8163
8164 /* fails because the primary key already
8165 * has an MSI_NULL_INTEGER value set above
8166 */
8167 query = "INSERT INTO `T` ( `C` ) VALUES ( 14 )";
8168 r = run_query(hdb, 0, query);
8170 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8171
8172 /* replicate the error where primary key is set twice */
8173 query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 1, 14 )";
8174 r = run_query(hdb, 0, query);
8176 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8177
8178 query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 14, 15 )";
8179 r = run_query(hdb, 0, query);
8180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8181
8182 query = "INSERT INTO `T` VALUES ( 16 )";
8183 r = run_query(hdb, 0, query);
8185 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8186
8187 query = "INSERT INTO `T` VALUES ( 17, 18 )";
8188 r = run_query(hdb, 0, query);
8190 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8191
8192 query = "INSERT INTO `T` VALUES ( 19, 20, 21 )";
8193 r = run_query(hdb, 0, query);
8195 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8196
8197 query = "SELECT * FROM `T`";
8198 r = MsiDatabaseOpenViewA(hdb, query, &view);
8199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8200 r = MsiViewExecute(view, 0);
8201 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8202
8203 for (i = 0; i < 6; i++)
8204 {
8205 r = MsiViewFetch(view, &rec);
8206 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8207
8208 r = MsiRecordGetInteger(rec, 1);
8209 ok(r == ordervals[i][0], "Expected %d, got %d\n", ordervals[i][0], r);
8210
8211 r = MsiRecordGetInteger(rec, 2);
8212 ok(r == ordervals[i][1], "Expected %d, got %d\n", ordervals[i][1], r);
8213
8214 r = MsiRecordGetInteger(rec, 3);
8215 ok(r == ordervals[i][2], "Expected %d, got %d\n", ordervals[i][2], r);
8216
8217 MsiCloseHandle(rec);
8218 }
8219
8220 r = MsiViewFetch(view, &rec);
8221 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8222
8225
8226 query = "DELETE FROM `T` WHERE `A` IS NULL";
8227 r = run_query(hdb, 0, query);
8228 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8229
8230 query = "INSERT INTO `T` ( `B`, `C` ) VALUES ( 12, 13 ) TEMPORARY";
8231 r = run_query(hdb, 0, query);
8232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8233
8234 query = "SELECT * FROM `T`";
8235 r = MsiDatabaseOpenViewA(hdb, query, &view);
8236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8237 r = MsiViewExecute(view, 0);
8238 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8239
8240 for (i = 0; i < 6; i++)
8241 {
8242 r = MsiViewFetch(view, &rec);
8243 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8244
8245 r = MsiRecordGetInteger(rec, 1);
8246 ok(r == ordervals[i][0], "Expected %d, got %d\n", ordervals[i][0], r);
8247
8248 r = MsiRecordGetInteger(rec, 2);
8249 ok(r == ordervals[i][1], "Expected %d, got %d\n", ordervals[i][1], r);
8250
8251 r = MsiRecordGetInteger(rec, 3);
8252 ok(r == ordervals[i][2], "Expected %d, got %d\n", ordervals[i][2], r);
8253
8254 MsiCloseHandle(rec);
8255 }
8256
8257 r = MsiViewFetch(view, &rec);
8258 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8259
8262 MsiCloseHandle(hdb);
8264}
static const UINT ordervals[6][3]
Definition: db.c:8120

Referenced by START_TEST().

◆ test_integers()

static void test_integers ( void  )
static

Definition at line 4125 of file db.c.

4126{
4127 MSIHANDLE hdb = 0, view = 0, rec = 0;
4128 DWORD i;
4129 const char *query;
4130 UINT r;
4131
4132 /* just MsiOpenDatabase should not create a file */
4134 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
4135
4136 /* create a table */
4137 query = "CREATE TABLE `integers` ( "
4138 "`one` SHORT, `two` INT, `three` INTEGER, `four` LONG, "
4139 "`five` SHORT NOT NULL, `six` INT NOT NULL, "
4140 "`seven` INTEGER NOT NULL, `eight` LONG NOT NULL "
4141 "PRIMARY KEY `one`)";
4142 r = MsiDatabaseOpenViewA(hdb, query, &view);
4143 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4144 r = MsiViewExecute(view, 0);
4145 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4146 r = MsiViewClose(view);
4147 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4149 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4150
4151 query = "SELECT * FROM `integers`";
4152 r = MsiDatabaseOpenViewA(hdb, query, &view);
4153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4154
4156 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4157 check_record(rec, 8, "one", "two", "three", "four", "five", "six", "seven", "eight");
4158 MsiCloseHandle(rec);
4159
4161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4162 check_record(rec, 8, "I2", "I2", "I2", "I4", "i2", "i2", "i2", "i4");
4163 MsiCloseHandle(rec);
4164
4167
4168 /* insert values into it, NULL where NOT NULL is specified */
4169 query = "INSERT INTO `integers` ( `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight` )"
4170 "VALUES('', '', '', '', '', '', '', '')";
4171 r = MsiDatabaseOpenViewA(hdb, query, &view);
4172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4173 r = MsiViewExecute(view, 0);
4174 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
4175
4178
4179 query = "SELECT * FROM `integers`";
4180 r = do_query(hdb, query, &rec);
4181 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
4182
4184 ok(r == -1, "record count wrong: %d\n", r);
4185
4186 MsiCloseHandle(rec);
4187
4188 /* insert legitimate values into it */
4189 query = "INSERT INTO `integers` ( `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight` )"
4190 "VALUES('', '2', '', '4', '5', '6', '7', '8')";
4191 r = MsiDatabaseOpenViewA(hdb, query, &view);
4192 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4193 r = MsiViewExecute(view, 0);
4194 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4195
4196 query = "SELECT * FROM `integers`";
4197 r = do_query(hdb, query, &rec);
4198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4199
4201 ok(r == 8, "record count wrong: %d\n", r);
4202
4203 i = MsiRecordGetInteger(rec, 1);
4204 ok(i == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %lu\n", i);
4205 i = MsiRecordGetInteger(rec, 3);
4206 ok(i == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %lu\n", i);
4207 i = MsiRecordGetInteger(rec, 2);
4208 ok(i == 2, "Expected 2, got %lu\n", i);
4209 i = MsiRecordGetInteger(rec, 4);
4210 ok(i == 4, "Expected 4, got %lu\n", i);
4211 i = MsiRecordGetInteger(rec, 5);
4212 ok(i == 5, "Expected 5, got %lu\n", i);