- Timestamp:
- May 2, 2026, 3:48:37 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/psLib/src/db/psDB.c
r42826 r43004 713 713 714 714 // Create SQL statement string 715 psString query = psDBGenerateDeleteRowSQL(tableName, where, limit);715 psString query = psDBGenerateDeleteRowSQL(tableName, where, limit); 716 716 if (!query) { 717 717 psError(PS_ERR_UNEXPECTED_NULL, false, "Query generation failed."); … … 871 871 } 872 872 873 bool psDBFreeQueryPrepared (void) { 874 875 // initalize the prepared query cache 876 if (!preparedQuery) { 877 return true; 878 } 879 880 // start lock on query cache 881 if (psMemGetThreadSafety()) { 882 pthread_mutex_lock(&preparedQueryMutex); 883 } 884 885 psFree (preparedQuery); 886 preparedQuery = NULL; 887 888 pthread_mutex_unlock(&preparedQueryMutex); 889 890 return true; 891 } 892 873 893 long p_psDBRunQueryPrepared(psDB *dbh, 874 894 const psArray *rowSet, … … 918 938 // add this statement to the cache 919 939 psHashAdd(preparedQuery, query, stmt); 940 psFree (stmt); 920 941 } else { 921 942 psTrace("psLib.db", PS_LOG_INFO, "found statment in query cache"); … … 1608 1629 // have to be free'd 1609 1630 MYSQL_TIME *myTime = psAlloc(sizeof(MYSQL_TIME)); 1631 memset(myTime, 0, sizeof(MYSQL_TIME)); 1632 1610 1633 myTime->year = (unsigned int)tmTime->tm_year + 1900; 1611 1634 myTime->month = (unsigned int)tmTime->tm_mon + 1; … … 1619 1642 // in 5.0 and 5.6, my_bool is char 1620 1643 myTime->neg = (bool)false; 1621 // currently unused by mysql 1622 myTime->second_part = (unsigned long)time->nsec; 1644 1645 // MySQL expects fractional seconds in microseconds, not nanoseconds 1646 myTime->second_part = (unsigned long)(time->nsec / 1000); 1647 1648 // XXX remove: currently unused by mysql 1649 // myTime->second_part = (unsigned long)time->nsec; 1650 1623 1651 psFree(tmTime); 1624 1652 1625 1653 bind[i].buffer = myTime; 1626 1654 bind[i].buffer_length = sizeof(MYSQL_TIME); 1627 bind[i].length = &bind[i].buffer_length; 1655 // XXX bind[i].length = &bind[i].buffer_length; 1656 bind[i].length = 0; 1628 1657 bind[i].is_null = NULL; 1629 1658 } else { … … 2129 2158 char *limitString; 2130 2159 2131 // delete all rows if where is NULL2132 if (!where ) {2160 // delete all rows if WHERE is NULL and no limit is given (limit == 0) 2161 if (!where && !limit) { 2133 2162 psStringAppend(&query, "TRUNCATE TABLE %s", tableName); 2134 2163 return query; 2135 2164 } 2136 2165 2137 // Generate where SQL substring 2138 whereSQL = psDBGenerateWhereSQL(where, tableName); 2139 if (!whereSQL) { 2166 psStringAppend(&query, "DELETE FROM %s", tableName); 2167 2168 if (where) { 2169 // Generate where SQL substring 2170 whereSQL = psDBGenerateWhereSQL(where, tableName); 2171 if (!whereSQL) { 2140 2172 psError(PS_ERR_UNEXPECTED_NULL, false, _("SQL substring generation failed.")); 2141 2173 return NULL; 2142 } 2143 2144 psStringAppend(&query, "DELETE FROM %s %s", tableName, whereSQL); 2174 } 2175 psStringAppend(&query, " %s", whereSQL); 2176 psFree(whereSQL); 2177 } 2145 2178 2146 2179 // Complete delete SQL command string … … 2151 2184 psFree(limitString); 2152 2185 } 2153 psFree(whereSQL);2154 2186 2155 2187 return query; … … 2945 2977 2946 2978 #endif // HAVE_PSDB 2979
Note:
See TracChangeset
for help on using the changeset viewer.
