~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_getdate.cc

  • Committer: Stewart Smith
  • Date: 2009-05-15 06:57:12 UTC
  • mto: (991.1.5 for-brian)
  • mto: This revision was merged to the branch mainline in revision 1022.
  • Revision ID: stewart@flamingspork.com-20090515065712-bmionylacjmexmmm
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.

Also fix DEFAULT keyword handling for auto-increment so that it defaults to
NULL and not 0 so that the following is valid and generates two auto-inc
values:

create table t1 (a int auto_increment primary key)
insert into t1 (a) values (default);
insert into t1 (a) values (default);

Important to note that 0 is no longer magic. So this gives you duplicate
primary key error:

insert into t1 (a) values(0);
insert into t1 (a) values(0);

as you've inserted the explicit value of 0 twice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* Get date in a printable form: yyyy-mm-dd hh:mm:ss */
17
17
 
18
 
#include "config.h"
19
 
 
20
 
#include "drizzled/internal/my_sys.h"
21
 
#include "drizzled/internal/m_string.h"
22
 
#include <cstdio>
23
 
 
24
 
namespace drizzled
25
 
{
26
 
namespace internal
27
 
{
 
18
#include "mysys/mysys_priv.h"
 
19
#include <mystrings/m_string.h>
 
20
#include <stdio.h>
28
21
 
29
22
/*
30
23
  get date as string
46
39
{
47
40
   register struct tm *start_time;
48
41
   time_t skr;
49
 
   struct tm tm_tmp;
 
42
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
 
43
  struct tm tm_tmp;
 
44
#endif
50
45
 
51
46
   skr= date ? (time_t) date : time(0);
 
47
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
52
48
   if (flag & GETDATE_GMT)
53
49
     localtime_r(&skr,&tm_tmp);
54
50
   else
55
51
     gmtime_r(&skr,&tm_tmp);
56
52
   start_time= &tm_tmp;
 
53
#else
 
54
   if (flag & GETDATE_GMT)
 
55
     start_time= localtime(&skr);
 
56
   else
 
57
     start_time= gmtime(&skr);
 
58
#endif
57
59
   if (flag & GETDATE_SHORT_DATE)
58
60
     sprintf(to,"%02d%02d%02d",
59
61
             start_time->tm_year % 100,
78
80
             start_time->tm_min,
79
81
             start_time->tm_sec);
80
82
} /* get_date */
81
 
 
82
 
} /* namespace internal */
83
 
} /* namespace drizzled */