"EXPLAIN PARTITIONS" in MySQL 8 - mysql

In an old project that we have not changed for some time, the following request is used for partitioning:
EXPLAIN PARTITIONS SELECT * FROM table
Then, the list of partitions is retrieved from the column "partitions" of this request result, and the actions to be taken over the partitions are deduced from this list.
This project is deployed and running on multiple servers that use MySQL 5.7.xx.
Now, we are trying to deploy it on our new AWS servers, using RDS instances that run MySQL 8.0.21, but the "EXPLAIN PARTITIONS" request is not recognized, the error is :
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'SELECT * FROM table' at line 1
My questions are:
Is there a MySQL page in which this regression is documented? I read all their pages about the EXPLAIN keyword but could not find any information about it.
Has it been replaced by another syntax that gives the exact same result?

From Features Removed in MySQL 8.0
The EXTENDED and PARTITIONS keywords for the EXPLAIN statement have been removed. These keywords are unnecessary because their effect is always enabled.
So the "new syntax" is simply EXPLAIN SELECT * FROM table.

Related

how to get precise locations of syntax errors in a .sql script?

I'm trying to execute a .sql script which inserts values into a database.
Problem is, there's some issues in the syntax of the script.
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 0.078 sec
But the script is pretty large, a few Mos, so I can't check manually where the error is. According to the error message it should be close to quotes, but sadly all the values inserted are on one line in the script file so the indication "on line 1" is not helpful at all.
Is there a way to get a precise position for the error ? I'd like, in particular, the column number where the syntax is wrong. Is that possible ?
I'm using command of the type :
mysql -u root -p Wikicategory < path\to\script\script.sql
MySQL Workbench uses a different parser (ANTLR4 based) than the MySQL server (yacc based). ANTLR4 based parsers often (but not always) can report errors with a precise location.
I don't think the query is too large. If it were you would get a different error (because the connection buffer would not be large enough).
So, you best option is to reformat the query. For SELECTs you can use MySQL Workbench, but better try Visual Studio Code with the SQLTools plugin. Not the best results there either, but it seems to be able to reformat all types of queries.
Then run the script again to see if you get a better error location.

Issue with MySQL and phpAdmin

I am using MySQL 5.1.5 on a Yahoo Sight Server, with phpMyAdmin as the databse interface.
I use the following Query
UPDATE table_family SET last_name='Smith' WHERE id=1;
Then I get the following error:
Error There seems to be an error in your SQL query. The MySQL server
error output below, if there is any, may also help you in diagnosing
the problem
ERROR: Unknown Punctuation String # 34 STR: =\ SQL: UPDATE
table_family SET last_name=\'Smith\' WHERE id=1;
SQL query:
UPDATE table_family SET last_name=\'Smith\' WHERE id=1;
MySQL said: Documentation
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near '\'Smith\' WHERE id=1' at line 1
Ideas? I feel like its an issue with the database, not with my code. the last_name field is a varchar(50). I actually opened a ticket with support on this issue, but it happened to me on two different domains I have with Yahoo, so that makes me think there is more than I know is going on. I have done this with integer fields that don't require the (') single quote and have had no issues. I have also run my syntax through a local access database I created just to make sure it wan't a syntax issue. Worked perfectly first time. Then I had 2 database guys I know look at it. They think its good too. So now I am lost.
Thanks for any help you can provide.
Andy

SSIS DataFlow error when inserting a MySQL Table

I'm not being able to transfer some SQL-MySQL data using SSIS.
I've done the same thing with other packages for different tables but this time I can't.
Here's a screenshot, data is being retrieved absolutely fine from the SQL server.
And here's a shoot if the progress tab.
First error shown in the Progress tab is as follows:
[dest mysql [190]] Error: An exception has occurred during data insertion, the message returned from the provider is:
ERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.6.16]You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '"persona_id", "franqueos", "reiteros", "pcrc_id", "fecha") VALUES (55, 12, 1, 1,' at line 1
I'm not sure on how to approach the situation in order to solve it.
Thank you.
Your MySQL database needs to have the ANSI_QUOTES SQL_MODE option enabled. Or check whether null is allowed on columns, particularity for fecha field in your mysql database table.
Have a look of this as well: Workaround - Writing to a MySQL database from SSIS Bug

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

I am using Sybase Power Designer to create a database from a physical data model (Sybase creates an SQL file) . When i import the SQL file with phpMyAdmin I have the following error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_CREATES_ARTIST'' at line 7 .
Any ideas? Could this error appear due to errors on the physical model or there is another problem?
This is the code :
if exists(select 1 from sys.sysforeignkey where role='FK_ARTWORK_HAS_BUY') then
alter table artwork
delete foreign key FK_ARTWORK_HAS_BUY
end if;
The error you are getting is from MySQL. Regardless of the tool used to generate SQL, the database seems to be MySQL (or something is terribly wrong with your systems if they are confused and think they are MySQL).
The MySQL if statement (documented here) has to be inside a stored program. That means that this code only compiles inside a stored procedure, user defined function, or trigger. It doesn't "just work" on its own.
In addition, MySQL doesn't have sys tables. It uses information_schema tables. My strongest suggestion is to use tools appropriate for your actual database. If you are using a tool to generate Sybase, then use Sybase as the destination database. If you are using MySQL, then use a tool to generate MySQL code. Or, better yet, learn how to write the commands yourself.
Finally, if you intend to use Sybase, then connect to the correct database and your problem should be fixed.
As I can't post here, and sqlfiddle.com temporary unavailable, I decided to post code with correct syntax for Sybase on the PasteBin

UNION SELECT error 1064 but works if executed on it's own

I've got two mySQL servers - offline is version 5.5.25, online is version 5.0.95. I am attempting to run a UNION SELECT to join two result sets together. Both queries extract the same data from the same tables using the same joins - the only difference to each is the where query. Basic syntax is:
(SELECT QUERY A)
UNION
(SELECT QUERY B)
ORDER BY date_created DESC, subscription_rate_id ASC
If I run this query offline, I get this error:
Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'INNER JOIN webmaster d ON d.dupe_master_id =
webmaster.webmaster_id IN' at line 16
If I run the queries separately then both of them work. If I run the whole query ONLINE, it works. This only occurs in my OFFLINE mySQL which is running the newer mySQL version of the two. I believe the error relates to query B - but the same INNER JOIN is in query A.
The query is horrendously long and not easily shortened / broken down which is why I haven't pasted it here. I will find a way to provide it if absolutely neccessary.
Any help appreciated.
Remove the braces around
FROM (`webmaster`)
to
FROM `webmaster`
See SQL Fiddle for different versions and error message.