Minor fixes

This commit is contained in:
Vinoth Veeraraghavan
2022-12-05 11:27:19 +08:00
parent 7784e48e23
commit e71d571b6d
6 changed files with 9 additions and 45 deletions

View File

@ -261,7 +261,7 @@ public:
m_refCount = m_refCount & (~S_COUNTER_LOCK_BIT);
#else
uint64_t v = GetRefCount();
uint32_t v = GetRefCount();
while (!__sync_bool_compare_and_swap(&m_refCount, v, (v & ~S_COUNTER_LOCK_BIT))) {
PAUSE
v = GetRefCount();

View File

@ -592,7 +592,7 @@ public:
* @brief Retrieves the number of fields (columns) in each row in the table.
* @return Number of fields in a row.
*/
inline uint64_t GetFieldCount() const
inline uint32_t GetFieldCount() const
{
return m_fieldCnt;
}

View File

@ -54,26 +54,6 @@ bool IsDirExists(const std::string& dirName)
return true;
}
bool OpenFileWrite(const std::string& fileName, FILE*& pFile)
{
pFile = fopen(fileName.c_str(), "wb");
if (pFile == nullptr) {
MOT_REPORT_SYSTEM_ERROR(fopen, "N/A", "Failed to open file %s for writing", fileName.c_str());
return false;
}
return true;
}
bool OpenFileRead(const std::string& fileName, FILE*& pFile)
{
pFile = fopen(fileName.c_str(), "rb");
if (pFile == nullptr) {
MOT_REPORT_SYSTEM_ERROR(fopen, "N/A", "Failed to open file %s for reading", fileName.c_str());
return false;
}
return true;
}
bool OpenFileWrite(const std::string& fileName, int& fd)
{
fd = open(fileName.c_str(), O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR); /* 0600 */
@ -132,9 +112,9 @@ int FlushFile(int fd)
return rc;
}
bool SeekFile(int fd, uint64_t offset)
bool SeekFile(int fd, off64_t offset)
{
int rc = lseek(fd, offset, SEEK_SET);
int rc = lseek64(fd, offset, SEEK_SET);
if (rc == -1) {
MOT_REPORT_SYSTEM_ERROR(write, "N/A", "Failed to seek file descriptor %d to offset %" PRIu64, fd);
}

View File

@ -77,22 +77,6 @@ bool IsFileExists(const std::string& fileName);
*/
bool IsDirExists(const std::string& dirName);
/**
* @brief A wrapper function that opens a file for writing.
* @param fileName The file name to open
* @param pFile The returned FILE* pointer
* @return Boolean value denoting success or failure.
*/
bool OpenFileWrite(const std::string& fileName, FILE*& pFile);
/**
* @brief A wrapper function that opens a file for reading.
* @param fileName The file name to open
* @param pFile The returned FILE* pointer
* @return Boolean value denoting success or failure.
*/
bool OpenFileRead(const std::string& fileName, FILE*& pFile);
/**
* @brief A wrapper function that opens a file for writing.
* @param fileName The file name to open
@ -147,7 +131,7 @@ int FlushFile(int fd);
* @param offset The offset in the file to seek to.
* @return Boolean value denoting success or failure.
*/
bool SeekFile(int fd, uint64_t offset);
bool SeekFile(int fd, off64_t offset);
/**
* @brief Frees a row's stable version row.

View File

@ -2008,11 +2008,11 @@ RC TxnIxColUpdate::InitAndBuildOldKeys(Row* row)
for (uint64_t i = 0; i < m_cols; i++) {
if (BITMAP_GET(m_modBitmap, i)) {
if (m_tab->GetField((uint16_t)(i + 1))->IsUsedByIndex()) {
if (m_tab->GetField((i + 1))->IsUsedByIndex()) {
for (uint16_t j = 0; j < m_arrLen; j++) {
if (m_ix[j] == nullptr) {
MOT::Index* ix = m_tab->GetIndex(j);
if (ix->IsFieldPresent((uint16_t)(i + 1))) {
if (ix->IsFieldPresent(static_cast<int16_t>(i + 1))) {
m_ix[j] = ix;
}
}

View File

@ -940,7 +940,7 @@ MOT::RC MOTAdaptor::CreateIndex(IndexStmt* stmt, ::TransactionId tid)
stmt->idxname,
stmt->indexOid,
stmt->relation->relname);
uint64_t keyLength = 0;
uint32_t keyLength = 0;
MOT::Index* index = nullptr;
MOT::IndexOrder index_order = MOT::IndexOrder::INDEX_ORDER_SECONDARY;
@ -964,7 +964,7 @@ MOT::RC MOTAdaptor::CreateIndex(IndexStmt* stmt, ::TransactionId tid)
return MOT::RC_ABORT;
}
index->SetExtId(stmt->indexOid);
if (!index->SetNumTableFields((uint32_t)table->GetFieldCount())) {
if (!index->SetNumTableFields(table->GetFieldCount())) {
table->GetOrigTable()->Unlock();
delete index;
report_pg_error(MOT::RC_ABORT);