ReactOS  0.4.13-dev-92-gf251225
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.

Classes

struct  join_res
 
struct  join_res_4col
 
struct  join_res_uint
 

Macros

#define COBJMACROS
 
#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 */
 
#define NUM_TRANSFORM_TABLES   (sizeof table_transform_data/sizeof table_transform_data[0])
 

Functions

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 BOOL check_record (MSIHANDLE rec, UINT field, LPCSTR val)
 
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)
 
 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 [] = {'w','i','n','e','t','e','s','t','-','d','b','.','m','s','i',0}
 
static const WCHAR msifile2W [] = {'w','i','n','e','t','s','t','2','-','d','b','.','m','s','i',0}
 
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 struct join_res join_res_first []
 
static const struct join_res join_res_second []
 
static const struct join_res join_res_third []
 
static const struct join_res join_res_fourth []
 
static const struct join_res join_res_fifth []
 
static const struct join_res join_res_sixth []
 
static const struct join_res join_res_seventh []
 
static const struct join_res_4col join_res_eighth []
 
static const struct join_res_uint join_res_ninth []
 
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:277
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 307 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 )")
static UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
Definition: db.c:277
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 291 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 )")
static UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
Definition: db.c:277
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 296 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 )")
static UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
Definition: db.c:277
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

Definition at line 300 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 )")
static UINT add_entry(const char *file, int line, const char *type, MSIHANDLE hdb, const char *values, const char *insert)
Definition: db.c:277
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666

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

◆ MY_NVIEWS

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

Definition at line 2822 of file db.c.

◆ NUM_TRANSFORM_TABLES

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

