mysql workbench. the ultimate guide to dba productivity: writing plugins and scripts

13
MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts Vladimir Kolesnikov Software Engineer, Developer Tools

Upload: xiu

Post on 02-Feb-2016

58 views

Category:

Documents


1 download

DESCRIPTION

MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts. Vladimir Kolesnikov Software Engineer, Developer Tools. Session Contents. Workbench General Overview Workbench Architecture, GRT [break] GRT Shell LUA scripting and Libraries [break] GRT LUA Plugins - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

MySQL Workbench. The Ultimate Guide to

DBA Productivity: Writing Plugins and

Scripts

Vladimir Kolesnikov

Software Engineer,

Developer Tools

Page 2: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Workbench General Overview

• Workbench Architecture, GRT

• [break]

• GRT Shell

• LUA scripting and Libraries

• [break]

• GRT LUA Plugins

• [break]

• GRT C++ Plugins

Session Contents

Page 3: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• EER modeling tool• Overview page lists model entities• Canvas is where you visually create and edit your EER

models• Use export/import/synchronization tools to interact with

live servers or store data in SQL scripts• Use validation tools to check your models• Various utilities for your convenience – printing, export to

PDF, PNG…• Cross-platform with native GUIs. Runs on Win 32/64

XP/Vista, with OS X and Linux coming soon

Workbench General Overview

Page 4: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Two Editions – OSS and Standard

Workbench General Overview

Page 5: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Workbench core manages the most essential functions– OS Abstraction– Inter-thread communication and messaging – Graphics– GUI– Generic APIs

• GRT (Generic Run-Time) System– Object model, built after the architecture of dynamic

languages (such as Objective-C)– Modules and scripting support

Workbench Architecture

Page 6: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Modular Decomposition

Workbench Architecture

Page 7: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Threading & Messaging Model

App Frontend

GRT

Canvas

CanvasBridge

WBContextevents

events

updates

WB Context

callbacks

CanvasViewer

Modules

calls

Dis

patc

her

commands

Dispatcher

notifications

notifications

events

updates

Workbench Architecture

Page 8: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

Workbench Architecture

• Modules

and Scripting Support

Object

Struct

C++Bridge

C++ Object Wrapper

Class

C++ Module Wrapper Class

C++ Loader(DLLs)

Loaders for Other

Languages

Lua Loader

DictList

Simple

C++ ValueWrappers

Python Modules

JavaScript Modules

...

ModuleImplemen

tation

Lua ModuleImplementation

C++ ModuleImplementation

GRT

ModulesModules

Page 9: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• GRT Object Model GrtObject

GrtNamedObject

db_Schema db_Table db_View db_Routine

db_User

db_mysql_Schema

db_mysql_Table

db_mysql_View

db_mysql_Routine

db_Column db_ForeignKey

db_Tablespace

db_UserDatatype

db_Role

db_mysql_Catalog

db_Index

db_mysql_Tablespace

GrtDatabaseObject

db_mysql_StorageEngine

db_mysql_Indexdb_mysql_ForeignKey

db_Catalog

db_mysql_Column

Workbench Architecture

Page 10: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Shell is command line interface to the Workbench internals

• Uses LUA for Scripting

• Supports single- and multi-line editing modes

• Can be used for script debugging

• Start using shell– Opening shell: Ctrl-F3– Getting help: /> ? [subtopic-name]– To enter multi-line mode: Shift-Enter– To launch commands in multi-line mode: Ctrl-Enter

GRT Shell

Page 11: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

• Why LUA:– Fast– Light-weight– Portable– Easily-embeddable

• LUA Standard Libraries Handle All Basic Functions– Runtime support– Strings, numbers, conversions, other utility– Data structure manipulation– Threading

GRT Lua Scripting and Libraries

Page 12: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

GRT Lua Modules & Plugins

• Modules are loaded at Workbench startup and become globally visible

• Use predefined source templates

• Use Workbench scripting framework to create/edit/manage scripts

• Use GRT Shell for debugging your code

• You can re-use existing modules from your code

Page 13: MySQL Workbench. The Ultimate Guide to DBA Productivity: Writing Plugins and Scripts

GRT C++ Modules & Plugins• Use C++ for Implementing complex and/or

computation-intensive modules

• Use Workbench abstractions facilities for implementing platform-independent code

• Implementing GUI– Windows: Use Windows Managed/Native Interop

services for interfacing with GUI part– Linux: GUI is based GTKmm which is a C++ framework– Mac OS X: You can mix C++ and Objective-C code

within the same source to implement COCOA-based GUI