void Lexer::numberExponent() { switch (*idx) { case '+': case '-': idx++; break; } if (!decimalDigits(-1)) compiler->syntaxError(lineno, "Illegal number: missing digits in exponent"); }
void Lexer::numberFraction(bool has_leading_digits) { if (!decimalDigits (-1) && !has_leading_digits) compiler->syntaxError(lineno, "Illegal number: must have digits before or after decimal point"); switch (*idx) { case 'e': case 'E': idx++; numberExponent (); break; } }
bool Lexer::numberLiteralPrime() { if (!decimalDigits(-1)) compiler->syntaxError(lineno, "Illegal number: no digits"); switch (*idx) { case '.': idx++; numberFraction (true); return true; case 'e': case 'E': idx++; numberExponent (); return true; default: return false; } }
SQLRETURN StatementHandle::sqlColumns(SQLCHAR *catalogName, SQLSMALLINT catalogNameLen, SQLCHAR *schemaName, SQLSMALLINT schemaNameLen, SQLCHAR *tableName, SQLSMALLINT tableNameLen, SQLCHAR *columnName, SQLSMALLINT columnNameLen) { _cursorColumns.clear(); _cursor.reset(); _resultSet.clear(); _rowIdx = -1; std::list<std::string> schemas; int rc = _connHandle->getDbNames(&schemas); if (0 != rc) { return SQL_ERROR; } std::string schemaNameStr; if (NULL != schemaName) { if (schemaNameLen == SQL_NTS) { schemaNameStr.assign((char *)schemaName); } else { schemaNameStr.assign((char *)schemaName, (int)schemaNameLen); } } std::string tableNameStr; if (NULL != tableName) { if (tableNameLen == SQL_NTS) { tableNameStr.assign((char *)tableName); } else { tableNameStr.assign((char *)tableName, (int)tableNameLen); } } // map from schema name to table names for (std::list<std::string>::const_iterator it = schemas.begin(); it != schemas.end(); ++it) { if (schemaNameStr.size() && *it != schemaNameStr) { continue; } std::list<std::string> tables; int rc = _connHandle->getCollectionNames(*it, &tables); if (0 != rc) { return SQL_ERROR; } for (std::list<std::string>::const_iterator tableIt = tables.begin(); tableIt != tables.end(); ++tableIt) { size_t periodIdx = tableIt->find('.'); size_t periodIdx2 = tableIt->find('.', periodIdx + 1); if (periodIdx2 != std::string::npos) { periodIdx2 = periodIdx2 - periodIdx - 1; } std::string tableName(*tableIt, periodIdx + 1, periodIdx2); if ("system" == tableName) { // skip mongodb internal tables continue; } if (tableNameStr.size() && tableName != tableNameStr) { continue; } std::auto_ptr<mongo::DBClientCursor> cursor = _connHandle->query(*tableIt); int columnNum = 1; while (cursor->more()) { mongo::BSONObj::iterator fieldIt = cursor->next().begin(); while(fieldIt.more()) { mongo::BSONElement elem = fieldIt.next(); SQLSMALLINT dataType = mapMongoToODBCDataType(elem.type()); _resultSet.push_back(std::list<Result>()); std::list<Result>& results = _resultSet.back(); results.push_back("NULL"); results.push_back(*it); results.push_back(tableName); results.push_back(elem.fieldName()); results.push_back(dataType); results.push_back(dataTypeName(dataType)); results.push_back(columnSize(dataType)); results.push_back(bufferLength(dataType)); results.push_back(decimalDigits(dataType)); results.push_back(numPercRadix(dataType)); results.push_back((SQLSMALLINT)SQL_NULLABLE); results.push_back(""); results.push_back("NULL"); results.push_back(mapODBCDataTypeToSQLDataType(dataType)); results.push_back(getDatetimeSubcode(dataType)); results.push_back(maxCharLen(dataType)); results.push_back(columnNum++); results.push_back("\"YES\""); } break; } } } return SQL_SUCCESS; }
static bool fractionalPart() { char c; if (!next(c) || (c != '.')) return false; return decimalDigits(); }