- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
how to print barcode in c# net ADDING FUNCTIONS AND COMMANDS TO MYSQL in Font
CHAPTER 8 ADDING FUNCTIONS AND COMMANDS TO MYSQL QR Code Creation In None Using Barcode maker for Font Control to generate, create Quick Response Code image in Font applications. www.OnBarcode.comUSS-128 Generator In None Using Barcode printer for Font Control to generate, create GS1-128 image in Font applications. www.OnBarcode.comLet s assume you want to add a command to the server to show the current disk usage of all of the databases in the server. Although there are external tools that can retrieve this information, you desire a SQL equivalent function that you can easily use in your own databasedriven applications. Let s also assume you want to add this as a SHOW command. Specifically, you want to be able to execute the command SHOW DISK_USAGE and retrieve a result set that has each database listed as a row along with the total size of all of the files (tables) listed in kilobytes. Adding a new SQL command involves adding symbols to the lexical analyzer and adding the SHOW DISK_USAGE command syntax to the YACC parser (sql_yacc.yy). The new parser must be compiled into a C program by Bison and then a new lexical hash created using the gen_lex_hash utility described earlier. The code for the parser to direct control to the new command is placed in the large case statement in sql_parse.cc with a case for the new command symbol. Let s begin with adding the symbols to the lexical analyzer. Open the lex.h file and locate the static SYMBOL symbols[] array. You can make the symbol anything you want, but it should be something meaningful (like all good variable names). Be sure to choose a symbol that isn t already in use. In this case, use the symbol DISK_USAGE. This acts like a label to the parser identifying it as a token. Place a statement in the array to direct the lexical analyzer to generate the symbol and call it DISK_USAGE_SYM. The list is in (roughly) alphabetic order, so place it in the proper location. Listing 8-17 shows an excerpt of the array with the symbols added. Listing 8-17. Updates to the lex.h File for the SHOW DISK_USAGE Command static SYMBOL symbols[] = { { "&&", SYM(AND_AND_SYM)}, ... { "DISK", SYM(DISK_SYM)}, /* BEGIN CAB MODIFICATION */ /* Reason for Modification: */ /* This section identifies the tokens for the SHOW DISK_USAGE command*/ { "DISK_USAGE", SYM(DISK_USAGE_SYM)}, /* END CAB MODIFICATION */ { "DISTINCT", SYM(DISTINCT)}, ... The next thing you need to do is add a mnemonic to identify the command. This mnemonic will be used in the parser to assign to the internal query structure and to control the flow of execution via a case in the large switch statement in the sql_parse.cc file. Open the sql_lex.h file and add the new command to the enum_sql_command enumeration. Listing 8-18 shows the modifications with the new command mnemonic. Listing 8-18. Changes to the sql_lex.h File for the SHOW DISK_USAGE Command enum enum_sql_command { SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE, SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT, SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX, ... UPC Symbol Generation In None Using Barcode printer for Font Control to generate, create UPC Symbol image in Font applications. www.OnBarcode.comCreating EAN-13 Supplement 5 In None Using Barcode creator for Font Control to generate, create EAN13 image in Font applications. www.OnBarcode.comCHAPTER 8 ADDING FUNCTIONS AND COMMANDS TO MYSQL
Code 128 Code Set B Maker In None Using Barcode printer for Font Control to generate, create Code 128A image in Font applications. www.OnBarcode.comBarcode Encoder In None Using Barcode maker for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comSQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES, /* BEGIN CAB MODIFICATION */ /* Reason for Modification: */ /* This section captures the enumerations for the SHOW DISK_USAGE command tokens */ SQLCOM_SHOW_DISK_USAGE, /* END CAB MODIFICATION */ SQLCOM_HELP, SQLCOM_CREATE_USER, SQLCOM_DROP_USER, SQLCOM_RENAME_USER, ... Now that you have the new symbol and the command mnemonic, you now need to add code to the sql_yacc.yy file to define the new token that you used in the lex.h file and add the source code for the new SHOW DISK_USAGE SQL command. Open the sql_yacc.yy file and add the new token to the list of tokens (near the top). These are defined (roughly) in alphabetical order, so place the new token in the proper order. Listing 8-19 shows the modifications to the sql_yacc.yy file. Listing 8-19. Adding the Token to the sql_yacc.yy File ... %token DISK_SYM /* BEGIN CAB MODIFICATION */ /* Reason for Modification: */ /* This section defines the tokens for the SHOW DISK_USAGE command */ %token DISK_USAGE_SYM /* END CAB MODIFICATION */ %token DISTINCT ... Encode Code 39 Extended In None Using Barcode generator for Font Control to generate, create Code 39 Extended image in Font applications. www.OnBarcode.comCode11 Generator In None Using Barcode encoder for Font Control to generate, create Code 11 image in Font applications. www.OnBarcode.com Note If you use Windows, the sql_yacc.yy file is not included in the source code distribution. You must QR Code JIS X 0510 Generator In Objective-C Using Barcode generator for iPad Control to generate, create QR image in iPad applications. www.OnBarcode.comQuick Response Code Generator In Java Using Barcode generation for Java Control to generate, create QR Code 2d barcode image in Java applications. www.OnBarcode.comdownload one of the Linux source code distributions and retrieve the file from there. Make sure you use the same version of the Linux source code that matches your Windows source code. Barcode Creator In Java Using Barcode maker for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comUSS Code 128 Generator In None Using Barcode creator for Microsoft Excel Control to generate, create Code 128 Code Set B image in Microsoft Excel applications. www.OnBarcode.comYou also need to add the command syntax to the parser YACC code (also in sql_yacc.yy). Locate the show: label and add the command as shown in Listing 8-20. Listing 8-20. Parser Syntax Source Code for the SHOW DISK_USAGE Command show: /* BEGIN CAB MODIFICATION */ /* Reason for Modification: */ /* This section captures (parses) the SHOW ALV statement */ SHOW DISK_USAGE_SYM { LEX *lex=Lex; lex->sql_command= SQLCOM_SHOW_DISK_USAGE; Creating QR In Objective-C Using Barcode generator for iPhone Control to generate, create QR Code image in iPhone applications. www.OnBarcode.comCreating USS Code 39 In None Using Barcode printer for Word Control to generate, create Code 39 image in Word applications. www.OnBarcode.comCreating EAN 13 In None Using Barcode encoder for Office Word Control to generate, create EAN13 image in Word applications. www.OnBarcode.comDrawing Universal Product Code Version A In Java Using Barcode creation for Java Control to generate, create GTIN - 12 image in Java applications. www.OnBarcode.comData Matrix ECC200 Drawer In .NET Using Barcode generation for Reporting Service Control to generate, create ECC200 image in Reporting Service applications. www.OnBarcode.comGenerating PDF417 In .NET Framework Using Barcode encoder for Reporting Service Control to generate, create PDF-417 2d barcode image in Reporting Service applications. www.OnBarcode.comDecoding DataMatrix In Visual C# Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.com1D Generator In Visual Studio .NET Using Barcode drawer for Visual Studio .NET Control to generate, create Linear 1D Barcode image in VS .NET applications. www.OnBarcode.com |
|