278 {
279  char *query;
280  UINT sz, r;
281 
282  sz = strlen(values) + strlen(insert) + 1;
283  query = HeapAlloc(GetProcessHeap(), 0, sz);
285  r = run_query(hdb, 0, query);
287  ok_(file, line)(r == ERROR_SUCCESS, "failed to insert into %s table: %u\n", type, r);
288  return r;
289 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_(x1, x2)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int insert
Definition: xmllint.c:144
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
Definition: parser.c:48
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned int UINT
Definition: ndis.h:50
GLenum query
Definition: glext.h:7781
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

◆ add_table_to_db()

static UINT add_table_to_db ( MSIHANDLE  hdb,
LPCSTR  table_data 
)
static

Definition at line 2239 of file db.c.

2240 {
2241  UINT r;
2242 
2243  write_file("temp_file", table_data, (lstrlenA(table_data) - 1) * sizeof(char));
2244  r = MsiDatabaseImportA(hdb, CURR_DIR, "temp_file");
2245  DeleteFileA("temp_file");
2246 
2247  return r;
2248 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static CHAR CURR_DIR[MAX_PATH]
Definition: db.c:2186
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
unsigned int UINT
Definition: ndis.h:50
static void write_file(const CHAR *filename, const char *data, int data_size)
Definition: db.c:2229
UINT WINAPI MsiDatabaseImportA(MSIHANDLE handle, LPCSTR szFolder, LPCSTR szFilename)
Definition: database.c:900

Referenced by test_msiimport(), and test_suminfo_import().

◆ check_record()

static BOOL check_record ( MSIHANDLE  rec,
UINT  field,
LPCSTR  val 
)
static

Definition at line 1302 of file db.c.

1303 {
1304  CHAR buffer[0x20];
1305  UINT r;
1306  DWORD sz;
1307 
1308  sz = sizeof buffer;
1309  r = MsiRecordGetStringA( rec, field, buffer, &sz );
1310  return (r == ERROR_SUCCESS ) && !strcmp(val, buffer);
1311 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
char CHAR
Definition: xmlstorage.h:175
GLuint buffer
Definition: glext.h:5915
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
GLuint GLfloat * val
Definition: glext.h:7180
Definition: parser.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: ndis.h:50
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by test_integers(), test_msiimport(), test_storages_table(), test_streamtable(), test_viewgetcolumninfo(), test_where(), and test_where_not_in_selected().

◆ create_binary_table()

static UINT create_binary_table ( MSIHANDLE  hdb)
static

Definition at line 266 of file db.c.

267 {
268  UINT r = run_query( hdb, 0,
269  "CREATE TABLE `Binary` ( "
270  "`Name` CHAR(72) NOT NULL, "
271  "`Data` CHAR(72) NOT NULL "
272  "PRIMARY KEY `Name` )" );
273  ok(r == ERROR_SUCCESS, "Failed to create Binary table: %u\n", r);
274  return r;
275 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by test_join().

◆ create_component_table()

static UINT create_component_table ( MSIHANDLE  hdb)
static

Definition at line 204 of file db.c.

205 {
206  UINT r = run_query( hdb, 0,
207  "CREATE TABLE `Component` ( "
208  "`Component` CHAR(72) NOT NULL, "
209  "`ComponentId` CHAR(38), "
210  "`Directory_` CHAR(72) NOT NULL, "
211  "`Attributes` SHORT NOT NULL, "
212  "`Condition` CHAR(255), "
213  "`KeyPath` CHAR(72) "
214  "PRIMARY KEY `Component`)" );
215  ok(r == ERROR_SUCCESS, "Failed to create Component table: %u\n", r);
216  return r;
217 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by test_join().

◆ create_custom_action_table()

static UINT create_custom_action_table ( MSIHANDLE  hdb)
static

Definition at line 219 of file db.c.

220 {
221  UINT r = run_query( hdb, 0,
222  "CREATE TABLE `CustomAction` ( "
223  "`Action` CHAR(72) NOT NULL, "
224  "`Type` SHORT NOT NULL, "
225  "`Source` CHAR(72), "
226  "`Target` CHAR(255) "
227  "PRIMARY KEY `Action`)" );
228  ok(r == ERROR_SUCCESS, "Failed to create CustomAction table: %u\n", r);
229  return r;
230 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by test_dbtopackage().

◆ create_db()

static MSIHANDLE create_db ( void  )
static

Definition at line 1173 of file db.c.

1174 {
1175  MSIHANDLE hdb = 0;
1176  UINT res;
1177 
1179 
1180  /* create an empty database */
1182  ok( res == ERROR_SUCCESS , "Failed to create database\n" );
1183  if( res != ERROR_SUCCESS )
1184  return hdb;
1185 
1186  res = MsiDatabaseCommit( hdb );
1187  ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
1188 
1189  return hdb;
1190 }
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define ok(value,...)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613

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

◆ create_directory_table()

static UINT create_directory_table ( MSIHANDLE  hdb)
static

Definition at line 232 of file db.c.

233 {
234  UINT r = run_query( hdb, 0,
235  "CREATE TABLE `Directory` ( "
236  "`Directory` CHAR(255) NOT NULL, "
237  "`Directory_Parent` CHAR(255), "
238  "`DefaultDir` CHAR(255) NOT NULL "
239  "PRIMARY KEY `Directory`)" );
240  ok(r == ERROR_SUCCESS, "Failed to create Directory table: %u\n", r);
241  return r;
242 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by create_package_db(), and test_dbtopackage().

◆ create_feature_components_table()

static UINT create_feature_components_table ( MSIHANDLE  hdb)
static

Definition at line 244 of file db.c.

245 {
246  UINT r = run_query( hdb, 0,
247  "CREATE TABLE `FeatureComponents` ( "
248  "`Feature_` CHAR(38) NOT NULL, "
249  "`Component_` CHAR(72) NOT NULL "
250  "PRIMARY KEY `Feature_`, `Component_` )" );
251  ok(r == ERROR_SUCCESS, "Failed to create FeatureComponents table: %u\n", r);
252  return r;
253 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by test_join().

◆ create_file_data()

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

Definition at line 1561 of file db.c.

1562 {
1563  HANDLE file;
1564  DWORD written;
1565 
1567  if (file == INVALID_HANDLE_VALUE)
1568  return;
1569 
1570  WriteFile(file, data, strlen(data), &written, NULL);
1571  WriteFile(file, "\n", strlen("\n"), &written, NULL);
1572 
1573  if (size)
1574  {
1576  SetEndOfFile(file);
1577  }
1578 
1579  CloseHandle(file);
1580 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:1154
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_BEGIN
Definition: winbase.h:112
Definition: name.c:36
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
Definition: fci.c:126

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

3124 {
3125  MSIHANDLE hdb = 0;
3126  UINT res;
3127 
3129 
3130  /* create an empty database */
3132  ok( res == ERROR_SUCCESS , "Failed to create database\n" );
3133  if( res != ERROR_SUCCESS )
3134  return hdb;
3135 
3136  res = MsiDatabaseCommit( hdb );
3137  ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
3138 
3139  res = set_summary_info(hdb);
3140  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3141 
3143 
3144  return hdb;
3145 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const char * filename
Definition: ioapi.h:135
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define ok(value,...)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
static UINT create_directory_table(MSIHANDLE hdb)
Definition: db.c:232
static const WCHAR msifileW[]
Definition: db.c:36
static UINT set_summary_info(MSIHANDLE hdb)
Definition: db.c:3079
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613

Referenced by test_try_transform().

◆ create_std_dlls_table()

static UINT create_std_dlls_table ( MSIHANDLE  hdb)
static

Definition at line 255 of file db.c.

256 {
257  UINT r = run_query( hdb, 0,
258  "CREATE TABLE `StdDlls` ( "
259  "`File` CHAR(255) NOT NULL, "
260  "`Binary_` CHAR(72) NOT NULL "
261  "PRIMARY KEY `File` )" );
262  ok(r == ERROR_SUCCESS, "Failed to create StdDlls table: %u\n", r);
263  return r;
264 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
#define ok(value,...)
unsigned int UINT
Definition: ndis.h:50

Referenced by test_join().

◆ create_storage()

static BOOL create_storage ( LPCSTR  name)
static

Definition at line 7480 of file db.c.

7481 {
7482  WCHAR nameW[MAX_PATH];
7483  IStorage *stg;
7484  IStream *stm;
7485  HRESULT hr;
7486  DWORD count;
7487  BOOL res = FALSE;
7488 
7491  STGM_DIRECT | STGM_SHARE_EXCLUSIVE, 0, &stg);
7492  if (FAILED(hr))
7493  return FALSE;
7494 
7495  hr = IStorage_CreateStream(stg, nameW, STGM_WRITE | STGM_SHARE_EXCLUSIVE,
7496  0, 0, &stm);
7497  if (FAILED(hr))
7498  goto done;
7499 
7500  hr = IStream_Write(stm, "stgdata", 8, &count);
7501  if (SUCCEEDED(hr))
7502  res = TRUE;
7503 
7504 done:
7505  IStream_Release(stm);
7506  IStorage_Release(stg);
7507 
7508  return res;
7509 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define STGM_CREATE
Definition: objbase.h:925
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STGM_WRITE
Definition: objbase.h:917
static const WCHAR nameW[]
Definition: main.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define STGM_DIRECT
Definition: objbase.h:913
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8637
#define STGM_READWRITE
Definition: objbase.h:918
#define MultiByteToWideChar
Definition: compat.h:100
Definition: name.c:36
GLuint res
Definition: glext.h:9613
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_storages_table().

◆ do_query()

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

Definition at line 147 of file db.c.

148 {
149  MSIHANDLE hview = 0;
150  UINT r, ret;
151 
152  if (phrec)
153  *phrec = 0;
154 
155  /* open a select query */
156  r = MsiDatabaseOpenViewA(hdb, query, &hview);
157  if (r != ERROR_SUCCESS)
158  return r;
159  r = MsiViewExecute(hview, 0);
160  if (r != ERROR_SUCCESS)
161  return r;
162  ret = MsiViewFetch(hview, phrec);
163  r = MsiViewClose(hview);
164  if (r != ERROR_SUCCESS)
165  return r;
166  r = MsiCloseHandle(hview);
167  if (r != ERROR_SUCCESS)
168  return r;
169  return ret;
170 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:385
int ret
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50

Referenced by 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 6192 of file db.c.

6193 {
6194  IEnumSTATSTG *stgenum = NULL;
6195  IStream *stm;
6196  HRESULT hr;
6197  STATSTG stat;
6198  ULONG n, count;
6199  BYTE data[MAX_PATH];
6200  BYTE check[MAX_PATH];
6201  DWORD sz;
6202 
6203  memset(check, 'a', MAX_PATH);
6204 
6205  hr = IStorage_EnumElements(stg, 0, NULL, 0, &stgenum);
6206  ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
6207 
6208  n = 0;
6209  while(TRUE)
6210  {
6211  count = 0;
6212  hr = IEnumSTATSTG_Next(stgenum, 1, &stat, &count);
6213  if(FAILED(hr) || !count)
6214  break;
6215 
6216  ok(!lstrcmpW(stat.pwcsName, database_table_data[n].name),
6217  "Expected table %d name to match\n", n);
6218 
6219  stm = NULL;
6220  hr = IStorage_OpenStream(stg, stat.pwcsName, NULL,
6221  STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stm);
6222  ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
6223  ok(stm != NULL, "Expected non-NULL stream\n");
6224 
6225  CoTaskMemFree(stat.pwcsName);
6226 
6227  sz = MAX_PATH;
6228  memset(data, 'a', MAX_PATH);
6229  hr = IStream_Read(stm, data, sz, &count);
6230  ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
6231 
6233  "Expected %d, got %d\n", database_table_data[n].size, count);
6234 
6235  if (!database_table_data[n].size)
6236  ok(!memcmp(data, check, MAX_PATH), "data should not be changed\n");
6237  else
6239  "Expected table %d data to match\n", n);
6240 
6241  IStream_Release(stm);
6242  n++;
6243  }
6244 
6245  ok(n == 3, "Expected 3, got %d\n", n);
6246 
6247  IEnumSTATSTG_Release(stgenum);
6248 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
void check(CONTEXT *pContext)
Definition: NtContinue.c:61
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: stat.h:55
unsigned char BYTE
Definition: mem.h:68
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define S_OK
Definition: intsafe.h:59
unsigned int ULONG
Definition: retypes.h:1
static const struct @1602 database_table_data[]
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_defaultdatabase().

◆ generate_transform()

static void generate_transform ( void  )
static

Definition at line 2862 of file db.c.

2863 {
2864  MSIHANDLE hdb1, hdb2, hrec;
2865  LPCSTR query;
2866  UINT r;
2867 
2868  /* start with two identical databases */
2870 
2872  ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2873 
2874  r = MsiDatabaseCommit( hdb1 );
2875  ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
2876 
2878  ok( r == ERROR_SUCCESS , "Failed to create database\n" );
2879 
2880  /* the transform between two identical database should be empty */
2881  r = MsiDatabaseGenerateTransformA(hdb1, hdb2, NULL, 0, 0);
2882  todo_wine {
2883  ok( r == ERROR_NO_DATA, "return code %d, should be ERROR_NO_DATA\n", r );
2884  }
2885 
2886  query = "CREATE TABLE `AAR` ( `BAR` SHORT NOT NULL, `CAR` CHAR(255) PRIMARY KEY `CAR`)";
2887  r = run_query(hdb1, 0, query);
2888  ok(r == ERROR_SUCCESS, "failed to add table\n");
2889 
2890  query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 1, 'vw' )";
2891  r = run_query(hdb1, 0, query);
2892  ok(r == ERROR_SUCCESS, "failed to add row 1\n");
2893 
2894  query = "INSERT INTO `AAR` ( `BAR`, `CAR` ) VALUES ( 2, 'bmw' )";
2895  r = run_query(hdb1, 0, query);
2896  ok(r == ERROR_SUCCESS, "failed to add row 2\n");
2897 
2898  query = "UPDATE `MOO` SET `OOO` = 'c' WHERE `NOO` = 1";
2899  r = run_query(hdb1, 0, query);
2900  ok(r == ERROR_SUCCESS, "failed to modify row\n");
2901 
2902  query = "DELETE FROM `MOO` WHERE `NOO` = 3";
2903  r = run_query(hdb1, 0, query);
2904  ok(r == ERROR_SUCCESS, "failed to delete row\n");
2905 
2906  hrec = MsiCreateRecord(2);
2907  r = MsiRecordSetInteger(hrec, 1, 1);
2908  ok(r == ERROR_SUCCESS, "failed to set integer\n");
2909 
2910  write_file("testdata.bin", "naengmyon", 9);
2911  r = MsiRecordSetStreamA(hrec, 2, "testdata.bin");
2912  ok(r == ERROR_SUCCESS, "failed to set stream\n");
2913 
2914  query = "INSERT INTO `BINARY` ( `ID`, `BLOB` ) VALUES ( ?, ? )";
2915  r = run_query(hdb1, hrec, query);
2916  ok(r == ERROR_SUCCESS, "failed to add row with blob\n");
2917 
2918  MsiCloseHandle(hrec);
2919 
2920  query = "ALTER TABLE `MOO` ADD `COW` INTEGER";
2921  r = run_query(hdb1, 0, query);
2922  ok(r == ERROR_SUCCESS, "failed to add column\n");
2923 
2924  query = "ALTER TABLE `MOO` ADD `PIG` INTEGER";
2925  r = run_query(hdb1, 0, query);
2926  ok(r == ERROR_SUCCESS, "failed to add column\n");
2927 
2928  query = "UPDATE `MOO` SET `PIG` = 5 WHERE `NOO` = 1";
2929  r = run_query(hdb1, 0, query);
2930  ok(r == ERROR_SUCCESS, "failed to modify row\n");
2931 
2932  query = "CREATE TABLE `Property` ( `Property` CHAR(72) NOT NULL, "
2933  "`Value` CHAR(0) PRIMARY KEY `Property`)";
2934  r = run_query(hdb1, 0, query);
2935  ok(r == ERROR_SUCCESS, "failed to add property table\n");
2936 
2937  query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
2938  r = run_query(hdb1, 0, query);
2939  ok(r == ERROR_SUCCESS, "failed to add property\n");
2940 
2941  /* database needs to be committed */
2942  MsiDatabaseCommit(hdb1);
2943 
2944  r = MsiDatabaseGenerateTransformA(hdb1, hdb2, mstfile, 0, 0);
2945  ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r );
2946 
2947  MsiCloseHandle( hdb1 );
2948  MsiCloseHandle( hdb2 );
2949 
2950  DeleteFileA("testdata.bin");
2951 }
#define MSIDBOPEN_READONLY
Definition: msiquery.h:66
MSIHANDLE WINAPI MsiCreateRecord(UINT cParams)
Definition: record.c:95
UINT WINAPI MsiRecordSetInteger(MSIHANDLE handle, UINT iField, int iVal)
Definition: record.c:351
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static const char * mstfile
Definition: db.c:35
UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, UINT iField, LPCSTR szFilename)
Definition: record.c:777
BOOL WINAPI CopyFileA(IN LPCSTR lpExistingFileName, IN LPCSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:404
unsigned long MSIHANDLE
Definition: msiserver.idl:25
static const char * msifile2
Definition: db.c:34
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
static const WCHAR msifile2W[]
Definition: db.c:37
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI MsiDatabaseGenerateTransformA(MSIHANDLE hdb, MSIHANDLE hdbref, LPCSTR szTransformFile, int iReserved1, int iReserved2)
Definition: msiquery.c:797
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
const char * LPCSTR
Definition: xmlstorage.h:183
#define ERROR_NO_DATA
Definition: winerror.h:284
#define MSIDBOPEN_TRANSACT
Definition: msiquery.h:67
#define todo_wine
Definition: test.h:154
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
static void write_file(const CHAR *filename, const char *data, int data_size)
Definition: db.c:2229
GLenum query
Definition: glext.h:7781

Referenced by test_try_transform().

◆ generate_transform_manual()

static void generate_transform_manual ( void  )
static

Definition at line 3038 of file db.c.

3039 {
3040  IStorage *stg = NULL;
3041  IStream *stm;
3042  WCHAR name[0x20];
3043  HRESULT r;
3044  DWORD i, count;
3046 
3047  const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}};
3048 
3049  MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20);
3050 
3051  r = StgCreateDocfile(name, mode, 0, &stg);
3052  ok(r == S_OK, "failed to create storage\n");
3053  if (!stg)
3054  return;
3055 
3056  r = IStorage_SetClass( stg, &CLSID_MsiTransform );
3057  ok(r == S_OK, "failed to set storage type\n");
3058 
3059  for (i=0; i<NUM_TRANSFORM_TABLES; i++)
3060  {
3061  r = IStorage_CreateStream( stg, table_transform_data[i].name,
3062  STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
3063  if (FAILED(r))
3064  {
3065  ok(0, "failed to create stream %08x\n", r);
3066  continue;
3067  }
3068 
3069  r = IStream_Write( stm, table_transform_data[i].data,
3071  if (FAILED(r) || count != table_transform_data[i].size)
3072  ok(0, "failed to write stream\n");
3073  IStream_Release(stm);
3074  }
3075 
3076  IStorage_Release(stg);
3077 }
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define STGM_CREATE
Definition: objbase.h:925
static const char * mstfile
Definition: db.c:35
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
static const struct @1601 table_transform_data[]
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define STGM_WRITE
Definition: objbase.h:917
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define STGM_DIRECT
Definition: objbase.h:913
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8637
GLenum mode
Definition: glext.h:6217
#define STGM_READWRITE
Definition: objbase.h:918
#define S_OK
Definition: intsafe.h:59
#define MultiByteToWideChar
Definition: compat.h:100
Definition: name.c:36
#define NUM_TRANSFORM_TABLES
Definition: db.c:3036

Referenced by test_try_transform().

◆ get_column_info()

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

Definition at line 1252 of file db.c.

1253 {
1254  MSIHANDLE hview = 0, rec = 0;
1255  UINT r;
1256 
1257  r = MsiDatabaseOpenViewA(hdb, query, &hview);
1258  if( r != ERROR_SUCCESS )
1259  return r;
1260 
1261  r = MsiViewExecute(hview, 0);
1262  if( r == ERROR_SUCCESS )
1263  {
1264  MsiViewGetColumnInfo( hview, type, &rec );
1265  }
1266  MsiViewClose(hview);
1267  MsiCloseHandle(hview);
1268  return rec;
1269 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
Definition: msiquery.c:569

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

1272 {
1273  MSIHANDLE hview = 0, rec = 0;
1274  UINT r, type = 0;
1275  char query[0x100];
1276 
1277  sprintf(query, "select * from `_Columns` where `Table` = '%s'", table );
1278 
1279  r = MsiDatabaseOpenViewA(hdb, query, &hview);
1280  if( r != ERROR_SUCCESS )
1281  return r;
1282 
1283  r = MsiViewExecute(hview, 0);
1284  if( r == ERROR_SUCCESS )
1285  {
1286  while (1)
1287  {
1288  r = MsiViewFetch( hview, &rec );
1289  if( r != ERROR_SUCCESS)
1290  break;
1291  r = MsiRecordGetInteger( rec, 2 );
1292  if (r == field)
1293  type = MsiRecordGetInteger( rec, 4 );
1294  MsiCloseHandle( rec );
1295  }
1296  }
1297  MsiViewClose(hview);
1298  MsiCloseHandle(hview);
1299  return type;
1300 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI MsiRecordGetInteger(MSIHANDLE handle, UINT iField)
Definition: record.c:271
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define sprintf(buf, format,...)
Definition: sprintf.c:55
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
Definition: parser.c:43
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:385
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50

Referenced by test_viewgetcolumninfo().

◆ package_from_db()

static UINT package_from_db ( MSIHANDLE  hdb,
MSIHANDLE handle 
)
static

Definition at line 3147 of file db.c.

3148 {
3149  UINT res;
3150  CHAR szPackage[12];
3151  MSIHANDLE hPackage;
3152 
3153  sprintf(szPackage, "#%u", hdb);
3154  res = MsiOpenPackageA(szPackage, &hPackage);
3155  if (res != ERROR_SUCCESS)
3156  return res;
3157 
3158  res = MsiCloseHandle(hdb);
3159  if (res != ERROR_SUCCESS)
3160  {
3161  MsiCloseHandle(hPackage);
3162  return res;
3163  }
3164 
3165  *handle = hPackage;
3166  return ERROR_SUCCESS;
3167 }
UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
Definition: package.c:1687
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define sprintf(buf, format,...)
Definition: sprintf.c:55
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613

Referenced by test_try_transform().

◆ read_file_data()

static void read_file_data ( LPCSTR  filename,
LPSTR  buffer 
)
static

Definition at line 7208 of file db.c.

7209 {
7210  HANDLE file;
7211  DWORD read;
7212 
7216  CloseHandle(file);
7217 }
#define CloseHandle
Definition: compat.h:398
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
const char * filename
Definition: ioapi.h:135
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
#define MAX_PATH
Definition: compat.h:26
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GENERIC_READ
Definition: compat.h:124
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
Definition: fci.c:126

Referenced by test_forcecodepage().

◆ run_query()

static UINT run_query ( MSIHANDLE  hdb,
MSIHANDLE  hrec,
const char query 
)
static

Definition at line 172 of file db.c.

173 {
174  MSIHANDLE hview = 0;
175  UINT r;
176 
177  r = MsiDatabaseOpenViewA(hdb, query, &hview);
178  if( r != ERROR_SUCCESS )
179  return r;
180 
181  r = MsiViewExecute(hview, hrec);
182  if( r == ERROR_SUCCESS )
183  r = MsiViewClose(hview);
184  MsiCloseHandle(hview);
185  return r;
186 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50

Referenced by add_entry(), create_binary_table(), create_component_table(), create_custom_action_table(), create_directory_table(), create_feature_components_table(), create_std_dlls_table(), generate_transform(), test_alter(), test_binary(), test_carriagereturn(), test_collation(), test_columnorder(), test_dbmerge(), test_deleterow(), test_droptable(), test_forcecodepage(), test_insertorder(), test_join(), test_markers(), test_noquotes(), test_order(), test_quotes(), test_rows_order(), test_select_markers(), test_select_with_tablenames(), test_special_tables(), test_streamtable(), test_stringtable(), test_tables_order(), test_temporary_table(), test_try_transform(), test_update(), test_viewgetcolumninfo(), test_viewmodify(), test_viewmodify_assign(), test_viewmodify_delete(), test_viewmodify_delete_temporary(), test_viewmodify_refresh(), test_viewmodify_update(), test_where(), test_where_not_in_selected(), and test_where_viewmodify().

◆ run_queryW()

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

Definition at line 188 of file db.c.

189 {
190  MSIHANDLE hview = 0;
191  UINT r;
192 
193  r = MsiDatabaseOpenViewW(hdb, query, &hview);
194  if( r != ERROR_SUCCESS )
195  return r;
196 
197  r = MsiViewExecute(hview, hrec);
198  if( r == ERROR_SUCCESS )
199  r = MsiViewClose(hview);
200  MsiCloseHandle(hview);
201  return r;
202 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, LPCWSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:241

Referenced by test_collation().

◆ set_summary_info()

static UINT set_summary_info ( MSIHANDLE  hdb)
static

Definition at line 3079 of file db.c.

3080 {
3081  UINT res;
3083 
3084  /* build summary info */
3086  ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
3087 
3089  "Installation Database");
3090  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3091 
3093  "Installation Database");
3094  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3095 
3097  "Wine Hackers");
3098  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3099 
3101  ";1033,2057");
3102  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3103 
3105  "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
3106  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3107 
3109  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3110 
3112  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
3113 
3115  ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
3116 
3118  ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
3119 
3120  return res;
3121 }
Definition: compat.h:1939
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned long MSIHANDLE
Definition: msiserver.idl:25
static const CHAR suminfo[]
Definition: db.c:2211
#define ok(value,...)
UINT WINAPI MsiSummaryInfoSetPropertyA(MSIHANDLE handle, UINT uiProperty, UINT uiDataType, INT iValue, FILETIME *pftValue, LPCSTR szValue)
Definition: suminfo.c:863
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
Definition: suminfo.c:586
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE handle)
Definition: suminfo.c:1152
GLuint res
Definition: glext.h:9613

Referenced by create_package_db(), and test_dbtopackage().

◆ START_TEST()

START_TEST ( db  )

Definition at line 9704 of file db.c.

9705 {
9706  test_msidatabase();
9707  test_msiinsert();
9710  test_viewmodify();
9712  test_getcolinfo();
9713  test_msiexport();
9714  test_longstrings();
9715  test_streamtable();
9716  test_binary();
9718  test_where();
9719  test_msiimport();
9721  test_markers();
9724  test_join();
9726  test_alter();
9727  test_integers();
9728  test_update();
9731  test_rows_order();
9735  test_stringtable();
9738  test_order();
9740  test_deleterow();
9741  test_quotes();
9743  test_noquotes();
9748  test_dbtopackage();
9749  test_droptable();
9750  test_dbmerge();
9752  test_insertorder();
9753  test_columnorder();
9755  test_createtable();
9756  test_collation();
9759 }
static void test_defaultdatabase(void)
Definition: db.c:6250
static void test_select_column_names(void)
Definition: db.c:9455
static void test_viewmodify_update(void)
Definition: db.c:5428
static void test_viewmodify_assign(void)
Definition: db.c:5686
static void test_integers(void)
Definition: db.c:4360
static void test_alter(void)
Definition: db.c:4183
static void test_columnorder(void)
Definition: db.c:8825
static void test_quotes(void)
Definition: db.c:6718
static void test_update(void)
Definition: db.c:4487
static void test_embedded_nulls(void)
Definition: db.c:9421
static void test_where_viewmodify(void)
Definition: db.c:7379
static void test_markers(void)
Definition: db.c:2638
static void test_dbtopackage(void)
Definition: db.c:7634
static void test_viewmodify(void)
Definition: db.c:823
static void test_suminfo_import(void)
Definition: db.c:2250
static void test_deleterow(void)
Definition: db.c:6651
static void test_msibadqueries(void)
Definition: db.c:604
static void test_join(void)
Definition: db.c:3459
static void test_getcolinfo(void)
Definition: db.c:1192
static void test_stringtable(void)
Definition: db.c:5836
static void test_handle_limit(void)
Definition: db.c:2823
static void test_collation(void)
Definition: db.c:5121
static void test_streamtable(void)
Definition: db.c:1584
static void test_viewmodify_delete_temporary(void)
Definition: db.c:6535
static void test_forcecodepage(void)
Definition: db.c:7219
static void test_rows_order(void)
Definition: db.c:4985
static void test_longstrings(void)
Definition: db.c:1502
static void test_select_with_tablenames(void)
Definition: db.c:8605
static void test_binary(void)
Definition: db.c:1835
static void test_viewmodify_delete(void)
Definition: db.c:6074
static void test_noquotes(void)
Definition: db.c:7010
static void test_where(void)
Definition: db.c:2043
static void test_dbmerge(void)
Definition: db.c:7979
static void test_msiinsert(void)
Definition: db.c:310
static void test_storages_table(void)
Definition: db.c:7511
static void test_select_markers(void)
Definition: db.c:5287
static void test_try_transform(void)
Definition: db.c:3169
static void test_binary_import(void)
Definition: db.c:2587
static void test_special_tables(void)
Definition: db.c:4793
static void test_carriagereturn(void)
Definition: db.c:6824
static void test_where_not_in_selected(void)
Definition: db.c:1949
static void test_msiimport(void)
Definition: db.c:2372
static void test_tables_order(void)
Definition: db.c:4831
static void test_viewmodify_refresh(void)
Definition: db.c:7289
static void test_msiexport(void)
Definition: db.c:1427
static void test_createtable(void)
Definition: db.c:9312
static void test_msidecomposedesc(void)
Definition: db.c:468
static void test_order(void)
Definition: db.c:6277
static void test_temporary_table(void)
Definition: db.c:4062
static void test_insertorder(void)
Definition: db.c:8689
static void test_viewgetcolumninfo(void)
Definition: db.c:1313
static void test_droptable(void)
Definition: db.c:7760
static void test_msidatabase(void)
Definition: db.c:39

◆ test_alter()

static void test_alter ( void  )
static

Definition at line 4183 of file db.c.

4184 {
4185  MSICONDITION cond;
4186  MSIHANDLE hdb = 0;
4187  const char *query;
4188  UINT r;
4189 
4190  hdb = create_db();
4191  ok( hdb, "failed to create db\n");
4192 
4193  query = "CREATE TABLE `T` ( `B` SHORT NOT NULL TEMPORARY, `C` CHAR(255) TEMPORARY PRIMARY KEY `C`) HOLD";
4194  r = run_query(hdb, 0, query);
4195  ok(r == ERROR_SUCCESS, "failed to add table\n");
4196 
4197  cond = MsiDatabaseIsTablePersistentA(hdb, "T");
4198  ok( cond == MSICONDITION_FALSE, "wrong return condition\n");
4199 
4200  query = "ALTER TABLE `T` HOLD";
4201  r = run_query(hdb, 0, query);
4202  ok(r == ERROR_SUCCESS, "failed to hold table %d\n", r);
4203 
4204  query = "ALTER TABLE `T` FREE";
4205  r = run_query(hdb, 0, query);
4206  ok(r == ERROR_SUCCESS, "failed to free table\n");
4207 
4208  query = "ALTER TABLE `T` FREE";
4209  r = run_query(hdb, 0, query);
4210  ok(r == ERROR_SUCCESS, "failed to free table\n");
4211 
4212  query = "ALTER TABLE `T` FREE";
4213  r = run_query(hdb, 0, query);
4214  ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to free table\n");
4215 
4216  query = "ALTER TABLE `T` HOLD";
4217  r = run_query(hdb, 0, query);
4218  ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to hold table %d\n", r);
4219 
4220  /* table T is removed */
4221  query = "SELECT * FROM `T`";
4222  r = run_query(hdb, 0, query);
4223  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4224 
4225  /* create the table again */
4226  query = "CREATE TABLE `U` ( `A` INTEGER, `B` INTEGER PRIMARY KEY `B`)";
4227  r = run_query(hdb, 0, query);
4228  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4229 
4230  /* up the ref count */
4231  query = "ALTER TABLE `U` HOLD";
4232  r = run_query(hdb, 0, query);
4233  ok(r == ERROR_SUCCESS, "failed to free table\n");
4234 
4235  /* add column, no data type */
4236  query = "ALTER TABLE `U` ADD `C`";
4237  r = run_query(hdb, 0, query);
4238  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4239 
4240  query = "ALTER TABLE `U` ADD `C` INTEGER";
4241  r = run_query(hdb, 0, query);
4242  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4243 
4244  /* add column C again */
4245  query = "ALTER TABLE `U` ADD `C` INTEGER";
4246  r = run_query(hdb, 0, query);
4247  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4248 
4249  query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY";
4250  r = run_query(hdb, 0, query);
4251  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4252 
4253  query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 1, 2, 3, 4 )";
4254  r = run_query(hdb, 0, query);
4255  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4256 
4257  query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY HOLD";
4258  r = run_query(hdb, 0, query);
4259  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4260 
4261  query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 5, 6, 7, 8 )";
4262  r = run_query(hdb, 0, query);
4263  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4264 
4265  query = "SELECT * FROM `U` WHERE `D` = 8";
4266  r = run_query(hdb, 0, query);
4267  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4268 
4269  query = "ALTER TABLE `U` ADD `D` INTEGER TEMPORARY FREE";
4270  r = run_query(hdb, 0, query);
4271  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4272 
4273  query = "ALTER COLUMN `D` FREE";
4274  r = run_query(hdb, 0, query);
4275  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4276 
4277  /* drop the ref count */
4278  query = "ALTER TABLE `U` FREE";
4279  r = run_query(hdb, 0, query);
4280  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4281 
4282  /* table is not empty */
4283  query = "SELECT * FROM `U`";
4284  r = run_query(hdb, 0, query);
4285  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4286 
4287  /* column D is removed */
4288  query = "SELECT * FROM `U` WHERE `D` = 8";
4289  r = run_query(hdb, 0, query);
4290  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4291 
4292  query = "INSERT INTO `U` ( `A`, `B`, `C`, `D` ) VALUES ( 9, 10, 11, 12 )";
4293  r = run_query(hdb, 0, query);
4294  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4295 
4296  /* add the column again */
4297  query = "ALTER TABLE `U` ADD `E` INTEGER TEMPORARY HOLD";
4298  r = run_query(hdb, 0, query);
4299  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4300 
4301  /* up the ref count */
4302  query = "ALTER TABLE `U` HOLD";
4303  r = run_query(hdb, 0, query);
4304  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4305 
4306  query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 13, 14, 15, 16 )";
4307  r = run_query(hdb, 0, query);
4308  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4309 
4310  query = "SELECT * FROM `U` WHERE `E` = 16";
4311  r = run_query(hdb, 0, query);
4312  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4313 
4314  /* drop the ref count */
4315  query = "ALTER TABLE `U` FREE";
4316  r = run_query(hdb, 0, query);
4317  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4318 
4319  query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 17, 18, 19, 20 )";
4320  r = run_query(hdb, 0, query);
4321  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4322 
4323  query = "SELECT * FROM `U` WHERE `E` = 20";
4324  r = run_query(hdb, 0, query);
4325  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4326 
4327  /* drop the ref count */
4328  query = "ALTER TABLE `U` FREE";
4329  r = run_query(hdb, 0, query);
4330  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4331 
4332  /* table still exists */
4333  query = "SELECT * FROM `U`";
4334  r = run_query(hdb, 0, query);
4335  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4336 
4337  /* col E is removed */
4338  query = "SELECT * FROM `U` WHERE `E` = 20";
4339  r = run_query(hdb, 0, query);
4340  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4341 
4342  query = "INSERT INTO `U` ( `A`, `B`, `C`, `E` ) VALUES ( 20, 21, 22, 23 )";
4343  r = run_query(hdb, 0, query);
4344  ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
4345 
4346  /* drop the ref count once more */
4347  query = "ALTER TABLE `U` FREE";
4348  r = run_query(hdb, 0, query);
4349  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4350 
4351  /* table still exists */
4352  query = "SELECT * FROM `U`";
4353  r = run_query(hdb, 0, query);
4354  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4355 
4356  MsiCloseHandle( hdb );
4358 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned long MSIHANDLE
Definition: msiserver.idl:25
MSICONDITION WINAPI MsiDatabaseIsTablePersistentA(MSIHANDLE hDatabase, LPCSTR szTableName)
Definition: msiquery.c:1003
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static MSIHANDLE create_db(void)
Definition: db.c:1173
int MSICONDITION
Definition: msiserver.idl:33
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
GLenum query
Definition: glext.h:7781
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by START_TEST().

◆ test_binary()

static void test_binary ( void  )
static

Definition at line 1835 of file db.c.

1836 {
1837  MSIHANDLE hdb = 0, rec;
1838  char file[MAX_PATH];
1839  char buf[MAX_PATH];
1840  DWORD size;
1841  LPCSTR query;
1842  UINT r;
1843 
1844  /* insert a file into the Binary table */
1846  ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1847 
1848  query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1849  r = run_query( hdb, 0, query );
1850  ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1851 
1852  create_file( "test.txt" );
1853  rec = MsiCreateRecord( 1 );
1854  r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1855  ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r);
1856  DeleteFileA( "test.txt" );
1857 
1858  /* try a name that exceeds maximum OLE stream name length */
1859  query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'encryption.dll.CB4E6205_F99A_4C51_ADD4_184506EFAB87', 10000, ? )";
1860  r = run_query( hdb, rec, query );
1861  ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1862 
1863  r = MsiCloseHandle( rec );
1864  ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1865 
1866  r = MsiDatabaseCommit( hdb );
1867  ok( r == ERROR_FUNCTION_FAILED , "got %u\n", r );
1868 
1869  r = MsiCloseHandle( hdb );
1870  ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1871 
1873  ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1874 
1875  query = "CREATE TABLE `Binary` ( `Name` CHAR(72) NOT NULL, `ID` INT NOT NULL, `Data` OBJECT PRIMARY KEY `Name`, `ID`)";
1876  r = run_query( hdb, 0, query );
1877  ok( r == ERROR_SUCCESS, "Cannot create Binary table: %d\n", r );
1878 
1879  create_file( "test.txt" );
1880  rec = MsiCreateRecord( 1 );
1881  r = MsiRecordSetStreamA( rec, 1, "test.txt" );
1882  ok( r == ERROR_SUCCESS, "Failed to add stream data to the record: %d\n", r );
1883  DeleteFileA( "test.txt" );
1884 
1885  query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1886  r = run_query( hdb, rec, query );
1887  ok( r == ERROR_SUCCESS, "Insert into Binary table failed: %d\n", r );
1888 
1889  query = "INSERT INTO `Binary` ( `Name`, `ID`, `Data` ) VALUES ( 'filename1', 1, ? )";
1890  r = run_query( hdb, rec, query );
1891  ok( r == ERROR_FUNCTION_FAILED, "got %u\n", r );
1892 
1893  r = MsiCloseHandle( rec );
1894  ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1895 
1896  r = MsiDatabaseCommit( hdb );
1897  ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
1898 
1899  r = MsiCloseHandle( hdb );
1900  ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1901 
1902  /* read file from the Stream table */
1904  ok( r == ERROR_SUCCESS , "Failed to open database\n" );
1905 
1906  query = "SELECT * FROM `_Streams`";
1907  r = do_query( hdb, query, &rec );
1908  ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1909 
1910  size = MAX_PATH;
1911  r = MsiRecordGetStringA( rec, 1, file, &size );
1912  ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1913  ok( !lstrcmpA(file, "Binary.filename1.1"), "Expected 'Binary.filename1.1', got %s\n", file );
1914 
1915  size = MAX_PATH;
1916  memset( buf, 0, MAX_PATH );
1917  r = MsiRecordReadStream( rec, 2, buf, &size );
1918  ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1919  ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf );
1920 
1921  r = MsiCloseHandle( rec );
1922  ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1923 
1924  /* read file from the Binary table */
1925  query = "SELECT * FROM `Binary`";
1926  r = do_query( hdb, query, &rec );
1927  ok( r == ERROR_SUCCESS, "SELECT query failed: %d\n", r );
1928 
1929  size = MAX_PATH;
1930  r = MsiRecordGetStringA( rec, 1, file, &size );
1931  ok( r == ERROR_SUCCESS, "Failed to get string: %d\n", r );
1932  ok( !lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file );
1933 
1934  size = MAX_PATH;
1935  memset( buf, 0, MAX_PATH );
1936  r = MsiRecordReadStream( rec, 3, buf, &size );
1937  ok( r == ERROR_SUCCESS, "Failed to get stream: %d\n", r );
1938  ok( !lstrcmpA(buf, "test.txt\n"), "Expected 'test.txt\\n', got %s\n", buf );
1939 
1940  r = MsiCloseHandle( rec );
1941  ok( r == ERROR_SUCCESS , "Failed to close record handle\n" );
1942 
1943  r = MsiCloseHandle( hdb );
1944  ok( r == ERROR_SUCCESS , "Failed to close database\n" );
1945 
1946  DeleteFileA( msifile );
1947 }
#define MSIDBOPEN_READONLY
Definition: msiquery.h:66
MSIHANDLE WINAPI MsiCreateRecord(UINT cParams)
Definition: record.c:95
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, UINT iField, LPCSTR szFilename)
Definition: record.c:777
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
const char * LPCSTR
Definition: xmlstorage.h:183
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
DWORD size
Definition: db.c:3022
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
#define create_file(name)
Definition: db.c:1582
UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, UINT iField, char *buf, LPDWORD sz)
Definition: record.c:872
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
Definition: db.c:147
#define memset(x, y, z)
Definition: compat.h:39
GLenum query
Definition: glext.h:7781
Definition: fci.c:126

