ReactOS 0.4.15-dev-8621-g4b051b9
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 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 create_file(name)   create_file_data(name, name, 0)
 
#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_query (MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
 
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 create_file_data (LPCSTR name, LPCSTR data, DWORD size)
 
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 CHAR CURR_DIR [MAX_PATH]
 
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:320
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 350 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 334 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 339 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 343 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 347 of file db.c.

◆ check_record

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

Definition at line 62 of file db.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file db.c.

◆ create_file

#define create_file (   name)    create_file_data(name, name, 0)

Definition at line 1526 of file db.c.

◆ MY_NVIEWS

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

Definition at line 2743 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 320 of file db.c.

321{
322 char *query;
323 UINT sz, r;
324
325 sz = strlen(values) + strlen(insert) + 1;
326 query = malloc(sz);
328 r = run_query(hdb, 0, query);
329 free(query);
330 ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r);
331 return r;
332}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ok_(x1, x2)
Definition: atltest.h:61
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:215
#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 2234 of file db.c.

2235{
2236 UINT r;
2237
2238 write_file("temp_file", table_data, (lstrlenA(table_data) - 1) * sizeof(char));
2239 r = MsiDatabaseImportA(hdb, CURR_DIR, "temp_file");
2240 DeleteFileA("temp_file");
2241
2242 return r;
2243}
static CHAR CURR_DIR[MAX_PATH]
Definition: db.c:2181
static void write_file(const CHAR *filename, const char *data, int data_size)
Definition: db.c:2224
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
UINT WINAPI MsiDatabaseImportA(MSIHANDLE handle, const char *szFolder, const char *szFilename)
Definition: database.c:853
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 39 of file db.c.

40{
42 UINT i;
43
44 ok_(__FILE__, line)(count == MsiRecordGetFieldCount(rec),
45 "expected %u fields, got %u\n", count, MsiRecordGetFieldCount(rec));
46
48
49 for (i = 1; i <= count; ++i)
50 {
51 const char *expect = va_arg(args, const char *);
52 char buffer[200] = "x";
53 DWORD sz = sizeof(buffer);
54 UINT r = MsiRecordGetStringA(rec, i, buffer, &sz);
55 ok_(__FILE__, line)(r == ERROR_SUCCESS, "field %u: got unexpected error %u\n", i, r);
56 ok_(__FILE__, line)(!strcmp(buffer, expect),
57 "field %u: expected \"%s\", got \"%s\"\n", i, expect, buffer);
58 }
59
60 va_end(args);
61}
#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 309 of file db.c.

310{
311 UINT r = run_query( hdb, 0,
312 "CREATE TABLE `Binary` ( "
313 "`Name` CHAR(72) NOT NULL, "
314 "`Data` CHAR(72) NOT NULL "
315 "PRIMARY KEY `Name` )" );
316 ok(r == ERROR_SUCCESS, "Failed to create Binary table: %u\n", r);
317 return r;
318}
#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 247 of file db.c.

248{
249 UINT r = run_query( hdb, 0,
250 "CREATE TABLE `Component` ( "
251 "`Component` CHAR(72) NOT NULL, "
252 "`ComponentId` CHAR(38), "
253 "`Directory_` CHAR(72) NOT NULL, "
254 "`Attributes` SHORT NOT NULL, "
255 "`Condition` CHAR(255), "
256 "`KeyPath` CHAR(72) "
257 "PRIMARY KEY `Component`)" );
258 ok(r == ERROR_SUCCESS, "Failed to create Component table: %u\n", r);
259 return r;
260}

Referenced by test_join().

◆ create_custom_action_table()

static UINT create_custom_action_table ( MSIHANDLE  hdb)
static

Definition at line 262 of file db.c.

263{
264 UINT r = run_query( hdb, 0,
265 "CREATE TABLE `CustomAction` ( "
266 "`Action` CHAR(72) NOT NULL, "
267 "`Type` SHORT NOT NULL, "
268 "`Source` CHAR(72), "
269 "`Target` CHAR(255) "
270 "PRIMARY KEY `Action`)" );
271 ok(r == ERROR_SUCCESS, "Failed to create CustomAction table: %u\n", r);
272 return r;
273}

Referenced by test_dbtopackage().

◆ create_db()

static MSIHANDLE create_db ( void  )
static

Definition at line 1163 of file db.c.

1164{
1165 MSIHANDLE hdb = 0;
1166 UINT res;
1167
1169
1170 /* create an empty database */
1172 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
1173 if( res != ERROR_SUCCESS )
1174 return hdb;
1175
1176 res = MsiDatabaseCommit( hdb );
1177 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
1178
1179 return hdb;
1180}
static const WCHAR msifileW[]
Definition: db.c:36
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:963
#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 275 of file db.c.

276{
277 UINT r = run_query( hdb, 0,
278 "CREATE TABLE `Directory` ( "
279 "`Directory` CHAR(255) NOT NULL, "
280 "`Directory_Parent` CHAR(255), "
281 "`DefaultDir` CHAR(255) NOT NULL "
282 "PRIMARY KEY `Directory`)" );
283 ok(r == ERROR_SUCCESS, "Failed to create Directory table: %u\n", r);
284 return r;
285}

Referenced by create_package_db(), and test_dbtopackage().

◆ create_feature_components_table()

static UINT create_feature_components_table ( MSIHANDLE  hdb)
static

Definition at line 287 of file db.c.

288{
289 UINT r = run_query( hdb, 0,
290 "CREATE TABLE `FeatureComponents` ( "
291 "`Feature_` CHAR(38) NOT NULL, "
292 "`Component_` CHAR(72) NOT NULL "
293 "PRIMARY KEY `Feature_`, `Component_` )" );
294 ok(r == ERROR_SUCCESS, "Failed to create FeatureComponents table: %u\n", r);
295 return r;
296}

Referenced by test_join().

◆ create_file_data()

static void create_file_data ( LPCSTR  name,
LPCSTR  data,
DWORD  size 
)
static

Definition at line 1505 of file db.c.

1506{
1507 HANDLE file;
1508 DWORD written;
1509
1512 return;
1513
1514 WriteFile(file, data, strlen(data), &written, NULL);
1515 WriteFile(file, "\n", strlen("\n"), &written, NULL);
1516
1517 if (size)
1518 {
1521 }
1522
1524}
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define FILE_BEGIN
Definition: compat.h:761
#define SetFilePointer
Definition: compat.h:743
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1004
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: name.c:39

Referenced by test_binary_import(), test_dbmerge(), and test_forcecodepage().

◆ create_package_db()

static MSIHANDLE create_package_db ( const WCHAR filename)
static

Definition at line 3042 of file db.c.

3043{
3044 MSIHANDLE hdb = 0;
3045 UINT res;
3046
3048
3049 /* create an empty database */
3051 ok( res == ERROR_SUCCESS , "Failed to create database\n" );
3052 if( res != ERROR_SUCCESS )
3053 return hdb;
3054
3055 res = MsiDatabaseCommit( hdb );
3056 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
3057
3058 res = set_summary_info(hdb);
3059 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3060
3062
3063 return hdb;
3064}
static UINT set_summary_info(MSIHANDLE hdb)
Definition: db.c:2998
static UINT create_directory_table(MSIHANDLE hdb)
Definition: db.c:275
const char * filename
Definition: ioapi.h:137

◆ create_std_dlls_table()

static UINT create_std_dlls_table ( MSIHANDLE  hdb)
static

Definition at line 298 of file db.c.

299{
300 UINT r = run_query( hdb, 0,
301 "CREATE TABLE `StdDlls` ( "
302 "`File` CHAR(255) NOT NULL, "
303 "`Binary_` CHAR(72) NOT NULL "
304 "PRIMARY KEY `File` )" );
305 ok(r == ERROR_SUCCESS, "Failed to create StdDlls table: %u\n", r);
306 return r;
307}

Referenced by test_join().

◆ create_storage()

static BOOL create_storage ( LPCSTR  name)
static

Definition at line 7084 of file db.c.

7085{
7087 IStorage *stg;
7088 IStream *stm;
7089 HRESULT hr;
7090 DWORD count;
7091 BOOL res = FALSE;
7092
7096 if (FAILED(hr))
7097 return FALSE;
7098
7099 hr = IStorage_CreateStream(stg, nameW, STGM_WRITE | STGM_SHARE_EXCLUSIVE,
7100 0, 0, &stm);
7101 if (FAILED(hr))
7102 goto done;
7103
7104 hr = IStream_Write(stm, "stgdata", 8, &count);
7105 if (SUCCEEDED(hr))
7106 res = TRUE;
7107
7108done:
7109 IStream_Release(stm);
7110 IStorage_Release(stg);
7111
7112 return res;
7113}
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ do_query()

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

Definition at line 190 of file db.c.

191{
192 MSIHANDLE hview = 0;
193 UINT r, ret;
194
195 if (phrec)
196 *phrec = 0;
197
198 /* open a select query */
199 r = MsiDatabaseOpenViewA(hdb, query, &hview);
200 if (r != ERROR_SUCCESS)
201 return r;
202 r = MsiViewExecute(hview, 0);
203 if (r != ERROR_SUCCESS)
204 return r;
205 ret = MsiViewFetch(hview, phrec);
206 r = MsiViewClose(hview);
207 if (r != ERROR_SUCCESS)
208 return r;
209 r = MsiCloseHandle(hview);
210 if (r != ERROR_SUCCESS)
211 return r;
212 return ret;
213}
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 5885 of file db.c.

