~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSMutex.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-08-06 11:21:12 UTC
  • mto: (1711.1.21 build) (1725.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1714.
  • Revision ID: prafulla_t@users.sourceforge.net-20100806112112-7w5u0s3nx9u67nzt
Fix for Bug 586051

1. test_if_ref method which checks whether predicate is already evaluated
   due to ref/eq_ref access or not was incorrectly removing a predicate 
   that was not implicitly evaluated due to ref access (due to presence of filesort ?)
   It was field=NULL predicate.
   Such predicate should be kept and execution engine will filter out rows
   correctly. Removal of such predicate led to returning of rows which had
   NULL for join/predicate columns.
2. field COMP_OP NULL will always false for all fields except when COMP_OP
   is NULL-safe equality operator. Modified range optimizer to return zero
   row count in such cases.
   Query now does not even run. It returns zero result. As such Fix(1) is not
   required but we might hit that case in some other query (I have not tried it
   yet)
3. Fixed Field::val_str to print "NULL" for literal NULL instead of "0". It
   added lot of confusion while debugging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 * You should have received a copy of the GNU General Public License
16
16
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
 *
19
19
 * Original author: Paul McCullagh (H&G2JCtL)
20
20
 * Continued development: Barry Leslie
28
28
#include "CSConfig.h"
29
29
 
30
30
#include <assert.h>
31
 
#ifdef OS_WINDOWS
32
 
extern int gettimeofday(struct timeval *tv, struct timezone *tz);
33
 
#else
34
31
#include <sys/time.h>
35
 
#endif
36
 
 
37
32
 
38
33
#include "CSException.h"
39
34
#include "CSMutex.h"
40
35
#include "CSGlobal.h"
41
 
#include "CSLog.h"
42
36
 
43
37
/*
44
38
 * ---------------------------------------------------------------
46
40
 */
47
41
 
48
42
CSMutex::CSMutex()
49
 
#ifdef DEBUG
50
 
:
51
 
iLocker(NULL),
52
 
trace(false)
53
 
#endif
54
43
{
55
44
        int err;
56
45
 
69
58
 
70
59
        if ((err = pthread_mutex_lock(&iMutex)))
71
60
                CSException::throwOSError(CS_CONTEXT, err);
72
 
#ifdef DEBUG
73
 
        iLocker = CSThread::getSelf();
74
 
        if (trace)
75
 
                CSL.logf(iLocker, CSLog::Protocol, "Mutex locked\n");
76
 
#endif
77
61
}
78
62
 
79
63
void CSMutex::unlock()
80
64
{
81
 
#ifdef DEBUG
82
 
        if (trace)
83
 
                CSL.logf(iLocker, CSLog::Protocol, "Mutex unlocked\n");
84
 
        iLocker = NULL;
85
 
#endif
86
65
        pthread_mutex_unlock(&iMutex);
87
66
}
88
67
 
175
154
        struct timespec abstime;
176
155
        int                             lock_count;
177
156
        int                             err;
178
 
        uint64_t                micro_sec;
179
157
 
180
158
        enter_();
 
159
#ifdef XT_WIN
 
160
        union ft64              now;
 
161
  
 
162
        GetSystemTimeAsFileTime(&now.ft);
 
163
 
 
164
        /* System time is measured in 100ns units.
 
165
         * This calculation will be reversed by the Windows implementation
 
166
         * of pthread_cond_timedwait(), in order to extract the
 
167
         * milli-second timeout!
 
168
         */
 
169
        abstime.tv.i64 = now.i64 + (milli_sec * 10000);
 
170
  
 
171
        abstime.max_timeout_msec = milli_sec;
 
172
#else
181
173
        struct timeval  now;
 
174
        uint64_t                        micro_sec;
182
175
 
183
176
        /* Get the current time in microseconds: */
184
177
        gettimeofday(&now, NULL);
190
183
        /* Setup the end time, which is in nano-seconds. */
191
184
        abstime.tv_sec = (long) (micro_sec / 1000000);                          /* seconds */
192
185
        abstime.tv_nsec = (long) ((micro_sec % 1000000) * 1000);        /* and nanoseconds */
193
 
 
 
186
#endif
194
187
        ASSERT(iLockingThread == self);
195
188
        lock_count = iLockCount;
196
189
        iLockCount = 0;