~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_lock.h

Replace MAX_(DATE|TIME).*_WIDTH defines in definitions.h with real (and correct) static const members to Temporal types.

This fixes the buffer overflow in https://bugs.launchpad.net/drizzle/+bug/373468

It also removes a handwritten snprintf in field/datetime.cc
However... this caused us to have to change Temporal to have a way to not
"convert" the int64_t value (so 20090101 becomes 20090101000000 etc) as it
has already been converted and we just want the Temporal type to do the
to_string conversion.

This still causes a failure in 'metadata' test due to size of timestamp type. I need feedback from Jay on when the usecond code comes into play to know the correct fix for this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
/* For use with thr_locks */
17
 
 
18
 
#ifndef DRIZZLED_THR_LOCK_H
19
 
#define DRIZZLED_THR_LOCK_H
20
 
 
21
 
#include <pthread.h>
22
 
 
23
 
namespace drizzled
24
 
{
 
16
/* For use with thr_lock:s */
 
17
 
 
18
#ifndef _thr_lock_h
 
19
#define _thr_lock_h
 
20
#ifdef  __cplusplus
 
21
extern "C" {
 
22
#endif
 
23
 
 
24
#include <mysys/my_pthread.h>
 
25
#include <mysys/definitions.h>
25
26
 
26
27
struct st_thr_lock;
27
28
extern uint32_t locks_immediate,locks_waited ;
28
 
 
29
 
namespace internal
30
 
{
31
29
extern pthread_mutex_t THR_LOCK_lock;
32
 
}
 
30
 
33
31
 
34
32
extern uint64_t max_write_lock_count;
35
33
extern uint64_t table_lock_wait_timeout;
36
34
extern bool thr_lock_inited;
37
 
 
38
 
 
39
 
enum thr_lock_type { TL_IGNORE=-1,
40
 
                     /* UNLOCK ANY LOCK */
41
 
                     TL_UNLOCK,
42
 
                     /* Read lock */
43
 
                     TL_READ,
44
 
                     TL_READ_WITH_SHARED_LOCKS,
45
 
                     /* READ, Don't allow concurrent insert */
46
 
                     TL_READ_NO_INSERT,
47
 
                     /*
48
 
                       Write lock, but allow other threads to read / write.
49
 
                       Used by BDB tables in MySQL to mark that someone is
50
 
                       reading/writing to the table.
51
 
                     */
52
 
                     TL_WRITE_ALLOW_WRITE,
53
 
                     /*
54
 
                       Write lock, but allow other threads to read.
55
 
                       Used by ALTER TABLE in MySQL to allow readers
56
 
                       to use the table until ALTER TABLE is finished.
57
 
                     */
58
 
                     TL_WRITE_ALLOW_READ,
59
 
                     /*
60
 
                       WRITE lock used by concurrent insert. Will allow
61
 
                       READ, if one could use concurrent insert on table.
62
 
                     */
63
 
                     TL_WRITE_CONCURRENT_INSERT,
64
 
                     /*
65
 
                       parser only! Late bound low_priority flag.
66
 
                       At open_tables() becomes thd->update_lock_default.
67
 
                     */
68
 
                     TL_WRITE_DEFAULT,
69
 
                     /* Normal WRITE lock */
70
 
                     TL_WRITE,
71
 
                     /* Abort new lock request with an error */
72
 
                     TL_WRITE_ONLY};
73
 
 
74
 
enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
75
 
                            THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 };
 
35
extern enum thr_lock_type thr_upgraded_concurrent_insert_lock;
 
36
 
76
37
/*
77
38
  A description of the thread which owns the lock. The address
78
39
  of an instance of this structure is used to uniquely identify the thread.
81
42
typedef struct st_thr_lock_info
82
43
{
83
44
  pthread_t thread;
84
 
  uint64_t thread_id;
 
45
  my_thread_id thread_id;
85
46
  uint32_t n_cursors;
86
47
} THR_LOCK_INFO;
87
48
 
134
95
void thr_lock_delete(THR_LOCK *lock);
135
96
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
136
97
                        void *status_param);
 
98
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
 
99
                                   THR_LOCK_OWNER *owner,
 
100
                                   enum thr_lock_type lock_type);
 
101
void thr_unlock(THR_LOCK_DATA *data);
137
102
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
138
103
                                         uint32_t count, THR_LOCK_OWNER *owner);
139
104
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
140
 
void thr_abort_locks(THR_LOCK *lock);
141
 
bool thr_abort_locks_for_thread(THR_LOCK *lock, uint64_t thread);
142
 
 
143
 
} /* namespace drizzled */
144
 
 
145
 
#endif /* DRIZZLED_THR_LOCK_H */
 
105
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
 
106
bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
 
107
#ifdef  __cplusplus
 
108
}
 
109
#endif
 
110
#endif /* _thr_lock_h */