5886{
5887 IEnumSTATSTG *stgenum = NULL;
5888 IStream *stm;
5889 HRESULT hr;
5890 STATSTG stat;
5891 ULONG n, count;
5894 DWORD sz;
5895
5896 memset(check, 'a', MAX_PATH);
5897
5898 hr = IStorage_EnumElements(stg, 0, NULL, 0, &stgenum);
5899 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5900
5901 n = 0;
5902 while(TRUE)
5903 {
5904 count = 0;
5905 hr = IEnumSTATSTG_Next(stgenum, 1, &stat, &count);
5906 if(FAILED(hr) || !count)
5907 break;
5908
5909 ok(!lstrcmpW(stat.pwcsName, database_table_data[n].name),
5910 "Expected table %lu name to match\n", n);
5911
5912 stm = NULL;
5913 hr = IStorage_OpenStream(stg, stat.pwcsName, NULL,
5914 STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm);
5915 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5916 ok(stm != NULL, "Expected non-NULL stream\n");
5917
5918 CoTaskMemFree(stat.pwcsName);
5919
5920 sz = MAX_PATH;
5921 memset(data, 'a', MAX_PATH);
5922 hr = IStream_Read(stm, data, sz, &count);
5923 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5924
5926 "Expected %lu, got %lu\n", database_table_data[n].size, count);
5927
5929 ok(!memcmp(data, check, MAX_PATH), "data should not be changed\n");
5930 else
5932 "Expected table %lu data to match\n", n);
5933
5934 IStream_Release(stm);
5935 n++;
5936 }
5937
5938 ok(n == 3, "Expected 3, got %lu\n", n);
5939
5940 IEnumSTATSTG_Release(stgenum);
5941}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define stat
Definition: acwin.h:99
static const struct @1679 database_table_data[]
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
#define check(expected, result)
Definition: dplayx.c:32
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 2783 of file db.c.

2784{
2785 MSIHANDLE hdb1, hdb2, hrec;
2786 LPCSTR query;
2787 UINT r;
2788
2789 /* start with two identical databases */
2791
2793 ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2794
2795 r = MsiDatabaseCommit( hdb1 );
2796 ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
2797
2799 ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2800
2801 /* the transform between two identical database should be empty */
2802 r = MsiDatabaseGenerateTransformA(hdb1, hdb2, NULL, 0, 0);
2803 todo_wine {
2804 ok( r == ERROR_NO_DATA, "return code %d, should be ERROR_NO_DATA\n", r );
2805 }
2806
2807 query = "CREATE TABLE `AAR` ( `BAR` SHORT NOT NULL, `CAR` CHAR(255) PRIMARY KEY `CAR`)";
2808 r = run_query(hdb1, 0, query);
2809 ok(r == ERROR_SUCCESS, "failed to add table\n");
2810
2811 query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 1, 'vw' )";
2812 r = run_query(hdb1, 0, query);
2813 ok(r == ERROR_SUCCESS, "failed to add row 1\n");
2814
2815 query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 2, 'bmw' )";
2816 r = run_query(hdb1, 0, query);
2817 ok(r == ERROR_SUCCESS, "failed to add row 2\n");
2818
2819 query = "UPDATE `MOO` SET `OOO` = 'c' WHERE `NOO` = 1";
2820 r = run_query(hdb1, 0, query);
2821 ok(r == ERROR_SUCCESS, "failed to modify row\n");
2822
2823 query = "DELETE FROM `MOO` WHERE `NOO` = 3";
2824 r = run_query(hdb1, 0, query);
2825 ok(r == ERROR_SUCCESS, "failed to delete row\n");
2826
2827 hrec = MsiCreateRecord(2);
2828 r = MsiRecordSetInteger(hrec, 1, 1);
2829 ok(r == ERROR_SUCCESS, "failed to set integer\n");
2830
2831 write_file("testdata.bin", "naengmyon", 9);
2832 r = MsiRecordSetStreamA(hrec, 2, "testdata.bin");
2833 ok(r == ERROR_SUCCESS, "failed to set stream\n");
2834
2835 query = "INSERT INTO `BINARY` ( `ID`, `BLOB` ) VALUES ( ?, ? )";
2836 r = run_query(hdb1, hrec, query);
2837 ok(r == ERROR_SUCCESS, "failed to add row with blob\n");
2838
2839 MsiCloseHandle(hrec);
2840
2841 query = "ALTER TABLE `MOO` ADD `COW` INTEGER";
2842 r = run_query(hdb1, 0, query);
2843 ok(r == ERROR_SUCCESS, "failed to add column\n");
2844
2845 query = "ALTER TABLE `MOO` ADD `PIG` INTEGER";
2846 r = run_query(hdb1, 0, query);
2847 ok(r == ERROR_SUCCESS, "failed to add column\n");
2848
2849 query = "UPDATE `MOO` SET `PIG` = 5 WHERE `NOO` = 1";
2850 r = run_query(hdb1, 0, query);
2851 ok(r == ERROR_SUCCESS, "failed to modify row\n");
2852
2853 query = "CREATE TABLE `Property` ( `Property` CHAR(72) NOT NULL, "
2854 "`Value` CHAR(0) PRIMARY KEY `Property`)";
2855 r = run_query(hdb1, 0, query);
2856 ok(r == ERROR_SUCCESS, "failed to add property table\n");
2857
2858 query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2859 r = run_query(hdb1, 0, query);
2860 ok(r == ERROR_SUCCESS, "failed to add property\n");
2861
2862 /* database needs to be committed */
2863 MsiDatabaseCommit(hdb1);
2864
2865 r = MsiDatabaseGenerateTransformA(hdb1, hdb2, mstfile, 0, 0);
2866 ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r );
2867
2868 MsiCloseHandle( hdb1 );
2869 MsiCloseHandle( hdb2 );
2870
2871 DeleteFileA("testdata.bin");
2872}
static const WCHAR msifile2W[]
Definition: db.c:37
static const char * msifile2
Definition: db.c:34
static const char * msifile
Definition: db.c:33
static const char * mstfile
Definition: db.c:35
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:79
UINT WINAPI MsiDatabaseGenerateTransformA(MSIHANDLE hdb, MSIHANDLE hdbref, const char *szTransformFile, int iReserved1, int iReserved2)
Definition: msiquery.c:949
#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 2957 of file db.c.

2958{
2959 IStorage *stg = NULL;
2960 IStream *stm;
2961 WCHAR name[0x20];
2962 HRESULT r;
2963 DWORD i, count;
2965
2966 const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
2967
2968 MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
2969
2970 r = StgCreateDocfile(name, mode, 0, &stg);
2971 ok(r == S_OK, "failed to create storage\n");
2972 if (!stg)
2973 return;
2974
2975 r = IStorage_SetClass( stg, &CLSID_MsiTransform );
2976 ok(r == S_OK, "failed to set storage type\n");
2977
2978 for (i=0; i<ARRAY_SIZE(table_transform_data); i++)
2979 {
2980 r = IStorage_CreateStream( stg, table_transform_data[i].name,
2981 STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
2982 if (FAILED(r))
2983 {
2984 ok(0, "failed to create stream %#lx\n", r);
2985 continue;
2986 }
2987
2988 r = IStream_Write( stm, table_transform_data[i].data,
2991 ok(0, "failed to write stream\n");
2992 IStream_Release(stm);
2993 }
2994
2995 IStorage_Release(stg);
2996}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct @1678 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 1234 of file db.c.

1235{
1236 MSIHANDLE hview = 0, rec = 0;
1237 UINT r;
1238
1239 r = MsiDatabaseOpenViewA(hdb, query, &hview);
1240 if( r != ERROR_SUCCESS )
1241 return r;
1242
1243 r = MsiViewExecute(hview, 0);
1244 if( r == ERROR_SUCCESS )
1245 {
1246 MsiViewGetColumnInfo( hview, type, &rec );
1247 }
1248 MsiViewClose(hview);
1249 MsiCloseHandle(hview);
1250 return rec;
1251}
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
Definition: msiquery.c:642

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 1253 of file db.c.

1254{
1255 MSIHANDLE hview = 0, rec = 0;
1256 UINT r, type = 0;
1257 char query[0x100];
1258
1259 sprintf(query, "select * from `_Columns` where `Table` = '%s'", table );
1260
1261 r = MsiDatabaseOpenViewA(hdb, query, &hview);
1262 if( r != ERROR_SUCCESS )
1263 return r;
1264
1265 r = MsiViewExecute(hview, 0);
1266 if( r == ERROR_SUCCESS )
1267 {
1268 while (1)
1269 {
1270 r = MsiViewFetch( hview, &rec );
1271 if( r != ERROR_SUCCESS)
1272 break;
1273 r = MsiRecordGetInteger( rec, 2 );
1274 if (r == field)
1275 type = MsiRecordGetInteger( rec, 4 );
1276 MsiCloseHandle( rec );
1277 }
1278 }
1279 MsiViewClose(hview);
1280 MsiCloseHandle(hview);
1281 return type;
1282}
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 3066 of file db.c.

3067{
3068 UINT res;
3069 CHAR szPackage[12];
3070 MSIHANDLE hPackage;
3071
3072 sprintf(szPackage, "#%lu", hdb);
3073 res = MsiOpenPackageA(szPackage, &hPackage);
3074 if (res != ERROR_SUCCESS)
3075 return res;
3076
3077 res = MsiCloseHandle(hdb);
3078 if (res != ERROR_SUCCESS)
3079 {
3080 MsiCloseHandle(hPackage);
3081 return res;
3082 }
3083
3084 *handle = hPackage;
3085 return ERROR_SUCCESS;
3086}
UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
Definition: package.c:1669
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 6793 of file db.c.

6794{
6795 HANDLE file;
6796 DWORD read;
6797
6802}
#define read
Definition: acwin.h:96
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define ZeroMemory
Definition: winbase.h:1712

Referenced by test_forcecodepage().

◆ run_query()

◆ run_queryW()

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

Definition at line 231 of file db.c.

232{
233 MSIHANDLE hview = 0;
234 UINT r;
235
236 r = MsiDatabaseOpenViewW(hdb, query, &hview);
237 if( r != ERROR_SUCCESS )
238 return r;
239
240 r = MsiViewExecute(hview, hrec);
241 if( r == ERROR_SUCCESS )
242 r = MsiViewClose(hview);
243 MsiCloseHandle(hview);
244 return r;
245}
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 2998 of file db.c.

2999{
3000 UINT res;
3002
3003 /* build summary info */
3005 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
3006
3008 "Installation Database");
3009 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3010
3012 "Installation Database");
3013 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3014
3016 "Wine Hackers");
3017 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3018
3020 ";1033,2057");
3021 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3022
3024 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
3025 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3026
3028 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3029
3031 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3032
3034 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
3035
3037 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
3038
3039 return res;
3040}
static const CHAR suminfo[]
Definition: db.c:2206
@ 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:937
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, const char *szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
Definition: suminfo.c:584
UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE handle)
Definition: suminfo.c:1222

