Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5788c90d
Commit
5788c90d
authored
Jun 24, 2003
by
venu@myvenu.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test for SQL_MODE with PIPES_AS_CONCAT, ANSI and IGNORE_SPACE
parent
cb4539e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
4 deletions
+135
-4
tests/client_test.c
tests/client_test.c
+135
-4
No files found.
tests/client_test.c
View file @
5788c90d
...
@@ -7327,6 +7327,136 @@ static void test_free_store_result()
...
@@ -7327,6 +7327,136 @@ static void test_free_store_result()
mysql_stmt_close
(
stmt
);
mysql_stmt_close
(
stmt
);
}
}
/********************************************************
To test SQLmode
*********************************************************/
static
void
test_sqlmode
()
{
MYSQL_STMT
*
stmt
;
MYSQL_BIND
bind
[
2
];
char
c1
[
5
],
c2
[
5
];
int
rc
;
myheader
(
"test_sqlmode"
);
rc
=
mysql_query
(
mysql
,
"DROP TABLE IF EXISTS test_piping"
);
myquery
(
rc
);
rc
=
mysql_commit
(
mysql
);
myquery
(
rc
);
rc
=
mysql_query
(
mysql
,
"CREATE TABLE test_piping(name varchar(10))"
);
myquery
(
rc
);
/* PIPES_AS_CONCAT */
strcpy
(
query
,
"SET SQL_MODE=
\"
PIPES_AS_CONCAT
\"
"
);
fprintf
(
stdout
,
"
\n
With %s"
,
query
);
rc
=
mysql_query
(
mysql
,
query
);
myquery
(
rc
);
strcpy
(
query
,
"INSERT INTO test_piping VALUES(?||?)"
);
fprintf
(
stdout
,
"
\n
query: %s"
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
,
strlen
(
query
));
mystmt_init
(
stmt
);
fprintf
(
stdout
,
"
\n
total parameters: %ld"
,
mysql_param_count
(
stmt
));
bind
[
0
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
0
].
buffer
=
(
char
*
)
c1
;
bind
[
0
].
buffer_length
=
2
;
bind
[
0
].
is_null
=
0
;
bind
[
0
].
length
=
0
;
bind
[
1
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind
[
1
].
buffer
=
(
char
*
)
c2
;
bind
[
1
].
buffer_length
=
3
;
bind
[
1
].
is_null
=
0
;
bind
[
1
].
length
=
0
;
rc
=
mysql_bind_param
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
strcpy
(
c1
,
"My"
);
strcpy
(
c2
,
"SQL"
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
mysql_stmt_close
(
stmt
);
verify_col_data
(
"test_piping"
,
"name"
,
"MySQL"
);
rc
=
mysql_query
(
mysql
,
"DELETE FROM test_piping"
);
myquery
(
rc
);
strcpy
(
query
,
"SELECT connection_id ()"
);
fprintf
(
stdout
,
"
\n
query: %s"
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
,
70
);
mystmt_init_r
(
stmt
);
/* ANSI */
strcpy
(
query
,
"SET SQL_MODE=
\"
ANSI
\"
"
);
fprintf
(
stdout
,
"
\n
With %s"
,
query
);
rc
=
mysql_query
(
mysql
,
query
);
myquery
(
rc
);
strcpy
(
query
,
"INSERT INTO test_piping VALUES(?||?)"
);
fprintf
(
stdout
,
"
\n
query: %s"
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
,
strlen
(
query
));
mystmt_init
(
stmt
);
fprintf
(
stdout
,
"
\n
total parameters: %ld"
,
mysql_param_count
(
stmt
));
rc
=
mysql_bind_param
(
stmt
,
bind
);
mystmt
(
stmt
,
rc
);
strcpy
(
c1
,
"My"
);
strcpy
(
c2
,
"SQL"
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
mysql_stmt_close
(
stmt
);
verify_col_data
(
"test_piping"
,
"name"
,
"MySQL"
);
/* ANSI mode spaces ... */
strcpy
(
query
,
"SELECT connection_id ()"
);
fprintf
(
stdout
,
"
\n
query: %s"
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
,
70
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
fprintf
(
stdout
,
"
\n
returned 1 row
\n
"
);
mysql_stmt_close
(
stmt
);
/* IGNORE SPACE MODE */
strcpy
(
query
,
"SET SQL_MODE=
\"
IGNORE_SPACE
\"
"
);
fprintf
(
stdout
,
"
\n
With %s"
,
query
);
rc
=
mysql_query
(
mysql
,
query
);
myquery
(
rc
);
strcpy
(
query
,
"SELECT connection_id ()"
);
fprintf
(
stdout
,
"
\n
query: %s"
,
query
);
stmt
=
mysql_prepare
(
mysql
,
query
,
70
);
mystmt_init
(
stmt
);
rc
=
mysql_execute
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
mystmt
(
stmt
,
rc
);
rc
=
mysql_fetch
(
stmt
);
myassert
(
rc
==
MYSQL_NO_DATA
);
fprintf
(
stdout
,
"
\n
returned 1 row"
);
mysql_stmt_close
(
stmt
);
}
/*
/*
Read and parse arguments and MySQL options from my.cnf
Read and parse arguments and MySQL options from my.cnf
*/
*/
...
@@ -7467,10 +7597,6 @@ int main(int argc, char **argv)
...
@@ -7467,10 +7597,6 @@ int main(int argc, char **argv)
start_time
=
time
((
time_t
*
)
0
);
start_time
=
time
((
time_t
*
)
0
);
client_query
();
/* simple client query test */
client_query
();
/* simple client query test */
test_mem_overun
();
test_list_fields
();
test_fetch_offset
();
/* to test mysql_fetch_column with offset */
test_fetch_column
();
/* to test mysql_fetch_column */
#if NOT_YET_WORKING
#if NOT_YET_WORKING
/* Used for internal new development debugging */
/* Used for internal new development debugging */
test_drop_temp
();
/* to test DROP TEMPORARY TABLE Access checks */
test_drop_temp
();
/* to test DROP TEMPORARY TABLE Access checks */
...
@@ -7572,6 +7698,11 @@ int main(int argc, char **argv)
...
@@ -7572,6 +7698,11 @@ int main(int argc, char **argv)
test_free_result
();
/* test mysql_stmt_free_result() */
test_free_result
();
/* test mysql_stmt_free_result() */
test_free_store_result
();
/* test to make sure stmt results are cleared
test_free_store_result
();
/* test to make sure stmt results are cleared
during stmt_free_result() */
during stmt_free_result() */
test_mem_overun
();
/* memory ovverun bug */
test_list_fields
();
/* list_fields test */
test_fetch_offset
();
/* to test mysql_fetch_column with offset */
test_fetch_column
();
/* to test mysql_fetch_column */
test_sqlmode
();
/* test for SQL_MODE */
end_time
=
time
((
time_t
*
)
0
);
end_time
=
time
((
time_t
*
)
0
);
total_time
+=
difftime
(
end_time
,
start_time
);
total_time
+=
difftime
(
end_time
,
start_time
);
...
...
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