473,671 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysqldump wraps all trigger code in comments.

25 New Member
I was trying to compare a particular trigger on multiple servers.

First I tried phpMyAdmin to script the trigger code, which unfortunately only worked on one server that has newer version of phpMyAdmin...

Then I used mysqldump, which scripted trigger code on all the servers, bur with comments around all the trigger related code:
/*!50003 SET @SAVE_SQL_MODE= @@SQL_MODE*/;

DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@ `localhost` */ /*!50003 TRIGGER `t_dobj_ins` BEFORE INSERT ON `mytable` FOR EACH ROW BEGIN
...
phpMyAdmine scripted trigger code without comments. Why are those comments there?

I searched thru documents tion on MySQL.com website and found nothing.

Searching for "mysqldump trigger comment" on google triggered lots of hits on bugs.mysql.com, but I found no explanation there. Bugs were about "DEFINER" clause missing, or no space between "ROW" and "BEGIN", etc. There were code samples with those funny comments, but no explanation why they are there and no questions about them.

I tried all the mysqldup options, and I couldn't get rid of comments. How does phpMyAdmin manage to get rid of those comments?

And can I learn more about those comments, such as why are they there in the first place? Is there any documentation anywhere about them?
Sep 17 '09 #1
6 11970
code green
1,726 Recognized Expert Top Contributor
I think they are there for version control.
Not sure what I mean by that but building a MySQL DB in older versions
from mysqldump fails because of the triggers.

Trouble is the commenting out causes failure also.
I update a older version database from MySQL dump and had to write a script that removed the comments and the DELIMITER words also
Sep 18 '09 #2
Marjeta
25 New Member
I just found this in the reference manual:
http://dev.mysql.com/doc/refman/5.0/en/comments.html

This page explains, as you said, that it's related to the version.

I'm still wondering how to get rid of those comments. We have no intentions of going back to 4.* or even 3.*, and the comments make the dump hard to read.
And even if we ever want to go back, I'd prefer to get the error messages, so I could redesign the parts that stop working.

The documentation on mysqldump makes no reference of those comments at all.

So, is there maybe an undocumented option that suppresses them?

Or do I have to write a script that will remove them??? In that case, has anyone already written a script like that so I don't reinvent the wheel?
Sep 18 '09 #3
code green
1,726 Recognized Expert Top Contributor
You can have this chunk of code.
It is by no means a refined function.
It just does the job need
Expand|Select|Wrap|Line Numbers
  1. ///////////////////////////////////////////////////////////////////////
  2.     print '<br>Now remove oneandone version problems ';
  3.     $remove = '/\/\\*[\\s\\S]*?\\*\//';
  4.     $find = 'DELIMITER';
  5.      //Different attempts to remove multiple line comments
  6.     #'(/\*[\w|\W][^\*/]*\*/)';
  7.     #'/\/\*(.|\s)*?\*\//';
  8.     #'/\/\*(?:\w|\s|\.|\n)+\*\//';
  9.  
  10.     if($handle = fopen($dirtyFile,'r'))
  11.     {
  12.         print '<br>Re-opened file';
  13.         $cleanFile = $backupPath.'C'.$filename;
  14.         if($newfile = fopen($cleanFile,'w'))
  15.         {
  16.             print '<br>Opened new file';
  17.             while(!feof($handle))
  18.             {
  19.                 $line = fgets($handle);
  20.                 if(strpos($line,$find)!==false){
  21.                     continue; # Will jump out of loop
  22.                 }
  23.                 $line = preg_replace($remove,'',$line);
  24.                 if(!strcmp(trim($line),';;')){
  25.                     continue; # Will jump out of loop
  26.                }    
  27.                 if(!strcmp(trim($line),';')){
  28.                     continue; # Will jump out of loop
  29.                 }
  30.                 fwrite($newfile,$line);
  31.             }
  32.             print '<br>Copied clean text across';
  33.  
  34.             if(!fclose($handle)){
  35.                 errormessage('Could not close '.$dirtyFile);
  36.                 }    
  37.             if(!fclose($newfile)){
  38.                 errormessage('Could not close '.$cleanFile);
  39.                }    
  40.             if(!unlink($dirtyFile)) #Delete the previous backup
  41.             {
  42.                 errormessage('Could not delete dirtyfile.sql');        
  43.             }        
  44.             if(!rename($cleanFile,$dirtyFile)) 
  45.             {
  46.                 errormessage('Could not rename '.$cleanFile);
  47.             }        
  48.         }
  49.     }
  50.     ///////////////////////////////////////////////////////////////////////
Sep 21 '09 #4
Marjeta
25 New Member
@code green
Thanks for the code. Though it's not what I need. Your code removes the comments completely, while I'd just like to remove the comment marks and keep the code iside comment. For example:
Expand|Select|Wrap|Line Numbers
  1. /*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */
  2. /*!50003 TRIGGER `t_dobj_ins`
  3. BEFORE INSERT ON `mytable` /* insert trigger for mytable */
  4. FOR EACH ROW BEGIN .../*more code*/ */