Referenced by create_package_db(), and test_dbtopackage().

◆ START_TEST()

START_TEST ( db  )

Definition at line 9379 of file db.c.

9380{
9391 test_binary();
9393 test_where();
9396 test_markers();
9399 test_join();
9401 test_alter();
9402 test_integers();
9403 test_update();
9413 test_order();
9416 test_quotes();
9418 test_noquotes();
9425 test_dbmerge();
9439}
static void test_quotes(void)
Definition: db.c:6395
static void test_viewgetcolumninfo(void)
Definition: db.c:1284
static void test_deleterow(void)
Definition: db.c:6335
static void test_msiimport(void)
Definition: db.c:2368
static void test_integers(void)
Definition: db.c:4165
static void test_defaultdatabase(void)
Definition: db.c:5943
static void test_viewfetch_wraparound(void)
Definition: db.c:9297
static void test_update(void)
Definition: db.c:4274
static void test_getcolinfo(void)
Definition: db.c:1182
static void test_collation(void)
Definition: db.c:4795
static void test_temporary_table(void)
Definition: db.c:3858
static void test_noquotes(void)
Definition: db.c:6656
static void test_msiinsert(void)
Definition: db.c:353
static void test_handle_limit(void)
Definition: db.c:2744
static void test_viewmodify_delete_temporary(void)
Definition: db.c:6219
static void test_try_transform(void)
Definition: db.c:3088
static void test_where_viewmodify(void)
Definition: db.c:6983
static void test_binary_import(void)
Definition: db.c:2508
static void test_msidatabase(void)
Definition: db.c:64
static void test_viewmodify_update(void)
Definition: db.c:5020
static void test_suminfo_import(void)
Definition: db.c:2245
static void test_storages_table(void)
Definition: db.c:7115
static void test_primary_keys(void)
Definition: db.c:8782
static void test_viewmodify_delete(void)
Definition: db.c:5781
static void test_markers(void)
Definition: db.c:2559
static void test_select_markers(void)
Definition: db.c:4933
static void test_select_with_tablenames(void)
Definition: db.c:8087
static void test_binary(void)
Definition: db.c:1851
static void test_order(void)
Definition: db.c:5970
static void test_special_tables(void)
Definition: db.c:4543
static void test_viewmodify_insert(void)
Definition: db.c:9018
static void test_viewmodify_assign(void)
Definition: db.c:5278
static void test_tables_order(void)
Definition: db.c:4581
static void test_join(void)
Definition: db.c:3414
static void test_createtable(void)
Definition: db.c:8482
static void test_viewmodify_merge(void)
Definition: db.c:8821
static void test_columnorder(void)
Definition: db.c:8307
static void test_select_column_names(void)
Definition: db.c:8615
static void test_forcecodepage(void)
Definition: db.c:6804
static void test_stringtable(void)
Definition: db.c:5576
static void test_viewmodify_refresh(void)
Definition: db.c:6874
static void test_droptable(void)
Definition: db.c:7360
static void test_streamtable(void)
Definition: db.c:1528
static void test_where(void)
Definition: db.c:2057
static void test_rows_order(void)
Definition: db.c:4689
static void test_msidecomposedesc(void)
Definition: db.c:511
static void test_carriagereturn(void)
Definition: db.c:6487
static void test_msiexport(void)
Definition: db.c:1372
static void test_insertorder(void)
Definition: db.c:8171
static void test_msibadqueries(void)
Definition: db.c:647
static void test_longstrings(void)
Definition: db.c:1447
static void test_where_not_in_selected(void)
Definition: db.c:1965
static void test_dbtopackage(void)
Definition: db.c:7234
static void test_viewmodify(void)
Definition: db.c:866
static void test_view_get_error(void)
Definition: db.c:9182
static void test_embedded_nulls(void)
Definition: db.c:8580
static void test_dbmerge(void)
Definition: db.c:7530
static void test_alter(void)
Definition: db.c:3968

◆ test_alter()

static void test_alter ( void  )
static

Definition at line 3968 of file db.c.

3969{
3970 MSICONDITION cond;
3971 MSIHANDLE hdb = 0, rec;
3972 const char *query;
3973 UINT r;
3974
3975 hdb = create_db();
3976 ok( hdb, "failed to create db\n");
3977
3978 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`)";
3979 r = run_query(hdb, 0, query);
3980 ok(r == ERROR_SUCCESS, "failed to add table\n");
3981
3982 query = "SELECT * FROM `T`";
3983 r = run_query(hdb, 0, query);
3984 ok(r == ERROR_BAD_QUERY_SYNTAX, "expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
3985
3986 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`) HOLD";
3987 r = run_query(hdb, 0, query);
3988 ok(r == ERROR_SUCCESS, "failed to add table\n");
3989
3990 query = "SELECT * FROM `T`";
3991 r = run_query(hdb, 0, query);
3992 ok(r == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", r);
3993
3994 cond = MsiDatabaseIsTablePersistentA(hdb, "T");
3995 ok( cond == MSICONDITION_FALSE, "wrong return condition\n");
3996
3997 query = "ALTER TABLE `T` HOLD";
3998 r = run_query(hdb, 0, query);
3999 ok(r == ERROR_SUCCESS, "failed to hold table %d\n", r);
4000
4001 query = "ALTER TABLE `T` FREE";
4002 r = run_query(hdb, 0, query);
4003 ok(r == ERROR_SUCCESS, "failed to free table\n");
4004
4005 query = "ALTER TABLE `T` FREE";
4006 r = run_query(hdb, 0, query);
4007 ok(r == ERROR_SUCCESS, "failed to free table\n");
4008
4009 query = "ALTER TABLE `T` FREE";
4010 r = run_query(hdb, 0, query);
4011 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to free table\n");
4012
4013 query = "ALTER TABLE `T` HOLD";
4014 r = run_query(hdb, 0, query);
4015 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to hold table %d\n", r);
4016
4017 /* table T is removed */
4018 query = "SELECT * FROM `T`";
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 /* create the table again */
4023 query = "CREATE TABLE `U` ( `A` INTEGER, `B` INTEGER PRIMARY KEY `B`)";
4024 r = run_query(hdb, 0, query);
4025 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4026
4027 /* up the ref count */
4028 query = "ALTER TABLE `U` HOLD";
4029 r = run_query(hdb, 0, query);
4030 ok(r == ERROR_SUCCESS, "failed to free table\n");
4031
4032 /* add column, no data type */
4033 query = "ALTER TABLE `U` ADD `C`";
4034 r = run_query(hdb, 0, query);
4035 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4036
4037 query = "ALTER TABLE `U` ADD `C` INTEGER";
4038 r = run_query(hdb, 0, query);
4039 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4040
4041 query = "SELECT * FROM `_Columns` WHERE `Table` = 'U' AND `Name` = 'C'";
4042 r = do_query(hdb, query, &rec);
4043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4044
4045 /* add column C again */
4046 query = "ALTER TABLE `U` ADD `C` INTEGER";
4047 r = run_query(hdb, 0, query);
4048 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4049
4050 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY";
4051 r = run_query(hdb, 0, query);
4052 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4053
4054 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 1, 2, 3, 4 )";
4055 r = run_query(hdb, 0, query);
4056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4057
4058 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY HOLD";
4059 r = run_query(hdb, 0, query);
4060 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4061
4062 query = "SELECT * FROM `_Columns` WHERE `Table` = 'U' AND `Name` = 'D'";
4063 r = do_query(hdb, query, &rec);
4064 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
4065
4066 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 5, 6, 7, 8 )";
4067 r = run_query(hdb, 0, query);
4068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4069
4070 query = "SELECT * FROM `U` WHERE `D` = 8";
4071 r = run_query(hdb, 0, query);
4072 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4073
4074 query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY FREE";
4075 r = run_query(hdb, 0, query);
4076 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4077
4078 query = "ALTER COLUMN `D` FREE";
4079 r = run_query(hdb, 0, query);
4080 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4081
4082 /* drop the ref count */
4083 query = "ALTER TABLE `U` FREE";
4084 r = run_query(hdb, 0, query);
4085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4086
4087 /* table is not empty */
4088 query = "SELECT * FROM `U`";
4089 r = run_query(hdb, 0, query);
4090 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4091
4092 /* column D is removed */
4093 query = "SELECT * FROM `U` WHERE `D` = 8";
4094 r = run_query(hdb, 0, query);
4095 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4096
4097 query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 9, 10, 11, 12 )";
4098 r = run_query(hdb, 0, query);
4099 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4100
4101 /* add the column again */
4102 query = "ALTER TABLE `U` ADD `E` INTEGER TEMPORARY HOLD";
4103 r = run_query(hdb, 0, query);
4104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4105
4106 /* up the ref count */
4107 query = "ALTER TABLE `U` HOLD";
4108 r = run_query(hdb, 0, query);
4109 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4110
4111 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 13, 14, 15, 16 )";
4112 r = run_query(hdb, 0, query);
4113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4114
4115 query = "SELECT * FROM `U` WHERE `E` = 16";
4116 r = run_query(hdb, 0, query);
4117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4118
4119 /* drop the ref count */
4120 query = "ALTER TABLE `U` FREE";
4121 r = run_query(hdb, 0, query);
4122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4123
4124 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 17, 18, 19, 20 )";
4125 r = run_query(hdb, 0, query);
4126 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4127
4128 query = "SELECT * FROM `U` WHERE `E` = 20";
4129 r = run_query(hdb, 0, query);
4130 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4131
4132 /* drop the ref count */
4133 query = "ALTER TABLE `U` FREE";
4134 r = run_query(hdb, 0, query);
4135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4136
4137 /* table still exists */
4138 query = "SELECT * FROM `U`";
4139 r = run_query(hdb, 0, query);
4140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4141
4142 /* col E is removed */
4143 query = "SELECT * FROM `U` WHERE `E` = 20";
4144 r = run_query(hdb, 0, query);
4145 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4146
4147 query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 20, 21, 22, 23 )";
4148 r = run_query(hdb, 0, query);
4149 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4150
4151 /* drop the ref count once more */
4152 query = "ALTER TABLE `U` FREE";
4153 r = run_query(hdb, 0, query);
4154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4155
4156 /* table still exists */
4157 query = "SELECT * FROM `U`";
4158 r = run_query(hdb, 0, query);
4159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4160
4161 MsiCloseHandle( hdb );
4163}
static MSIHANDLE create_db(void)
Definition: db.c:1163
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
Definition: db.c:190
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
MSICONDITION WINAPI MsiDatabaseIsTablePersistentA(MSIHANDLE hDatabase, const char *szTableName)
Definition: msiquery.c:1148
@ 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 1851 of file db.c.

