Legger til støtte for CREATE TEMPORARY TABLES og LOCK TABLES

This commit is contained in:
Geir Hauge 2006-11-17 14:32:46 +00:00
parent 5a1f013a31
commit 82155cedc3
1 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.16 2006-08-15 11:51:59 geirha Exp $
* @(#) $Header: /tmp/cvs/mysql-admutils/mysql-dbadm.c,v 1.17 2006-11-17 14:32:46 geirha Exp $
*
* mysql-dbadm.c
*
@ -264,24 +264,25 @@ writeperm(FILE *f, MYSQL *pmysql, const char *db)
MYSQL_ROW row;
sprintf(query, "select user,select_priv,insert_priv,update_priv,"
"delete_priv,create_priv,drop_priv,alter_priv,index_priv from db where db='%s'", db);
"delete_priv,create_priv,drop_priv,alter_priv,index_priv,"
"create_tmp_table_priv,lock_tables_priv from db where db='%s'", db);
if (mysql_query(pmysql, query))
return dberror(pmysql, "Query for permissions failed.");
res = mysql_store_result(pmysql);
rows = mysql_num_rows(res);
fprintf(f, "# User "
"Select Insert Update Delete Create Drop Alter Index\n");
"Select Insert Update Delete Create Drop Alter Index Create temporary tables Lock tables\n");
fprintf(f, "# ---------------- "
"------ ------ ------ ------ ------ ---- ----- -----\n");
"------ ------ ------ ------ ------ ---- ----- ----- ----------------------- -----------\n");
if (rows == 0)
fprintf(f, "# (no permissions currently granted to any users)\n");
else {
for (i = 0; i < rows; i++) {
row = mysql_fetch_row(res);
fprintf(f, " %-16s %-7s %-7s %-7s %-7s %-7s %-7s %-7s %s\n",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]);
fprintf(f, " %-16s %-7s %-7s %-7s %-7s %-6s %-6s %-6s %-15s %-18s %s\n",
row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10]);
}
}
free(res);
@ -313,7 +314,8 @@ editperm(MYSQL *pmysql, const char *db)
char line[1024]; /* buffer to hold one line */
char *cp; /* used to interate through a line */
char *user, *select_priv, *insert_priv, *update_priv, *delete_priv,
*create_priv, *drop_priv, *alter_priv, *index_priv;
*create_priv, *drop_priv, *alter_priv, *index_priv, *create_tmp_table_priv,
*lock_tables_priv;
char query[1024]; /* used to build a query */
char *queries[MAX_GRANTS]; /* insert queries */
int lines; /* number of grant lines processed */
@ -386,15 +388,20 @@ editperm(MYSQL *pmysql, const char *db)
CHECK_PRIV(alter_priv);
STRTOK_WHITESPACE(index_priv, NULL);
CHECK_PRIV(index_priv);
STRTOK_WHITESPACE(create_tmp_table_priv, NULL);
CHECK_PRIV(create_tmp_table_priv);
STRTOK_WHITESPACE(lock_tables_priv, NULL);
CHECK_PRIV(lock_tables_priv);
#undef STRTOK_WHITESPACE
#undef CHECK_PRIV
sprintf(query, "insert into db (host, db, user, select_priv, insert_priv, "
"update_priv, delete_priv, create_priv, drop_priv, alter_priv, index_priv) values "
"('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
"update_priv, delete_priv, create_priv, drop_priv, alter_priv, index_priv, "
"create_tmp_table_priv, lock_tables_priv) values "
"('%%', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
db, user, select_priv, insert_priv, update_priv, delete_priv,
create_priv, drop_priv, alter_priv, index_priv);
create_priv, drop_priv, alter_priv, index_priv, create_tmp_table_priv, lock_tables_priv);
queries[lines] = strdup(query);
lines++;
if (lines >= MAX_GRANTS)