Referenced by START_TEST().

◆ test_binary_import()

static void test_binary_import ( void  )
static

Definition at line 2587 of file db.c.

2588 {
2589  MSIHANDLE hdb = 0, rec;
2590  char file[MAX_PATH];
2591  char buf[MAX_PATH];
2592  char path[MAX_PATH];
2593  DWORD size;
2594  LPCSTR query;
2595  UINT r;
2596 
2597  /* create files to import */
2598  write_file("bin_import.idt", bin_import_dat,
2599  (sizeof(bin_import_dat) - 1) * sizeof(char));
2600  CreateDirectoryA("bin_import", NULL);
2601  create_file_data("bin_import/filename1.ibd", "just some words", 15);
2602 
2603  /* import files into database */
2605  ok( r == ERROR_SUCCESS , "Failed to open database\n");
2606 
2608  r = MsiDatabaseImportA(hdb, path, "bin_import.idt");
2609  ok(r == ERROR_SUCCESS , "Failed to import Binary table\n");
2610 
2611  /* read file from the Binary table */
2612  query = "SELECT * FROM `Binary`";
2613  r = do_query(hdb, query, &rec);
2614  ok(r == ERROR_SUCCESS, "SELECT query failed: %d\n", r);
2615 
2616  size = MAX_PATH;
2617  r = MsiRecordGetStringA(rec, 1, file, &size);
2618  ok(r == ERROR_SUCCESS, "Failed to get string: %d\n", r);
2619  ok(!lstrcmpA(file, "filename1"), "Expected 'filename1', got %s\n", file);
2620 
2621  size = MAX_PATH;
2622  memset(buf, 0, MAX_PATH);
2623  r = MsiRecordReadStream(rec, 2, buf, &size);
2624  ok(r == ERROR_SUCCESS, "Failed to get stream: %d\n", r);
2625  ok(!lstrcmpA(buf, "just some words"), "Expected 'just some words', got %s\n", buf);
2626 
2627  r = MsiCloseHandle(rec);
2628  ok(r == ERROR_SUCCESS , "Failed to close record handle\n");
2629 
2630  r = MsiCloseHandle(hdb);
2631  ok(r == ERROR_SUCCESS , "Failed to close database\n");
2632 
2633  DeleteFileA("bin_import/filename1.ibd");
2634  RemoveDirectoryA("bin_import");
2635  DeleteFileA("bin_import.idt");
2636 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define ok(value,...)
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
const char * LPCSTR
Definition: xmlstorage.h:183
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
DWORD size
Definition: db.c:3022
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
static const CHAR bin_import_dat[]
Definition: db.c:2582
static void create_file_data(LPCSTR name, LPCSTR data, DWORD size)
Definition: db.c:1561
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
Definition: services.c:325
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiRecordReadStream(MSIHANDLE handle, UINT iField, char *buf, LPDWORD sz)
Definition: record.c:872
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
Definition: db.c:147
static void write_file(const CHAR *filename, const char *data, int data_size)
Definition: db.c:2229
#define memset(x, y, z)
Definition: compat.h:39
GLenum query
Definition: glext.h:7781
UINT WINAPI MsiDatabaseImportA(MSIHANDLE handle, LPCSTR szFolder, LPCSTR szFilename)
Definition: database.c:900
Definition: fci.c:126

Referenced by START_TEST().

◆ test_carriagereturn()

static void test_carriagereturn ( void  )
static

Definition at line 6824 of file db.c.

6825 {
6826  MSIHANDLE hdb, hview, hrec;
6827  const char *query;
6828  char buf[MAX_PATH];
6829  UINT r;
6830  DWORD size;
6831 
6833 
6835  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6836 
6837  query = "CREATE TABLE `Table`\r ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6838  r = run_query(hdb, 0, query);
6840  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6841 
6842  query = "CREATE TABLE `Table` \r( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6843  r = run_query(hdb, 0, query);
6845  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6846 
6847  query = "CREATE\r TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6848  r = run_query(hdb, 0, query);
6850  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6851 
6852  query = "CREATE TABLE\r `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6853  r = run_query(hdb, 0, query);
6855  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6856 
6857  query = "CREATE TABLE `Table` (\r `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6858  r = run_query(hdb, 0, query);
6860  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6861 
6862  query = "CREATE TABLE `Table` ( `A`\r CHAR(72) NOT NULL PRIMARY KEY `A` )";
6863  r = run_query(hdb, 0, query);
6865  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6866 
6867  query = "CREATE TABLE `Table` ( `A` CHAR(72)\r NOT NULL PRIMARY KEY `A` )";
6868  r = run_query(hdb, 0, query);
6870  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6871 
6872  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT\r NULL PRIMARY KEY `A` )";
6873  r = run_query(hdb, 0, query);
6875  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6876 
6877  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT \rNULL PRIMARY KEY `A` )";
6878  r = run_query(hdb, 0, query);
6880  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6881 
6882  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL\r PRIMARY KEY `A` )";
6883  r = run_query(hdb, 0, query);
6885  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6886 
6887  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL \rPRIMARY KEY `A` )";
6888  r = run_query(hdb, 0, query);
6890  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6891 
6892  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY\r KEY `A` )";
6893  r = run_query(hdb, 0, query);
6895  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6896 
6897  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY \rKEY `A` )";
6898  r = run_query(hdb, 0, query);
6900  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6901 
6902  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY\r `A` )";
6903  r = run_query(hdb, 0, query);
6905  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6906 
6907  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A`\r )";
6908  r = run_query(hdb, 0, query);
6910  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6911 
6912  query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )\r";
6913  r = run_query(hdb, 0, query);
6915  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6916 
6917  query = "CREATE TABLE `\rOne` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6918  r = run_query(hdb, 0, query);
6919  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6920 
6921  query = "CREATE TABLE `Tw\ro` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6922  r = run_query(hdb, 0, query);
6923  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6924 
6925  query = "CREATE TABLE `Three\r` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6926  r = run_query(hdb, 0, query);
6927  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6928 
6929  query = "CREATE TABLE `Four` ( `A\r` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6930  r = run_query(hdb, 0, query);
6932  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6933 
6934  query = "CREATE TABLE `Four` ( `\rA` CHAR(72) NOT NULL PRIMARY KEY `A` )";
6935  r = run_query(hdb, 0, query);
6937  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6938 
6939  query = "CREATE TABLE `Four` ( `A` CHAR(72\r) NOT NULL PRIMARY KEY `A` )";
6940  r = run_query(hdb, 0, query);
6942  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6943 
6944  query = "CREATE TABLE `Four` ( `A` CHAR(\r72) NOT NULL PRIMARY KEY `A` )";
6945  r = run_query(hdb, 0, query);
6947  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6948 
6949  query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `\rA` )";
6950  r = run_query(hdb, 0, query);
6952  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6953 
6954  query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6955  r = run_query(hdb, 0, query);
6957  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6958 
6959  query = "CREATE TABLE `Four` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A\r` )";
6960  r = run_query(hdb, 0, query);
6962  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
6963 
6964  query = "SELECT * FROM `_Tables`";
6965  r = MsiDatabaseOpenViewA(hdb, query, &hview);
6966  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6967  r = MsiViewExecute(hview, 0);
6968  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6969 
6970  r = MsiViewFetch(hview, &hrec);
6971  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6972 
6973  size = MAX_PATH;
6974  r = MsiRecordGetStringA(hrec, 1, buf, &size);
6975  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6976  ok(!lstrcmpA(buf, "\rOne"), "Expected \"\\rOne\", got \"%s\"\n", buf);
6977 
6978  MsiCloseHandle(hrec);
6979 
6980  r = MsiViewFetch(hview, &hrec);
6981  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6982 
6983  size = MAX_PATH;
6984  r = MsiRecordGetStringA(hrec, 1, buf, &size);
6985  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6986  ok(!lstrcmpA(buf, "Tw\ro"), "Expected \"Tw\\ro\", got \"%s\"\n", buf);
6987 
6988  MsiCloseHandle(hrec);
6989 
6990  r = MsiViewFetch(hview, &hrec);
6991  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6992 
6993  size = MAX_PATH;
6994  r = MsiRecordGetStringA(hrec, 1, buf, &size);
6995  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6996  ok(!lstrcmpA(buf, "Three\r"), "Expected \"Three\r\", got \"%s\"\n", buf);
6997 
6998  MsiCloseHandle(hrec);
6999 
7000  r = MsiViewFetch(hview, &hrec);
7001  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
7002 
7003  MsiViewClose(hview);
7004  MsiCloseHandle(hview);
7005 
7006  MsiCloseHandle(hdb);
7008 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
GLsizeiptr size
Definition: glext.h:5919
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:385
#define MAX_PATH
Definition: compat.h:26
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
DWORD size
Definition: db.c:3022
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
GLenum query
Definition: glext.h:7781
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by START_TEST().

