licoffe / POE-Stash-indexer-NG

High performance Path of Exile stash indexer
MIT License
43 stars 12 forks source link

Writing file behaviour for LOAD INFILE differs from the reading behaviour #10

Closed GCRVL closed 7 years ago

GCRVL commented 7 years ago

When the various loops write the temporary files it's done this way:

path << DB_DATA_DIR << "/mods_" << random_id(10) << ".txt"; mod_file.open( path.str());

However, when the parser tries to read them for DB insertion, this happens:

threaded_insert( "LOAD DATA CONCURRENT INFILE '" + mod_file + "' REPLACE INTO TABLEModsFIELDS TERMINATED BY ',' ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\n'" ); path << DB_DATA_DIR + "/" + mod_file;

This causes all insertions to fail as it will attempt to load the files from the same folder as the indexer itself, while the user might have specified another location.

GCRVL commented 7 years ago

BTW, I fixed it in my source by placing the line path << DB_DATA_DIR + "/" + mod_file; above the threaded_insert(

licoffe commented 7 years ago

It works fine on my side and I remember not putting an absolute path. On my Debian, MySQL does not expect the file path to be absolute if this file is in the MySQL data folder. Since your tweak also works, I guess I'll update all the loops to use your approach in order to be compatible with everybody.