MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Timothy Smith Date:June 5 2001 8:44pm
Subject:Re: finding the path and filenames for a table
View as plain text  
On 2001 Jun 04, DAVE THOMAS <DAVET@stripped> wrote:

> I am trying to create a file in the directory that the .frm,
> .MYI, and .MYD files are located for a particular table. I
> can create the file by hard-coding the path and specifying a
> filename but I need to be able to create the file in the folder
> of the database the table belongs to. How do I get the path
> that the database files are located? and the database name?

Dave, do it the same way myisam does it.  Look in
ha_myisam::create(), which (when you trace through with a
debugger), will show you that the name of the table is passed in
with a path.  You can use the fn_format() function just the way
that ha_myisam::create() does to trim the extension, get a full
path, etc.

Do not name your files *.MYI and *.MYD.  Those are MyISAM

For your text data file, you could use .TEXT.  You don't even
need an index file.

In general, the best way to answer these questions is to fire
up a debugger, put a breakpoint in ha_myisam somewhere, and
see what happens with a MYISAM table.  Then, you do the same
thing, only call your own functions instead of the mi_* ones.
You'll notice that a lot of the handler functions have an
exact mi_* counterpart.  I mean, mi_open is a counterpart of
Handler::open(), and so forth.  That's because the MYISAM code
was written to be used inside MySQL.  If you need an example
that's not quite so clean, you can look at the ha_berkeley or
ha_innodb code.


   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Tim Smith <tim@stripped>
 / /|_/ / // /\ \/ /_/ / /__   MySQL AB, Development Team
/_/  /_/\_, /___/\___\_\___/   Boone, NC  USA
finding the path and filenames for a tableDAVE THOMAS5 Jun
  • Re: finding the path and filenames for a tableJeremy Zawodny5 Jun
  • Re: finding the path and filenames for a tableTimothy Smith5 Jun
  • finding the path and filenames for a tableMichael Widenius5 Jun