1852{
1853 MSIHANDLE hdb = 0, rec;
1854 char file[MAX_PATH];
1855 char buf[MAX_PATH];
1856 DWORD size;
1857 LPCSTR query;
1858 UINT r;
1859
1860 /* insert a file into the Binary table */
1862 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1863
1864 query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1865 r = run_query( hdb, 0, query );
1866 ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1867
1868 create_file( "test.txt" );
1869 rec = MsiCreateRecord( 1 );
1870 r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1871 ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r);
1872 DeleteFileA( "test.txt" );
1873
1874 /* try a name that exceeds maximum OLE stream name length */
1875 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'encryption.dll.CB4E6205_F99A_4C51_ADD4_184506EFAB87', 10000, ? )";
1876 r = run_query( hdb, rec, query );
1877 ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1878
1879 r = MsiCloseHandle( rec );
1880 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1881
1882 r = MsiDatabaseCommit( hdb );
1883 ok( r == ERROR_FUNCTION_FAILED , "got %u\n", r );
1884
1885 r = MsiCloseHandle( hdb );
1886 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1887
1889 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1890
1891 query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1892 r = run_query( hdb, 0, query );
1893 ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1894
1895 create_file( "test.txt" );
1896 rec = MsiCreateRecord( 1 );
1897 r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1898 ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r );
1899 DeleteFileA( "test.txt" );
1900
1901 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1902 r = run_query( hdb, rec, query );
1903 ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1904
1905 query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1906 r = run_query( hdb, rec, query );
1907 ok( r == ERROR_FUNCTION_FAILED, "got %u\n", r );
1908
1909 r = MsiCloseHandle( rec );
1910 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1911
1912 r = MsiDatabaseCommit( hdb );
1913 ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
1914
1915 r = MsiCloseHandle( hdb );
1916 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1917
1918 /* read file from the Stream table */
1920 ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1921
1922 query = "SELECT * FROM `_Streams`";
1923 r = do_query( hdb, query, &rec );
1924 ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1925
1926 size = MAX_PATH;
1927 r = MsiRecordGetStringA( rec, 1, file, &size );
1928 ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1929 ok( !lstrcmpA(file, "Binary.filename1.1"), "Expected 'Binary.filename1.1', got %s\n", file );
1930
1931 size = MAX_PATH;
1932 memset( buf, 0, MAX_PATH );
1933 r = MsiRecordReadStream( rec, 2, buf, &size );
1934 ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1935 ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf );
1936
1937 r = MsiCloseHandle( rec );
1938 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1939
1940 /* read file from the Binary table */
1941 query = "SELECT * FROM `Binary`";
1942 r = do_query( hdb, query, &rec );
1943 ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1944
1945 size = MAX_PATH;
1946 r = MsiRecordGetStringA( rec, 1, file, &size );
1947 ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1948 ok( !lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file );
1949
1950 size = MAX_PATH;
1951 memset( buf, 0, MAX_PATH );
1952 r = MsiRecordReadStream( rec, 3, buf, &size );
1953 ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1954 ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf );
1955
1956 r = MsiCloseHandle( rec );
1957 ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1958
1959 r = MsiCloseHandle( hdb );
1960 ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1961
1963}
#define create_file(name)
Definition: db.c:1526
DWORD size
Definition: db.c:2943
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4194
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 ERROR_FUNCTION_FAILED
Definition: winerror.h:985

Referenced by START_TEST().

◆ test_binary_import()

static void test_binary_import ( void  )
static

Definition at line 2508 of file db.c.

2509{
2510 MSIHANDLE hdb = 0, rec;
2511 char file[MAX_PATH];
2512 char buf[MAX_PATH];
2513 char path[MAX_PATH];
2514 DWORD size;
2515 LPCSTR query;
2516 UINT r;
2517
2518 /* create files to import */
2519 write_file("bin_import.idt", bin_import_dat,
2520 (sizeof(bin_import_dat) - 1) * sizeof(char));
2521 CreateDirectoryA("bin_import", NULL);
2522 create_file_data("bin_import/filename1.ibd", "just some words", 15);
2523
2524 /* import files into database */
2526 ok( r == ERROR_SUCCESS , "Failed to open database\n");
2527
2529 r = MsiDatabaseImportA(hdb, path, "bin_import.idt");
2530 ok(r == ERROR_SUCCESS , "Failed to import Binary table\n");
2531
2532 /* read file from the Binary table */
2533 query = "SELECT * FROM `Binary`";
2534 r = do_query(hdb, query, &rec);
2535 ok(r == ERROR_SUCCESS, "SELECT query failed: %d\n", r);
2536
2537 size = MAX_PATH;
2538 r = MsiRecordGetStringA(rec, 1, file, &size);
2539 ok(r == ERROR_SUCCESS, "Failed to get string: %d\n", r);
2540 ok(!lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file);
2541
2542 size = MAX_PATH;
2543 memset(buf, 0, MAX_PATH);
2544 r = MsiRecordReadStream(rec, 2, buf, &size);
2545 ok(r == ERROR_SUCCESS, "Failed to get stream: %d\n", r);
2546 ok(!lstrcmpA(buf, "just some words"), "Expected 'just some words', got %s\n", buf);
2547
2548 r = MsiCloseHandle(rec);
2549 ok(r == ERROR_SUCCESS , "Failed to close record handle\n");
2550
2551 r = MsiCloseHandle(hdb);
2552 ok(r == ERROR_SUCCESS , "Failed to close database\n");
2553
2554 DeleteFileA("bin_import/filename1.ibd");
2555 RemoveDirectoryA("bin_import");
2556 DeleteFileA("bin_import.idt");
2557}
static const CHAR bin_import_dat[]
Definition: db.c:2503
static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
Definition: db.c:1505
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

Referenced by START_TEST().

◆ test_carriagereturn()

static void test_carriagereturn ( void  )
static

Definition at line 6487 of file db.c.

