hellios78 / flexviews

Automatically exported from code.google.com/p/flexviews
0 stars 0 forks source link

flexcdc dies when trying to insert a DATETIME field #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Have flexCDC monitor a table which has a DATETIME field 
2. Modify the source table
3. Watch flexcdc.err for an error 

What is the expected output? What do you see instead?

"timestamp" fields are ok, but "datetime" fields cause an error

flexcdc.err --------------------------------
SQL_ERROR IN STATEMENT:
INSERT INTO `flexviews`.`example_table` VALUES (1, @fv_uow_id, 
1,'test1','test2',2011-04-28 11:10:28,from_unixtime(1303985428))

What version of the product are you using? On what operating system?
1.7 (latest) - fedora 14 w/ mysql-server-5.1.56-1.fc14.x86_64

Please provide any additional information below.

The bin log doesn't quote the time like it does for a string, so I suppose it's 
up to the app to quote it. The following patch fixes the problem for me:

@@ -598,6 +598,7 @@
                        $datatype = $this->table_ordinal_datatype($this->tables[$table]['schema'],$this->tables[$table]['table'],count($row)+1);

                        if($datatype=='timestamp') $col = 'from_unixtime(' . $col . ')';
+                       if($datatype=='datetime') $col = "'" . 
mysql_real_escape_string(trim($col,"'")) . "'";
                        $row[] = $col;
                    }

Original issue reported on code.google.com by adri...@magmadigital.co.uk on 28 Apr 2011 at 11:18

GoogleCodeExporter commented 9 years ago
Thank you for your submission.  

This is a regression introduced when adding support for TIMESTAMP columns.

This fix will be included in the next release of Flexviews.

Original comment by justin.s...@percona.com on 28 Apr 2011 at 2:38

GoogleCodeExporter commented 9 years ago
SVN includes fixes for DATETIME and INT UNSIGNED.

This isn't a complete fix yet.  I need to add support for all datatypes which 
support UNSIGNED values.  I will add a test case which includes all data types.

Original comment by justin.s...@percona.com on 30 Apr 2011 at 3:11

GoogleCodeExporter commented 9 years ago
Fixed in latest SVN.

These data types have been tested: 
TIMESTAMP
DATETIME
INT (ALL FLAVORS) SIGNED AND UNSIGNED
DECIMAL SIGNED AND UNSIGNED
FLOAT/DOUBLE SIGNED AND UNSIGNED <-- DON'T USE FLOAT/DOUBLE, GREAT LOSS OF 
PRECISION!!!
BIT
ENUM

Original comment by greenlion@gmail.com on 1 Jul 2012 at 9:11