Excellent. This is good to know. Unfortunately, this breaks

BTW, I found this in the docs [1]:

[[[
 Beginning with MySQL 4.1.6, you can include the NULL attribute in the
definition of a TIMESTAMP column to allow the column to contain NULL
values. For example:

CREATE TABLE t (
  ts1 TIMESTAMP NULL DEFAULT NULL,
  ts2 TIMESTAMP NULL DEFAULT 0,
  ts3 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
);

Before MySQL 4.1.6 (and even as of 4.1.6 if the NULL attribute is not
specified), setting the column to NULL sets it to the current
timestamp. Note that a TIMESTAMP column which allows NULL values does
not take on the current timestamp unless either its default value is
defined as CURRENT_TIMESTAMP, or either NOW() or CURRENT_TIMESTAMP is
inserted into the column. In other words, a TIMESTAMP column defined
as NULL auto-updates only if it defined using a definition such as the
following:

CREATE TABLE t (ts NULL DEFAULT CURRENT_TIMESTAMP);

Otherwise — that is, if the TIMESTAMP column is defined using NULL but
not using DEFAULT TIMESTAMP, as shown here:

CREATE TABLE t1 (ts NULL DEFAULT NULL);
CREATE TABLE t2 (ts NULL DEFAULT '0000-00-00 00:00:00');

— then you must explicitly insert a value corresponding to the current
date and time, for example:

INSERT INTO t1 VALUES (NOW());
INSERT INTO t2 VALUES (CURRENT_TIMESTAMP);
]]]

I have checked this with DB2 and it works fine:

[[[
CREATE TABLE t1 (  ts1 TIMESTAMP DEFAULT NULL );
]]]

Regards,

Elias

[1] http://dev.mysql.com/doc/refman/4.1/en/timestamp-4-1.html
[2] http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html



On 10/17/05, Allen Gilliland <[EMAIL PROTECTED]> wrote:
> On Sun, 2005-10-16 at 17:12, Elias Torres wrote:
> > I just noticed that change in the schema (date field in weblogentry)
> > too and it breaks DB2 since the field type is not supported. I checked
> > documentation and datetime is also not supported on Derby either.
> > Anyways, I don't know the differences between datetime and timestamp.
> > Why does pubtime need to be a datetime as opposed to a timestamp? Is
> > this something that can be done via a customizable datatype as in
> > TEXT? Just a thought.
>
> I put in the change from Timestamp to Datetime because in Mysql if you insert 
> a NULL value into a Timestamp column then Mysql will automatically set it to 
> the current date/time.  The modification I made to the way pubtime works 
> requires that we be able to save draft entries with a NULL pubtime.
>
> In Mysql the Timestamp and Datetime are the exact same thing except that a 
> Datetime will never be set automatically.
>
> -- Allen
>
>
> >
> > Elias
> >
> > On 10/16/05, Dave Johnson <[EMAIL PROTECTED]> wrote:
> > >
> > > Here's my theory. We changed the weblog entry pubtime into a date field
> > > rather than a timestamp and I bet we didn't test against PostgreSQL (I
> > > know I didn't).
> > >
> > > According to the docs below, we need to do the temp table trick if we
> > > want to change a column type in PostgreSQL:
> > >
> > >     http://techdocs.postgresql.org/techdocs/updatingcolumns.php
> > >
> > > Then, we may have data type issues. I hope PostgreSQL has a compatible
> > > DATETIME field.
> > >
> > > I'm out of the office for the next couple of days, so I won't have a
> > > chance to look into this.
> > >
> > > - Dave
> > >
> > >
> > > On Oct 16, 2005, at 12:19 AM, Henri Yandell wrote:
> > >
> > > > On 10/12/05, Dave Johnson <[EMAIL PROTECTED]> wrote:
> > > >> Is this complete? Can we close the JIRA issues for DB2 and Derby
> > > >> support and if not, what remains to be done?
> > > >>
> > > >> And BTW, the 2.0 bug list is getting pretty slim.
> > > >
> > > > Heh, there I was thinking it had a long time to go; which explained
> > > > the problems I was seeing where posting an entry to a new blog
> > > > buggered it up big time.
> > > >
> > > > http://opensource2.atlassian.com/projects/roller/browse/ROL-844
> > > >
> > >
> > >
> > >
>
>
>

Reply via email to