25
25
#include "odbctap.h"
26
26
#include "../VersionInfo.h"
27
27
28
+ /*
29
+ 18641824 SQLFOREIGNKEYS() CRASHING WHEN SQL_MODE='ANSI_QUOTES'
30
+ 26388694 SQLForeignKeys() returns empty result with NO_I_S=0
31
+
32
+ This test case will run with NO_I_S=0 and NO_I_S=1 and test for
33
+ two bugs for each NO_I_S value
34
+ */
35
+ DECLARE_TEST (t_bug18641824 )
36
+ {
37
+ int i = 0 ;
38
+ char * pk_tab = "tab_pk" ;
39
+ char * fk_tab = "tab_fk" ;
40
+ char * pk_cols [] = { "i1d" , "i2d" };
41
+ char * fk_cols [] = { "fi1d" , "fi2d" };
42
+
43
+ DECLARE_BASIC_HANDLES (henv1 , hdbc1 , hstmt1 );
44
+ is (OK == alloc_basic_handles (& henv1 , & hdbc1 , & hstmt1 ));
45
+
46
+ ok_sql (hstmt1 , "set SQL_MODE='ANSI_QUOTES'" );
47
+ ok_sql (hstmt1 , "DROP SCHEMA IF EXISTS fk_check" );
48
+ ok_sql (hstmt1 , "CREATE SCHEMA fk_check" );
49
+ ok_sql (hstmt1 , "USE fk_check" );
50
+ ok_sql (hstmt1 , "CREATE TABLE tab_pk (i1d int, unique(i1d), i2d int, unique (i2d))" );
51
+ ok_sql (hstmt1 , "CREATE TABLE tab_fk (" \
52
+ "fi1d int,CONSTRAINT Constraint_1 FOREIGN KEY(fi1d) REFERENCES tab_pk(i1d)," \
53
+ "fi2d int,CONSTRAINT Constraint_2 FOREIGN KEY(fi2d) REFERENCES tab_pk(i2d))" );
54
+ ok_stmt (hstmt1 , SQLForeignKeys (hstmt1 , NULL , 0 , NULL , 0 , (SQLCHAR * )"tab_pk" , SQL_NTS ,
55
+ NULL , 0 , NULL , 0 , (SQLCHAR * )"tab_fk" , SQL_NTS ));
56
+
57
+ while (SQLFetch (hstmt1 ) == SQL_SUCCESS )
58
+ {
59
+ char buf [1024 ];
60
+ printf ("Row: %d\n" , ++ i );
61
+ ok_stmt (hstmt1 , SQLGetData (hstmt1 , 3 , SQL_CHAR , buf , sizeof (buf ), NULL ));
62
+ printf ("Primary key table: %s\n" , buf );
63
+ is_str (pk_tab , buf , strlen (buf ));
64
+
65
+ ok_stmt (hstmt1 , SQLGetData (hstmt1 , 4 , SQL_CHAR , buf , sizeof (buf ), NULL ));
66
+ printf ("Primary key column: %s\n" , buf );
67
+ is (strcmp (pk_cols [0 ], buf ) == 0 || strcmp (pk_cols [1 ], buf ) == 0 );
68
+
69
+ ok_stmt (hstmt1 , SQLGetData (hstmt1 , 7 , SQL_CHAR , buf , sizeof (buf ), NULL ));
70
+ printf ("Foreign key table: %s\n" , buf );
71
+ is_str (fk_tab , buf , strlen (buf ));
72
+
73
+ ok_stmt (hstmt1 , SQLGetData (hstmt1 , 8 , SQL_CHAR , buf , sizeof (buf ), NULL ));
74
+ printf ("Foreign key column: %s\n" , buf );
75
+ is (strcmp (fk_cols [0 ], buf ) == 0 || strcmp (fk_cols [1 ], buf ) == 0 );
76
+ }
77
+ is (i == 2 );
78
+ free_basic_handles (& henv1 , & hdbc1 , & hstmt1 );
79
+ return OK ;
80
+ }
28
81
29
82
/*
30
83
18805392 SEGMENTATION FAULT IN SQLFETCH() WHEN USED WITH DYNAMIC CURSOR
@@ -40,9 +93,9 @@ DECLARE_TEST(t_bug18805392)
40
93
41
94
ok_stmt (hstmt1 , SQLSetStmtAttr (hstmt1 , SQL_ATTR_CURSOR_TYPE ,
42
95
(SQLPOINTER )SQL_CURSOR_DYNAMIC , 0 ));
43
- ok_sql (hstmt , "DROP TABLE IF EXISTS t_bug18805392" );
44
- ok_sql (hstmt , "CREATE TABLE t_bug18805392 (record bigint)" );
45
- ok_sql (hstmt , "INSERT INTO t_bug18805392 VALUES (1234567891234),"
96
+ ok_sql (hstmt1 , "DROP TABLE IF EXISTS t_bug18805392" );
97
+ ok_sql (hstmt1 , "CREATE TABLE t_bug18805392 (record bigint)" );
98
+ ok_sql (hstmt1 , "INSERT INTO t_bug18805392 VALUES (1234567891234),"
46
99
"(51234567891234),(61234567891234),(56789453632)" );
47
100
48
101
ok_stmt (hstmt1 , SQLPrepare (hstmt1 , (SQLCHAR * )"SELECT * FROM t_bug18805392 where record>?" , SQL_NTS ));
@@ -628,7 +681,7 @@ DECLARE_TEST(t_bug18286366)
628
681
is_str (my_fetch_str (hstmt1 , buff , 12 ), tmp_buff , len );
629
682
}
630
683
631
- ok_sql (hstmt , "DROP TABLE IF EXISTS t_bug16920750b, t_bug16920750a " );
684
+ ok_sql (hstmt , "DROP TABLE IF EXISTS t_bug18286366b, t_bug18286366a " );
632
685
free_basic_handles (& henv1 , & hdbc1 , & hstmt1 );
633
686
return OK ;
634
687
}
@@ -889,7 +942,8 @@ DECLARE_TEST(t_bug18796005)
889
942
890
943
891
944
BEGIN_TESTS
892
- //ADD_TEST(t_bug18805392)
945
+ ADD_TEST (t_bug18641824 )
946
+ ADD_TEST (t_bug18805392 )
893
947
ADD_TEST (t_bug19148246 )
894
948
ADD_TEST (t_bug69950 )
895
949
ADD_TEST (t_bug70642 )
0 commit comments