From dffe1f7472e6195adcbda754429aabc624a48abb Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sat, 10 Apr 2010 13:36:25 +0200 Subject: [PATCH] Rename sql_insert_id into sql_insert_autokey_record so things are somewhat cleaner in name and things don't seem to imply we are just a mysql_insert_id replacement, which we are not. --- bacula/src/cats/cats.h | 24 ++++++++++++------------ bacula/src/cats/dbi.c | 2 +- bacula/src/cats/mysql.c | 2 +- bacula/src/cats/postgresql.c | 2 +- bacula/src/cats/sql_create.c | 24 ++++++++++++------------ bacula/src/cats/sqlite.c | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/bacula/src/cats/cats.h b/bacula/src/cats/cats.h index e1dce822fe..423004ebd3 100644 --- a/bacula/src/cats/cats.h +++ b/bacula/src/cats/cats.h @@ -163,7 +163,7 @@ struct B_DB { #define sql_free_result(x) my_sqlite_free_table(x) #define sql_fetch_row(x) my_sqlite_fetch_row(x) #define sql_query(x, y) my_sqlite_query((x), (y)) -#define sql_insert_id(x, y, z) my_sqlite_sql_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_sqlite_insert_autokey_record((x), (y), (z)) #ifdef HAVE_SQLITE3 #define sql_close(x) sqlite3_close((x)->db) #define sql_affected_rows(x) sqlite3_changes((x)->db) @@ -195,7 +195,7 @@ SQL_ROW my_sqlite_fetch_row(B_DB *mdb); int my_sqlite_query(B_DB *mdb, const char *cmd); void my_sqlite_field_seek(B_DB *mdb, int field); SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb); -int my_sqlite_sql_insert_id(B_DB *mdb, const char *query, const char *table_name); +int my_sqlite_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name); extern const char* my_sqlite_batch_lock_query; extern const char* my_sqlite_batch_unlock_query; extern const char* my_sqlite_batch_fill_filename_query; @@ -295,7 +295,7 @@ struct B_DB { #define sql_free_result(x) my_sqlite_free_table(x) #define sql_fetch_row(x) my_sqlite_fetch_row(x) #define sql_query(x, y) my_sqlite_query((x), (y)) -#define sql_insert_id(x, y, z) my_sqlite_sql_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_sqlite_insert_autokey_record((x), (y), (z)) #ifdef HAVE_SQLITE3 #define sql_close(x) sqlite3_close((x)->db) #else @@ -325,7 +325,7 @@ SQL_ROW my_sqlite_fetch_row(B_DB *mdb); int my_sqlite_query(B_DB *mdb, const char *cmd); void my_sqlite_field_seek(B_DB *mdb, int field); SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb); -int my_sqlite_sql_insert_id(B_DB *mdb, const char *query, const char *table_name); +int my_sqlite_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name); extern const char* my_sqlite_batch_lock_query; extern const char* my_sqlite_batch_unlock_query; extern const char* my_sqlite_batch_fill_filename_query; @@ -390,7 +390,7 @@ struct B_DB { #define sql_num_rows(x) mysql_num_rows((x)->result) #define sql_data_seek(x, i) mysql_data_seek((x)->result, (i)) #define sql_affected_rows(x) mysql_affected_rows((x)->db) -#define sql_insert_id(x, y, z) my_mysql_sql_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_mysql_insert_autokey_record((x), (y), (z)) #define sql_field_seek(x, y) mysql_field_seek((x)->result, (y)) #define sql_fetch_field(x) mysql_fetch_field((x)->result) #define sql_num_fields(x) (int)mysql_num_fields((x)->result) @@ -414,7 +414,7 @@ extern const char* my_mysql_batch_unlock_tables_query; extern const char* my_mysql_batch_fill_filename_query; extern const char* my_mysql_batch_fill_path_query; extern void my_mysql_free_result(B_DB *mdb); -extern int my_mysql_sql_insert_id(B_DB *mdb, const char *query, const char *table_name); +extern int my_mysql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name); #else @@ -486,7 +486,7 @@ void my_postgresql_free_result(B_DB *mdb); POSTGRESQL_ROW my_postgresql_fetch_row (B_DB *mdb); int my_postgresql_query (B_DB *mdb, const char *query); void my_postgresql_data_seek (B_DB *mdb, int row); -int my_postgresql_insert_id (B_DB *mdb, const char *query, const char *table_name); +int my_postgresql_insert_autokey_record (B_DB *mdb, const char *query, const char *table_name); void my_postgresql_field_seek (B_DB *mdb, int row); POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb); @@ -512,7 +512,7 @@ extern const char* my_pg_batch_fill_path_query; #define sql_num_rows(x) ((unsigned) PQntuples((x)->result)) #define sql_data_seek(x, i) my_postgresql_data_seek((x), (i)) #define sql_affected_rows(x) ((unsigned) atoi(PQcmdTuples((x)->result))) -#define sql_insert_id(x, y, z) my_postgresql_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_postgresql_insert_autokey_record((x), (y), (z)) #define sql_field_seek(x, y) my_postgresql_field_seek((x), (y)) #define sql_fetch_field(x) my_postgresql_fetch_field(x) #define sql_num_fields(x) ((x)->num_fields) @@ -599,7 +599,7 @@ void my_ingres_data_seek (B_DB *mdb, int row); void my_ingres_field_seek (B_DB *mdb, int row); INGRES_FIELD * my_ingres_fetch_field(B_DB *mdb); void my_ingres_close (B_DB *mdb); -int my_ingres_insert_id (B_DB *mdb, const char *query, const char *table_name); +int my_ingres_insert_autokey_record (B_DB *mdb, const char *query, const char *table_name); bool my_ingres_batch_start(JCR *jcr, B_DB *mdb); bool my_ingres_batch_end(JCR *jcr, B_DB *mdb, const char *error); @@ -623,7 +623,7 @@ extern const char* my_ingres_batch_fill_path_query; #define sql_num_rows(x) ((unsigned) INGntuples((x)->result)) #define sql_data_seek(x, i) my_ingres_data_seek((x), (i)) #define sql_affected_rows(x) ((x)->num_rows) -#define sql_insert_id(x, y, z) my_ingres_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_ingres_insert_autokey_record((x), (y), (z)) #define sql_field_seek(x, y) my_ingres_field_seek((x), (y)) #define sql_fetch_field(x) my_ingres_fetch_field(x) #define sql_num_fields(x) ((x)->num_fields) @@ -729,7 +729,7 @@ const char * my_dbi_strerror (B_DB *mdb); int my_dbi_getisnull (dbi_result *result, int row_number, int column_number); char * my_dbi_getvalue (dbi_result *result, int row_number, unsigned int column_number); //int my_dbi_getvalue (dbi_result *result, int row_number, unsigned int column_number, char *value); -int my_dbi_sql_insert_id(B_DB *mdb, const char *query, const char *table_name); +int my_dbi_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name); int my_dbi_batch_start(JCR *jcr, B_DB *mdb); int my_dbi_batch_end(JCR *jcr, B_DB *mdb, const char *error); @@ -760,7 +760,7 @@ extern const char* my_dbi_match[5]; #define SQL_MATCH my_dbi_match[db_type] /* #define sql_affected_rows(x) dbi_result_get_numrows_affected((x)->result) */ #define sql_affected_rows(x) 1 -#define sql_insert_id(x, y, z) my_dbi_sql_insert_id((x), (y), (z)) +#define sql_insert_autokey_record(x, y, z) my_dbi_insert_autokey_record((x), (y), (z)) #define sql_field_seek(x, y) my_dbi_field_seek((x), (y)) #define sql_fetch_field(x) my_dbi_fetch_field(x) #define sql_num_fields(x) ((x)->num_fields) diff --git a/bacula/src/cats/dbi.c b/bacula/src/cats/dbi.c index a9d90ee744..78d1e330c2 100644 --- a/bacula/src/cats/dbi.c +++ b/bacula/src/cats/dbi.c @@ -1275,7 +1275,7 @@ static int my_dbi_sequence_last(B_DB *mdb, const char *table_name) return id; } -int my_dbi_sql_insert_id(B_DB *mdb, const char *query, const char *table_name) +int my_dbi_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name) { /* * First execute the insert query and then retrieve the currval. diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index 5124dd2a90..c8dce1e9eb 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -380,7 +380,7 @@ void my_mysql_free_result(B_DB *mdb) db_unlock(mdb); } -int my_mysql_sql_insert_id(B_DB *mdb, const char *query, const char *table_name) +int my_mysql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name) { /* * First execute the insert query and then retrieve the currval. diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 74ced4d6e4..f6919995cc 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -657,7 +657,7 @@ bail_out: return id; } -int my_postgresql_insert_id(B_DB *mdb, const char *query, const char *table_name) +int my_postgresql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name) { /* * First execute the insert query and then retrieve the currval. diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 3a1d02faf8..44d1c2c552 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -96,7 +96,7 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) (char)(jr->JobStatus), dt, edit_uint64(JobTDate, ed1), edit_int64(jr->ClientId, ed2), buf.c_str()); - jr->JobId = sql_insert_id(mdb, mdb->cmd, NT_("Job")); + jr->JobId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Job")); if (jr->JobId == 0) { Mmsg2(&mdb->errmsg, _("Create DB Job record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -213,7 +213,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr) pr->ActionOnPurge ); Dmsg1(200, "Create Pool: %s\n", mdb->cmd); - pr->PoolId = sql_insert_id(mdb, mdb->cmd, NT_("Pool")); + pr->PoolId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Pool")); if (pr->PoolId == 0) { Mmsg2(&mdb->errmsg, _("Create db Pool record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -260,7 +260,7 @@ db_create_device_record(JCR *jcr, B_DB *mdb, DEVICE_DBR *dr) edit_uint64(dr->MediaTypeId, ed1), edit_int64(dr->StorageId, ed2)); Dmsg1(200, "Create Device: %s\n", mdb->cmd); - dr->DeviceId = sql_insert_id(mdb, mdb->cmd, NT_("Device")); + dr->DeviceId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Device")); if (dr->DeviceId == 0) { Mmsg2(&mdb->errmsg, _("Create db Device record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -318,7 +318,7 @@ bool db_create_storage_record(JCR *jcr, B_DB *mdb, STORAGE_DBR *sr) Mmsg(mdb->cmd, "INSERT INTO Storage (Name,AutoChanger)" " VALUES ('%s',%d)", sr->Name, sr->AutoChanger); - sr->StorageId = sql_insert_id(mdb, mdb->cmd, NT_("Storage")); + sr->StorageId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Storage")); if (sr->StorageId == 0) { Mmsg2(&mdb->errmsg, _("Create DB Storage record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -366,7 +366,7 @@ db_create_mediatype_record(JCR *jcr, B_DB *mdb, MEDIATYPE_DBR *mr) mr->MediaType, mr->ReadOnly); Dmsg1(200, "Create mediatype: %s\n", mdb->cmd); - mr->MediaTypeId = sql_insert_id(mdb, mdb->cmd, NT_("MediaType")); + mr->MediaTypeId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("MediaType")); if (mr->MediaTypeId == 0) { Mmsg2(&mdb->errmsg, _("Create db mediatype record %s failed: ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -445,7 +445,7 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr) Dmsg1(500, "Create Volume: %s\n", mdb->cmd); - mr->MediaId = sql_insert_id(mdb, mdb->cmd, NT_("Media")); + mr->MediaId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Media")); if (mr->MediaId == 0) { Mmsg2(&mdb->errmsg, _("Create DB Media record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -524,7 +524,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr) edit_uint64(cr->FileRetention, ed1), edit_uint64(cr->JobRetention, ed2)); - cr->ClientId = sql_insert_id(mdb, mdb->cmd, NT_("Client")); + cr->ClientId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Client")); if (cr->ClientId == 0) { Mmsg2(&mdb->errmsg, _("Create DB Client record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -589,7 +589,7 @@ int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) Mmsg(mdb->cmd, "INSERT INTO Path (Path) VALUES ('%s')", mdb->esc_name); - ar->PathId = sql_insert_id(mdb, mdb->cmd, NT_("Path")); + ar->PathId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Path")); if (ar->PathId == 0) { Mmsg2(&mdb->errmsg, _("Create db Path record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -702,7 +702,7 @@ bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr) Mmsg(mdb->cmd, "INSERT INTO FileSet (FileSet,MD5,CreateTime) " "VALUES ('%s','%s','%s')", fsr->FileSet, fsr->MD5, fsr->cCreateTime); - fsr->FileSetId = sql_insert_id(mdb, mdb->cmd, NT_("FileSet")); + fsr->FileSetId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("FileSet")); if (fsr->FileSetId == 0) { Mmsg2(&mdb->errmsg, _("Create DB FileSet record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -1024,7 +1024,7 @@ static int db_create_file_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) ar->FileIndex, ar->JobId, ar->PathId, ar->FilenameId, ar->attr, digest); - ar->FileId = sql_insert_id(mdb, mdb->cmd, NT_("File")); + ar->FileId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("File")); if (ar->FileId == 0) { Mmsg2(&mdb->errmsg, _("Create db File record %s failed. ERR=%s"), mdb->cmd, sql_strerror(mdb)); @@ -1071,7 +1071,7 @@ static int db_create_filename_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) Mmsg(mdb->cmd, "INSERT INTO Filename (Name) VALUES ('%s')", mdb->esc_name); - ar->FilenameId = sql_insert_id(mdb, mdb->cmd, NT_("Filename")); + ar->FilenameId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("Filename")); if (ar->FilenameId == 0) { Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), mdb->cmd, sql_strerror(mdb)); @@ -1292,7 +1292,7 @@ bool db_create_restore_object_record(JCR *jcr, B_DB *mdb, ROBJECT_DBR *ro) mdb->esc_name, mdb->esc_path, mdb->esc_path, esc_obj, ro->object_len, ro->ObjectIndex, FT_RESTORE_FIRST, ro->FileIndex, ro->JobId); - ro->RestoreObjectId = sql_insert_id(mdb, mdb->cmd, NT_("RestoreObject")); + ro->RestoreObjectId = sql_insert_autokey_record(mdb, mdb->cmd, NT_("RestoreObject")); if (ro->RestoreObjectId == 0) { Mmsg2(&mdb->errmsg, _("Create db Object record %s failed. ERR=%s"), mdb->cmd, sql_strerror(mdb)); diff --git a/bacula/src/cats/sqlite.c b/bacula/src/cats/sqlite.c index 96e131c7a9..da61ab814e 100644 --- a/bacula/src/cats/sqlite.c +++ b/bacula/src/cats/sqlite.c @@ -500,7 +500,7 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb) } } -int my_sqlite_sql_insert_id(B_DB *mdb, const char *query, const char *table_name) +int my_sqlite_sql_insert_autokey_record(B_DB *mdb, const char *query, const char *table_name) { /* * First execute the insert query and then retrieve the currval. -- 2.39.5