Skip to content

Commit 11deebd

Browse files
committed
create html file per table upon CREATE TABLE
1 parent a00e0b8 commit 11deebd

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

storage/example/ha_example.cc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
#pragma implementation // gcc: Class implementation
9292
#endif
9393

94+
// include them before any other headers which might include my_global.h
95+
// see https://trac.osgeo.org/gdal/ticket/2972
96+
#include <fstream>
97+
#include <cassert>
98+
9499
#include "sql_priv.h"
95100
#include "sql_class.h" // MYSQL_HANDLERTON_INTERFACE_VERSION
96101
#include "ha_example.h"
@@ -298,7 +303,8 @@ ha_example::ha_example(handlerton *hton, TABLE_SHARE *table_arg)
298303
*/
299304

300305
static const char *ha_example_exts[] = {
301-
NullS
306+
".html",
307+
NullS
302308
};
303309

304310
const char **ha_example::bas_ext() const
@@ -1016,19 +1022,25 @@ ha_rows ha_example::records_in_range(uint inx, key_range *min_key,
10161022
ha_create_table() in handle.cc
10171023
*/
10181024

1019-
int ha_example::create(const char *name, TABLE *table_arg,
1020-
HA_CREATE_INFO *create_info)
1025+
int ha_example::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info)
10211026
{
1022-
DBUG_ENTER("ha_example::create");
1027+
DBUG_ENTER("ha_example::create");
10231028

1024-
String file_name;
1025-
file_name.append("foo");
1026-
file_name.append("bar");
1027-
file_name.append("baz");
1029+
String file_name;
1030+
file_name.append(name);
1031+
file_name.append(*bas_ext());
10281032

1029-
DBUG_PRINT("ha_example", ("filename is '%s'", file_name.c_ptr()));
1033+
DBUG_PRINT("ha_example", ("filename is '%s'", file_name.c_ptr()));
10301034

1031-
DBUG_RETURN(0);
1035+
std::ofstream table_file;
1036+
table_file.open(file_name.c_ptr());
1037+
assert(table_file.is_open());
1038+
1039+
table_file << "<h1>Contents of " << table_arg->s->table_name.str << "</h1>\n";
1040+
1041+
table_file.close();
1042+
1043+
DBUG_RETURN(0);
10321044
}
10331045

10341046

0 commit comments

Comments
 (0)