Skip to content

Commit f39ce6c

Browse files
committed
open html file when table needs to be opened. need to store reference to file in member variable
1 parent 11deebd commit f39ce6c

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

storage/example/ha_example.cc

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
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
9694
#include <fstream>
9795
#include <cassert>
9896

@@ -390,13 +388,27 @@ static bool example_is_supported_system_table(const char *db,
390388

391389
int ha_example::open(const char *name, int mode, uint test_if_locked)
392390
{
393-
DBUG_ENTER("ha_example::open");
391+
DBUG_ENTER("ha_example::open");
394392

395-
if (!(share = get_share(name, table)))
396-
DBUG_RETURN(1);
397-
thr_lock_data_init(&share->lock,&lock,NULL);
393+
if (!(share = get_share(name, table))) {
394+
DBUG_RETURN(1);
395+
}
398396

399-
DBUG_RETURN(0);
397+
thr_lock_data_init(&share->lock, &lock, NULL);
398+
399+
String table_file_pathname;
400+
table_file_pathname.append(name);
401+
table_file_pathname.append(*bas_ext());
402+
403+
DBUG_PRINT("ha_example", ("filename is '%s'", table_file_pathname.c_ptr()));
404+
405+
std::ofstream table_file;
406+
table_file.open(table_file_pathname.c_ptr());
407+
assert(table_file.is_open());
408+
409+
// open_table_file = table_file;
410+
411+
DBUG_RETURN(0);
400412
}
401413

402414

@@ -1026,17 +1038,24 @@ int ha_example::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *creat
10261038
{
10271039
DBUG_ENTER("ha_example::create");
10281040

1029-
String file_name;
1030-
file_name.append(name);
1031-
file_name.append(*bas_ext());
1041+
String table_file_pathname;
1042+
table_file_pathname.append(name);
1043+
table_file_pathname.append(*bas_ext());
10321044

1033-
DBUG_PRINT("ha_example", ("filename is '%s'", file_name.c_ptr()));
1045+
DBUG_PRINT("ha_example", ("filename is '%s'", table_file_pathname.c_ptr()));
10341046

10351047
std::ofstream table_file;
1036-
table_file.open(file_name.c_ptr());
1048+
table_file.open(table_file_pathname.c_ptr());
10371049
assert(table_file.is_open());
10381050

10391051
table_file << "<h1>Contents of " << table_arg->s->table_name.str << "</h1>\n";
1052+
table_file << "<ul>\n";
1053+
1054+
for (uint i = 0; i < table_arg->s->fields; i++) {
1055+
table_file << "<li>" << table_arg->field[i]->field_name << "</li>\n";
1056+
}
1057+
1058+
table_file << "</ul>\n";
10401059

10411060
table_file.close();
10421061

storage/example/ha_example.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#pragma interface/* gcc class implementation */
3636
#endif
3737

38+
// include c++ standard headers before any other headers which might include my_global.h
39+
// see https://trac.osgeo.org/gdal/ticket/2972
40+
#include <fstream>
41+
3842
#include "my_global.h" /* ulonglong */
3943
#include "thr_lock.h" /* THR_LOCK, THR_LOCK_DATA */
4044
#include "handler.h" /* handler */
@@ -59,6 +63,9 @@ class ha_example: public handler
5963
THR_LOCK_DATA lock; ///< MySQL lock
6064
EXAMPLE_SHARE *share; ///< Shared lock info
6165

66+
private:
67+
std::ofstream open_table_file;
68+
6269
public:
6370
ha_example(handlerton *hton, TABLE_SHARE *table_arg);
6471
~ha_example()

0 commit comments

Comments
 (0)