Changeset 8335
- Timestamp:
- Aug 14, 2006, 4:26:50 PM (20 years ago)
- Location:
- trunk/psLib/src/db
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r8305 r8335 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-08-1 2 03:33:15$14 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-08-15 02:26:50 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 86 86 static char *psDBGenerateSetSQL(const psMetadata *set 87 87 ); 88 static char *psDBGenerateConditionalSQL(const psMetadataItem *item); 88 static char *psDBGenerateConditionalSQL(const psMetadataItem *item, const char *tableName); 89 89 90 // lookup table functions 90 91 static psElemType psDBMySQLToPType(enum enum_field_types type, unsigned int flags); … … 1348 1349 // select all rows if where is NULL 1349 1350 if (where) { 1350 whereSQL = psDBGenerateWhereSQL(where );1351 whereSQL = psDBGenerateWhereSQL(where, tableName); 1351 1352 if (!whereSQL) { 1352 1353 psError(PS_ERR_UNEXPECTED_NULL, false, "SQL substring generation failed."); … … 1437 1438 1438 1439 // Create where SQL substring 1439 whereSQL = psDBGenerateWhereSQL(where );1440 whereSQL = psDBGenerateWhereSQL(where, tableName); 1440 1441 if (!whereSQL) { 1441 1442 psError(PS_ERR_UNEXPECTED_NULL, false, _("SQL substring generation failed.")); … … 1468 1469 1469 1470 // Generate where SQL substring 1470 whereSQL = psDBGenerateWhereSQL(where );1471 whereSQL = psDBGenerateWhereSQL(where, tableName); 1471 1472 if (!whereSQL) { 1472 1473 psError(PS_ERR_UNEXPECTED_NULL, false, _("SQL substring generation failed.")); … … 1488 1489 } 1489 1490 1490 char *psDBGenerateWhereSQL(const psMetadata *where )1491 char *psDBGenerateWhereSQL(const psMetadata *where, const char *tableName) 1491 1492 { 1492 1493 PS_ASSERT_PTR_NON_NULL(where, NULL); 1493 1494 1494 psString search = psDBGenerateWhereConditionSQL(where );1495 psString search = psDBGenerateWhereConditionSQL(where, tableName); 1495 1496 if (search) { 1496 1497 psStringPrepend(&search, "WHERE "); … … 1500 1501 } 1501 1502 1502 char *psDBGenerateWhereConditionSQL(const psMetadata *where )1503 char *psDBGenerateWhereConditionSQL(const psMetadata *where, const char *tableName) 1503 1504 { 1504 1505 PS_ASSERT_PTR_NON_NULL(where, NULL); … … 1536 1537 psStringAppend(&query, "("); 1537 1538 while ((mItem = psListGetAndIncrement(mCursor))) { 1538 char *conditional = psDBGenerateConditionalSQL(mItem );1539 char *conditional = psDBGenerateConditionalSQL(mItem, tableName); 1539 1540 if (!conditional) { 1540 1541 psError(PS_ERR_UNKNOWN, false, … … 1560 1561 psStringAppend(&query, ")"); 1561 1562 } else { 1562 char *conditional = psDBGenerateConditionalSQL(item );1563 char *conditional = psDBGenerateConditionalSQL(item, tableName); 1563 1564 if (!conditional) { 1564 1565 psError(PS_ERR_UNKNOWN, false, … … 1614 1615 } 1615 1616 1616 static char *psDBGenerateConditionalSQL(const psMetadataItem *item )1617 static char *psDBGenerateConditionalSQL(const psMetadataItem *item, const char *tableName) 1617 1618 { 1618 1619 PS_ASSERT_PTR_NON_NULL(item, NULL); … … 1627 1628 // the comparison to be done on the server provides some consistency 1628 1629 // between clients on different archs. 1630 1631 // if tableName is specified prepend it to the item name 1632 if (tableName) { 1633 psStringAppend(&query, "%s.", tableName); 1634 } 1635 1629 1636 if ((item->type == PS_DATA_S32) || (item->type == PS_TYPE_S32)) { 1630 1637 psStringAppend(&query, "%s=%d", item->name, (int)(item->data.S32)); -
trunk/psLib/src/db/psDB.h
r8305 r8335 10 10 * @author Joshua Hoblitt 11 11 * 12 * @version $Revision: 1.2 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-08-1 2 03:33:15$12 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-08-15 02:26:50 $ 14 14 * 15 15 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 362 362 * @return psString: A psString or NULL on failure 363 363 */ 364 char *psDBGenerateWhereSQL(const psMetadata *where );364 char *psDBGenerateWhereSQL(const psMetadata *where, const char *tableName); 365 365 366 366 /** Generates an SQL "where conditon" statement … … 372 372 * @return psString: A psString or NULL on failure 373 373 */ 374 char *psDBGenerateWhereConditionSQL(const psMetadata *where );374 char *psDBGenerateWhereConditionSQL(const psMetadata *where, const char *tableName); 375 375 376 376
Note:
See TracChangeset
for help on using the changeset viewer.