should be:
Expand|Select|Wrap|Line Numbers
  1. CREATE DEFINER=`root`@`localhost` TRIGGER `t_dobj_ins`
  2. BEFORE INSERT ON `mytable` /* insert trigger for mytable */
  3. FOR EACH ROW BEGIN .../*more code*/ 
This takes a little more work than just a regular expression. I wrote a simple parser in PHP which has 163 lines, and does what I want, but only if comments aren't nested. I need to dig out and dust off my C/Lex/Yacc and do the real thing...

In any case, it seems funny I have to put extra work to remove something that needed extra work to be inserted...

I have tried all the options and none of them seems to have any effect on the /*!ddddd ... */ comments.
Sep 22 '09 #5
code green
1,726 Recognized Expert Top Contributor
Just check that the backup/rebuild works with the comments removed.
I have had further problems from dumps with triggers where DROP TRIGGER IF EXISTS was not present.
Maybe only DROP TRIGGER which caused the query to fail if it did not already exist.or nothing so the query failed because the trigger already existed.

I have been tempted to write my own dump routine
Sep 22 '09 #6
MosheElisha
1 New Member
These are MySQL-specific code comments. Comments with numbers indicate the minimal version of the MySQL server that knows to handle the commented section.

For example, stored procedures did not exist before version 5.0.3 . So all of the stored procedure will be enclosed with comments that look like

/*!50003 */
Nov 28 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1591
by: William F. O'Neill | last post by:
Am using SQL Server 2000 on WINXP Pro. Have a requirement to change some Oracle triggers to SQL 2000. I have modied this one Insert Trigger, but get an error when I attempt to compile: CREATE TRIGGER trg_ins_attend_audit_log ON ATTEND AFTER INSERT -- Insert Trigger for SQL Server AS DECLARE
13
1414
by: Christopher Benson-Manica | last post by:
This is intended to be a simple version of the Unix "head" command, i.e. a utility that displays the first n lines of a file. Comments welcomed... #include <cstdlib> #include <iostream> #include <fstream> #include <sstream> #include <string>
1
1363
by: Tomk | last post by:
I'm using VB.DOC & NDoc for now until Whidbey is released and I'm looking for a way to extract and compile my XML comments for private methods. These tools and I beleive the existing C# doc functions only extract XML for public Fields & Methods. I presume because reflection does not reveal private members. However the XML parser should be able to build the file. Or maybe I'm doing it all wrong which has been known to happen before....
2
1198
by: Ole Olsen | last post by:
Hi When writing code comments (to e.g. methods) in an Interface, this comments does not seem to be transferred to the implementing class? When ever instantiating a class implementing a "commented" interface, none of the comments are shown in IntelliSense? What am I doing wrong?
1
1233
by: Russell Mangel | last post by:
Is it possible to create code comments in VC++ 2003.NET? I have created a Mixed-mode .dll which will be called from C#.NET or VB.NET. When I add a reference to this .net .dll file using C# or Vb.net I am unable to see any code Comments for methods or properties. What am I missing? Thanks Russell Mangel Las Vegas, MV Universal MSDN Subsciption holder
2
1395
by: Mythran | last post by:
I have asked this question here before but was given an answer I didn't like (stubborn I am!). I believe the way my question was interpreted was not as I had hoped...so I am trying again. In C#, code commenting with Intellisense is used. In VB.Net, it's not. Fine, dandy, but not what I am looking for. I just want to write the XML by hand and use it in my library so it displays the intellisense itself, not through code comments <--...
6
1244
by: Steve | last post by:
Hi all, I have just installed the latest version of VBCommenter, but from what I can make out it seems it is not useable in VB.net standard. According to the docs you will only get comments displayed in the IDE if you reference a dll. However vb.net standard cannot compile class libraries, so I am therefore unable to get VBCommenter to build the XML file for a dll. I do compile my own class libraries via the command line. Can...
6
1671
by: planetthoughtful | last post by:
Hi All, I've written my first piece of practical Python code (included below), and would appreciate some comments. My situation was that I had a directory with a number of subdirectories that contained one or more zip files in each. Many of the zipfiles had the same filename (which is why they had previously been stored in separate directories). I wanted to bring all of the zip files (several hundrd in total) down to the common parent...
4
1568
by: Elioth | last post by:
I am creating my own library (.DLL), I need to know the code to put a comments or Tooltip to my library. I want a Tooltip when I choose any function of my library when I working with, like the original library of VB when I press Ctrl & SpaceBar and I put the mouse point over the function name it show me a tooltip with description of this function and short explain of this. ThanKs,
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.