IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 14, 2006, 4:26:50 PM (20 years ago)
Author:
jhoblitt
Message:

add tableName param to psDBGenerateConditionalSQL()
add tableName param to psDBGenerateWhereSQL()
add tableName param to psDBGenerateWhereConditionSQL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/db/psDB.c

    r8305 r8335  
    1212 *  @author Joshua Hoblitt
    1313 *
    14  *  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2006-08-12 03:33:15 $
     14 *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2006-08-15 02:26:50 $
    1616 *
    1717 *  Copyright (C) 2005-2006  Joshua Hoblitt, University of Hawaii
     
    8686static char    *psDBGenerateSetSQL(const psMetadata *set
    8787                                  );
    88 static char    *psDBGenerateConditionalSQL(const psMetadataItem *item);
     88static char *psDBGenerateConditionalSQL(const psMetadataItem *item, const char *tableName);
     89
    8990// lookup table functions
    9091static psElemType psDBMySQLToPType(enum enum_field_types type, unsigned int flags);
     
    13481349    // select all rows if where is NULL
    13491350    if (where) {
    1350         whereSQL = psDBGenerateWhereSQL(where);
     1351        whereSQL = psDBGenerateWhereSQL(where, tableName);
    13511352        if (!whereSQL) {
    13521353            psError(PS_ERR_UNEXPECTED_NULL, false, "SQL substring generation failed.");
     
    14371438
    14381439    // Create where SQL substring
    1439     whereSQL = psDBGenerateWhereSQL(where);
     1440    whereSQL = psDBGenerateWhereSQL(where, tableName);
    14401441    if (!whereSQL) {
    14411442        psError(PS_ERR_UNEXPECTED_NULL, false, _("SQL substring generation failed."));
     
    14681469
    14691470    // Generate where SQL substring
    1470     whereSQL = psDBGenerateWhereSQL(where);
     1471    whereSQL = psDBGenerateWhereSQL(where, tableName);
    14711472    if (!whereSQL) {
    14721473        psError(PS_ERR_UNEXPECTED_NULL, false, _("SQL substring generation failed."));
     
    14881489}
    14891490
    1490 char *psDBGenerateWhereSQL(const psMetadata *where)
     1491char *psDBGenerateWhereSQL(const psMetadata *where, const char *tableName)
    14911492{
    14921493    PS_ASSERT_PTR_NON_NULL(where, NULL);
    14931494
    1494     psString search = psDBGenerateWhereConditionSQL(where);
     1495    psString search = psDBGenerateWhereConditionSQL(where, tableName);
    14951496    if (search) {
    14961497        psStringPrepend(&search, "WHERE ");
     
    15001501}
    15011502
    1502 char *psDBGenerateWhereConditionSQL(const psMetadata *where)
     1503char *psDBGenerateWhereConditionSQL(const psMetadata *where, const char *tableName)
    15031504{
    15041505    PS_ASSERT_PTR_NON_NULL(where, NULL);
     
    15361537            psStringAppend(&query, "(");
    15371538            while ((mItem = psListGetAndIncrement(mCursor))) {
    1538                 char *conditional = psDBGenerateConditionalSQL(mItem);
     1539                char *conditional = psDBGenerateConditionalSQL(mItem, tableName);
    15391540                if (!conditional) {
    15401541                    psError(PS_ERR_UNKNOWN, false,
     
    15601561            psStringAppend(&query, ")");
    15611562        } else {
    1562             char *conditional = psDBGenerateConditionalSQL(item);
     1563            char *conditional = psDBGenerateConditionalSQL(item, tableName);
    15631564            if (!conditional) {
    15641565                psError(PS_ERR_UNKNOWN, false,
     
    16141615}
    16151616
    1616 static char *psDBGenerateConditionalSQL(const psMetadataItem *item)
     1617static char *psDBGenerateConditionalSQL(const psMetadataItem *item, const char *tableName)
    16171618{
    16181619    PS_ASSERT_PTR_NON_NULL(item, NULL);
     
    16271628    // the comparison to be done on the server provides some consistency
    16281629    // 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
    16291636    if ((item->type == PS_DATA_S32) || (item->type == PS_TYPE_S32)) {
    16301637        psStringAppend(&query, "%s=%d", item->name, (int)(item->data.S32));
Note: See TracChangeset for help on using the changeset viewer.