goto bail_out;
}
- /* TODO: handle basejob and MySQL/SQLite3 */
- Mmsg(query, "CREATE TABLE %s AS ( "
- "SELECT JobId, FileIndex, FileId "
- "FROM ( "
- "SELECT DISTINCT ON (PathId, FilenameId) JobId, FileIndex, FileId "
- "FROM btemp%s "
- "ORDER BY PathId, FilenameId, JobId DESC "
- ") AS T "
- "WHERE FileIndex > 0)", output_table, output_table);
+ /* TODO: handle basejob and SQLite3 */
+ Mmsg(query, sql_bvfs_select[db_type], output_table, output_table);
Dmsg1(dbglevel_sql, "q=%s\n", query.c_str());
if (!db_sql_query(db, query.c_str(), NULL, NULL)) {
/* Ingres (TODO) */
0
};
+
+const char *sql_bvfs_select[5] = {
+ /* Mysql */
+ "CREATE TABLE %s AS ( "
+ "SELECT max(JobId) as JobId, FileIndex, FileId "
+ "FROM btemp%s "
+ "GROUP BY PathId, FilenameId "
+ "HAVING FileIndex > 0 ",
+ /* Postgresql */
+ "CREATE TABLE %s AS ( "
+ "SELECT JobId, FileIndex, FileId "
+ "FROM ( "
+ "SELECT DISTINCT ON (PathId, FilenameId) JobId, FileIndex, FileId "
+ "FROM btemp%s "
+ "ORDER BY PathId, FilenameId, JobId DESC "
+ ") AS T "
+ "WHERE FileIndex > 0)",
+ /* SQLite */
+ "SELECT 0",
+ /* SQLite3 */
+ "SELECT 0",
+ /* Ingres (TODO) */
+ "SELECT 0"
+};
extern const char CATS_IMP_EXP *sql_media_order_most_recently_written[5];
extern const char CATS_IMP_EXP *sql_get_max_connections[5];
extern const uint32_t CATS_IMP_EXP sql_get_max_connections_index[5];
+extern const char *sql_bvfs_select[5];