6488{
6489 MSIHANDLE hdb, hview, hrec;
6490 const char *query;
6491 UINT r;
6492
6494
6496 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6497
6498 query = "CREATE TABLE `Table`\r ( `A` CHAR(72) NOT NULL 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` \r( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6504 r = run_query(hdb, 0, query);
6506 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6507
6508 query = "CREATE\r TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6509 r = run_query(hdb, 0, query);
6511 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6512
6513 query = "CREATE TABLE\r `Table` ( `A` CHAR(72) NOT NULL PRIMARY 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` (\r `A` CHAR(72) NOT NULL PRIMARY KEY `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`\r CHAR(72) NOT NULL PRIMARY KEY `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)\r NOT NULL PRIMARY KEY `A` )";
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\r NULL PRIMARY KEY `A` )";
6534 r = run_query(hdb, 0, query);
6536 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6537
6538 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT \rNULL PRIMARY KEY `A` )";
6539 r = run_query(hdb, 0, query);
6541 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6542
6543 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL\r PRIMARY KEY `A` )";
6544 r = run_query(hdb, 0, query);
6546 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6547
6548 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL \rPRIMARY KEY `A` )";
6549 r = run_query(hdb, 0, query);
6551 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6552
6553 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY\r KEY `A` )";
6554 r = run_query(hdb, 0, query);
6556 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6557
6558 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY \rKEY `A` )";
6559 r = run_query(hdb, 0, query);
6561 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6562
6563 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY\r `A` )";
6564 r = run_query(hdb, 0, query);
6566 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6567
6568 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A`\r )";
6569 r = run_query(hdb, 0, query);
6571 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6572
6573 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )\r";
6574 r = run_query(hdb, 0, query);
6576 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6577
6578 query = "CREATE TABLE `\rOne` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6579 r = run_query(hdb, 0, query);
6580 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6581
6582 query = "CREATE TABLE `Tw\ro` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6583 r = run_query(hdb, 0, query);
6584 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6585
6586 query = "CREATE TABLE `Three\r` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6587 r = run_query(hdb, 0, query);
6588 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6589
6590 query = "CREATE TABLE `Four` ( `A\r` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6591 r = run_query(hdb, 0, query);
6593 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6594
6595 query = "CREATE TABLE `Four` ( `\rA` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6596 r = run_query(hdb, 0, query);
6598 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6599
6600 query = "CREATE TABLE `Four` ( `A` CHAR(72\r) NOT NULL PRIMARY KEY `A` )";
6601 r = run_query(hdb, 0, query);
6603 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6604
6605 query = "CREATE TABLE `Four` ( `A` CHAR(\r72) NOT NULL PRIMARY KEY `A` )";
6606 r = run_query(hdb, 0, query);
6608 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6609
6610 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `\rA` )";
6611 r = run_query(hdb, 0, query);
6613 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6614
6615 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6616 r = run_query(hdb, 0, query);
6618 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6619
6620 query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6621 r = run_query(hdb, 0, query);
6623 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6624
6625 query = "SELECT `Name` FROM `_Tables`";
6626 r = MsiDatabaseOpenViewA(hdb, query, &hview);
6627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6628 r = MsiViewExecute(hview, 0);
6629 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6630
6631 r = MsiViewFetch(hview, &hrec);
6632 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6633 check_record(hrec, 1, "\rOne");
6634 MsiCloseHandle(hrec);
6635
6636 r = MsiViewFetch(hview, &hrec);
6637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6638 check_record(hrec, 1, "Tw\ro");
6639 MsiCloseHandle(hrec);
6640
6641 r = MsiViewFetch(hview, &hrec);
6642 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6643 check_record(hrec, 1, "Three\r");
6644 MsiCloseHandle(hrec);
6645
6646 r = MsiViewFetch(hview, &hrec);
6647 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6648
6649 MsiViewClose(hview);
6650 MsiCloseHandle(hview);
6651
6652 MsiCloseHandle(hdb);
6654}
#define check_record(rec,...)
Definition: db.c:62

Referenced by START_TEST().

◆ test_collation()

static void test_collation ( void  )
static

Definition at line 4795 of file db.c.

4796{
4797 const char *query;
4798 MSIHANDLE hdb = 0, hview = 0, hrec = 0;
4799 UINT r;
4800 char buffer[100];
4801 WCHAR bufferW[100];
4802 DWORD sz;
4803
4805 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
4806
4807 query = "CREATE TABLE `bar` ( "
4808 "`foo` LONGCHAR NOT NULL, "
4809 "`baz` LONGCHAR NOT NULL "
4810 "PRIMARY KEY `foo` )";
4811 r = run_query(hdb, 0, query);
4812 ok(r == ERROR_SUCCESS, "failed to create table\n");
4813
4814 r = run_query(hdb, 0, query);
4815 ok(r == ERROR_BAD_QUERY_SYNTAX, "wrong error %u\n", r);
4816
4817 r = run_query(hdb, 0, "INSERT INTO `bar` "
4818 "( `foo`, `baz` ) VALUES ( '\2', 'A' )");
4819 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4820
4821 r = run_query(hdb, 0, "INSERT INTO `bar` "
4822 "( `foo`, `baz` ) VALUES ( '\1', 'B' )");
4823 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4824
4825 r = run_queryW(hdb, 0, L"INSERT INTO `bar` (`foo`,`baz`) VALUES ('a\x30a','C')");
4826 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4827
4828 r = run_queryW(hdb, 0, L"INSERT INTO `bar` (`foo`,`baz`) VALUES ('\xe5','D')");
4829 ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
4830
4831 r = run_queryW(hdb, 0, L"CREATE TABLE `baz` ( `a\x30a` LONGCHAR NOT NULL, `\xe5` LONGCHAR NOT NULL PRIMARY KEY `a\x30a`)");
4832 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4833
4834 r = run_queryW(hdb, 0, L"CREATE TABLE `a\x30a` ( `foo` LONGCHAR NOT NULL PRIMARY KEY `foo`)");
4835 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4836
4837 r = run_queryW(hdb, 0, L"CREATE TABLE `\xe5` ( `foo` LONGCHAR NOT NULL PRIMARY KEY `foo`)");
4838 ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
4839
4840 query = "SELECT * FROM `bar`";
4841 r = MsiDatabaseOpenViewA(hdb, query, &hview);
4842 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4843 r = MsiViewExecute(hview, 0);
4844 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4845
4846 r = MsiViewFetch(hview, &hrec);
4847 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4848 sz = sizeof(buffer);
4849 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
4850 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4851 ok(!lstrcmpA(buffer, "\2"), "Expected \\2, got '%s'\n", buffer);
4852 sz = sizeof(buffer);
4853 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
4854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4855 ok(!lstrcmpA(buffer, "A"), "Expected A, got '%s'\n", buffer);
4856 MsiCloseHandle(hrec);
4857
4858 r = MsiViewFetch(hview, &hrec);
4859 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4860 sz = sizeof(buffer);
4861 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
4862 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4863 ok(!lstrcmpA(buffer, "\1"), "Expected \\1, got '%s'\n", buffer);
4864 sz = sizeof(buffer);
4865 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
4866 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4867 ok(!lstrcmpA(buffer, "B"), "Expected B, got '%s'\n", buffer);
4868 MsiCloseHandle(hrec);
4869
4870 r = MsiViewFetch(hview, &hrec);
4871 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4872 sz = ARRAY_SIZE(bufferW);
4873 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4874 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4875 ok(!memcmp(bufferW, L"a\x30a", sizeof(L"a\x30a")),
4876 "Expected %s, got %s\n", wine_dbgstr_w(L"a\x30a"), wine_dbgstr_w(bufferW));
4877 sz = ARRAY_SIZE(bufferW);
4878 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4879 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4880 ok(!lstrcmpW(bufferW, L"C"), "Expected C, got %s\n", wine_dbgstr_w(bufferW));
4881 MsiCloseHandle(hrec);
4882
4883 r = MsiViewFetch(hview, &hrec);
4884 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4885 sz = ARRAY_SIZE(bufferW);
4886 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4887 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4888 ok(!memcmp(bufferW, L"\xe5", sizeof(L"\xe5")),
4889 "Expected %s, got %s\n", wine_dbgstr_w(L"\xe5"), wine_dbgstr_w(bufferW));
4890 sz = ARRAY_SIZE(bufferW);
4891 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4892 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4893 ok(!lstrcmpW(bufferW, L"D"), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
4894 MsiCloseHandle(hrec);
4895
4896 r = MsiViewClose(hview);
4897 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4898 r = MsiCloseHandle(hview);
4899 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4900
4901 r = MsiDatabaseOpenViewW(hdb, L"SELECT * FROM `bar` WHERE `foo` ='\xe5'", &hview);
4902 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4903 r = MsiViewExecute(hview, 0);
4904 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4905
4906 r = MsiViewFetch(hview, &hrec);
4907 ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
4908 sz = ARRAY_SIZE(bufferW);
4909 r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
4910 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4911 ok(!memcmp(bufferW, L"\xe5", sizeof(L"\xe5")),
4912 "Expected %s, got %s\n", wine_dbgstr_w(L"\xe5"), wine_dbgstr_w(bufferW));
4913 sz = ARRAY_SIZE(bufferW);
4914 r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
4915 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4916 ok(!lstrcmpW(bufferW, L"D"), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
4917 MsiCloseHandle(hrec);
4918
4919 r = MsiViewFetch(hview, &hrec);
4920 ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
4921
4922 r = MsiViewClose(hview);
4923 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4924 r = MsiCloseHandle(hview);
4925 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4926
4927 r = MsiCloseHandle(hdb);
4928 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4929
4931}
static UINT run_queryW(MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query)
Definition: db.c:231
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 8307 of file db.c.

8308{
8309 MSIHANDLE hdb, view, rec;
8310 LPCSTR query;
8311 UINT r;
8312
8313 hdb = create_db();
8314 ok(hdb, "failed to create db\n");
8315
8316 /* Each column is a slot:
8317 * ---------------------
8318 * | B | C | A | E | D |
8319 * ---------------------
8320 *
8321 * When a column is selected as a primary key,
8322 * the column occupying the nth primary key slot is swapped
8323 * with the current position of the primary key in question:
8324 *
8325 * set primary key `D`
8326 * --------------------- ---------------------
8327 * | B | C | A | E | D | -> | D | C | A | E | B |
8328 * --------------------- ---------------------
8329 *
8330 * set primary key `E`
8331 * --------------------- ---------------------
8332 * | D | C | A | E | B | -> | D | E | A | C | B |
8333 * --------------------- ---------------------
8334 */
8335
8336 query = "CREATE TABLE `T` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
8337 "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
8338 "PRIMARY KEY `D`, `E`)";
8339 r = run_query(hdb, 0, query);
8340 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8341
8342 query = "SELECT * FROM `T`";
8343 r = MsiDatabaseOpenViewA(hdb, query, &view);
8344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8345
8347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8348 check_record(rec, 5, "s255", "I2", "S255", "i2", "i2");
8349 MsiCloseHandle(rec);
8350
8352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8353 check_record(rec, 5, "D", "E", "A", "C", "B");
8354 MsiCloseHandle(rec);
8355
8358
8359 query = "INSERT INTO `T` ( `B`, `C`, `A`, `E`, `D` ) "
8360 "VALUES ( 1, 2, 'a', 3, 'bc' )";
8361 r = run_query(hdb, 0, query);
8362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8363
8364 query = "SELECT * FROM `T`";
8365 r = do_query(hdb, query, &rec);
8366 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8367 check_record(rec, 5, "bc", "3", "a", "2", "1");
8368 MsiCloseHandle(rec);
8369
8370 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'T'";
8371 r = MsiDatabaseOpenViewA(hdb, query, &view);
8372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8373 r = MsiViewExecute(view, 0);
8374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8375
8376 r = MsiViewFetch(view, &rec);
8377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8378 check_record(rec, 3, "T", "1", "D");
8379 MsiCloseHandle(rec);
8380
8381 r = MsiViewFetch(view, &rec);
8382 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8383 check_record(rec, 3, "T", "2", "E");
8384 MsiCloseHandle(rec);
8385
8386 r = MsiViewFetch(view, &rec);
8387 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8388 check_record(rec, 3, "T", "3", "A");
8389 MsiCloseHandle(rec);
8390
8391 r = MsiViewFetch(view, &rec);
8392 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8393 check_record(rec, 3, "T", "4", "C");
8394 MsiCloseHandle(rec);
8395
8396 r = MsiViewFetch(view, &rec);
8397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8398 check_record(rec, 3, "T", "5", "B");
8399 MsiCloseHandle(rec);
8400
8401 r = MsiViewFetch(view, &rec);
8402 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8403
8406
8407 query = "CREATE TABLE `Z` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
8408 "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
8409 "PRIMARY KEY `C`, `A`, `D`)";
8410 r = run_query(hdb, 0, query);
8411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8412
8413 query = "SELECT * FROM `Z`";
8414 r = MsiDatabaseOpenViewA(hdb, query, &view);
8415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8416
8418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8419 check_record(rec, 5, "i2", "S255", "s255", "I2", "i2");
8420 MsiCloseHandle(rec);
8421
8423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8424 check_record(rec, 5, "C", "A", "D", "E", "B");
8425 MsiCloseHandle(rec);
8426
8429
8430 query = "INSERT INTO `Z` ( `B`, `C`, `A`, `E`, `D` ) "
8431 "VALUES ( 1, 2, 'a', 3, 'bc' )";
8432 r = run_query(hdb, 0, query);
8433 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8434
8435 query = "SELECT * FROM `Z`";
8436 r = do_query(hdb, query, &rec);
8437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8438 check_record(rec, 5, "2", "a", "bc", "3", "1");
8439 MsiCloseHandle(rec);
8440
8441 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'T'";
8442 r = MsiDatabaseOpenViewA(hdb, query, &view);
8443 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8444 r = MsiViewExecute(view, 0);
8445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8446
8447 r = MsiViewFetch(view, &rec);
8448 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8449 check_record(rec, 3, "T", "1", "D");
8450 MsiCloseHandle(rec);
8451
8452 r = MsiViewFetch(view, &rec);
8453 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8454 check_record(rec, 3, "T", "2", "E");
8455 MsiCloseHandle(rec);
8456
8457 r = MsiViewFetch(view, &rec);
8458 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8459 check_record(rec, 3, "T", "3", "A");
8460 MsiCloseHandle(rec);
8461
8462 r = MsiViewFetch(view, &rec);
8463 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8464 check_record(rec, 3, "T", "4", "C");
8465 MsiCloseHandle(rec);
8466
8467 r = MsiViewFetch(view, &rec);
8468 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8469 check_record(rec, 3, "T", "5", "B");
8470 MsiCloseHandle(rec);
8471
8472 r = MsiViewFetch(view, &rec);
8473 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8474
8477
8478 MsiCloseHandle(hdb);
8480}
@ 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 8482 of file db.c.

8483{
8484 MSIHANDLE hdb, htab = 0, hrec = 0;
8485 LPCSTR query;
8486 UINT res;
8487 DWORD size;
8488 char buffer[0x20];
8489
8490 hdb = create_db();
8491 ok(hdb, "failed to create db\n");
8492
8493 query = "CREATE TABLE `blah` (`foo` CHAR(72) NOT NULL PRIMARY KEY `foo`)";
8494 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8495 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8496 if(res == ERROR_SUCCESS )
8497 {
8498 res = MsiViewExecute( htab, hrec );
8499 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8500
8501 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8502 todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8503
8504 size = sizeof(buffer);
8505 res = MsiRecordGetStringA(hrec, 1, buffer, &size );
8506 todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8507 MsiCloseHandle( hrec );
8508
8509 res = MsiViewClose( htab );
8510 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8511
8512 res = MsiCloseHandle( htab );
8513 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8514 }
8515
8516 query = "CREATE TABLE `a` (`b` INT PRIMARY KEY `b`)";
8517 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8518 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8519 if(res == ERROR_SUCCESS )
8520 {
8521 res = MsiViewExecute( htab, 0 );
8522 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8523
8524 res = MsiViewClose( htab );
8525 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8526
8527 res = MsiCloseHandle( htab );
8528 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8529
8530 query = "SELECT * FROM `a`";
8531 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8532 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8533
8534 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8535 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8536 check_record(hrec, 1, "b");
8537 MsiCloseHandle( hrec );
8538
8539 res = MsiViewClose( htab );
8540 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8541
8542 res = MsiCloseHandle( htab );
8543 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8544
8545 res = MsiDatabaseCommit(hdb);
8546 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8547
8548 res = MsiCloseHandle(hdb);
8549 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8550
8552 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8553
8554 query = "SELECT * FROM `a`";
8555 res = MsiDatabaseOpenViewA( hdb, query, &htab );
8556 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8557
8558 res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
8559 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8560 check_record(hrec, 1, "b");
8561 res = MsiCloseHandle( hrec );
8562 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8563
8564 res = MsiViewClose( htab );
8565 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8566
8567 res = MsiCloseHandle( htab );
8568 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8569 }
8570
8571 res = MsiDatabaseCommit(hdb);
8572 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8573
8574 res = MsiCloseHandle(hdb);
8575 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8576
8578}

Referenced by START_TEST().

◆ test_dbmerge()

static void test_dbmerge ( void  )
static

Definition at line 7530 of file db.c.

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

7235{
7236 MSIHANDLE hdb, hpkg;
7237 CHAR package[12], buf[MAX_PATH];
7238 DWORD size;
7239 UINT r;
7240
7241 /* create an empty database, transact mode */
7243 ok(r == ERROR_SUCCESS, "Failed to create database\n");
7244
7245 set_summary_info(hdb);
7246
7248
7250 add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
7251
7252 sprintf(package, "#%lu", hdb);
7253 r = MsiOpenPackageA(package, &hpkg);
7255 {
7256 skip("Not enough rights to perform tests\n");
7257 goto error;
7258 }
7259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7260
7261 /* property is not set yet */
7262 size = MAX_PATH;
7263 lstrcpyA(buf, "kiwi");
7264 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7266 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7267 ok(size == 0, "Expected 0, got %lu\n", size);
7268
7269 /* run the custom action to set the property */
7270 r = MsiDoActionA(hpkg, "SetProp");
7271 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7272
7273 /* property is now set */
7274 size = MAX_PATH;
7275 lstrcpyA(buf, "kiwi");
7276 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7277 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7278 ok(!lstrcmpA(buf, "grape"), "Expected \"grape\", got \"%s\"\n", buf);
7279 ok(size == 5, "Expected 5, got %lu\n", size);
7280
7281 MsiCloseHandle(hpkg);
7282
7283 /* reset the package */
7284 r = MsiOpenPackageA(package, &hpkg);
7285 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7286
7287 /* property is not set anymore */
7288 size = MAX_PATH;
7289 lstrcpyA(buf, "kiwi");
7290 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7291 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7292 todo_wine
7293 {
7294 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7295 ok(size == 0, "Expected 0, got %lu\n", size);
7296 }
7297
7298 MsiCloseHandle(hdb);
7299 MsiCloseHandle(hpkg);
7300
7301 /* create an empty database, direct mode */
7303 ok(r == ERROR_SUCCESS, "Failed to create database\n");
7304
7305 set_summary_info(hdb);
7306
7308
7310 add_custom_action_entry(hdb, "'SetProp', 51, 'MYPROP', 'grape'");
7311
7312 sprintf(package, "#%lu", hdb);
7313 r = MsiOpenPackageA(package, &hpkg);
7314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7315
7316 /* property is not set yet */
7317 size = MAX_PATH;
7318 lstrcpyA(buf, "kiwi");
7319 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7321 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7322 ok(size == 0, "Expected 0, got %lu\n", size);
7323
7324 /* run the custom action to set the property */
7325 r = MsiDoActionA(hpkg, "SetProp");
7326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7327
7328 /* property is now set */
7329 size = MAX_PATH;
7330 lstrcpyA(buf, "kiwi");
7331 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7333 ok(!lstrcmpA(buf, "grape"), "Expected \"grape\", got \"%s\"\n", buf);
7334 ok(size == 5, "Expected 5, got %lu\n", size);
7335
7336 MsiCloseHandle(hpkg);
7337
7338 /* reset the package */
7339 r = MsiOpenPackageA(package, &hpkg);
7340 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7341
7342 /* property is not set anymore */
7343 size = MAX_PATH;
7344 lstrcpyA(buf, "kiwi");
7345 r = MsiGetPropertyA(hpkg, "MYPROP", buf, &size);
7346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7347 todo_wine
7348 {
7349 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
7350 ok(size == 0, "Expected 0, got %lu\n", size);
7351 }
7352
7353 MsiCloseHandle(hpkg);
7354
7355error:
7356 MsiCloseHandle(hdb);
7358}
#define skip(...)
Definition: atltest.h:64
static UINT create_custom_action_table(MSIHANDLE hdb)
Definition: db.c:262
#define add_custom_action_entry(hdb, values)
Definition: db.c:339
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 5943 of file db.c.

5944{
5945 UINT r;
5946 HRESULT hr;
5947 MSIHANDLE hdb;
5948 IStorage *stg = NULL;
5949
5951
5953 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5954
5955 r = MsiDatabaseCommit(hdb);
5956 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5957
5958 MsiCloseHandle(hdb);
5959
5961 ok(hr == S_OK, "Expected S_OK, got %#lx\n", hr);
5962 ok(stg != NULL, "Expected non-NULL stg\n");
5963
5964 enum_stream_names(stg);
5965
5966 IStorage_Release(stg);
5968}
static void enum_stream_names(IStorage *stg)
Definition: db.c:5885
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 6335 of file db.c.

6336{
6337 MSIHANDLE hdb, hview, hrec;
6338 const char *query;
6339 UINT r;
6340
6342
6344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6345
6346 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6347 r = run_query(hdb, 0, query);
6348 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6349
6350 query = "INSERT INTO `Table` (`A`) VALUES ('one')";
6351 r = run_query(hdb, 0, query);
6352 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6353
6354 query = "INSERT INTO `Table` (`A`) VALUES ('two')";
6355 r = run_query(hdb, 0, query);
6356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6357
6358 query = "DELETE FROM `Table` WHERE `A` = 'one'";
6359 r = run_query(hdb, 0, query);
6360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6361
6362 r = MsiDatabaseCommit(hdb);
6363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6364
6365 MsiCloseHandle(hdb);
6366
6368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6369
6370 query = "SELECT * FROM `Table`";
6371 r = MsiDatabaseOpenViewA(hdb, query, &hview);
6372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6373 r = MsiViewExecute(hview, 0);
6374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6375
6376 r = MsiViewFetch(hview, &hrec);
6377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6378 check_record(hrec, 1, "two");
6379 MsiCloseHandle(hrec);
6380
6381 r = MsiViewFetch(hview, &hrec);
6382 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
6383
6384 MsiViewClose(hview);
6385 MsiCloseHandle(hview);
6386 MsiCloseHandle(hdb);
6388}

Referenced by START_TEST().

◆ test_droptable()

static void test_droptable ( void  )
static

Definition at line 7360 of file db.c.

7361{
7362 MSIHANDLE hdb, hview, hrec;
7363 LPCSTR query;
7364 UINT r;
7365
7367 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7368
7369 query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
7370 r = run_query(hdb, 0, query);
7371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7372
7373 query = "SELECT * FROM `One`";
7374 r = do_query(hdb, query, &hrec);
7375 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7376
7377 query = "SELECT `Name` FROM `_Tables` WHERE `Name` = 'One'";
7378 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7379 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7380 r = MsiViewExecute(hview, 0);
7381 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7382
7383 r = MsiViewFetch(hview, &hrec);
7384 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7385 check_record(hrec, 1, "One");
7386 MsiCloseHandle(hrec);
7387
7388 MsiViewClose(hview);
7389 MsiCloseHandle(hview);
7390
7391 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'One'";
7392 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7394 r = MsiViewExecute(hview, 0);
7395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7396
7397 r = MsiViewFetch(hview, &hrec);
7398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7399 check_record(hrec, 3, "One", "1", "A");
7400 MsiCloseHandle(hrec);
7401
7402 r = MsiViewFetch(hview, &hrec);
7404 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7405
7406 MsiViewClose(hview);
7407 MsiCloseHandle(hview);
7408
7409 query = "DROP `One`";
7410 r = run_query(hdb, 0, query);
7412 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7413
7414 query = "DROP TABLE";
7415 r = run_query(hdb, 0, query);
7417 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7418
7419 query = "DROP TABLE `One`";
7420 hview = 0;
7421 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7422 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7423 r = MsiViewExecute(hview, 0);
7424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7425
7426 r = MsiViewFetch(hview, &hrec);
7428 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
7429
7430 MsiViewClose(hview);
7431 MsiCloseHandle(hview);
7432
7433 query = "SELECT * FROM `IDontExist`";
7434 r = do_query(hdb, query, &hrec);
7436 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7437
7438 query = "SELECT * FROM `One`";
7439 r = do_query(hdb, query, &hrec);
7441 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7442
7443 query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
7444 r = run_query(hdb, 0, query);
7445 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7446
7447 query = "DROP TABLE One";
7448 r = run_query(hdb, 0, query);
7449 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7450
7451 query = "SELECT * FROM `One`";
7452 r = do_query(hdb, query, &hrec);
7454 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7455
7456 query = "SELECT * FROM `_Tables` WHERE `Name` = 'One'";
7457 r = do_query(hdb, query, &hrec);
7458 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7459
7460 query = "SELECT * FROM `_Columns` WHERE `Table` = 'One'";
7461 r = do_query(hdb, query, &hrec);
7462 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7463
7464 query = "CREATE TABLE `One` ( `B` INT, `C` INT PRIMARY KEY `B` )";
7465 r = run_query(hdb, 0, query);
7466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7467
7468 query = "SELECT * FROM `One`";
7469 r = do_query(hdb, query, &hrec);
7470 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7471
7472 query = "SELECT `Name` FROM `_Tables` WHERE `Name` = 'One'";
7473 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7474 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7475 r = MsiViewExecute(hview, 0);
7476 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7477
7478 r = MsiViewFetch(hview, &hrec);
7479 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7480 check_record(hrec, 1, "One");
7481 MsiCloseHandle(hrec);
7482
7483 MsiViewClose(hview);
7484 MsiCloseHandle(hview);
7485
7486 query = "SELECT `Table`, `Number`, `Name` FROM `_Columns` WHERE `Table` = 'One'";
7487 r = MsiDatabaseOpenViewA(hdb, query, &hview);
7488 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7489 r = MsiViewExecute(hview, 0);
7490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7491
7492 r = MsiViewFetch(hview, &hrec);
7493 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7494 check_record(hrec, 3, "One", "1", "B");
7495 MsiCloseHandle(hrec);
7496
7497 r = MsiViewFetch(hview, &hrec);
7498 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7499 check_record(hrec, 3, "One", "2", "C");
7500 MsiCloseHandle(hrec);
7501
7502 r = MsiViewFetch(hview, &hrec);
7504 "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7505
7506 MsiViewClose(hview);
7507 MsiCloseHandle(hview);
7508
7509 query = "DROP TABLE One";
7510 r = run_query(hdb, 0, query);
7511 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7512
7513 query = "SELECT * FROM `One`";
7514 r = do_query(hdb, query, &hrec);
7516 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
7517
7518 query = "SELECT * FROM `_Tables` WHERE `Name` = 'One'";
7519 r = do_query(hdb, query, &hrec);
7520 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7521
7522 query = "SELECT * FROM `_Columns` WHERE `Table` = 'One'";
7523 r = do_query(hdb, query, &hrec);
7524 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7525
7526 MsiCloseHandle(hdb);
7528}

Referenced by START_TEST().

◆ test_embedded_nulls()

static void test_embedded_nulls ( void  )
static

Definition at line 8580 of file db.c.

8581{
8582 static const char control_table[] =
8583 "Dialog\tText\n"
8584 "s72\tL0\n"
8585 "Control\tDialog\n"
8586 "LicenseAgreementDlg\ttext\x11\x19text\0text";
8587 UINT r;
8588 DWORD sz;
8589 MSIHANDLE hdb, hrec;
8590 char buffer[32];
8591
8593 ok( r == ERROR_SUCCESS, "failed to open database %u\n", r );
8594
8596 write_file( "temp_file", control_table, sizeof(control_table) );
8597 r = MsiDatabaseImportA( hdb, CURR_DIR, "temp_file" );
8598 ok( r == ERROR_SUCCESS, "failed to import table %u\n", r );
8599 DeleteFileA( "temp_file" );
8600
8601 r = do_query( hdb, "SELECT `Text` FROM `Control` WHERE `Dialog` = 'LicenseAgreementDlg'", &hrec );
8602 ok( r == ERROR_SUCCESS, "query failed %u\n", r );
8603
8604 buffer[0] = 0;
8605 sz = sizeof(buffer);
8606 r = MsiRecordGetStringA( hrec, 1, buffer, &sz );
8607 ok( r == ERROR_SUCCESS, "failed to get string %u\n", r );
8608 ok( !memcmp( "text\r\ntext\ntext", buffer, sizeof("text\r\ntext\ntext") - 1 ), "wrong buffer contents \"%s\"\n", buffer );
8609
8610 MsiCloseHandle( hrec );
8611 MsiCloseHandle( hdb );
8613}

Referenced by START_TEST().

◆ test_forcecodepage()

static void test_forcecodepage ( void  )
static

Definition at line 6804 of file db.c.

6805{
6806 MSIHANDLE hdb;
6807 const char *query;
6808 char buffer[MAX_PATH];
6809 UINT r;
6810
6813
6815 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6816
6817 query = "SELECT * FROM `_ForceCodepage`";
6818 r = run_query(hdb, 0, query);
6819 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6820
6821 query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6822 r = run_query(hdb, 0, query);
6823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6824
6825 query = "SELECT * FROM `_ForceCodepage`";
6826 r = run_query(hdb, 0, query);
6827 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6828
6829 r = MsiDatabaseCommit(hdb);
6830 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6831
6832 query = "SELECT * FROM `_ForceCodepage`";
6833 r = run_query(hdb, 0, query);
6834 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6835
6836 MsiCloseHandle(hdb);
6837
6839 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6840
6841 query = "SELECT * FROM `_ForceCodepage`";
6842 r = run_query(hdb, 0, query);
6843 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6844
6845 r = MsiDatabaseExportA(hdb, "_ForceCodepage", CURR_DIR, "forcecodepage.idt");
6846 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6847
6848 read_file_data("forcecodepage.idt", buffer);
6849 ok(!lstrcmpA(buffer, "\r\n\r\n0\t_ForceCodepage\r\n"),
6850 "Expected \"\r\n\r\n0\t_ForceCodepage\r\n\", got \"%s\"\n", buffer);
6851
6852 create_file_data("forcecodepage.idt", "\r\n\r\n850\t_ForceCodepage\r\n", 0);
6853
6854 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
6855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6856
6857 r = MsiDatabaseExportA(hdb, "_ForceCodepage", CURR_DIR, "forcecodepage.idt");
6858 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6859
6860 read_file_data("forcecodepage.idt", buffer);
6861 ok(!lstrcmpA(buffer, "\r\n\r\n850\t_ForceCodepage\r\n"),
6862 "Expected \"\r\n\r\n850\t_ForceCodepage\r\n\", got \"%s\"\n", buffer);
6863
6864 create_file_data("forcecodepage.idt", "\r\n\r\n9999\t_ForceCodepage\r\n", 0);
6865
6866 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
6867 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
6868
6869 MsiCloseHandle(hdb);
6871 DeleteFileA("forcecodepage.idt");
6872}
static void read_file_data(LPCSTR filename, LPSTR buffer)
Definition: db.c:6793
UINT WINAPI MsiDatabaseExportA(MSIHANDLE handle, const char *szTable, const char *szFolder, const char *szFilename)
Definition: database.c:1158
#define MSIDBOPEN_DIRECT
Definition: msiquery.h:68

Referenced by START_TEST().

◆ test_getcolinfo()

static void test_getcolinfo ( void  )
static

Definition at line 1182 of file db.c.

1183{
1184 MSIHANDLE hdb, hview = 0, rec = 0;
1185 UINT r;
1186
1187 /* create an empty db */
1188 hdb = create_db();
1189 ok( hdb, "failed to create db\n");
1190
1191 /* tables should be present */
1192 r = MsiDatabaseOpenViewA(hdb, "select Name from _Tables", &hview);
1193 ok( r == ERROR_SUCCESS, "failed to open query\n");
1194
1195 r = MsiViewExecute(hview, 0);
1196 ok( r == ERROR_SUCCESS, "failed to execute query\n");
1197
1198 /* check that NAMES works */
1199 rec = 0;
1200 r = MsiViewGetColumnInfo( hview, MSICOLINFO_NAMES, &rec );
1201 ok( r == ERROR_SUCCESS, "failed to get names\n");
1202 check_record(rec, 1, "Name");
1203 r = MsiCloseHandle( rec );
1204 ok( r == ERROR_SUCCESS, "failed to close record handle\n");
1205
1206 /* check that TYPES works */
1207 rec = 0;
1208 r = MsiViewGetColumnInfo( hview, MSICOLINFO_TYPES, &rec );
1209 ok( r == ERROR_SUCCESS, "failed to get names\n");
1210 check_record(rec, 1, "s64");
1211 r = MsiCloseHandle( rec );
1212 ok( r == ERROR_SUCCESS, "failed to close record handle\n");
1213
1214 /* check that invalid values fail */
1215 rec = 0;
1216 r = MsiViewGetColumnInfo( hview, 100, &rec );
1217 ok( r == ERROR_INVALID_PARAMETER, "wrong error code\n");
1218 ok( rec == 0, "returned a record\n");
1219
1221 ok( r == ERROR_INVALID_PARAMETER, "wrong error code\n");
1222
1224 ok( r == ERROR_INVALID_HANDLE, "wrong error code\n");
1225
1226 r = MsiViewClose(hview);
1227 ok( r == ERROR_SUCCESS, "failed to close view\n");
1228 r = MsiCloseHandle(hview);
1229 ok( r == ERROR_SUCCESS, "failed to close view handle\n");
1230 r = MsiCloseHandle(hdb);
1231 ok( r == ERROR_SUCCESS, "failed to close database\n");
1232}
#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 2744 of file db.c.

2745{
2746 int i;
2747 MSIHANDLE hdb;
2748 MSIHANDLE hviews[MY_NVIEWS];
2749 UINT r;
2750
2751 /* create an empty db */
2752 hdb = create_db();
2753 ok( hdb, "failed to create db\n");
2754
2755 memset(hviews, 0, sizeof(hviews));
2756
2757 for (i=0; i<MY_NVIEWS; i++) {
2758 static char szQueryBuf[256] = "SELECT * from `_Tables`";
2759 hviews[i] = 0xdeadbeeb;
2760 r = MsiDatabaseOpenViewA(hdb, szQueryBuf, &hviews[i]);
2761 if( r != ERROR_SUCCESS || hviews[i] == 0xdeadbeeb ||
2762 hviews[i] == 0 || (i && (hviews[i] == hviews[i-1])))
2763 break;
2764 }
2765
2766 ok( i == MY_NVIEWS, "problem opening views\n");
2767
2768 for (i=0; i<MY_NVIEWS; i++) {
2769 if (hviews[i] != 0 && hviews[i] != 0xdeadbeeb) {
2770 MsiViewClose(hviews[i]);
2771 r = MsiCloseHandle(hviews[i]);
2772 if (r != ERROR_SUCCESS)
2773 break;
2774 }
2775 }
2776
2777 ok( i == MY_NVIEWS, "problem closing views\n");
2778
2779 r = MsiCloseHandle(hdb);
2780 ok( r == ERROR_SUCCESS, "failed to close database\n");
2781}
#define MY_NVIEWS
Definition: db.c:2743

Referenced by START_TEST().

◆ test_insertorder()

static void test_insertorder ( void  )
static

Definition at line 8171 of file db.c.

8172{
8173 MSIHANDLE hdb, view, rec;
8174 LPCSTR query;
8175 UINT r;
8176 int i;
8177
8178 hdb = create_db();
8179 ok(hdb, "failed to create db\n");
8180
8181 query = "CREATE TABLE `T` ( `A` SHORT, `B` SHORT, `C` SHORT PRIMARY KEY `A`)";
8182 r = run_query(hdb, 0, query);
8183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184
8185 query = "INSERT INTO `T` ( `A`, `B`, `C` ) VALUES ( 1, 2, 3 )";
8186 r = run_query(hdb, 0, query);
8187 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8188
8189 query = "INSERT INTO `T` ( `B`, `C`, `A` ) VALUES ( 4, 5, 6 )";
8190 r = run_query(hdb, 0, query);
8191 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8192
8193 query = "INSERT INTO `T` ( `C`, `A`, `B` ) VALUES ( 7, 8, 9 )";
8194 r = run_query(hdb, 0, query);
8195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8196
8197 query = "INSERT INTO `T` ( `A`, `B` ) VALUES ( 10, 11 )";
8198 r = run_query(hdb, 0, query);
8199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8200
8201 query = "INSERT INTO `T` ( `B`, `C` ) VALUES ( 12, 13 )";
8202 r = run_query(hdb, 0, query);
8203 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8204
8205 /* fails because the primary key already
8206 * has an MSI_NULL_INTEGER value set above
8207 */
8208 query = "INSERT INTO `T` ( `C` ) VALUES ( 14 )";
8209 r = run_query(hdb, 0, query);
8211 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8212
8213 /* replicate the error where primary key is set twice */
8214 query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 1, 14 )";
8215 r = run_query(hdb, 0, query);
8217 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8218
8219 query = "INSERT INTO `T` ( `A`, `C` ) VALUES ( 14, 15 )";
8220 r = run_query(hdb, 0, query);
8221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8222
8223 query = "INSERT INTO `T` VALUES ( 16 )";
8224 r = run_query(hdb, 0, query);
8226 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8227
8228 query = "INSERT INTO `T` VALUES ( 17, 18 )";
8229 r = run_query(hdb, 0, query);
8231 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8232
8233 query = "INSERT INTO `T` VALUES ( 19, 20, 21 )";
8234 r = run_query(hdb, 0, query);
8236 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8237
8238 query = "SELECT * FROM `T`";
8239 r = MsiDatabaseOpenViewA(hdb, query, &view);
8240 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8241 r = MsiViewExecute(view, 0);
8242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8243
8244 for (i = 0; i < 6; i++)
8245 {
8246 r = MsiViewFetch(view, &rec);
8247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8248
8249 r = MsiRecordGetInteger(rec, 1);
8250 ok(r == ordervals[i][0], "Expected %d, got %d\n", ordervals[i][0], r);
8251
8252 r = MsiRecordGetInteger(rec, 2);
8253 ok(r == ordervals[i][1], "Expected %d, got %d\n", ordervals[i][1], r);
8254
8255 r = MsiRecordGetInteger(rec, 3);
8256 ok(r == ordervals[i][2], "Expected %d, got %d\n", ordervals[i][2], r);
8257
8258 MsiCloseHandle(rec);
8259 }
8260
8261 r = MsiViewFetch(view, &rec);
8262 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8263
8266
8267 query = "DELETE FROM `T` WHERE `A` IS NULL";
8268 r = run_query(hdb, 0, query);
8269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8270
8271 query = "INSERT INTO `T` ( `B`, `C` ) VALUES ( 12, 13 ) TEMPORARY";
8272 r = run_query(hdb, 0, query);
8273 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8274
8275 query = "SELECT * FROM `T`";
8276 r = MsiDatabaseOpenViewA(hdb, query, &view);
8277 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8278 r = MsiViewExecute(view, 0);
8279 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8280
8281 for (i = 0; i < 6; i++)
8282 {
8283 r = MsiViewFetch(view, &rec);
8284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8285
8286 r = MsiRecordGetInteger(rec, 1);
8287 ok(r == ordervals[i][0], "Expected %d, got %d\n", ordervals[i][0], r);
8288
8289 r = MsiRecordGetInteger(rec, 2);
8290 ok(r == ordervals[i][1], "Expected %d, got %d\n", ordervals[i][1], r);
8291
8292 r = MsiRecordGetInteger(rec, 3);
8293 ok(r == ordervals[i][2], "Expected %d, got %d\n", ordervals[i][2], r);
8294
8295 MsiCloseHandle(rec);
8296 }
8297
8298 r = MsiViewFetch(view, &rec);
8299 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
8300
8303 MsiCloseHandle(hdb);
8305}
static const UINT ordervals[6][3]
Definition: db.c:8161

Referenced by START_TEST().

◆ test_integers()

static void test_integers ( void  )
static

Definition at line 4165 of file db.c.

4166{
4167 MSIHANDLE hdb = 0, view = 0, rec = 0;
4168 DWORD i;
4169 const char *query;
4170 UINT r;
4171
4172 /* just MsiOpenDatabase should not create a file */
4174 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
4175
4176 /* create a table */
4177 query = "CREATE TABLE `integers` ( "
4178 "`one` SHORT, `two` INT, `three` INTEGER, `four` LONG, "
4179 "`five` SHORT NOT NULL, `six` INT NOT NULL, "
4180 "`seven` INTEGER NOT NULL, `eight` LONG NOT NULL "
4181 "PRIMARY KEY `one`)";
4182 r = MsiDatabaseOpenViewA(hdb, query, &view);
4183 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
4184 r = MsiViewExecute(view, 0);
4185 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
4186 r = MsiViewClose(view);
4187 ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
4189 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
4190
4191 query = "SELECT * FROM `integers`";
4192 r = MsiDatabaseOpenViewA(hdb, query, &view);
4193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4194
4196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4197 check_record(rec, 8, "one", "two", "three", "four", "five", "six", "seven", "eight");
4198 MsiCloseHandle(rec);
4199
4201 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4202 check_record(rec, 8, "I2", "I2", "I2", "I4", "i2", "i2", "i2", "i4");
4203 MsiCloseHandle(rec);
4204
4207
4208 /* insert values into it, NULL where NOT NULL is specified */
4209 query = "INSERT INTO `integers` ( `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight` )"
4210 "VALUES('', '', '', '', '', '', '', '')";
4211 r = MsiDatabaseOpenViewA(hdb, query, &view);
4212 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4213 r = MsiViewExecute(view, 0);
4214 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
4215
4218
4219 query = "SELECT * FROM `integers`";
4220 r = do_query(hdb, query, &rec);
4221 ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
4222
4224 ok(r == -1, "record count wrong: %d\n", r);
4225
4226 MsiCloseHandle(rec);
4227
4228 /* insert legitimate values into it */
4229 query = "INSERT INTO `integers` ( `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight` )"
4230 "VALUES('', '2', '', '4', '5', '6', '7', '8')";
4231 r = MsiDatabaseOpenViewA(hdb, query, &view);
4232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4233 r = MsiViewExecute(view, 0);
4234