Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
91ec65d7
Commit
91ec65d7
authored
Aug 01, 2006
by
James Hawkins
Committed by
Alexandre Julliard
Aug 02, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi: Add tests for SQL query markers.
parent
1dd97aa1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
193 additions
and
11 deletions
+193
-11
db.c
dlls/msi/tests/db.c
+193
-11
No files found.
dlls/msi/tests/db.c
View file @
91ec65d7
...
...
@@ -457,7 +457,7 @@ static void test_msibadqueries(void)
ok
(
r
==
TRUE
,
"file didn't exist after commit
\n
"
);
}
static
UINT
run_query
(
MSIHANDLE
hdb
,
const
char
*
query
)
static
UINT
run_query
(
MSIHANDLE
hdb
,
MSIHANDLE
hrec
,
const
char
*
query
)
{
MSIHANDLE
hview
=
0
;
UINT
r
;
...
...
@@ -466,7 +466,7 @@ static UINT run_query( MSIHANDLE hdb, const char *query )
if
(
r
!=
ERROR_SUCCESS
)
return
r
;
r
=
MsiViewExecute
(
hview
,
0
);
r
=
MsiViewExecute
(
hview
,
hrec
);
if
(
r
==
ERROR_SUCCESS
)
r
=
MsiViewClose
(
hview
);
MsiCloseHandle
(
hview
);
...
...
@@ -490,7 +490,7 @@ static void test_viewmodify(void)
query
=
"CREATE TABLE `phone` ( "
"`id` INT, `name` CHAR(32), `number` CHAR(32) "
"PRIMARY KEY `id`)"
;
r
=
run_query
(
hdb
,
query
);
r
=
run_query
(
hdb
,
0
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"query failed
\n
"
);
/* check what the error function reports without doing anything */
...
...
@@ -736,7 +736,7 @@ static void test_viewgetcolumninfo(void)
hdb
=
create_db
();
ok
(
hdb
,
"failed to create db
\n
"
);
r
=
run_query
(
hdb
,
r
=
run_query
(
hdb
,
0
,
"CREATE TABLE `Properties` "
"( `Property` CHAR(255), `Value` CHAR(1) PRIMARY KEY `Property`)"
);
ok
(
r
==
ERROR_SUCCESS
,
"Failed to create table
\n
"
);
...
...
@@ -763,7 +763,7 @@ static void test_viewgetcolumninfo(void)
MsiCloseHandle
(
rec
);
r
=
run_query
(
hdb
,
r
=
run_query
(
hdb
,
0
,
"CREATE TABLE `Binary` "
"( `Name` CHAR(255), `Data` OBJECT PRIMARY KEY `Name`)"
);
ok
(
r
==
ERROR_SUCCESS
,
"Failed to create table
\n
"
);
...
...
@@ -789,7 +789,7 @@ static void test_viewgetcolumninfo(void)
ok
(
check_record
(
rec
,
2
,
"Data"
),
"wrong record type
\n
"
);
MsiCloseHandle
(
rec
);
r
=
run_query
(
hdb
,
r
=
run_query
(
hdb
,
0
,
"CREATE TABLE `UIText` "
"( `Key` CHAR(72) NOT NULL, `Text` CHAR(255) LOCALIZABLE PRIMARY KEY `Key`)"
);
ok
(
r
==
ERROR_SUCCESS
,
"Failed to create table
\n
"
);
...
...
@@ -957,7 +957,7 @@ static void test_streamtable(void)
hdb
=
create_db
();
ok
(
hdb
,
"failed to create db
\n
"
);
r
=
run_query
(
hdb
,
r
=
run_query
(
hdb
,
0
,
"CREATE TABLE `Properties` "
"( `Property` CHAR(255), `Value` CHAR(1) PRIMARY KEY `Property`)"
);
ok
(
r
==
ERROR_SUCCESS
,
"Failed to create table
\n
"
);
...
...
@@ -996,7 +996,7 @@ static void test_where(void)
hdb
=
create_db
();
ok
(
hdb
,
"failed to create db
\n
"
);
r
=
run_query
(
hdb
,
r
=
run_query
(
hdb
,
0
,
"CREATE TABLE `Media` ("
"`DiskId` SHORT NOT NULL, "
"`LastSequence` LONG, "
...
...
@@ -1007,17 +1007,17 @@ static void test_where(void)
"PRIMARY KEY `DiskId`)"
);
ok
(
r
==
S_OK
,
"cannot create Media table: %d
\n
"
,
r
);
r
=
run_query
(
hdb
,
"INSERT INTO `Media` "
r
=
run_query
(
hdb
,
0
,
"INSERT INTO `Media` "
"( `DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source` ) "
"VALUES ( 1, 0, '', 'zero.cab', '', '' )"
);
ok
(
r
==
S_OK
,
"cannot add file to the Media table: %d
\n
"
,
r
);
r
=
run_query
(
hdb
,
"INSERT INTO `Media` "
r
=
run_query
(
hdb
,
0
,
"INSERT INTO `Media` "
"( `DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source` ) "
"VALUES ( 2, 1, '', 'one.cab', '', '' )"
);
ok
(
r
==
S_OK
,
"cannot add file to the Media table: %d
\n
"
,
r
);
r
=
run_query
(
hdb
,
"INSERT INTO `Media` "
r
=
run_query
(
hdb
,
0
,
"INSERT INTO `Media` "
"( `DiskId`, `LastSequence`, `DiskPrompt`, `Cabinet`, `VolumeLabel`, `Source` ) "
"VALUES ( 3, 2, '', 'two.cab', '', '' )"
);
ok
(
r
==
S_OK
,
"cannot add file to the Media table: %d
\n
"
,
r
);
...
...
@@ -1172,6 +1172,187 @@ static void test_msiimport(void)
ok
(
i
==
-
2147483640
,
"Expected -2147483640, got %d
\n
"
,
i
);
}
MsiCloseHandle
(
rec
);
MsiCloseHandle
(
view
);
MsiCloseHandle
(
hdb
);
DeleteFileA
(
msifile
);
}
static
void
test_markers
(
void
)
{
MSIHANDLE
hdb
,
rec
;
LPCSTR
query
;
UINT
r
;
hdb
=
create_db
();
ok
(
hdb
,
"failed to create db
\n
"
);
rec
=
MsiCreateRecord
(
3
);
MsiRecordSetString
(
rec
,
1
,
"Table"
);
MsiRecordSetString
(
rec
,
2
,
"Apples"
);
MsiRecordSetString
(
rec
,
3
,
"Oranges"
);
/* try a legit create */
query
=
"CREATE TABLE `Table` ( `One` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`)"
;
r
=
run_query
(
hdb
,
0
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* try table name as marker */
rec
=
MsiCreateRecord
(
1
);
MsiRecordSetString
(
rec
,
1
,
"Fable"
);
query
=
"CREATE TABLE `?` ( `One` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* try table name as marker without backticks */
MsiRecordSetString
(
rec
,
1
,
"Mable"
);
query
=
"CREATE TABLE ? ( `One` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try one column name as marker */
MsiRecordSetString
(
rec
,
1
,
"One"
);
query
=
"CREATE TABLE `Mable` ( `?` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try column names as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
2
);
MsiRecordSetString
(
rec
,
1
,
"One"
);
MsiRecordSetString
(
rec
,
2
,
"Two"
);
query
=
"CREATE TABLE `Mable` ( `?` SHORT NOT NULL, `?` CHAR(255) PRIMARY KEY `One`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try names with backticks */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
3
);
MsiRecordSetString
(
rec
,
1
,
"One"
);
MsiRecordSetString
(
rec
,
2
,
"Two"
);
MsiRecordSetString
(
rec
,
3
,
"One"
);
query
=
"CREATE TABLE `Mable` ( `?` SHORT NOT NULL, `?` CHAR(255) PRIMARY KEY `?`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
todo_wine
{
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
}
/* try names with backticks, minus definitions */
query
=
"CREATE TABLE `Mable` ( `?`, `?` PRIMARY KEY `?`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try names without backticks */
query
=
"CREATE TABLE `Mable` ( ? SHORT NOT NULL, ? CHAR(255) PRIMARY KEY ?)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try one long marker */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
1
);
MsiRecordSetString
(
rec
,
1
,
"`One` SHORT NOT NULL, `Two` CHAR(255) PRIMARY KEY `One`"
);
query
=
"CREATE TABLE `Mable` ( ? )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try all names as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
4
);
MsiRecordSetString
(
rec
,
1
,
"Mable"
);
MsiRecordSetString
(
rec
,
2
,
"One"
);
MsiRecordSetString
(
rec
,
3
,
"Two"
);
MsiRecordSetString
(
rec
,
4
,
"One"
);
query
=
"CREATE TABLE `?` ( `?` SHORT NOT NULL, `?` CHAR(255) PRIMARY KEY `?`)"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try a legit insert */
query
=
"INSERT INTO `Table` ( `One`, `Two` ) VALUES ( 5, 'hello' )"
;
r
=
run_query
(
hdb
,
0
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* try values as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
2
);
MsiRecordSetInteger
(
rec
,
1
,
4
);
MsiRecordSetString
(
rec
,
2
,
"hi"
);
query
=
"INSERT INTO `Table` ( `One`, `Two` ) VALUES ( ?, '?' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* try column names and values as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
4
);
MsiRecordSetString
(
rec
,
1
,
"One"
);
MsiRecordSetString
(
rec
,
2
,
"Two"
);
MsiRecordSetInteger
(
rec
,
3
,
5
);
MsiRecordSetString
(
rec
,
4
,
"hi"
);
query
=
"INSERT INTO `Table` ( `?`, `?` ) VALUES ( ?, '?' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try column names as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
2
);
MsiRecordSetString
(
rec
,
1
,
"One"
);
MsiRecordSetString
(
rec
,
2
,
"Two"
);
query
=
"INSERT INTO `Table` ( `?`, `?` ) VALUES ( 3, 'yellow' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* try table name as a marker */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
1
);
MsiRecordSetString
(
rec
,
1
,
"Table"
);
query
=
"INSERT INTO `?` ( `One`, `Two` ) VALUES ( 2, 'green' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* try table name and values as markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
3
);
MsiRecordSetString
(
rec
,
1
,
"Table"
);
MsiRecordSetInteger
(
rec
,
2
,
10
);
MsiRecordSetString
(
rec
,
3
,
"haha"
);
query
=
"INSERT INTO `?` ( `One`, `Two` ) VALUES ( ?, '?' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
todo_wine
{
ok
(
r
==
ERROR_FUNCTION_FAILED
,
"Expected ERROR_FUNCTION_FAILED, got %d
\n
"
,
r
);
}
/* try all markers */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
5
);
MsiRecordSetString
(
rec
,
1
,
"Table"
);
MsiRecordSetString
(
rec
,
1
,
"One"
);
MsiRecordSetString
(
rec
,
1
,
"Two"
);
MsiRecordSetInteger
(
rec
,
2
,
10
);
MsiRecordSetString
(
rec
,
3
,
"haha"
);
query
=
"INSERT INTO `?` ( `?`, `?` ) VALUES ( ?, '?' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_BAD_QUERY_SYNTAX
,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d
\n
"
,
r
);
/* insert an integer as a string */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
2
);
MsiRecordSetString
(
rec
,
1
,
"11"
);
MsiRecordSetString
(
rec
,
2
,
"hi"
);
query
=
"INSERT INTO `Table` ( `One`, `Two` ) VALUES ( ?, '?' )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
/* leave off the '' for the string */
MsiCloseHandle
(
rec
);
rec
=
MsiCreateRecord
(
2
);
MsiRecordSetInteger
(
rec
,
1
,
12
);
MsiRecordSetString
(
rec
,
2
,
"hi"
);
query
=
"INSERT INTO `Table` ( `One`, `Two` ) VALUES ( ?, ? )"
;
r
=
run_query
(
hdb
,
rec
,
query
);
ok
(
r
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
r
);
MsiCloseHandle
(
hdb
);
DeleteFileA
(
msifile
);
}
...
...
@@ -1189,4 +1370,5 @@ START_TEST(db)
test_streamtable
();
test_where
();
test_msiimport
();
test_markers
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment