MariaDB - CONNECT ENGINE - ORDER BY error - mysql

I'm trying to get Asterisk CDR records from MySQL table (5.5.45) by CONNECT engine on other server running MariaDB (10.0.29).
I can create the connection between table easily:
CREATE TABLE `calls` engine=CONNECT table_type=MYSQL
CONNECTION='mysql://user#IP/asteriskcdrdb/calls';
When I run simple SELECT * FROM calls, everything works good, when I add some WHERE conditions, still everything okay.
But the problem start when I add ORDER BY column parameter, then I got this error from MariaDB:
#1032 - Can't find record in 'calls'
I checked MySQL log, MariaDB log - there are no errors at all.
Did I miss something?
Thank you!
Update: The whole query is simple:
SELECT * FROM `calls` ORDER BY `calldate`
The table structure:
CREATE TABLE `calls` (
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`uniqueid` varchar(32) NOT NULL default '',
`userfield` varchar(255) NOT NULL default '',
`recordingfile` varchar(255) NOT NULL default '',
`cnum` varchar(40) NOT NULL default '',
`cnam` varchar(40) NOT NULL default '',
`outbound_cnum` varchar(40) NOT NULL default '',
`outbound_cnam` varchar(40) NOT NULL default '',
`dst_cnam` varchar(40) NOT NULL default '',
`call_charge` float NOT NULL default '0',
`from_did` varchar(30) NOT NULL,
`did` varchar(50) NOT NULL default '',
`user_id` int(8) unsigned default NULL,
`client_id` int(8) unsigned default NULL,
KEY `IDX_UNIQUEID` (`uniqueid`),
KEY `src` (`src`),
KEY `dst` (`dst`),
KEY `calldate` (`calldate`),
KEY `uniqueid` (`uniqueid`),
KEY `userfield` (`userfield`),
KEY `from_did` (`from_did`),
KEY `user_id` (`user_id`),
KEY `client_id` (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Update #2: Update the table names, to don't confuse, but it's not the issue. The CONNECTION table is created okay.
Query works:
SELECT * FROM `calls`
Query works:
SELECT * FROM `calls` WHERE `user_id`=X
Query return error:
SELECT * FROM `calls` ORDER BY `calldate`
Update #3: The MySQL was updated to veriosn 5.5.45, the type was changed to InnoDB and the charset was converted to UTF8. But no success.
PROBLEM SOLVED
Well, it's MariaDB bug, when I changed to FederatedX engine (which is basically little bit limited version of CONNECT), everything works as expected.

In your query you do
SELECT * FROM calls
but in your table structure you have
CREATE TABLE cdr
and both have calldate column. Check if you querying the right table.

Related

Table doesn't appear to be accepting new rows?

It has come to my attention that one of my websites is not allowing users to register. Upon looking through the table and running through different scenarios it appears as if my table isn't allowing any more rows.
I'm on PHP 7.0 running MariaDB on cPanel. My table was at 499 rows and I could not add a new user from the script I haven't changed in years. I tested the code on a new table and it inserted the value just fine and the rest of the script executes just fine. This is leading me to believe it's something with the table.
CREATE TABLE `members` (
`id` int(10) NOT NULL,
`name` varchar(30) NOT NULL DEFAULT '',
`ipaddress` varchar(15) NOT NULL DEFAULT '',
`salt` varchar(32) NOT NULL DEFAULT '',
`gender` varchar(10) NOT NULL DEFAULT '',
`country` varchar(2) NOT NULL DEFAULT '',
`password` varchar(33) NOT NULL DEFAULT '',
`email` varchar(400) NOT NULL DEFAULT '',
`lastactive` varchar(20) NOT NULL DEFAULT '',
`photo` varchar(100) NOT NULL DEFAULT '',
`about` text NOT NULL,
`intrests` text NOT NULL,
`aim` varchar(15) NOT NULL DEFAULT '',
`yahoo` varchar(25) NOT NULL DEFAULT '',
`msn` varchar(25) NOT NULL DEFAULT '',
`website` varchar(30) NOT NULL DEFAULT '',
`points` int(10) NOT NULL DEFAULT 0,
`view` char(1) NOT NULL DEFAULT '',
`joined` timestamp NOT NULL DEFAULT current_timestamp(),
`act` char(1) NOT NULL DEFAULT '',
`xlink` varchar(30) NOT NULL,
`isstaff` int(1) NOT NULL DEFAULT 0,
`stgr` int(3) NOT NULL,
`rights` int(3) NOT NULL,
`stpr` int(10) NOT NULL,
`trs` varchar(30) NOT NULL,
`sttitle` varchar(60) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Indexes for table `members`
--
ALTER TABLE `members`
ADD PRIMARY KEY (`id`),
ADD KEY `id` (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `members`
--
ALTER TABLE `members`
MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=502;
COMMIT;
///Here is the insert code for my PHP script
mysqli_query($connection, "INSERT INTO members (name,ipaddress,salt,gender,country,password,email,act) VALUES (
'".mysqli_real_escape_string( $connection, $member['name'])."',
'".mysqli_real_escape_string( $connection, $ip)."',
'".mysqli_real_escape_string( $connection, $enurl)."',
'".mysqli_real_escape_string( $connection, $member['gender'])."',
'".mysqli_real_escape_string( $connection, $member['country'])."',
'".mysqli_real_escape_string( $connection, $pass2)."',
'".mysqli_real_escape_string( $connection, $member['email'])."',
'".mysqli_real_escape_string( $connection, $anumber)."')");
My error_log does not populate with any errors nor is there an error dumped on the page. Like I said the script runs it's course just fine inserting these same details into other tables.

MySQL Update query hangs - Time exceeded

Hello I have trouble running mysql update cross databases. MySQL UPDATE query hangs with error - Lock wait timeout exceeded; try restarting transaction. I know similar questions have been already raised but could not find any working solution. I am using this query inside of the PHP script. BUt when I run it within mysql server it does the same thing. When I kill the process, it completes. Here is what hangs. PS: This started like 2 days ago, before that, the query ran without problem. Temp table is filled only when admin pushes there data from html form. 'Teams to esc' table grows like 20 rows per day.
UPDATE query -
UPDATE escalations.teams_to_esc
JOIN domguard.temp_table ON escalations.teams_to_esc.ticket_number = domguard.temp_table.task_number
AND
escalations.teams_to_esc.team = domguard.temp_table.team
SET
escalations.teams_to_esc.`status` = domguard.temp_table.`status`,
escalations.teams_to_esc.`wiw_assigned` = domguard.temp_table.`person`
WHERE
(escalations.teams_to_esc.team,escalations.teams_to_esc.ticket_number) IN
(SELECT domguard.temp_table.team, domguard.temp_table.task_number
FROM domguard.temp_table);
First table - temp_table
CREATE TABLE `temp_table` (
`ID` INT(32) NOT NULL AUTO_INCREMENT,
`task_number` INT(10) NULL DEFAULT '0',
`type` VARCHAR(50) NULL DEFAULT '0',
`assign_date` DATE NULL DEFAULT NULL,
`team` VARCHAR(50) NULL DEFAULT NULL,
`person` VARCHAR(50) NULL DEFAULT NULL,
`task` VARCHAR(50) NULL DEFAULT NULL,
`comment` TEXT NULL,
`short_text` VARCHAR(500) NULL DEFAULT NULL,
`delay_comment` VARCHAR(500) NULL DEFAULT NULL,
`color` VARCHAR(500) NULL DEFAULT NULL,
`status` VARCHAR(500) NULL DEFAULT NULL,
`end_time` TIME NULL DEFAULT NULL,
`tel_it` INT(2) NULL DEFAULT '0',
`co_allocation` VARCHAR(500) NULL DEFAULT '0',
`co_allocation_text` VARCHAR(500) NULL DEFAULT '0',
`delay_code_text` VARCHAR(500) NULL DEFAULT '0',
PRIMARY KEY (`ID`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2483
;
Second table
CREATE TABLE `teams_to_esc` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`esc` INT(11) NOT NULL,
`team` VARCHAR(500) NOT NULL,
`ticket_number` VARCHAR(500) NOT NULL,
`closed_time` DATE NOT NULL,
`checked` VARCHAR(500) NULL DEFAULT NULL,
`reaction_from_tl` VARCHAR(50) NULL DEFAULT NULL,
`status` VARCHAR(50) NULL DEFAULT NULL,
`wiw_assigned` VARCHAR(50) NULL DEFAULT NULL,
PRIMARY KEY (`ID`),
INDEX `esc` (`esc`),
CONSTRAINT `teams_to_esc_ibfk_1` FOREIGN KEY (`esc`) REFERENCES `main_table` (`ID`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
AUTO_INCREMENT=2670
;
=== ERROR INVESTIGATING ===
Output from SHOW processlist;
17107338 root localhost \N Query 1278 Sending data UPDATE escalations.teams_to_esc JOIN domguard.temp_table ON
escalations.teams_to_esc.ticket_number
Output from Transaction settings
SELECT ##GLOBAL.tx_isolation, ##tx_isolation, ##session.tx_isolation;

Create table in magento module

I am new in magento. How can I create table in db ? I tried some code, but table didn't create. But in core_resource table I have setup my table. The version of my php file is match with version of my config file. Help me please, I am looking answer for that question two days , but nowhere can find anything.
There are many ways to create a table.
You can create table by direct phpmyadmin
write own sql and run that by php file
Both ways are applicable on magento too.
but if you are trying to create your own table by your own custom module then you have to play with xml and magento models.
I am providing you an example of module.
XML
<models>
<magenotification>
<class>Magestore_Magenotification_Model</class>
<resourceModel>magenotification_mysql4</resourceModel>
</magenotification>
<magenotification_mysql4>
<class>Magestore_Magenotification_Model_Mysql4</class>
<entities>
<magenotification>
<table>magenotification</table>
</magenotification>
<feedback>
<table>magenotification_extension_feedback</table>
</feedback>
<feedbackmessage>
<table>magenotification_extension_feedbackmessage</table>
</feedbackmessage>
<logger>
<table>magenotification_log</table>
</logger>
<license>
<table>magenotification_license</table>
</license>
</entities>
</magenotification_mysql4>
</models>
SQL
<?php
$installer = $this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('magenotification_extension_feedbackmessage')};
DROP TABLE IF EXISTS {$this->getTable('magenotification_extension_feedback')};
DROP TABLE IF EXISTS {$this->getTable('magenotification_log')};
DROP TABLE IF EXISTS {$this->getTable('magenotification')};
CREATE TABLE {$this->getTable('magenotification')} (
`magenotification_id` int(11) unsigned NOT NULL auto_increment,
`notification_id` int(10) unsigned NOT NULL,
`url` varchar(255) NOT NULL default '',
`added_date` datetime NOT NULL,
UNIQUE (`notification_id`, `url`),
PRIMARY KEY (`magenotification_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_log')} (
`log_id` int(11) unsigned NOT NULL auto_increment,
`extension_code` varchar(100) NOT NULL default '',
`license_type` varchar(50) NOT NULL default '',
`license_key` text NOT NULL default '',
`check_date` date NOT NULL,
`sum_code` varchar(255),
`response_code` smallint(5),
`expired_time` varchar(255),
`is_valid` tinyint(1),
PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_extension_feedback')} (
`feedback_id` int(11) unsigned NOT NULL auto_increment,
`code` varchar(255) NOT NULL default '',
`extension` varchar(255) NOT NULL default '',
`extension_version` varchar(50) NOT NULL default '',
`coupon_code` varchar(255) NOT NULL default '',
`coupon_value` varchar(50) NOT NULL default '',
`expired_counpon` datetime NOT NULL,
`content` text NOT NULL default '',
`file` text NOT NULL default '',
`comment` text NOT NULL default '',
`latest_message` text NOT NULL default '',
`latest_response` text NOT NULL default '',
`latest_response_time` datetime,
`status` tinyint(1) NOT NULL DEFAULT '3',
`is_sent` tinyint(1) NOT NULL DEFAULT '2',
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`feedback_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_extension_feedbackmessage')} (
`feedbackmessage_id` int(11) unsigned NOT NULL auto_increment,
`feedback_id` int(11) unsigned NOT NULL,
`feedback_code` varchar(255) NOT NULL default '',
`user` varchar(255) NOT NULL default '',
`is_customer` tinyint(1) default '2',
`message` text NOT NULL default '',
`file` text NOT NULL default '',
`posted_time` datetime NULL,
`is_sent` tinyint(1) default '2',
PRIMARY KEY (`feedbackmessage_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
You have to learn how to create custom module in magento for more information.
custom module with database

MySQL INSERT results in duplicate key, but no duplicate exists

I have read through many entries that people have claimed to have this problem and they've solved their issue but none of their answers solve MY issue. I am using phpMyAdmin to update the email address of a user. The "user_email" field is marked as UNIQUE. Whenever I update the email address to his actual email, I get:
Duplicate entry 'user#example.com' for key 'user_email'
I have Analyzed, Optimized, and Repaired the table and no errors appear -- everything comes up as OK.
I have run several SQL statements to find any duplication only to find out that none exists.
I even exported the table and imported the records again. I add the indexes and try and update... duplicate entry message. Here's the table structure:
CREATE TABLE IF NOT EXISTS `users` (
`id` bigint(20) NOT NULL,
`md5_id` varchar(200) NOT NULL DEFAULT '',
`full_name` tinytext,
`user_name` varchar(200) DEFAULT NULL,
`user_email` varchar(220) DEFAULT NULL,
`user_level` tinyint(4) NOT NULL DEFAULT '1',
`pwd` varchar(220) NOT NULL DEFAULT '',
`address` text COLLATE latin1_general_ci,
`country` varchar(200) DEFAULT NULL,
`tel` varchar(200) NOT NULL DEFAULT '',
`fax` varchar(200) DEFAULT NULL,
`website` text,
`date` date NOT NULL DEFAULT '0000-00-00',
`users_ip` varchar(200) NOT NULL DEFAULT '',
`approved` int(1) NOT NULL DEFAULT '0',
`activation_code` int(10) NOT NULL DEFAULT '0',
`banned` int(1) NOT NULL DEFAULT '0',
`ckey` varchar(220) NOT NULL DEFAULT '',
`ctime` varchar(220) NOT NULL DEFAULT '',
`location` tinyint(4) NOT NULL DEFAULT '9'
) ENGINE=MyISAM AUTO_INCREMENT=210 DEFAULT CHARSET=latin1;
ALTER TABLE `users` ADD PRIMARY KEY (`id`);
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=210;
Even now that I have REMOVED the UNIQUE index from the 'user_email' field, the error is STILL coming up. I REALLY don't understand that (Maybe something residual...? I'm just guessing).
Picture me with wads of hair in my hands. Can anyone please help?
UPDATE:
Here's the output from SHOW CREATE TABLE users
Here's the output from SHOW INDEX FROM users
Error message while editing:
Error message without using database name:
Output of: SHOW CREATE TABLE proctor.users

Cocoa UltraSms Database structure

Here's a quicky:
Can someone tell me the table structure that cocoa ultrasms creates or give me a link to a dump of the database? (2 tables)
Cocoa UltraSms is mac only, but I only have my windows machine with me, and I need to recreate the database structure.
well, just in case someone else would ever need it ... smsin tabel:
CREATE TABLE `smsin` (
`id` int(11) unsigned NOT NULL auto_increment,
`service` varchar(20) NOT NULL default '',
`service_number_type` varchar(16) NOT NULL default 'Unknown',
`service_number_npi` varchar(16) NOT NULL default 'Unknown',
`status_report_sent` int(1) unsigned NOT NULL default '0',
`sender` varchar(20) NOT NULL default '',
`sender_number_type` varchar(16) NOT NULL default 'Unknown',
`sender_number_npi` varchar(16) NOT NULL default 'Unknown',
`timestmp` varchar(14) NOT NULL default '',
`message` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;