◆ test_collation()

static void test_collation ( void  )
static

Definition at line 5121 of file db.c.

5122 {
5123  static const WCHAR query1[] =
5124  {'I','N','S','E','R','T',' ','I','N','T','O',' ','`','b','a','r','`',' ',
5125  '(','`','f','o','o','`',',','`','b','a','z','`',')',' ','V','A','L','U','E','S',' ',
5126  '(','\'','a',0x30a,'\'',',','\'','C','\'',')',0};
5127  static const WCHAR query2[] =
5128  {'I','N','S','E','R','T',' ','I','N','T','O',' ','`','b','a','r','`',' ',
5129  '(','`','f','o','o','`',',','`','b','a','z','`',')',' ','V','A','L','U','E','S',' ',
5130  '(','\'',0xe5,'\'',',','\'','D','\'',')',0};
5131  static const WCHAR query3[] =
5132  {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','b','a','z','`',' ',
5133  '(',' ','`','a',0x30a,'`',' ','L','O','N','G','C','H','A','R',' ','N','O','T',' ','N','U','L','L',',',
5134  ' ','`',0xe5,'`',' ','L','O','N','G','C','H','A','R',' ','N','O','T',' ','N','U','L','L',' ',
5135  'P','R','I','M','A','R','Y',' ','K','E','Y',' ','`','a',0x30a,'`',')',0};
5136  static const WCHAR query4[] =
5137  {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','a',0x30a,'`',' ',
5138  '(',' ','`','f','o','o','`',' ','L','O','N','G','C','H','A','R',' ','N','O','T',' ',
5139  'N','U','L','L',' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ','`','f','o','o','`',')',0};
5140  static const WCHAR query5[] =
5141  {'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`',0xe5,'`',' ',
5142  '(',' ','`','f','o','o','`',' ','L','O','N','G','C','H','A','R',' ','N','O','T',' ',
5143  'N','U','L','L',' ','P','R','I','M','A','R','Y',' ','K','E','Y',' ','`','f','o','o','`',')',0};
5144  static const WCHAR query6[] =
5145  {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','b','a','r','`',' ','W','H','E','R','E',
5146  ' ','`','f','o','o','`',' ','=','\'',0xe5,'\'',0};
5147  static const WCHAR letter_C[] = {'C',0};
5148  static const WCHAR letter_D[] = {'D',0};
5149  static const WCHAR letter_a_ring[] = {'a',0x30a,0};
5150  static const WCHAR letter_a_with_ring[] = {0xe5,0};
5151  const char *query;
5152  MSIHANDLE hdb = 0, hview = 0, hrec = 0;
5153  UINT r;
5154  char buffer[100];
5155  WCHAR bufferW[100];
5156  DWORD sz;
5157 
5159  ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
5160 
5161  query = "CREATE TABLE `bar` ( "
5162  "`foo` LONGCHAR NOT NULL, "
5163  "`baz` LONGCHAR NOT NULL "
5164  "PRIMARY KEY `foo` )";
5165  r = run_query(hdb, 0, query);
5166  ok(r == ERROR_SUCCESS, "failed to create table\n");
5167 
5168  r = run_query(hdb, 0, query);
5169  ok(r == ERROR_BAD_QUERY_SYNTAX, "wrong error %u\n", r);
5170 
5171  r = run_query(hdb, 0, "INSERT INTO `bar` "
5172  "( `foo`, `baz` ) VALUES ( '\2', 'A' )");
5173  ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
5174 
5175  r = run_query(hdb, 0, "INSERT INTO `bar` "
5176  "( `foo`, `baz` ) VALUES ( '\1', 'B' )");
5177  ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
5178 
5179  r = run_queryW(hdb, 0, query1);
5180  ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
5181 
5182  r = run_queryW(hdb, 0, query2);
5183  ok(r == ERROR_SUCCESS, "cannot add value to table %u\n", r);
5184 
5185  r = run_queryW(hdb, 0, query3);
5186  ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
5187 
5188  r = run_queryW(hdb, 0, query4);
5189  ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
5190 
5191  r = run_queryW(hdb, 0, query5);
5192  ok(r == ERROR_SUCCESS, "cannot create table %u\n", r);
5193 
5194  query = "SELECT * FROM `bar`";
5195  r = MsiDatabaseOpenViewA(hdb, query, &hview);
5196  ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
5197  r = MsiViewExecute(hview, 0);
5198  ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
5199 
5200  r = MsiViewFetch(hview, &hrec);
5201  ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
5202  sz = sizeof(buffer);
5203  r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
5204  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5205  ok(!lstrcmpA(buffer, "\2"), "Expected \\2, got '%s'\n", buffer);
5206  sz = sizeof(buffer);
5207  r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
5208  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5209  ok(!lstrcmpA(buffer, "A"), "Expected A, got '%s'\n", buffer);
5210  MsiCloseHandle(hrec);
5211 
5212  r = MsiViewFetch(hview, &hrec);
5213  ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
5214  sz = sizeof(buffer);
5215  r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
5216  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5217  ok(!lstrcmpA(buffer, "\1"), "Expected \\1, got '%s'\n", buffer);
5218  sz = sizeof(buffer);
5219  r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
5220  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5221  ok(!lstrcmpA(buffer, "B"), "Expected B, got '%s'\n", buffer);
5222  MsiCloseHandle(hrec);
5223 
5224  r = MsiViewFetch(hview, &hrec);
5225  ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
5226  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5227  r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
5228  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5229  ok(!memcmp(bufferW, letter_a_ring, sizeof(letter_a_ring)),
5230  "Expected %s, got %s\n", wine_dbgstr_w(letter_a_ring), wine_dbgstr_w(bufferW));
5231  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5232  r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
5233  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5234  ok(!lstrcmpW(bufferW, letter_C), "Expected C, got %s\n", wine_dbgstr_w(bufferW));
5235  MsiCloseHandle(hrec);
5236 
5237  r = MsiViewFetch(hview, &hrec);
5238  ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
5239  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5240  r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
5241  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5242  ok(!memcmp(bufferW, letter_a_with_ring, sizeof(letter_a_with_ring)),
5243  "Expected %s, got %s\n", wine_dbgstr_w(letter_a_with_ring), wine_dbgstr_w(bufferW));
5244  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5245  r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
5246  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5247  ok(!lstrcmpW(bufferW, letter_D), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
5248  MsiCloseHandle(hrec);
5249 
5250  r = MsiViewClose(hview);
5251  ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
5252  r = MsiCloseHandle(hview);
5253  ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
5254 
5255  r = MsiDatabaseOpenViewW(hdb, query6, &hview);
5256  ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
5257  r = MsiViewExecute(hview, 0);
5258  ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
5259 
5260  r = MsiViewFetch(hview, &hrec);
5261  ok(r == ERROR_SUCCESS, "MsiViewFetch failed\n");
5262  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5263  r = MsiRecordGetStringW(hrec, 1, bufferW, &sz);
5264  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5265  ok(!memcmp(bufferW, letter_a_with_ring, sizeof(letter_a_with_ring)),
5266  "Expected %s, got %s\n", wine_dbgstr_w(letter_a_with_ring), wine_dbgstr_w(bufferW));
5267  sz = sizeof(bufferW) / sizeof(bufferW[0]);
5268  r = MsiRecordGetStringW(hrec, 2, bufferW, &sz);
5269  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5270  ok(!lstrcmpW(bufferW, letter_D), "Expected D, got %s\n", wine_dbgstr_w(bufferW));
5271  MsiCloseHandle(hrec);
5272 
5273  r = MsiViewFetch(hview, &hrec);
5274  ok(r == ERROR_NO_MORE_ITEMS, "MsiViewFetch failed\n");
5275 
5276  r = MsiViewClose(hview);
5277  ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
5278  r = MsiCloseHandle(hview);
5279  ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
5280 
5281  r = MsiCloseHandle(hdb);
5282  ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
5283 
5285 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static UINT run_queryW(MSIHANDLE hdb, MSIHANDLE hrec, const WCHAR *query)
Definition: db.c:188
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define wine_dbgstr_w
Definition: kernel32.h:34
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
GLuint buffer
Definition: glext.h:5915
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
#define ok(value,...)
UINT WINAPI MsiRecordGetStringW(MSIHANDLE handle, UINT iField, LPWSTR szValue, LPDWORD pcchValue)
Definition: record.c:533
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:385
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, LPCWSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:241
GLenum query
Definition: glext.h:7781
#define ERROR_BAD_QUERY_SYNTAX
Definition: winerror.h:973

Referenced by START_TEST().

◆ test_columnorder()

static void test_columnorder ( void  )
static

Definition at line 8825 of file db.c.

8826 {
8827  MSIHANDLE hdb, view, rec;
8828  char buf[MAX_PATH];
8829  LPCSTR query;
8830  DWORD sz;
8831  UINT r;
8832 
8833  hdb = create_db();
8834  ok(hdb, "failed to create db\n");
8835 
8836  /* Each column is a slot:
8837  * ---------------------
8838  * | B | C | A | E | D |
8839  * ---------------------
8840  *
8841  * When a column is selected as a primary key,
8842  * the column occupying the nth primary key slot is swapped
8843  * with the current position of the primary key in question:
8844  *
8845  * set primary key `D`
8846  * --------------------- ---------------------
8847  * | B | C | A | E | D | -> | D | C | A | E | B |
8848  * --------------------- ---------------------
8849  *
8850  * set primary key `E`
8851  * --------------------- ---------------------
8852  * | D | C | A | E | B | -> | D | E | A | C | B |
8853  * --------------------- ---------------------
8854  */
8855 
8856  query = "CREATE TABLE `T` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
8857  "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
8858  "PRIMARY KEY `D`, `E`)";
8859  r = run_query(hdb, 0, query);
8860  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8861 
8862  query = "SELECT * FROM `T`";
8863  r = MsiDatabaseOpenViewA(hdb, query, &view);
8864  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8865 
8867  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8868 
8869  sz = MAX_PATH;
8870  lstrcpyA(buf, "kiwi");
8871  r = MsiRecordGetStringA(rec, 1, buf, &sz);
8872  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8873  ok(!lstrcmpA("s255", buf), "Expected \"s255\", got \"%s\"\n", buf);
8874 
8875  sz = MAX_PATH;
8876  lstrcpyA(buf, "kiwi");
8877  r = MsiRecordGetStringA(rec, 2, buf, &sz);
8878  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8879  ok(!lstrcmpA("I2", buf), "Expected \"I2\", got \"%s\"\n", buf);
8880 
8881  sz = MAX_PATH;
8882  lstrcpyA(buf, "kiwi");
8883  r = MsiRecordGetStringA(rec, 3, buf, &sz);
8884  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8885  ok(!lstrcmpA("S255", buf), "Expected \"S255\", got \"%s\"\n", buf);
8886 
8887  sz = MAX_PATH;
8888  lstrcpyA(buf, "kiwi");
8889  r = MsiRecordGetStringA(rec, 4, buf, &sz);
8890  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8891  ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
8892 
8893  sz = MAX_PATH;
8894  lstrcpyA(buf, "kiwi");
8895  r = MsiRecordGetStringA(rec, 5, buf, &sz);
8896  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8897  ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
8898 
8899  MsiCloseHandle(rec);
8900 
8902  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8903 
8904  sz = MAX_PATH;
8905  lstrcpyA(buf, "kiwi");
8906  r = MsiRecordGetStringA(rec, 1, buf, &sz);
8907  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8908  ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
8909 
8910  sz = MAX_PATH;
8911  lstrcpyA(buf, "kiwi");
8912  r = MsiRecordGetStringA(rec, 2, buf, &sz);
8913  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8914  ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
8915 
8916  sz = MAX_PATH;
8917  lstrcpyA(buf, "kiwi");
8918  r = MsiRecordGetStringA(rec, 3, buf, &sz);
8919  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8920  ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
8921 
8922  sz = MAX_PATH;
8923  lstrcpyA(buf, "kiwi");
8924  r = MsiRecordGetStringA(rec, 4, buf, &sz);
8925  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8926  ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
8927 
8928  sz = MAX_PATH;
8929  lstrcpyA(buf, "kiwi");
8930  r = MsiRecordGetStringA(rec, 5, buf, &sz);
8931  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8932  ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
8933 
8934  MsiCloseHandle(rec);
8935  MsiViewClose(view);
8937 
8938  query = "INSERT INTO `T` ( `B`, `C`, `A`, `E`, `D` ) "
8939  "VALUES ( 1, 2, 'a', 3, 'bc' )";
8940  r = run_query(hdb, 0, query);
8941  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8942 
8943  query = "SELECT * FROM `T`";
8944  r = do_query(hdb, query, &rec);
8945  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8946 
8947  sz = MAX_PATH;
8948  lstrcpyA(buf, "kiwi");
8949  r = MsiRecordGetStringA(rec, 1, buf, &sz);
8950  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8951  ok(!lstrcmpA("bc", buf), "Expected \"bc\", got \"%s\"\n", buf);
8952 
8953  r = MsiRecordGetInteger(rec, 2);
8954  ok(r == 3, "Expected 3, got %d\n", r);
8955 
8956  sz = MAX_PATH;
8957  lstrcpyA(buf, "kiwi");
8958  r = MsiRecordGetStringA(rec, 3, buf, &sz);
8959  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8960  ok(!lstrcmpA("a", buf), "Expected \"a\", got \"%s\"\n", buf);
8961 
8962  r = MsiRecordGetInteger(rec, 4);
8963  ok(r == 2, "Expected 2, got %d\n", r);
8964 
8965  r = MsiRecordGetInteger(rec, 5);
8966  ok(r == 1, "Expected 1, got %d\n", r);
8967 
8968  MsiCloseHandle(rec);
8969 
8970  query = "SELECT * FROM `_Columns` WHERE `Table` = 'T'";
8971  r = MsiDatabaseOpenViewA(hdb, query, &view);
8972  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8973  r = MsiViewExecute(view, 0);
8974  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8975 
8976  r = MsiViewFetch(view, &rec);
8977  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8978 
8979  sz = MAX_PATH;
8980  lstrcpyA(buf, "kiwi");
8981  r = MsiRecordGetStringA(rec, 1, buf, &sz);
8982  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8983  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
8984 
8985  r = MsiRecordGetInteger(rec, 2);
8986  ok(r == 1, "Expected 1, got %d\n", r);
8987 
8988  sz = MAX_PATH;
8989  lstrcpyA(buf, "kiwi");
8990  r = MsiRecordGetStringA(rec, 3, buf, &sz);
8991  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8992  ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
8993 
8994  MsiCloseHandle(rec);
8995 
8996  r = MsiViewFetch(view, &rec);
8997  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8998 
8999  sz = MAX_PATH;
9000  lstrcpyA(buf, "kiwi");
9001  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9002  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9003  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9004 
9005  r = MsiRecordGetInteger(rec, 2);
9006  ok(r == 2, "Expected 2, got %d\n", r);
9007 
9008  sz = MAX_PATH;
9009  lstrcpyA(buf, "kiwi");
9010  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9011  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9012  ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
9013 
9014  MsiCloseHandle(rec);
9015 
9016  r = MsiViewFetch(view, &rec);
9017  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9018 
9019  sz = MAX_PATH;
9020  lstrcpyA(buf, "kiwi");
9021  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9022  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9023  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9024 
9025  r = MsiRecordGetInteger(rec, 2);
9026  ok(r == 3, "Expected 3, got %d\n", r);
9027 
9028  sz = MAX_PATH;
9029  lstrcpyA(buf, "kiwi");
9030  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9031  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9032  ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
9033 
9034  MsiCloseHandle(rec);
9035 
9036  r = MsiViewFetch(view, &rec);
9037  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9038 
9039  sz = MAX_PATH;
9040  lstrcpyA(buf, "kiwi");
9041  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9042  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9043  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9044 
9045  r = MsiRecordGetInteger(rec, 2);
9046  ok(r == 4, "Expected 4, got %d\n", r);
9047 
9048  sz = MAX_PATH;
9049  lstrcpyA(buf, "kiwi");
9050  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9051  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9052  ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
9053 
9054  MsiCloseHandle(rec);
9055 
9056  r = MsiViewFetch(view, &rec);
9057  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9058 
9059  sz = MAX_PATH;
9060  lstrcpyA(buf, "kiwi");
9061  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9062  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9063  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9064 
9065  r = MsiRecordGetInteger(rec, 2);
9066  ok(r == 5, "Expected 5, got %d\n", r);
9067 
9068  sz = MAX_PATH;
9069  lstrcpyA(buf, "kiwi");
9070  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9071  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9072  ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
9073 
9074  MsiCloseHandle(rec);
9075 
9076  r = MsiViewFetch(view, &rec);
9077  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9078 
9079  MsiViewClose(view);
9081 
9082  query = "CREATE TABLE `Z` ( `B` SHORT NOT NULL, `C` SHORT NOT NULL, "
9083  "`A` CHAR(255), `E` INT, `D` CHAR(255) NOT NULL "
9084  "PRIMARY KEY `C`, `A`, `D`)";
9085  r = run_query(hdb, 0, query);
9086  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9087 
9088  query = "SELECT * FROM `Z`";
9089  r = MsiDatabaseOpenViewA(hdb, query, &view);
9090  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9091 
9093  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9094 
9095  sz = MAX_PATH;
9096  lstrcpyA(buf, "kiwi");
9097  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9098  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9099  ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
9100 
9101  sz = MAX_PATH;
9102  lstrcpyA(buf, "kiwi");
9103  r = MsiRecordGetStringA(rec, 2, buf, &sz);
9104  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9105  ok(!lstrcmpA("S255", buf), "Expected \"S255\", got \"%s\"\n", buf);
9106 
9107  sz = MAX_PATH;
9108  lstrcpyA(buf, "kiwi");
9109  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9110  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9111  ok(!lstrcmpA("s255", buf), "Expected \"s255\", got \"%s\"\n", buf);
9112 
9113  sz = MAX_PATH;
9114  lstrcpyA(buf, "kiwi");
9115  r = MsiRecordGetStringA(rec, 4, buf, &sz);
9116  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9117  ok(!lstrcmpA("I2", buf), "Expected \"I2\", got \"%s\"\n", buf);
9118 
9119  sz = MAX_PATH;
9120  lstrcpyA(buf, "kiwi");
9121  r = MsiRecordGetStringA(rec, 5, buf, &sz);
9122  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9123  ok(!lstrcmpA("i2", buf), "Expected \"i2\", got \"%s\"\n", buf);
9124 
9125  MsiCloseHandle(rec);
9126 
9128  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9129 
9130  sz = MAX_PATH;
9131  lstrcpyA(buf, "kiwi");
9132  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9133  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9134  ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
9135 
9136  sz = MAX_PATH;
9137  lstrcpyA(buf, "kiwi");
9138  r = MsiRecordGetStringA(rec, 2, buf, &sz);
9139  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9140  ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
9141 
9142  sz = MAX_PATH;
9143  lstrcpyA(buf, "kiwi");
9144  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9145  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9146  ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
9147 
9148  sz = MAX_PATH;
9149  lstrcpyA(buf, "kiwi");
9150  r = MsiRecordGetStringA(rec, 4, buf, &sz);
9151  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9152  ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
9153 
9154  sz = MAX_PATH;
9155  lstrcpyA(buf, "kiwi");
9156  r = MsiRecordGetStringA(rec, 5, buf, &sz);
9157  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9158  ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
9159 
9160  MsiCloseHandle(rec);
9161  MsiViewClose(view);
9163 
9164  query = "INSERT INTO `Z` ( `B`, `C`, `A`, `E`, `D` ) "
9165  "VALUES ( 1, 2, 'a', 3, 'bc' )";
9166  r = run_query(hdb, 0, query);
9167  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9168 
9169  query = "SELECT * FROM `Z`";
9170  r = do_query(hdb, query, &rec);
9171  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9172 
9173  r = MsiRecordGetInteger(rec, 1);
9174  ok(r == 2, "Expected 2, got %d\n", r);
9175 
9176  sz = MAX_PATH;
9177  lstrcpyA(buf, "kiwi");
9178  r = MsiRecordGetStringA(rec, 2, buf, &sz);
9179  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9180  ok(!lstrcmpA("a", buf), "Expected \"a\", got \"%s\"\n", buf);
9181 
9182  sz = MAX_PATH;
9183  lstrcpyA(buf, "kiwi");
9184  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9185  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9186  ok(!lstrcmpA("bc", buf), "Expected \"bc\", got \"%s\"\n", buf);
9187 
9188  r = MsiRecordGetInteger(rec, 4);
9189  ok(r == 3, "Expected 3, got %d\n", r);
9190 
9191  r = MsiRecordGetInteger(rec, 5);
9192  ok(r == 1, "Expected 1, got %d\n", r);
9193 
9194  MsiCloseHandle(rec);
9195 
9196  query = "SELECT * FROM `_Columns` WHERE `Table` = 'T'";
9197  r = MsiDatabaseOpenViewA(hdb, query, &view);
9198  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9199  r = MsiViewExecute(view, 0);
9200  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9201 
9202  r = MsiViewFetch(view, &rec);
9203  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9204 
9205  sz = MAX_PATH;
9206  lstrcpyA(buf, "kiwi");
9207  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9208  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9209  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9210 
9211  r = MsiRecordGetInteger(rec, 2);
9212  ok(r == 1, "Expected 1, got %d\n", r);
9213 
9214  sz = MAX_PATH;
9215  lstrcpyA(buf, "kiwi");
9216  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9217  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9218  ok(!lstrcmpA("D", buf), "Expected \"D\", got \"%s\"\n", buf);
9219 
9220  MsiCloseHandle(rec);
9221 
9222  r = MsiViewFetch(view, &rec);
9223  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9224 
9225  sz = MAX_PATH;
9226  lstrcpyA(buf, "kiwi");
9227  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9228  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9229  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9230 
9231  r = MsiRecordGetInteger(rec, 2);
9232  ok(r == 2, "Expected 2, got %d\n", r);
9233 
9234  sz = MAX_PATH;
9235  lstrcpyA(buf, "kiwi");
9236  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9237  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9238  ok(!lstrcmpA("E", buf), "Expected \"E\", got \"%s\"\n", buf);
9239 
9240  MsiCloseHandle(rec);
9241 
9242  r = MsiViewFetch(view, &rec);
9243  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9244 
9245  sz = MAX_PATH;
9246  lstrcpyA(buf, "kiwi");
9247  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9248  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9249  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9250 
9251  r = MsiRecordGetInteger(rec, 2);
9252  ok(r == 3, "Expected 3, got %d\n", r);
9253 
9254  sz = MAX_PATH;
9255  lstrcpyA(buf, "kiwi");
9256  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9257  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9258  ok(!lstrcmpA("A", buf), "Expected \"A\", got \"%s\"\n", buf);
9259 
9260  MsiCloseHandle(rec);
9261 
9262  r = MsiViewFetch(view, &rec);
9263  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9264 
9265  sz = MAX_PATH;
9266  lstrcpyA(buf, "kiwi");
9267  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9268  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9269  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9270 
9271  r = MsiRecordGetInteger(rec, 2);
9272  ok(r == 4, "Expected 4, got %d\n", r);
9273 
9274  sz = MAX_PATH;
9275  lstrcpyA(buf, "kiwi");
9276  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9277  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9278  ok(!lstrcmpA("C", buf), "Expected \"C\", got \"%s\"\n", buf);
9279 
9280  MsiCloseHandle(rec);
9281 
9282  r = MsiViewFetch(view, &rec);
9283  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9284 
9285  sz = MAX_PATH;
9286  lstrcpyA(buf, "kiwi");
9287  r = MsiRecordGetStringA(rec, 1, buf, &sz);
9288  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9289  ok(!lstrcmpA("T", buf), "Expected \"T\", got \"%s\"\n", buf);
9290 
9291  r = MsiRecordGetInteger(rec, 2);
9292  ok(r == 5, "Expected 5, got %d\n", r);
9293 
9294  sz = MAX_PATH;
9295  lstrcpyA(buf, "kiwi");
9296  r = MsiRecordGetStringA(rec, 3, buf, &sz);
9297  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9298  ok(!lstrcmpA("B", buf), "Expected \"B\", got \"%s\"\n", buf);
9299 
9300  MsiCloseHandle(rec);
9301 
9302  r = MsiViewFetch(view, &rec);
9303  ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
9304 
9305  MsiViewClose(view);
9307 
9308  MsiCloseHandle(hdb);
9310 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI MsiRecordGetInteger(MSIHANDLE handle, UINT iField)
Definition: record.c:271
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
static UINT run_query(MSIHANDLE hdb, MSIHANDLE hrec, const char *query)
Definition: db.c:172
static const char * msifile
Definition: db.c:33
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
const char * LPCSTR
Definition: xmlstorage.h:183
UINT WINAPI MsiViewFetch(MSIHANDLE hView, MSIHANDLE *record)
Definition: msiquery.c:385
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static MSIHANDLE create_db(void)
Definition: db.c:1173
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
Definition: msiquery.c:569
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
Definition: db.c:147
static IOleDocumentView * view
Definition: activex.c:1749
GLenum query
Definition: glext.h:7781

Referenced by START_TEST().

◆ test_createtable()

static void test_createtable ( void  )
static

Definition at line 9312 of file db.c.

9313 {
9314  MSIHANDLE hdb, htab = 0, hrec = 0;
9315  LPCSTR query;
9316  UINT res;
9317  DWORD size;
9318  char buffer[0x20];
9319 
9320  hdb = create_db();
9321  ok(hdb, "failed to create db\n");
9322 
9323  query = "CREATE TABLE `blah` (`foo` CHAR(72) NOT NULL PRIMARY KEY `foo`)";
9324  res = MsiDatabaseOpenViewA( hdb, query, &htab );
9325  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9326  if(res == ERROR_SUCCESS )
9327  {
9328  res = MsiViewExecute( htab, hrec );
9329  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9330 
9331  res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
9332  todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9333 
9334  size = sizeof(buffer);
9335  res = MsiRecordGetStringA(hrec, 1, buffer, &size );
9336  todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9337  MsiCloseHandle( hrec );
9338 
9339  res = MsiViewClose( htab );
9340  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9341 
9342  res = MsiCloseHandle( htab );
9343  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9344  }
9345 
9346  query = "CREATE TABLE `a` (`b` INT PRIMARY KEY `b`)";
9347  res = MsiDatabaseOpenViewA( hdb, query, &htab );
9348  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9349  if(res == ERROR_SUCCESS )
9350  {
9351  res = MsiViewExecute( htab, 0 );
9352  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9353 
9354  res = MsiViewClose( htab );
9355  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9356 
9357  res = MsiCloseHandle( htab );
9358  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9359 
9360  query = "SELECT * FROM `a`";
9361  res = MsiDatabaseOpenViewA( hdb, query, &htab );
9362  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9363 
9364  res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
9365  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9366 
9367  buffer[0] = 0;
9368  size = sizeof(buffer);
9369  res = MsiRecordGetStringA(hrec, 1, buffer, &size );
9370  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9371  ok(!strcmp(buffer,"b"), "b != %s\n", buffer);
9372  MsiCloseHandle( hrec );
9373 
9374  res = MsiViewClose( htab );
9375  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9376 
9377  res = MsiCloseHandle( htab );
9378  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9379 
9380  res = MsiDatabaseCommit(hdb);
9381  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9382 
9383  res = MsiCloseHandle(hdb);
9384  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9385 
9387  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9388 
9389  query = "SELECT * FROM `a`";
9390  res = MsiDatabaseOpenViewA( hdb, query, &htab );
9391  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9392 
9393  res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec );
9394  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9395 
9396  buffer[0] = 0;
9397  size = sizeof(buffer);
9398  res = MsiRecordGetStringA(hrec, 1, buffer, &size );
9399  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9400  ok(!strcmp(buffer,"b"), "b != %s\n", buffer);
9401 
9402  res = MsiCloseHandle( hrec );
9403  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9404 
9405  res = MsiViewClose( htab );
9406  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9407 
9408  res = MsiCloseHandle( htab );
9409  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9410  }
9411 
9412  res = MsiDatabaseCommit(hdb);
9413  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9414 
9415  res = MsiCloseHandle(hdb);
9416  ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
9417 
9419 }
UINT WINAPI MsiViewExecute(MSIHANDLE hView, MSIHANDLE hRec)
Definition: msiquery.c:459
#define ERROR_SUCCESS
Definition: deptool.c:10
GLuint buffer
Definition: glext.h:5915
UINT WINAPI MsiRecordGetStringA(MSIHANDLE handle, UINT iField, LPSTR szValue, LPDWORD pcchValue)
Definition: record.c:451
UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE *phView)
Definition: msiquery.c:88
unsigned long MSIHANDLE
Definition: msiserver.idl:25
UINT WINAPI MsiViewClose(MSIHANDLE hView)
Definition: msiquery.c:427
static const char * msifile
Definition: db.c:33
#define ok(value,...)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
const char * LPCSTR
Definition: xmlstorage.h:183
GLsizeiptr size
Definition: glext.h:5919
DWORD size
Definition: db.c:3022
unsigned long DWORD
Definition: ntddk_ex.h:95
#define MSIDBOPEN_TRANSACT
Definition: msiquery.h:67
static MSIHANDLE create_db(void)
Definition: db.c:1173
#define todo_wine
Definition: test.h:154
static const WCHAR msifileW[]
Definition: db.c:36
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI MsiViewGetColumnInfo(MSIHANDLE hView, MSICOLINFO info, MSIHANDLE *hRec)
Definition: msiquery.c:569
GLuint res
Definition: glext.h:9613
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
GLenum query
Definition: glext.h:7781

Referenced by START_TEST().

◆ test_dbmerge()

static void test_dbmerge ( void  )
static

Definition at line 7979 of file db.c.

7980 {
7981  static const WCHAR refdbW[] = {'r','e','f','d','b','.','m','s','i',0};
7982  MSIHANDLE hdb, href, hview, hrec;
7983  CHAR buf[MAX_PATH];
7984  LPCSTR query;
7985  DWORD size;
7986  UINT r;
7987 
7989  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7990 
7991  r = MsiOpenDatabaseW(refdbW, MSIDBOPEN_CREATE, &href);
7992  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7993 
7994  /* hDatabase is invalid */
7995  r = MsiDatabaseMergeA(0, href, "MergeErrors");
7997  "Expected ERROR_INVALID_HANDLE, got %d\n", r);
7998 
7999  /* hDatabaseMerge is invalid */
8000  r = MsiDatabaseMergeA(hdb, 0, "MergeErrors");
8002  "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8003 
8004  /* szTableName is NULL */
8005  r = MsiDatabaseMergeA(hdb, href, NULL);
8006  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8007 
8008  /* szTableName is empty */
8009  r = MsiDatabaseMergeA(hdb, href, "");
8010  ok(r == ERROR_INVALID_TABLE, "Expected ERROR_INVALID_TABLE, got %d\n", r);
8011 
8012  /* both DBs empty, szTableName is valid */
8013  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8014  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8015 
8016  query = "CREATE TABLE `One` ( `A` INT PRIMARY KEY `A` )";
8017  r = run_query(hdb, 0, query);
8018  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8019 
8020  query = "CREATE TABLE `One` ( `A` CHAR(72) PRIMARY KEY `A` )";
8021  r = run_query(href, 0, query);
8022  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8023 
8024  /* column types don't match */
8025  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8027  "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
8028 
8029  /* nothing in MergeErrors */
8030  query = "SELECT * FROM `MergeErrors`";
8031  r = do_query(hdb, query, &hrec);
8033  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8034 
8035  query = "DROP TABLE `One`";
8036  r = run_query(hdb, 0, query);
8037  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8038 
8039  query = "DROP TABLE `One`";
8040  r = run_query(href, 0, query);
8041  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8042 
8043  query = "CREATE TABLE `One` ( "
8044  "`A` CHAR(72), "
8045  "`B` CHAR(56), "
8046  "`C` CHAR(64) LOCALIZABLE, "
8047  "`D` LONGCHAR, "
8048  "`E` CHAR(72) NOT NULL, "
8049  "`F` CHAR(56) NOT NULL, "
8050  "`G` CHAR(64) NOT NULL LOCALIZABLE, "
8051  "`H` LONGCHAR NOT NULL "
8052  "PRIMARY KEY `A` )";
8053  r = run_query(hdb, 0, query);
8054  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8055 
8056  query = "CREATE TABLE `One` ( "
8057  "`A` CHAR(64), "
8058  "`B` CHAR(64), "
8059  "`C` CHAR(64), "
8060  "`D` CHAR(64), "
8061  "`E` CHAR(64) NOT NULL, "
8062  "`F` CHAR(64) NOT NULL, "
8063  "`G` CHAR(64) NOT NULL, "
8064  "`H` CHAR(64) NOT NULL "
8065  "PRIMARY KEY `A` )";
8066  r = run_query(href, 0, query);
8067  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8068 
8069  /* column string types don't match exactly */
8070  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8071  ok(r == ERROR_SUCCESS,
8072  "Expected ERROR_SUCCESS, got %d\n", r);
8073 
8074  /* nothing in MergeErrors */
8075  query = "SELECT * FROM `MergeErrors`";
8076  r = do_query(hdb, query, &hrec);
8078  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8079 
8080  query = "DROP TABLE `One`";
8081  r = run_query(hdb, 0, query);
8082  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8083 
8084  query = "DROP TABLE `One`";
8085  r = run_query(href, 0, query);
8086  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8087 
8088  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8089  r = run_query(hdb, 0, query);
8090  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8091 
8092  query = "CREATE TABLE `One` ( `A` INT, `C` INT PRIMARY KEY `A` )";
8093  r = run_query(href, 0, query);
8094  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8095 
8096  /* column names don't match */
8097  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8099  "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
8100 
8101  /* nothing in MergeErrors */
8102  query = "SELECT * FROM `MergeErrors`";
8103  r = do_query(hdb, query, &hrec);
8105  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8106 
8107  query = "DROP TABLE `One`";
8108  r = run_query(hdb, 0, query);
8109  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8110 
8111  query = "DROP TABLE `One`";
8112  r = run_query(href, 0, query);
8113  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8114 
8115  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8116  r = run_query(hdb, 0, query);
8117  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8118 
8119  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `B` )";
8120  r = run_query(href, 0, query);
8121  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8122 
8123  /* primary keys don't match */
8124  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8126  "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
8127 
8128  /* nothing in MergeErrors */
8129  query = "SELECT * FROM `MergeErrors`";
8130  r = do_query(hdb, query, &hrec);
8132  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8133 
8134  query = "DROP TABLE `One`";
8135  r = run_query(hdb, 0, query);
8136  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8137 
8138  query = "DROP TABLE `One`";
8139  r = run_query(href, 0, query);
8140  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8141 
8142  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8143  r = run_query(hdb, 0, query);
8144  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8145 
8146  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A`, `B` )";
8147  r = run_query(href, 0, query);
8148  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8149 
8150  /* number of primary keys doesn't match */
8151  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8153  "Expected ERROR_DATATYPE_MISMATCH, got %d\n", r);
8154 
8155  /* nothing in MergeErrors */
8156  query = "SELECT * FROM `MergeErrors`";
8157  r = do_query(hdb, query, &hrec);
8159  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8160 
8161  query = "DROP TABLE `One`";
8162  r = run_query(hdb, 0, query);
8163  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8164 
8165  query = "DROP TABLE `One`";
8166  r = run_query(href, 0, query);
8167  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8168 
8169  query = "CREATE TABLE `One` ( `A` INT, `B` INT, `C` INT PRIMARY KEY `A` )";
8170  r = run_query(hdb, 0, query);
8171  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172 
8173  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8174  r = run_query(href, 0, query);
8175  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8176 
8177  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 2 )";
8178  r = run_query(href, 0, query);
8179  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8180 
8181  /* number of columns doesn't match */
8182  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8183  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8184 
8185  query = "SELECT * FROM `One`";
8186  r = do_query(hdb, query, &hrec);
8187  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8188 
8189  r = MsiRecordGetInteger(hrec, 1);
8190  ok(r == 1, "Expected 1, got %d\n", r);
8191 
8192  r = MsiRecordGetInteger(hrec, 2);
8193  ok(r == 2, "Expected 2, got %d\n", r);
8194 
8195  r = MsiRecordGetInteger(hrec, 3);
8196  ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
8197 
8198  MsiCloseHandle(hrec);
8199 
8200  /* nothing in MergeErrors */
8201  query = "SELECT * FROM `MergeErrors`";
8202  r = do_query(hdb, query, &hrec);
8204  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8205 
8206  query = "DROP TABLE `One`";
8207  r = run_query(hdb, 0, query);
8208  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8209 
8210  query = "DROP TABLE `One`";
8211  r = run_query(href, 0, query);
8212  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8213 
8214  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8215  r = run_query(hdb, 0, query);
8216  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8217 
8218  query = "CREATE TABLE `One` ( `A` INT, `B` INT, `C` INT PRIMARY KEY `A` )";
8219  r = run_query(href, 0, query);
8220  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8221 
8222  query = "INSERT INTO `One` ( `A`, `B`, `C` ) VALUES ( 1, 2, 3 )";
8223  r = run_query(href, 0, query);
8224  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8225 
8226  /* number of columns doesn't match */
8227  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8228  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8229 
8230  query = "SELECT * FROM `One`";
8231  r = do_query(hdb, query, &hrec);
8232  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8233 
8234  r = MsiRecordGetInteger(hrec, 1);
8235  ok(r == 1, "Expected 1, got %d\n", r);
8236 
8237  r = MsiRecordGetInteger(hrec, 2);
8238  ok(r == 2, "Expected 2, got %d\n", r);
8239 
8240  r = MsiRecordGetInteger(hrec, 3);
8241  ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);
8242 
8243  MsiCloseHandle(hrec);
8244 
8245  /* nothing in MergeErrors */
8246  query = "SELECT * FROM `MergeErrors`";
8247  r = do_query(hdb, query, &hrec);
8249  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8250 
8251  query = "DROP TABLE `One`";
8252  r = run_query(hdb, 0, query);
8253  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8254 
8255  query = "DROP TABLE `One`";
8256  r = run_query(href, 0, query);
8257  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8258 
8259  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8260  r = run_query(hdb, 0, query);
8261  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8262 
8263  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 1 )";
8264  r = run_query(hdb, 0, query);
8265  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8266 
8267  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 2, 2 )";
8268  r = run_query(hdb, 0, query);
8269  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8270 
8271  query = "CREATE TABLE `One` ( `A` INT, `B` INT PRIMARY KEY `A` )";
8272  r = run_query(href, 0, query);
8273  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8274 
8275  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 2 )";
8276  r = run_query(href, 0, query);
8277  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8278 
8279  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 2, 3 )";
8280  r = run_query(href, 0, query);
8281  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8282 
8283  /* primary keys match, rows do not */
8284  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8286  "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8287 
8288  /* nothing in MergeErrors */
8289  query = "SELECT * FROM `MergeErrors`";
8290  r = do_query(hdb, query, &hrec);
8291  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8292 
8293  size = MAX_PATH;
8294  r = MsiRecordGetStringA(hrec, 1, buf, &size);
8295  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8296  ok(!lstrcmpA(buf, "One"), "Expected \"One\", got \"%s\"\n", buf);
8297 
8298  r = MsiRecordGetInteger(hrec, 2);
8299  ok(r == 2, "Expected 2, got %d\n", r);
8300 
8301  MsiCloseHandle(hrec);
8302 
8303  r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `MergeErrors`", &hview);
8304  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8305 
8306  r = MsiViewGetColumnInfo(hview, MSICOLINFO_NAMES, &hrec);
8307  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8308 
8309  size = MAX_PATH;
8310  r = MsiRecordGetStringA(hrec, 1, buf, &size);
8311  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8312  ok(!lstrcmpA(buf, "Table"), "Expected \"Table\", got \"%s\"\n", buf);
8313 
8314  size = MAX_PATH;
8315  r = MsiRecordGetStringA(hrec, 2, buf, &size);
8316  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8317  ok(!lstrcmpA(buf, "NumRowMergeConflicts"),
8318  "Expected \"NumRowMergeConflicts\", got \"%s\"\n", buf);
8319 
8320  MsiCloseHandle(hrec);
8321 
8322  r = MsiViewGetColumnInfo(hview, MSICOLINFO_TYPES, &hrec);
8323  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8324 
8325  size = MAX_PATH;
8326  r = MsiRecordGetStringA(hrec, 1, buf, &size);
8327  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8328  ok(!lstrcmpA(buf, "s255"), "Expected \"s255\", got \"%s\"\n", buf);
8329 
8330  size = MAX_PATH;
8331  r = MsiRecordGetStringA(hrec, 2, buf, &size);
8332  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8333  ok(!lstrcmpA(buf, "i2"), "Expected \"i2\", got \"%s\"\n", buf);
8334 
8335  MsiCloseHandle(hrec);
8336  MsiViewClose(hview);
8337  MsiCloseHandle(hview);
8338 
8339  query = "DROP TABLE `MergeErrors`";
8340  r = run_query(hdb, 0, query);
8341  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8342 
8343  query = "DROP TABLE `One`";
8344  r = run_query(hdb, 0, query);
8345  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8346 
8347  query = "DROP TABLE `One`";
8348  r = run_query(href, 0, query);
8349  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8350 
8351  query = "CREATE TABLE `One` ( `A` INT, `B` CHAR(72) PRIMARY KEY `A` )";
8352  r = run_query(href, 0, query);
8353  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8354 
8355  query = "INSERT INTO `One` ( `A`, `B` ) VALUES ( 1, 'hi' )";
8356  r = run_query(href, 0, query);
8357  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8358 
8359  /* table from merged database is not in target database */
8360  r = MsiDatabaseMergeA(hdb, href, "MergeErrors");
8361  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8362 
8363  query = "SELECT * FROM `One`";
8364  r = do_query(hdb, query, &hrec);
8365  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8366 
8367  r = MsiRecordGetInteger(hrec, 1);
8368  ok(r == 1, "Expected 1, got %d\n", r);
8369 
8370  size = MAX_PATH;
8371  r = MsiRecordGetStringA(hrec, 2, buf, &size);
8372  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8373  ok(!lstrcmpA(buf, "hi"), "Expected \"hi\", got \"%s\"\n", buf);
8374 
8375  MsiCloseHandle(hrec);
8376 
8377  /* nothing in MergeErrors */
8378  query = "SELECT * FROM `MergeErrors`";
8379  r = do_query(hdb, query, &hrec);
8381  "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8382 
8383  query = "DROP TABLE `One`";
8384  r = run_query(hdb, 0, query);
8385  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8386 
8387  query = "DROP TABLE `One`";
8388  r = run_query(href, 0, query);
8389  ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8390 
8391  query = "CREATE TABLE `One` ( "
8392  "`A` CHAR(72), `B` INT PRIMARY KEY `A` )";
8393  r = run_query(hdb, 0, query);
8394  ok(r == ERROR_SUCCESS,