1. The document discusses MySQL idiosyncrasies related to data integrity, transactions, and variable scope. It provides examples of unexpected behavior when the default storage engine is MyISAM rather than InnoDB, and the use of SQL modes to enforce data integrity.
2. Transactions examples show data is not rolled back as expected when tables are MyISAM rather than InnoDB.
3. Changing global variables like storage engine does not affect existing or new tables, demonstrating variable scope issues in MySQL.
While MySQL is a popular and widely used RDBMS, some default features and settings are very foreign in comparison with other commercial RDBMS products. In this discussion, Ronald Bradford will discuss some of the MySQL defaults including a non-transactional state, silent data truncations, date management, and transaction isolation options. These are all critical for data integrity and consistency. He will cover in-depth topics including SQL_MODE that saves the day. He will also cover character sets and collations and the best practices to ensure your UTF8 is stored and retrieved correctly.
While MySQL is a popular and widely used RDBMS, some default features and settings are very foreign in comparison with other commercial RDBMS products. In this discussion, Ronald Bradford will discuss some of the MySQL defaults including a non-transactional state, silent data truncations, date management, and transaction isolation options. These are all critical for data integrity and consistency. He will cover in-depth topics including SQL_MODE that saves the day. He will also cover character sets and collations and the best practices to ensure your UTF8 is stored and retrieved correctly.
Tracking Data Updates in Real-time with Change Data CaptureScyllaDB
Change Data Capture is one of the important new features coming to the Scylla NoSQL database. It enables the user to track updates to a table(s) in real time, supporting a variety of use cases, such as:
- Real-time update of microservices based on Scylla updates
Replicating the data, or part of it, between loosely coupled Scylla clusters
- Soft real-time analytics updates based on the stream of Scylla updates
MySQL 8.0 has come up with an exciting addition of window function which can make the developer life more ease with complex SQL's. This presentation will be a walk through over window functions in MySQL 8.0.
http://www.mydbops.com
Tracking Data Updates in Real-time with Change Data CaptureScyllaDB
Change Data Capture is one of the important new features coming to the Scylla NoSQL database. It enables the user to track updates to a table(s) in real time, supporting a variety of use cases, such as:
- Real-time update of microservices based on Scylla updates
Replicating the data, or part of it, between loosely coupled Scylla clusters
- Soft real-time analytics updates based on the stream of Scylla updates
MySQL 8.0 has come up with an exciting addition of window function which can make the developer life more ease with complex SQL's. This presentation will be a walk through over window functions in MySQL 8.0.
http://www.mydbops.com
Revolução na mídia, internet e redes socias - Café na web, dá para comercial...Paulo Henrique Leme
Café na web, dá para comercializar direto?
Aula 1 - Revolução na mídia, internet e redes sociais
Aula apresentada "Curso de Especialização em Gestão do Agronegócio Café" - UDC/Illy - PENSA/USP
Patrocínio, MG
31-07-2010
Paulo Henrique Leme
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
Monitoring MySQL has a long history within Nagios. Several plugins are available already. In addition to that, there are probably lots of plugins that have been developed by the community. We take a look at some of these and discuss what kind of additional useful information could be pulled out of a MySQL Server for monitoring it even better. A simple example on how to write such plugins will be shown, also using NDB API for monitoring MySQL Cluster. Now that MySQL Enterprise Monitor (MEM) is available, we'll go through the possibilities for combining the two platforms. We will also discuss the NDOUtils for storing configuration and event data using MySQL.
This talk starts with a brief overview of MySQL itself: some history, where it's heading too, and why it is so successful.
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)Valeriy Kravchuk
The recently released MariaDB 10.5 GA includes many new, useful features, but I’d like to concentrate on those helping DBAs and support engineers to find out what’s going on when a problem occurs.
Specifically I present and discuss the Performance Schema updates to match MySQL 5.7 instrumentation, new tables in the INFORMATION_SCHEMA to monitor the internals of a generic thread pool and improvements of ANALYZE for statements.
Character Encoding - MySQL DevRoom - FOSDEM 2015mushupl
Character encoding configuration in MySQL has always been a bit confusing. With too many options to set, unclear relationships between them, and the default settings that make MySQL incompatible with most languages, it is a headache to many users, many of whom end up with broken data. This lecture will provide an overview of the character set support in MySQL, guidelines on how to use it correctly, and will demonstrate several methods of detecting and repairing mangled data.
My talk for "MySQL, MariaDB and Friends" devroom at Fosdem on February 2, 2019
Born in 2010 in MySQL 5.5.3 as "a feature for monitoring server execution at a low level," grown in 5.6 times with performance fixes and DBA-faced features, in MySQL 5.7 Performance Schema is a mature tool, used by humans and more and more monitoring products. It becomes more popular over the years. In this talk I will give an overview of Performance Schema, focusing on its tuning, performance, and usability.
Performance Schema helps to troubleshoot query performance, complicated locking issues, memory leaks, resource usage, problematic behavior, caused by inappropriate settings and much more. It comes with hundreds of options which allow precisely tune what to instrument. More than 100 consumers store collected data.
Performance Schema is a potent tool. And very complicated at the same time. It does not affect performance in most cases and can slow down server dramatically if configured without care. It collects a lot of data, and sometimes this data is hard to read.
This talk will start from the introduction of how Performance Schema designed, and you will understand why it slowdowns server in some cases and does not affect your queries in others. Then we will discuss which information you can retrieve from Performance Schema and how to do it effectively.
I will cover its companion sys schema and graphical monitoring tools.
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Tesora
Amrith Kumar of Tesora and Peter Boros of Percona present an in-depth exploration of transparent database scale out use the Tesora DVE framework for MySQL.
Every website wants to become successful. Few websites however undertake the basic and fundamental steps to build a rock solid foundation to ensure a scalable
"Disaster is inevitable" and "To move forward you must first backup" should be known to all software developers. This presentation will discuss all the options for your valuable data assets in MySQL, and highlight how to maintain site reliability of your data
The History and Future of the MySQL ecosystemRonald Bradford
The history and future of the MySQL Ecosystem. This talk sub-titled “Spaghetti and MySQLBalls (with a side of greens)” detailed the beginnings of MySQL, the MySQL acquisition history, described the state of current MySQL versions/variants/forks, storage engines, related vendors, NoSQL and much more.
A video of the presentations is available on YouTube at http://www.youtube.com/watch?v=9mKwkbaB5X8&feature=youtu.be
Lessons Learned Managing Large AWS EnvironmentsRonald Bradford
How to you optimize management of 500+ AWS servers? In this presentation I share my experiences using Amazon Web Servers covering techniques for webscale. Learn how to optimized your cost, handle security, automate and be prepared for handling failure.
Monitoring your technology stack with New RelicRonald Bradford
There is no excuse to not have monitoring of your LAMP stack, NoSQL database like MongoDB/Redis/Cassandra/Memcache, Cloud services and much more when you can use the popular New Relic tool for free. As the MySQL plugin author I can offer the following link will give you access to free monitoring http://j.mp/newrelic-mysql There can never be an excuse to not know how your application is performing, from 1 server to 100+ servers.
Only after a successful preparation covered in IGNITION can you be ready for the implementation and management of a MySQL ecosystem and a successful launch of your product.
We Discuss:
* Escape Options – Before and after backup and recovery situations
* Good to Go – Knowing and confirming your MySQL environment is ready
* Full Throttle – Understanding and Improving MySQL database performance
* A Green Dashboard – Monitoring for Success
* The Human Factor – Nobody is perfect, dealing with the design changes
* Propellant – The murky mess of MySQL versions, patches and variants
* Best Practices – Proven techniques for consistency, automation and reproducibility
Note: This is volume 2 of a two part series
IGNITION is the preparation necessary for a successful launch of a MySQL ecosystem for an Oracle DBA. This volume covers the preparation needed to be ready for ongoing production administration of MySQL.
We discuss:
* Translation – Understanding the MySQL terminology
* Installation – Knowing the options for MySQL distributions
* Protection Detail – Security of MySQL information
* The Dashboard – Understanding what to monitor in MySQL
* Mechanics – Understanding more of MySQL Internals including storage engines
* Redundancy – Maintaining multiple copies via MySQL replication
* Checklists – Double checking and cross referencing your ecosystem
NOTE: This is Volume 1 of a two part series
This presentation discusses the current state of the Drizzle database project including the principles behind this leading open source project, and the healthy and growing community. For more information visit http://drizzle.org
There has been significant movement in recent times towards less structured approaches of storing and retrieving data. No longer the realm of Relational Databases, there is a new crop of structured key/value pair stores and unstructured data offerings. This closing panel debate at Open SQL Camp 2009 discussed the SQL v NoSQL topic.
Example section on MySQL for the Oracle DBA 1 day bootcamp.
In object management we look at the key SQL objects including what differs with Oracle and what is Oracle specific functionality.
We also look at the MySQL data dictionary, the INFORMATION_SCHEMA
2007 MySQL Conference and Expo 90 minute presentation specifically targeting Oracle Developers and DBAs. Topics included.
*DBA Tips, Tricks, Gotcha's & Tools
* Key Differences for Developers
* Migrating from Oracle to MySQL
MySQL for Oracle Developers and the companion MySQL for Oracle DBA's were two presentations for the 2006 MySQL Conference and Expo. These were specifically designed for Oracle resources to understand the usage, syntax and differences between MySQL and Oracle.
Learn how to avoid common mistakes, drill down to understand the true performance impact, and measure performance gains from corrections. Practical examples on configuration, schema, application code changes. Real-life case studies show disk space reduction, increases in throughput, and reduced query execution times.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Connector Corner: Automate dynamic content and events by pushing a button
MySQL Idiosyncrasies That Bite 2010.07
1. Title
MySQL Idiosyncrasies
that BITE
2010.07
Ronald Bradford
http://ronaldbradford.com2010.07
MySQL Idiosyncrasies That BITE - #mysql @ronaldbradford
2. Definitions
idiosyncrasy
[id-ee-uh-sing-kruh-see, -sin-]
–noun,plural-sies.
A characteristic, habit, mannerism, or the
like, that is peculiar to ...
http;//dictionary.com
MySQL Idiosyncrasies That BITE - 2010.07
3. Oracle != MySQL
Age
Development philosophies
Target audience
Developer practices
Installed versions
MySQL Idiosyncrasies That BITE - 2010.07
4. RDBMS Characteristics
Data Integrity
Transactions
ACID
Data Security
ANSI SQL
MySQL Idiosyncrasies That BITE - 2010.07
8. Data Integrity - Expected
CREATE TABLE sample_data (
i TINYINT UNSIGNED NOT NULL,
✔
c CHAR(2) NULL,
t TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET latin1;
INSERT INTO sample_data(i) VALUES (0), (100), (255);
Query OK, 3 rows affected (0.00 sec)
SELECT * FROM sample_data;
+-----+------+---------------------+
| i | c | t |
+-----+------+---------------------+
| 0 | NULL | 2010-06-06 13:28:44 |
| 100 | NULL | 2010-06-06 13:28:44 |
| 255 | NULL | 2010-06-06 13:28:44 |
+-----+------+---------------------+
3 rows in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
9. Data Integrity - Unexpected
✘
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i | c | t |
+-----+------+---------------------+
| 0 | NULL | 2010-06-06 13:28:44 |
| 100 | NULL | 2010-06-06 13:28:44 |
| 255 | NULL | 2010-06-06 13:28:44 |
| 0 | NULL | 2010-06-06 13:32:52 |
| 255 | NULL | 2010-06-06 13:32:52 |
+-----+------+---------------------+
5 rows in set (0.01 sec)
MySQL Idiosyncrasies That BITE - 2010.07
10. Data Integrity - Unexpected
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000); ✘
mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i | c | t |
+-----+------+---------------------+
| 0 | NULL | 2010-06-06 13:28:44 |
| 100 | NULL | 2010-06-06 13:28:44 |
| 255 | NULL | 2010-06-06 13:28:44 |
| 0 | NULL | 2010-06-06 13:32:52 |
| 255 | NULL | 2010-06-06 13:32:52 |
+-----+------+---------------------+
5 rows in set (0.01 sec)
TINYINT is 1 byte.
UNSIGNED supports
values 0-255
MySQL Idiosyncrasies That BITE - 2010.07
11. Data Integrity - Warnings
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
Query OK, 2 rows affected, 2 warnings (0.00 sec)
mysql> SHOW WARNINGS;
+---------+------+--------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------+
| Warning | 1264 | Out of range value for column 'i' at row 1 |
| Warning | 1264 | Out of range value for column 'i' at row 2 |
+---------+------+--------------------------------------------+
MySQL Idiosyncrasies That BITE - 2010.07
12. Data Integrity - Unexpected (2)
mysql> INSERT INTO sample_data (c)
-> VALUES ('A'),('BB'),('CCC');
✘
mysql> SELECT * FROM sample_data WHERE c IS NOT NULL;
+---+------+---------------------+
| i | c | t |
+---+------+---------------------+
| 0 | A | 2010-06-06 13:34:59 |
| 0 | BB | 2010-06-06 13:34:59 |
| 0 | CC | 2010-06-06 13:34:59 |
+---+------+---------------------+
3 rows in set (0.09 sec)
MySQL Idiosyncrasies That BITE - 2010.07
13. Data Integrity - Warnings (2)
mysql> INSERT INTO sample_data (c) VALUES ('A'),('BB'),('CCC');
Query OK, 3 rows affected, 2 warnings (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 1
mysql> SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+ Only listed
| Warning | 1364 | Field 'i' doesn't have a default value |
| Warning | 1265 | Data truncated for column 'c' at row 3 | for 1 row
+---------+------+----------------------------------------+
2 rows in set (0.01 sec)
MySQL Idiosyncrasies That BITE - 2010.07
14. Data Integrity with Dates - Warnings
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS;
✘
+---------+------+----------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------+
| Warning | 1265 | Data truncated for column 'd' at row 1 |
+---------+------+----------------------------------------+
mysql> SELECT * FROM sample_date;
+------------+
| d |
+------------+
| 0000-00-00 |
+------------+
MySQL Idiosyncrasies That BITE - 2010.07
15. SHOW WARNINGS
http://dev.mysql.com/doc/refman/5.1/en/show-warnings.html
MySQL Idiosyncrasies That BITE - 2010.07
16. Using SQL_MODE for Data Integrity
Recommended
Configuration
SQL_MODE =
STRICT_ALL_TABLES;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
MySQL Idiosyncrasies That BITE - 2010.07
17. Data Integrity - Expected
mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> TRUNCATE TABLE sample_data;
✔
mysql> INSERT INTO sample_data(i) VALUES (0), (100), (255);
mysql> INSERT INTO sample_data (i) VALUES (-1), (9000);
ERROR 1264 (22003): Out of range value for column 'i' at row 1
mysql> SELECT * FROM sample_data;
+-----+------+---------------------+
| i | c | t |
+-----+------+---------------------+
| 0 | NULL | 2010-06-06 14:39:48 |
| 100 | NULL | 2010-06-06 14:39:48 |
| 255 | NULL | 2010-06-06 14:39:48 |
+-----+------+---------------------+
3 rows in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
18. Data Integrity with Dates - Expected
mysql> SET SESSION SQL_MODE=STRICT_ALL_TABLES;
mysql> INSERT INTO sample_date (d) VALUES ('2010-02-31');
ERROR 1292 (22007): Incorrect date value: '2010-02-31' for
✔
column 'd' at row 1
MySQL Idiosyncrasies That BITE - 2010.07
19. Data Integrity with Dates - Unexpected
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00');
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05');
✘
mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00');
mysql> SELECT * FROM sample_date;
+------------+
| d |
+------------+
| 2010-00-00 |
| 2010-00-05 |
| 0000-00-00 |
+------------+
MySQL Idiosyncrasies That BITE - 2010.07
20. Using SQL_MODE for Date Integrity
Recommended
Configuration
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
MySQL Idiosyncrasies That BITE - 2010.07
21. Data Integrity with Dates - Expected
mysql> SET SESSION
SQL_MODE='STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE';
✔
mysql> TRUNCATE TABLE sample_date;
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-00');
ERROR 1292 (22007): Incorrect date value: '2010-00-00' for column
'd' at row 1
mysql> INSERT INTO sample_date (d) VALUES ('2010-00-05');
ERROR 1292 (22007): Incorrect date value: '2010-00-05' for column
'd' at row 1
mysql> INSERT INTO sample_date (d) VALUES ('0000-00-00');
ERROR 1292 (22007): Incorrect date value: '0000-00-00' for column
'd' at row 1
mysql> SELECT * FROM sample_date;
Empty set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
23. Transactions Example - Tables
DROP TABLE IF EXISTS parent;
CREATE TABLE parent (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
val VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (val)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
DROP TABLE IF EXISTS child;
CREATE TABLE child (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INT UNSIGNED NOT NULL,
created TIMESTAMP NOT NULL,
PRIMARY KEY (id),
INDEX (parent_id)
) ENGINE=InnoDB DEFAULT CHARSET latin1;
MySQL Idiosyncrasies That BITE - 2010.07
24. Transactions Example - SQL
START TRANSACTION;
INSERT INTO parent(val) VALUES("a");
INSERT INTO child(parent_id,created)
VALUES(LAST_INSERT_ID(),NOW());
# Expecting an error with next SQL
INSERT INTO parent(val) VALUES("a");
ROLLBACK;
SELECT * FROM parent;
SELECT * FROM child;
MySQL Idiosyncrasies That BITE - 2010.07
25. Transactions Example - Expected
...
mysql> INSERT INTO parent (val) VALUES("a");
✔
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'
mysql> ROLLBACK;
mysql> SELECT * FROM parent;
Empty set (0.00 sec)
mysql> SELECT * FROM child;
Empty set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
26. Transactions Example - Tables
MyISAM is the current
DROP TABLE IF EXISTS parent; default if not specified
CREATE TABLE parent (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
val VARCHAR(10) NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (val)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
DROP TABLE IF EXISTS child;
CREATE TABLE child (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INT UNSIGNED NOT NULL,
created TIMESTAMP NOT NULL,
PRIMARY KEY (id),
INDEX (parent_id)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
MySQL Idiosyncrasies That BITE - 2010.07
27. Transactions Example - Unexpected
mysql> INSERT INTO parent (val) VALUES("a");
ERROR 1062 (23000): Duplicate entry 'a' for key 'val'
✘
mysql> ROLLBACK;
mysql> SELECT * FROM parent;
+----+-----+
| id | val |
+----+-----+
| 1 | a |
+----+-----+
1 row in set (0.00 sec)
mysql> SELECT * FROM child;
+----+-----------+---------------------+
| id | parent_id | created |
+----+-----------+---------------------+
| 1 | 1 | 2010-06-03 13:53:38 |
+----+-----------+---------------------+
1 row in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
28. Transactions Example - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected, 1 warning (0.00 sec)
✘
mysql> SHOW WARNINGS;
+---------+-------+-------------------------------------
| Level | Code | Message
|
+---------+------+--------------------------------------
| Warning | 1196 | Some non-transactional changed tables
couldn't be rolled back |
+---------+------+--------------------------------------
MySQL Idiosyncrasies That BITE - 2010.07
29. Transactions Solution
Recommended
mysql> SET GLOBAL storage_engine=InnoDB; Configuration
# my.cnf
[mysqld]
default-storage-engine=InnoDB
# NOTE: Requires server restart
$ /etc/init.d/mysqld stop
$ /etc/init.d/mysqld start
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine
MySQL Idiosyncrasies That BITE - 2010.07
30. Why use Non Transactional Tables?
No transaction overhead
Much faster
Less disk writes
Lower disk space requirements
Less memory requirements
http://dev.mysql.com/doc/refman/5.1/en/storage-engine-compare-transactions.html
MySQL Idiosyncrasies That BITE - 2010.07
32. Variable Scope Example
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL MyISAM is the current
) ENGINE=MyISAM DEFAULT CHARSET=latin1 default if not specified
MySQL Idiosyncrasies That BITE - 2010.07
33. Variable Scope Example (2)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value | Changing in
+----------------+--------+ MySQL 5.5
| storage_engine | MyISAM |
+----------------+--------+
mysql> SET GLOBAL storage_engine='InnoDB';
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
MySQL Idiosyncrasies That BITE - 2010.07
34. Variable Scope Example (3)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
✘
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> DROP TABLE test1;
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> SHOW CREATE TABLE test1G
CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
MySQL Idiosyncrasies That BITE - 2010.07
35. Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
MySQL Idiosyncrasies That BITE - 2010.07
36. Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> SHOW SESSION VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
MySQL Idiosyncrasies That BITE - 2010.07
37. Variable Scope Example (4)
mysql> SHOW GLOBAL VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | InnoDB |
+----------------+--------+
mysql> SHOW SESSION VARIABLES LIKE 'storage_engine';
+----------------+--------+
| Variable_name | Value |
+----------------+--------+
| storage_engine | MyISAM |
+----------------+--------+
MySQL Variables have
two scopes.
SESSION & GLOBAL
MySQL Idiosyncrasies That BITE - 2010.07
38. Variable Scope Syntax
SHOW [GLOBAL | SESSION] VARIABLES;
SET [GLOBAL | SESSION] variable = value;
Default is GLOBAL since 5.0.2
http://dev.mysql.com/doc/refman/5.1/en/set-option.html
http://dev.mysql.com/doc/refman/5.1/en/user-variables.html
MySQL Idiosyncrasies That BITE - 2010.07
39. Variable Scope Precautions
Persistent connections (e.g. Java)
Replication SQL_THREAD
Be careful of existing
connections!
MySQL Idiosyncrasies That BITE - 2010.07
41. Storage Engines Example - Creation
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
✘
) ENGINE=InnoDB DEFAULT CHARSET latin1;
SHOW CREATE TABLE test1G
*************************** 1. row *************
Table: test1
Create Table: CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
MySQL Idiosyncrasies That BITE - 2010.07
42. Storage Engines Example - Creation
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
✘
) ENGINE=InnoDB DEFAULT CHARSET latin1;
SHOW CREATE TABLE test1G
*************************** 1. row *************
Table: test1
Create Table: CREATE TABLE `test1` (
`id` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Even specified the
storage engine reverted
to the default
MySQL Idiosyncrasies That BITE - 2010.07
43. Storage Engines Example - Unexpected
CREATE TABLE test1 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
Query OK, 0 rows affected, 2 warnings (0.13 sec)
SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnoDB' |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+
2 rows in set (0.00 sec)
MySQL Idiosyncrasies That BITE - 2010.07
44. Storage Engines Example - Cause
mysql> SHOW ENGINES;
+------------+---------+-------------------------+--------------+
| Engine | Support | Comment | Transactions |
+------------+---------+-------------------------+--------------+
| InnoDB | NO | Supports transaction... | NULL |
| MEMORY | YES | Hash based, stored i... | NO |
| MyISAM | DEFAULT | Default engine as ... | NO |
MySQL Idiosyncrasies That BITE - 2010.07
45. Storage Engines Example - Unexpected (2)
mysql> CREATE TABLE test1
id INT UNSIGNED NOT NULL
) ENGINE=InnDB DEFAULT CHARSET latin1;
✘
Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql> SHOW WARNINGS;
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1286 | Unknown table engine 'InnDB' |
| Warning | 1266 | Using storage engine MyISAM for table 'test1' |
+---------+------+-----------------------------------------------+
Be careful of spelling
mistakes as well.
MySQL Idiosyncrasies That BITE - 2010.07
46. Using SQL_MODE for Storage Engines
Recommended
Configuration
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE,
NO_ENGINE_SUBSTITUTION;
http://dev.mysql.com/doc/refman/5.1/en/server-sql-mode.html
MySQL Idiosyncrasies That BITE - 2010.07
47. Storage Engines Example - Solution
SET SESSION SQL_MODE=NO_ENGINE_SUBSTITUTION; ✔
DROP TABLE IF EXISTS test3;
CREATE TABLE test3 (
id INT UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET latin1;
ERROR 1286 (42000): Unknown table engine 'InnoDB'
MySQL Idiosyncrasies That BITE - 2010.07
49. Atomicity -
All or nothing
MySQL Idiosyncrasies That BITE - 2010.07
50. Atomicity - Table
DROP TABLE IF EXISTS test1;
CREATE TABLE test1(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
val CHAR(1) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET latin1;
MySQL Idiosyncrasies That BITE - 2010.07
51. Atomicity - Data
INSERT INTO test1(val)
VALUES ('a'),('b'),('c'),('d'),('e'),('f'),('g');
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
| 6 | f |
| 7 | g |
+----+-----+
7 rows in set (0.00 sec)
mysql> UPDATE test1 SET id = 10 - id;
MySQL Idiosyncrasies That BITE - 2010.07
52. Atomicity - Unexpected
mysql> UPDATE test1 SET id = 10 - id;
ERROR 1062 (23000): Duplicate entry '7' for key
✘
'PRIMARY'
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 9 | a |
| 8 | b |
| 3 | c |
| 4 | d |
| 5 | e |
| 6 | f |
| 7 | g |
+----+-----+
MySQL Idiosyncrasies That BITE - 2010.07
53. Atomicity - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
✘
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 9 | a |
| 8 | b |
...
MySQL Idiosyncrasies That BITE - 2010.07
54. Atomicity - Unexpected (2)
mysql> ROLLBACK;
Query OK, 0 rows affected (0.00 sec)
✘
mysql> SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 9 | a |
| 8 | b |
...
Rollback has no effect
on non transactional
tables
MySQL Idiosyncrasies That BITE - 2010.07
55. Atomicity - Transactional Table
ALTER TABLE test1 ENGINE=InnoDB;
DELETE FROM test1 WHERE id > 5;
SELECT * FROM test1;
✘
+----+-----+
| id | val |
+----+-----+
| 3 | c |
| 4 | d |
| 5 | e |
+----+-----+
ROLLBACK;
SELECT * FROM test1;
+----+-----+
| id | val |
+----+-----+
| 3 | c |
| 4 | d |
| 5 | e |
+----+-----+
MySQL Idiosyncrasies That BITE - 2010.07
56. Atomicity - The culprit
mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
MySQL Idiosyncrasies That BITE - 2010.07
57. Atomicity - The culprit
mysql> SHOW GLOBAL VARIABLES LIKE 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit | ON |
+---------------+-------+
The default for
autocommit is ON.
Great care is needed to
change the default.
MySQL Idiosyncrasies That BITE - 2010.07
58. Atomicity - Recommendations
Recommended
Practice
Always wrap SQL in transactions
START TRANSACTION | BEGIN [WORK]
COMMIT
MySQL Idiosyncrasies That BITE - 2010.07
59. Isolation -
Transactions do not affect
other transactions
MySQL Idiosyncrasies That BITE - 2010.07
60. Transaction Isolation - Levels
MySQL supports 4
isolation levels
READ-UNCOMMITTED
READ-COMMITTED
REPEATABLE-READ
SERIALIZABLE
http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html
http://ronaldbradford.com/blog/understanding-mysql-innodb-transaction-isolation-2009-09-24/
MySQL Idiosyncrasies That BITE - 2010.07
61. Transaction Isolation - Default
The default is
REPEATABLE-READ
SET GLOBAL tx_isolation = 'READ-COMMITTED';
This is a mistake
http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/
MySQL Idiosyncrasies That BITE - 2010.07
62. Transaction Isolation - Default
The default is
REPEATABLE-READ
SET GLOBAL tx_isolation = 'READ-COMMITTED';
This is a mistake
Common mistake by
Oracle DBA's
supporting MySQL
http://ronaldbradford.com/blog/dont-assume-common-terminology-2010-03-03/
MySQL Idiosyncrasies That BITE - 2010.07
63. Oracle READ COMMITTED
!=
MySQL READ-COMMITTED
MySQL Idiosyncrasies That BITE - 2010.07
64. Transaction Isolation - Binary Logging Errors
SET GLOBAL tx_isolation='READ-COMMITTED';
Query OK, 0 rows affected (0.00 sec)
✘
mysql> insert into test1 values (1,'x');
ERROR 1598 (HY000): Binary logging not possible.
Message: Transaction level 'READ-COMMITTED' in InnoDB is
not safe for binlog mode 'STATEMENT'
As of 5.1 this requires
further configuration
considerations
MySQL Idiosyncrasies That BITE - 2010.07
65. Durability -
No committed
transactions are lost
MySQL Idiosyncrasies That BITE - 2010.07
66. Data Safety
MyISAM writes/flushes data every statement
Does not flush indexes (*)
InnoDB can relax durability
flush all transactions per second
innodb_flush_log_at_trx_commit
sync_binlog
innodb_support_xa
MySQL Idiosyncrasies That BITE - 2010.07
67. Auto Recovery
InnoDB has it
MyISAM does not - (*) Indexes
MYISAM-RECOVER=FORCE,BACKUP
REPAIR TABLE
myisamchk
MySQL Idiosyncrasies That BITE - 2010.07
68. Recovery Time
InnoDB is consistent
Redo Log file size
Slow performance in Undo (*)
MyISAM grows with data volume
MySQL Idiosyncrasies That BITE - 2010.07
69. InnoDB Auto Recovery Example
InnoDB: Log scan progressed past the checkpoint lsn 0 188755039
100624 16:37:44 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
✔
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 193997824
InnoDB: Doing recovery: scanned up to log sequence number 0 195151897
InnoDB: 1 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 105565 row operations to undo
InnoDB: Trx id counter is 0 18688
100624 16:37:45 InnoDB: Starting an apply batch of log records to the
database...
InnoDB: Progress in percents: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
19 ... 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 12051, file name ./binary-log.
000003
InnoDB: Starting in background the rollback of uncommitted transactions
...
MySQL Idiosyncrasies That BITE - 2010.07
70. MyISAM Repair needed Example
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/
descriptions' is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table: './XXX/descriptions'
✘
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/taggings'
is marked as crashed and should be repaired
100126 22:44:35 [Warning] Checking table: './XXX/taggings'
100126 22:44:35 [ERROR] /var/lib/mysql5/bin/mysqld: Table './XXX/vehicle'
is marked as crashed and should be repaired
MySQL Idiosyncrasies That BITE - 2010.07
72. User Privileges - Practices
Best Practice
CREATE USER goodguy@localhost IDENTIFIED BY 'sakila';
GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON odtug.* TO
✔
goodguy@localhost;
Normal Practice
CREATE USER superman@'%';
GRANT ALL ON *.* TO superman@'%';
✘
http://dev.mysql.com/doc/refman/5.1/en/create-user.html
http://dev.mysql.com/doc/refman/5.1/en/grant.html
MySQL Idiosyncrasies That BITE - 2010.07
73. User Privileges - Normal Bad Practice
GRANT ALL ON *.* TO user@’%’
*.* gives you access to all tables in all schemas
@’%’ give you access from any external location
ALL gives you
ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY
TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, FILE,
INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION
CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOW VIEW,
SHUTDOWN, SUPER, TRIGGER, UPDATE, USAGE
MySQL Idiosyncrasies That BITE - 2010.07
74. User Privileges - Why SUPER is bad
SUPER
Bypasses read_only
Bypasses init_connect
Can Disable binary logging
Change configuration dynamically
No reserved connection
MySQL Idiosyncrasies That BITE - 2010.07
75. SUPER and Read Only
$ mysql -ugoodguy -psakila odtug
mysql> insert into test1(id) values(1);
✔
ERROR 1290 (HY000): The MySQL server is running with the
--read-only option so it cannot execute this statement
$ mysql -usuperman odtug
mysql> insert into test1(id) values(1);
Query OK, 1 row affected (0.01 sec)
✘
MySQL Idiosyncrasies That BITE - 2010.07
76. SUPER and Read Only
$ mysql -ugoodguy -psakila odtug
mysql> insert into test1(id) values(1);
ERROR 1290 (HY000): The MySQL server is running with the
--read-only option so it cannot execute this statement ✔
$ mysql -usuperman odtug
mysql> insert into test1(id) values(1);
Query OK, 1 row affected (0.01 sec)
✘
Data inconsistency
now exists
MySQL Idiosyncrasies That BITE - 2010.07
77. SUPER and Init Connect
Common configuration
#my.cnf practice to support
[client] UTF8
init_connect=SET NAMES utf8
This specifies to use UTF8 for communication with client
and data
MySQL Idiosyncrasies That BITE - 2010.07
78. SUPER and Init Connect (2)
MySQL Idiosyncrasies That BITE - 2010.07
79. SUPER and Init Connect (2)
✔
$ mysql -ugoodguy -psakila odtug
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
+--------------------------+----------+
MySQL Idiosyncrasies That BITE - 2010.07
80. SUPER and Init Connect (2)
✔ $ mysql -usuperman odtug
$ mysql -ugoodguy -psakila odtug
✘
mysql> SHOW SESSION VARIABLES LIKE
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
'character%';
+--------------------------+----------+
+--------------------------+----------+
| Variable_name | Value
| Variable_name| | Value |
+--------------------------+----------+
+--------------------------+----------+
| character_set_client | character_set_client
| utf8 | | latin1 |
| character_set_connection | utf8 |
| character_set_connection | latin1 |
| character_set_database character_set_database
| | latin1 | | latin1 |
| character_set_filesystem | binary |
| character_set_filesystem | binary |
| character_set_results | character_set_results
| utf8 | | latin1 |
| character_set_server | character_set_server
| latin1 | | latin1 |
| character_set_system | character_set_system
| utf8 | | utf8 |
+--------------------------+----------+
+--------------------------+----------+
MySQL Idiosyncrasies That BITE - 2010.07
81. SUPER and Init Connect (2)
✔ $ mysql -usuperman odtug
$ mysql -ugoodguy -psakila odtug
✘
mysql> SHOW SESSION VARIABLES LIKE
mysql> SHOW SESSION VARIABLES LIKE 'ch%';
'character%';
+--------------------------+----------+
+--------------------------+----------+
| Variable_name | Value
| Variable_name| | Value |
+--------------------------+----------+
+--------------------------+----------+
| character_set_client | character_set_client
| utf8 | | latin1 |
| character_set_connection | utf8 |
| character_set_connection | latin1 |
| character_set_database character_set_database
| | latin1 | | latin1 |
| character_set_filesystem | binary |
| character_set_filesystem | binary |
| character_set_results | character_set_results
| utf8 | | latin1 |
| character_set_server | character_set_server
| latin1 | | latin1 |
| character_set_system | character_set_system
| utf8 | | utf8 |
+--------------------------+----------+
+--------------------------+----------+
Data integrity can be
compromised
MySQL Idiosyncrasies That BITE - 2010.07
82. SUPER and Binary Log
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| binary-log.000001 | 354 | | |
+-------------------+----------+--------------+------------------+
mysql> DROP TABLE time_zone_leap_second;
mysql> SET SQL_LOG_BIN=0;
mysql> DROP TABLE time_zone_name;
mysql> SET SQL_LOG_BIN=1;
mysql> DROP TABLE time_zone_transition;
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| binary-log.000001 | 674 | | |
+-------------------+----------+--------------+------------------+
MySQL Idiosyncrasies That BITE - 2010.07
83. SUPER and Binary Log (2)
$ mysqlbinlog binary-log.000001 --start-position=354 --stop-position=674
# at 354
#100604 18:00:08 server id 1 end_log_pos 450 Query thread_id=1 exec_time=0
error_code=0
use mysql/*!*/;
SET TIMESTAMP=1275688808/*!*/;
✘
DROP TABLE time_zone_leap_second
/*!*/;
# at 579
#100604 18:04:31 server id 1 end_log_pos 674 Query thread_id=2 exec_time=0
error_code=0
use mysql/*!*/;
SET TIMESTAMP=1275689071/*!*/;
DROP TABLE time_zone_transition
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
Data auditability is now
compromised
MySQL Idiosyncrasies That BITE - 2010.07
84. SUPER and reserved connection
$ mysql -uroot ✔
mysql> show global variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 3 |
+-----------------+-------+
1 row in set (0.07 sec)
mysql> show global status like 'threads_connected';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_connected | 4 |
+-------------------+-------+ When connected
correctly, 1 connection
is reserved for SUPER
MySQL Idiosyncrasies That BITE - 2010.07
85. SUPER and reserved connection - Unexpected
$ mysql -uroot
ERROR 1040 (HY000): Too many connections
✘
mysql> SHOW PROCESSLIST;
+----+------+-----------+-------+---------+------+------------+---------------
| Id | User | Host | db | Command | Time | State | Info
+----+------+-----------+-------+---------+------+------------+---------------
| 13 | root | localhost | odtug | Query | 144 | User sleep | UPDATE test1 ...
| 14 | root | localhost | odtug | Query | 116 | Locked | select * from test1
| 15 | root | localhost | odtug | Query | 89 | Locked | select * from test1
When application
users all use SUPER,
administrator can't
diagnose problem
MySQL Idiosyncrasies That BITE - 2010.07
87. Group By Example
SELECT country, COUNT(*) AS color_count
FROM flags
GROUP BY country;
✔
+-----------+-------------+
| country | color_count |
+-----------+-------------+
| Australia | 3 |
| Canada | 2 |
| Japan | 2 |
| Sweden | 2 |
| USA | 3 |
+-----------+-------------+
SELECT country, COUNT(*)
✘
FROM flags;
+-----------+----------+
| country | COUNT(*) |
+-----------+----------+
| Australia | 12 |
+-----------+----------+
MySQL Idiosyncrasies That BITE - 2010.07
88. Group By Example (2)
SET SESSION sql_mode=ONLY_FULL_GROUP_BY;
✔
SELECT country, COUNT(*)
FROM flags;
ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...)
with no GROUP columns is illegal if there is no GROUP BY clause
http://ExpertPHPandMySQL.com Chapter 1 - Pg 31
MySQL Idiosyncrasies That BITE - 2010.07
89. Using SQL_MODE for ANSI SQL
Recommended
Configuration
SQL_MODE =
STRICT_ALL_TABLES,
NO_ZERO_DATE,
NO_ZERO_IN_DATE,
NO_ENGINE_SUBSTITUTION,
ONLY_FULL_GROUP_BY;
MySQL Idiosyncrasies That BITE - 2010.07
91. Case Sensitivity String Comparison
SELECT 'USA' = UPPER('usa');
+----------------------+
| 'USA' = UPPER('usa') |
+----------------------+
| 1 |
+----------------------+
SELECT 'USA' = 'USA', 'USA' = 'Usa', 'USA' = 'usa',
'USA' = 'usa' COLLATE latin1_general_cs AS different;
+---------------+---------------+---------------+-----------+
| 'USA' = 'USA' | 'USA' = 'Usa' | 'USA' = 'usa' | different |
+---------------+---------------+---------------+-----------+
| 1 | 1 | 1 | 0 |
+---------------+---------------+---------------+-----------+
SELECT name, address, email
FROM customer
✘
This practice is
WHERE name = UPPER('bradford')
unnecessary as does not
utilize index if exists
MySQL Idiosyncrasies That BITE - 2010.07
92. Case Sensitivity Tables
# Server 1
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);
# Server 2
mysql> CREATE TABLE test1(id INT UNSIGNED NOT NULL);
mysql> INSERT INTO test1 VALUES(1);
mysql> INSERT INTO TEST1 VALUES(2);
ERROR 1146 (42S02): Table 'test.TEST1' doesn't exist
MySQL Idiosyncrasies That BITE - 2010.07
93. Case Sensitivity Tables (2) - Operating Specific Settings
# Server 1 - Mac OS X / Windows Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | ON |
| lower_case_table_names | 2 |
+------------------------+-------+
# Server 2 - Linux Default
mysql> SHOW GLOBAL VARIABLES LIKE 'lower%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| lower_case_file_system | OFF |
| lower_case_table_names | 0 |
+------------------------+-------+
Be careful. This default
varies depending on
Operating System
MySQL Idiosyncrasies That BITE - 2010.07
95. Other features the BITE
Character Sets
Data/Client/Application/Web
Sub Queries
Rewrite as JOIN when possible
Views
No always efficient
Cascading Configuration Files
SQL_MODE's not to use
MySQL Idiosyncrasies That BITE - 2010.07
97. DON'T
ASSUME
MySQL Idiosyncrasies That BITE - 2010.07
98. Conclusion - The story so far
MySQL Idiosyncrasies that BITE
Definitions, Relational Database [Structure/Requirements], Oracle != MySQL, RDBMS Characteristics,
Data Integrity [Expected | Unexpected | Warnings | Unexpected (2) | Warnings (2) ],
Using SQL_MODE for Data Integrity,
Data Integrity [ Expected ], Data Integrity with Dates [Expected | Unexpected ],
Using SQL_MODE for Date Integrity, Data Integrity with Dates [Expected ],
Transactions Example [ Tables | SQL | Expected | Using MyISAM | Unexpected [ (2)],
Transactions Solution, Why use Non Transactional Tables?
Variable Scope Example [ | (2)| (3)| [4])| Syntax
Storage Engines Example [Creation | Unexpected | Cause | Unexpected (2) ]
Using SQL_MODE for Storage Engines, Storage Engines Example [Solution]
Atomicity [ Table | Data | Unexpected | Unexpected (2) | Transactional Table | The culprit | Recommendations ]
Transaction Isolation [ Levels | Default | Binary Logging ]
Durablilty [ Auto Recovery]
User Privileges [Practices | Normal Bad Practice | Why SUPER is bad ]
SUPER and [ Read Only | Init Connect [(2)] | Binary Log [2] | Reserved Connection [2] ]
Group by Example [2], Using SQL_MODE for ANSI SQL
Case Sensitivity [ String Comparison | Tables [2] ]
More Gotchas, Character Sets, Sub Queries, Views
Conclusion [ DON'T ASSUME | The Story so far | SQL_MODE ] RonaldBradford.com
MySQL Idiosyncrasies That BITE - 2010.07