Changeset 3209
- Timestamp:
- Feb 13, 2005, 12:23:07 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/psdb/psDB.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/psdb/psDB.c
r3208 r3209 8 8 * @author Joshua Hoblitt 9 9 * 10 * @version $Revision: 1.2 0$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-02-13 22: 09:46$10 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-02-13 22:23:07 $ 12 12 * 13 13 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 62 62 static char *psDBGenerateInsertRowSQL(const char *tableName, psMetadata *row); 63 63 static char *psDBGenerateCreateTableSQL(const char *tableName, psMetadata *where); 64 static char *psDBGenerateSelectColumnSQL(const char *tableName, const char *col, const psU64 limit); 65 static char *psDBGenerateSelectRowsSQL(const char *tableName, psMetadata *where); 64 static char *psDBGenerateSelectRowSQL(const char *tableName, const char *col, psMetadata *where, const psU64 limit); 66 65 static char *psDBGenerateUpdateRowSQL(const char *tableName, psMetadata *where, psMetadata *values); 67 66 static char *psDBGenerateSetSQL(psMetadata *set); … … 192 191 psPtr data; // copy of result field 193 192 194 query = psDBGenerateSelect ColumnSQL(tableName, col, limit);193 query = psDBGenerateSelectRowSQL(tableName, col, NULL, limit); 195 194 if (!query) { 196 195 return NULL; … … 354 353 psPtr data; // copy of result field 355 354 356 query = psDBGenerateSelectRow sSQL(tableName, where);355 query = psDBGenerateSelectRowSQL(tableName, NULL, where, 0); 357 356 if (!query) { 358 357 return NULL; … … 979 978 } 980 979 981 static char *psDBGenerateSelect ColumnSQL(const char *tableName, const char *col, const psU64 limit)980 static char *psDBGenerateSelectRowSQL(const char *tableName, const char *col, psMetadata *where, const psU64 limit) 982 981 { 983 982 char *query = NULL; 983 char *whereSQL; 984 984 char *limitString; 985 985 986 psStringAppend(&query, "SELECT %s FROM %s", col, tableName); 986 // select all columns if col is NULL 987 if (col) { 988 psStringAppend(&query, "SELECT %s FROM %s", col, tableName); 989 } else { 990 psStringAppend(&query, "SELECT * FROM %s", tableName); 991 } 992 993 // select all rows if where is NULL 994 if (where) { 995 whereSQL = psDBGenerateWhereSQL(where); 996 if (!whereSQL) { 997 psFree(query); 998 999 return NULL; 1000 } 1001 psStringAppend(&query, " %s", whereSQL); 1002 psFree(whereSQL); 1003 } 987 1004 988 1005 // treat limit == 0 as "no limit" … … 991 1008 psStringAppend(&query, " LIMIT %s", limitString); 992 1009 psFree(limitString); 993 }994 995 return query;996 }997 998 static char *psDBGenerateSelectRowsSQL(const char *tableName, psMetadata *where)999 {1000 char *query = NULL;1001 char *whereSQL;1002 1003 psStringAppend(&query, "SELECT * FROM %s", tableName);1004 1005 // select everything if where is NULL1006 if (where) {1007 whereSQL = psDBGenerateWhereSQL(where);1008 if (!whereSQL) {1009 psFree(query);1010 1011 return NULL;1012 }1013 psStringAppend(&query, " %s", whereSQL);1014 psFree(whereSQL);1015 1010 } 1016 1011
Note:
See TracChangeset
for help on using the changeset viewer.
