For readability, it's better that SQL words are uppercase.
This commit is contained in:
parent
55320ab85a
commit
8b63adbdf0
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* idpc - IDP as a C CGI program
|
||||
* Copyright (C) 2004 Entr'ouvert
|
||||
* Copyright (C) 2004-2005 Entr'ouvert
|
||||
*
|
||||
* Author: Frederic Peters <fpeters@entrouvert.com>
|
||||
* Authors: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -51,7 +51,7 @@ int db_get_dumps(char *user_id, char **identity_dump, char **session_dump)
|
|||
int rc;
|
||||
|
||||
snprintf(query, 500,
|
||||
"select identity_dump, session_dump from users where user_id = '%s'",
|
||||
"SELECT identity_dump, session_dump FROM users WHERE user_id = '%s'",
|
||||
user_id);
|
||||
if (mysql_query(sqlconn, query)) {
|
||||
return 1;
|
||||
|
@ -78,7 +78,7 @@ static int ensure_user(char *user_id)
|
|||
int rc;
|
||||
|
||||
snprintf(query, 500,
|
||||
"select * from users where user_id = '%s'",
|
||||
"SELECT * FROM users WHERE user_id = '%s'",
|
||||
user_id);
|
||||
if (mysql_query(sqlconn, query)) {
|
||||
return 1;
|
||||
|
@ -112,7 +112,7 @@ int db_save_identity(char *user_id, char *identity_dump)
|
|||
|
||||
query = malloc(500 + strlen(identity_dump));
|
||||
snprintf(query, 500 + strlen(identity_dump),
|
||||
"UPDATE users SET identity_dump = '%s' where user_id = '%s'",
|
||||
"UPDATE users SET identity_dump = '%s' WHERE user_id = '%s'",
|
||||
identity_dump,
|
||||
user_id);
|
||||
if (mysql_query(sqlconn, query)) {
|
||||
|
@ -135,7 +135,7 @@ int db_save_session(char *user_id, char *session_dump)
|
|||
|
||||
query = malloc(500 + strlen(session_dump));
|
||||
snprintf(query, 500 + strlen(session_dump),
|
||||
"UPDATE users SET session_dump = '%s' where user_id = '%s'",
|
||||
"UPDATE users SET session_dump = '%s' WHERE user_id = '%s'",
|
||||
session_dump,
|
||||
user_id);
|
||||
if (mysql_query(sqlconn, query)) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* idpc - IDP as a C CGI program
|
||||
* Copyright (C) 2004 Entr'ouvert
|
||||
* Copyright (C) 2004-2005 Entr'ouvert
|
||||
*
|
||||
* Author: Frederic Peters <fpeters@entrouvert.com>
|
||||
* Authors: See AUTHORS file in top-level directory.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -53,14 +53,14 @@ int db_get_dumps(char *user_id, char **identity_dump, char **session_dump)
|
|||
params[0] = user_id;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"SELECT identity_dump, session_dump FROM users where user_id = $1",
|
||||
"SELECT identity_dump, session_dump FROM users WHERE user_id = $1",
|
||||
1, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) == 0) {
|
||||
/* error or no tuple for this nameidentifier */
|
||||
PQclear(res);
|
||||
*identity_dump = NULL;
|
||||
*session_dump = NULL;
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
*identity_dump = strdup(PQgetvalue(res, 0, 0));
|
||||
*session_dump = strdup(PQgetvalue(res, 0, 1));
|
||||
|
@ -76,7 +76,7 @@ static int ensure_user(char *user_id)
|
|||
params[0] = user_id;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"SELECT * from users where user_id = $1",
|
||||
"SELECT * FROM users WHERE user_id = $1",
|
||||
1, NULL, params ,NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
PQclear(res);
|
||||
|
@ -121,7 +121,7 @@ int db_save_identity(char *user_id, char *identity_dump)
|
|||
params[0] = identity_dump;
|
||||
params[1] = user_id;
|
||||
res = PQexecParams(sqlconn,
|
||||
"UPDATE users SET identity_dump = $1 where user_id = $2",
|
||||
"UPDATE users SET identity_dump = $1 WHERE user_id = $2",
|
||||
2, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
PQclear(res);
|
||||
|
@ -146,8 +146,9 @@ int db_save_session(char *user_id, char *session_dump)
|
|||
params[0] = session_dump;
|
||||
params[1] = user_id;
|
||||
res = PQexecParams(sqlconn,
|
||||
"UPDATE users SET session_dump = $1 where user_id = $2",
|
||||
2, NULL, params, NULL, NULL, 1);
|
||||
"UPDATE users SET session_dump = $1 "
|
||||
"WHERE user_id = $2",
|
||||
2, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
PQclear(res);
|
||||
return 1;
|
||||
|
@ -166,8 +167,8 @@ int db_save_name_identifier(char *name_identifier, char *user_id)
|
|||
params[1] = user_id;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"SELECT * from nameidentifiers where name_identifier = $1",
|
||||
1, NULL, params ,NULL, NULL, 1);
|
||||
"SELECT * FROM nameidentifiers WHERE name_identifier = $1",
|
||||
1, NULL, params ,NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
PQclear(res);
|
||||
return 1;
|
||||
|
@ -178,8 +179,8 @@ int db_save_name_identifier(char *name_identifier, char *user_id)
|
|||
}
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"INSERT INTO nameidentifiers VALUES ($1, $2)",
|
||||
2, NULL, params, NULL, NULL, 1);
|
||||
"INSERT INTO nameidentifiers VALUES ($1, $2)",
|
||||
2, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
PQclear(res);
|
||||
return 1;
|
||||
|
@ -218,7 +219,7 @@ int db_get_artifact(char *artifact, char **user_id, char **provider_id)
|
|||
params[0] = artifact;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"SELECT user_id, provider_id from artifacts where artifact = $1",
|
||||
"SELECT user_id, provider_id FROM artifacts WHERE artifact = $1",
|
||||
1, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
PQclear(res);
|
||||
|
@ -228,7 +229,7 @@ int db_get_artifact(char *artifact, char **user_id, char **provider_id)
|
|||
if (PQntuples(res) == 0) {
|
||||
fprintf(stderr, "res: 0 tuples\n");
|
||||
PQclear(res);
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
*user_id = strdup(PQgetvalue(res, 0, 0));
|
||||
|
@ -245,7 +246,7 @@ int db_remove_artifact(char *artifact)
|
|||
params[0] = artifact;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"DELETE from artifacts where artifact = $1",
|
||||
"DELETE FROM artifacts WHERE artifact = $1",
|
||||
1, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
PQclear(res);
|
||||
|
@ -262,9 +263,9 @@ int db_get_user_id(char *name_identifier, char **user_id)
|
|||
params[0] = name_identifier;
|
||||
|
||||
res = PQexecParams(sqlconn,
|
||||
"SELECT user_id from nameidentifiers "
|
||||
"where name_identifier = $1",
|
||||
1, NULL, params, NULL, NULL, 1);
|
||||
"SELECT user_id FROM nameidentifiers "
|
||||
"WHERE name_identifier = $1",
|
||||
1, NULL, params, NULL, NULL, 1);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
||||
PQclear(res);
|
||||
return 1;
|
||||
|
|
Reference in New Issue