SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Roland Bouman
http://rpbouman.blogspot.com/
1
Writing MySQL 5.1 Information
Schema Plugins
Roland Bouman
http://rpbouman.blogspot.com/
2
Tasks Before Implementing
Information Schema Plugins
● Standard headers
– <stdlib.h>, <ctype.h>
● Non-specific MySQL headers:
– <mysql_version.h>, <mysql/plugin.h>
● Extra headers for Information Schema plug-ins
– <mysql_priv.h>
– <my_global.h>
– <my_dir.h>
Roland Bouman
http://rpbouman.blogspot.com/
3
Implementing Information
Schema Plug-ins
● Setup the column layout
– Defines the column names and data types
● Implement a fill function
– Is called to fill the (in-memory) table
● Hook up table object with colum layout and fill
function
– Plug-in initialization function
Roland Bouman
http://rpbouman.blogspot.com/
4
Information Schema Plug-ins:
Column Layout
● Array of ST_FIELD_INFO
– typedef struct st_field_info
– Defined in sql/table.h
typedef struct st_field_info
{
const char* field_name;
uint field_length;
enum enum_field_types field_type;
int value;
uint field_flags;
const char* old_name;
uint open_method;
} ST_FIELD_INFO;
Roland Bouman
http://rpbouman.blogspot.com/
5
ST_FIELD_INFO members (1/2)
● field_name: Column name
● field_length:
– String type columns: #characters
– Non-string types: 'display length'
● field_type: type constant
– enum_field_types (mysql_com.h)
● field_flags:
– MY_I_S_MAYBE_NULL
– MY_I_S_UNSIGNED
Roland Bouman
http://rpbouman.blogspot.com/
6
ST_FIELD_INFO members (2/2)
● open_method: (sql/table.h)
– SKIP_OPEN_TABLE
– OPEN_FRM_ONLY
– OPEN_FULL_TABLE
● old_name: Column name for SHOW command
● value: ??
Roland Bouman
http://rpbouman.blogspot.com/
7
Information Schema Plug-ins:
Column Layout Example
● information_schema.SCHEMATA
ST_FIELD_INFO schema_fields_info[]=
{
{"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING,
0, 1, 0, SKIP_OPEN_TABLE},
{"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING,
0, 0, "Database", SKIP_OPEN_TABLE},
{"DEFAULT_CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING,
0, 0, 0, SKIP_OPEN_TABLE},
{"DEFAULT_COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING,
0, 0, 0, SKIP_OPEN_TABLE},
{"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING,
0, 1, 0, SKIP_OPEN_TABLE},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
}
Roland Bouman
http://rpbouman.blogspot.com/
8
Information Schema Plug-ins:
Fill Function (1/4)
● fill_table(
THD *thd,
TABLE_LIST *tables,
COND *cond
)
● THD: thread descriptor (sql/sql_class.h)
● TABLE_LIST: (sql/sql_table.h)
– List of struct st_table (a.k.a. TABLE)
● COND: Condition.
Roland Bouman
http://rpbouman.blogspot.com/
9
Information Schema Plug-ins:
Fill Function (2/4)
● Grab first table from the list:
TABLE *table= (TABLE *)tables->table;
● Store data in fields:
table->field[i]->store(...);
● Store row in table
schema_table_store_record(thd, table);
Roland Bouman
http://rpbouman.blogspot.com/
10
Information Schema Plug-ins:
Fill Function (3/4)
● schema_table_store_record(
THD *thd
, TABLE *table
)
● Forward declaration in mysql_priv.h
● Defined in sql/sql_show.cc
Roland Bouman
http://rpbouman.blogspot.com/
11
Information Schema Plug-ins:
Fill Function (4/4)
int myplugin_fill_table(
THD *thd, TABLE_LIST *tables, COND *cond
){
int status;
CHARSET_INFO *scs= system_charset_info;
TABLE *table= (TABLE *)tables->table;
for ( ... ) { //
table->field[0]->store( ... );
...
table->field[X]->store( ... );
status= schema_table_store_record(
thd, table
);
}
return status;
}
Roland Bouman
http://rpbouman.blogspot.com/
12
Information Schema Plug-ins:
Hookup Column Layout and Filler
● plugin_init
static int myplugin_init(void *p)
{
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
schema->fields_info= myplugin_field_info;
schema->fill_table= myplugin_fill_table;
return 0;
}
Roland Bouman
http://rpbouman.blogspot.com/
13
Information Schema Plug-ins:
ST_SCHEMA_TABLE
● ST_SCHEMA_TABLE a.k.a st_schema_table
typedef struct st_schema_table
{
const char* table_name;
ST_FIELD_INFO *fields_info;
TABLE *(*create_table)(THD *thd, TABLE_LIST *table_list);
int (*fill_table) (
THD *thd, TABLE_LIST *tables, COND *cond);
int (*old_format) (
THD *thd, struct st_schema_table *schema_table);
int (*process_table) (
THD *thd, TABLE_LIST *tables,TABLE *table,
bool res, LEX_STRING *db_name, LEX_STRING *table_name);
int idx_field1, idx_field2;
bool hidden;
uint i_s_requested_object;
} ST_SCHEMA_TABLE;
Roland Bouman
http://rpbouman.blogspot.com/
14
Information Schema Plug-ins:
Hookup Column Layout and Filler
● plugin_init
static int myplugin_init(void *p)
{
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
schema->fields_info= myplugin_field_info;
schema->fill_table= myplugin_fill_table;
return 0;
}
Roland Bouman
http://rpbouman.blogspot.com/
15
Information Schema Plug-ins:
Hookup Column Layout and Filler
● plugin_init
static int myplugin_init(void *p)
{
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
schema->fields_info= myplugin_field_info;
schema->fill_table= myplugin_fill_table;
return 0;
}
Roland Bouman
http://rpbouman.blogspot.com/
16
Information Schema Plug-ins:
Hookup Column Layout and Filler
● plugin_init
static int myplugin_init(void *p)
{
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
schema->fields_info= myplugin_field_info;
schema->fill_table= myplugin_fill_table;
return 0;
}

Weitere ähnliche Inhalte

Was ist angesagt?

Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle BasicKamlesh Singh
 
235689260 oracle-forms-10g-tutorial
235689260 oracle-forms-10g-tutorial235689260 oracle-forms-10g-tutorial
235689260 oracle-forms-10g-tutorialhomeworkping3
 
11 Things About 11gr2
11 Things About 11gr211 Things About 11gr2
11 Things About 11gr2afa reg
 
PostgreSQL Procedural Languages: Tips, Tricks and Gotchas
PostgreSQL Procedural Languages: Tips, Tricks and GotchasPostgreSQL Procedural Languages: Tips, Tricks and Gotchas
PostgreSQL Procedural Languages: Tips, Tricks and GotchasJim Mlodgenski
 
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021Valeriy Kravchuk
 
MySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsMySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsOSSCube
 
PL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSraj upadhyay
 
Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7I Goo Lee
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @SilexJeen Lee
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Valeriy Kravchuk
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)Valeriy Kravchuk
 
Oracle postgre sql-mirgration-top-10-mistakes
Oracle postgre sql-mirgration-top-10-mistakesOracle postgre sql-mirgration-top-10-mistakes
Oracle postgre sql-mirgration-top-10-mistakesJim Mlodgenski
 

Was ist angesagt? (20)

Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
 
235689260 oracle-forms-10g-tutorial
235689260 oracle-forms-10g-tutorial235689260 oracle-forms-10g-tutorial
235689260 oracle-forms-10g-tutorial
 
11 Things About 11gr2
11 Things About 11gr211 Things About 11gr2
11 Things About 11gr2
 
PostgreSQL Procedural Languages: Tips, Tricks and Gotchas
PostgreSQL Procedural Languages: Tips, Tricks and GotchasPostgreSQL Procedural Languages: Tips, Tricks and Gotchas
PostgreSQL Procedural Languages: Tips, Tricks and Gotchas
 
Dbmsmanual
DbmsmanualDbmsmanual
Dbmsmanual
 
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021Linux  /proc filesystem for MySQL DBAs - FOSDEM 2021
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
 
Documento
DocumentoDocumento
Documento
 
MySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web ApplicationsMySQL Stored Procedures: Building High Performance Web Applications
MySQL Stored Procedures: Building High Performance Web Applications
 
PL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMSPL-SQL DIFFERENT PROGRAMS
PL-SQL DIFFERENT PROGRAMS
 
TRunner
TRunnerTRunner
TRunner
 
ZFINDALLZPROGAM
ZFINDALLZPROGAMZFINDALLZPROGAM
ZFINDALLZPROGAM
 
Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7Optimizer Cost Model MySQL 5.7
Optimizer Cost Model MySQL 5.7
 
Tuning SGA
Tuning SGATuning SGA
Tuning SGA
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
Raj mysql
Raj mysqlRaj mysql
Raj mysql
 
Ruby meetup ROM
Ruby meetup ROMRuby meetup ROM
Ruby meetup ROM
 
Oracle postgre sql-mirgration-top-10-mistakes
Oracle postgre sql-mirgration-top-10-mistakesOracle postgre sql-mirgration-top-10-mistakes
Oracle postgre sql-mirgration-top-10-mistakes
 
Les01
Les01Les01
Les01
 

Andere mochten auch

Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
LAMP security practices
LAMP security practicesLAMP security practices
LAMP security practicesAmit Kejriwal
 
What Permissions Does Your Database User REALLY Need?
What Permissions Does Your Database User REALLY Need?What Permissions Does Your Database User REALLY Need?
What Permissions Does Your Database User REALLY Need?Denim Group
 
Olap scalability
Olap scalabilityOlap scalability
Olap scalabilitylucboudreau
 
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksSoutheast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksDave Stokes
 

Andere mochten auch (8)

Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
LAMP security practices
LAMP security practicesLAMP security practices
LAMP security practices
 
2009 Comrise
2009 Comrise2009 Comrise
2009 Comrise
 
What Permissions Does Your Database User REALLY Need?
What Permissions Does Your Database User REALLY Need?What Permissions Does Your Database User REALLY Need?
What Permissions Does Your Database User REALLY Need?
 
Xml4js pentaho
Xml4js pentahoXml4js pentaho
Xml4js pentaho
 
Xmla4js
Xmla4jsXmla4js
Xmla4js
 
Olap scalability
Olap scalabilityOlap scalability
Olap scalability
 
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksSoutheast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
 

Ähnlich wie 3. writing MySql plugins for the information schema

Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema PluginsMark Leith
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads UpMindfire Solutions
 
How to make data available for analytics ASAP
How to make data available for analytics ASAPHow to make data available for analytics ASAP
How to make data available for analytics ASAPMariaDB plc
 
Playing with the CONNECT storage engine
Playing with the CONNECT storage enginePlaying with the CONNECT storage engine
Playing with the CONNECT storage engineFederico Razzoli
 
External Language Stored Procedures for MySQL
External Language Stored Procedures for MySQLExternal Language Stored Procedures for MySQL
External Language Stored Procedures for MySQLAntony T Curtis
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
 
Polymorphic Table Functions in 18c
Polymorphic Table Functions in 18cPolymorphic Table Functions in 18c
Polymorphic Table Functions in 18cAndrej Pashchenko
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespaceMarco Tusa
 
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Valerii Kravchuk
 
Less18 moving data
Less18 moving dataLess18 moving data
Less18 moving dataImran Ali
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRPeter Elst
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaFromDual GmbH
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Case_Study_-_Advanced_Oracle_PLSQL
Case_Study_-_Advanced_Oracle_PLSQLCase_Study_-_Advanced_Oracle_PLSQL
Case_Study_-_Advanced_Oracle_PLSQLZiemowit Jankowski
 
Meet MariaDB 10.3 Debconf 2017
Meet MariaDB 10.3   Debconf 2017Meet MariaDB 10.3   Debconf 2017
Meet MariaDB 10.3 Debconf 2017Vicentiu Ciorbaru
 

Ähnlich wie 3. writing MySql plugins for the information schema (20)

Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema Plugins
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Hive in Practice
Hive in PracticeHive in Practice
Hive in Practice
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads Up
 
How to make data available for analytics ASAP
How to make data available for analytics ASAPHow to make data available for analytics ASAP
How to make data available for analytics ASAP
 
IDUG 2015 NA Data Movement Utilities final
IDUG 2015 NA Data Movement Utilities finalIDUG 2015 NA Data Movement Utilities final
IDUG 2015 NA Data Movement Utilities final
 
Playing with the CONNECT storage engine
Playing with the CONNECT storage enginePlaying with the CONNECT storage engine
Playing with the CONNECT storage engine
 
External Language Stored Procedures for MySQL
External Language Stored Procedures for MySQLExternal Language Stored Procedures for MySQL
External Language Stored Procedures for MySQL
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
Polymorphic Table Functions in 18c
Polymorphic Table Functions in 18cPolymorphic Table Functions in 18c
Polymorphic Table Functions in 18c
 
Discard inport exchange table & tablespace
Discard inport exchange table & tablespaceDiscard inport exchange table & tablespace
Discard inport exchange table & tablespace
 
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
Instant add column for inno db in mariadb 10.3+ (fosdem 2018, second draft)
 
Less18 moving data
Less18 moving dataLess18 moving data
Less18 moving data
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
PERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schemaPERFORMANCE_SCHEMA and sys schema
PERFORMANCE_SCHEMA and sys schema
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Case_Study_-_Advanced_Oracle_PLSQL
Case_Study_-_Advanced_Oracle_PLSQLCase_Study_-_Advanced_Oracle_PLSQL
Case_Study_-_Advanced_Oracle_PLSQL
 
Meet MariaDB 10.3 Debconf 2017
Meet MariaDB 10.3   Debconf 2017Meet MariaDB 10.3   Debconf 2017
Meet MariaDB 10.3 Debconf 2017
 

Kürzlich hochgeladen

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

3. writing MySql plugins for the information schema

  • 2. Roland Bouman http://rpbouman.blogspot.com/ 2 Tasks Before Implementing Information Schema Plugins ● Standard headers – <stdlib.h>, <ctype.h> ● Non-specific MySQL headers: – <mysql_version.h>, <mysql/plugin.h> ● Extra headers for Information Schema plug-ins – <mysql_priv.h> – <my_global.h> – <my_dir.h>
  • 3. Roland Bouman http://rpbouman.blogspot.com/ 3 Implementing Information Schema Plug-ins ● Setup the column layout – Defines the column names and data types ● Implement a fill function – Is called to fill the (in-memory) table ● Hook up table object with colum layout and fill function – Plug-in initialization function
  • 4. Roland Bouman http://rpbouman.blogspot.com/ 4 Information Schema Plug-ins: Column Layout ● Array of ST_FIELD_INFO – typedef struct st_field_info – Defined in sql/table.h typedef struct st_field_info { const char* field_name; uint field_length; enum enum_field_types field_type; int value; uint field_flags; const char* old_name; uint open_method; } ST_FIELD_INFO;
  • 5. Roland Bouman http://rpbouman.blogspot.com/ 5 ST_FIELD_INFO members (1/2) ● field_name: Column name ● field_length: – String type columns: #characters – Non-string types: 'display length' ● field_type: type constant – enum_field_types (mysql_com.h) ● field_flags: – MY_I_S_MAYBE_NULL – MY_I_S_UNSIGNED
  • 6. Roland Bouman http://rpbouman.blogspot.com/ 6 ST_FIELD_INFO members (2/2) ● open_method: (sql/table.h) – SKIP_OPEN_TABLE – OPEN_FRM_ONLY – OPEN_FULL_TABLE ● old_name: Column name for SHOW command ● value: ??
  • 7. Roland Bouman http://rpbouman.blogspot.com/ 7 Information Schema Plug-ins: Column Layout Example ● information_schema.SCHEMATA ST_FIELD_INFO schema_fields_info[]= { {"CATALOG_NAME", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {"SCHEMA_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Database", SKIP_OPEN_TABLE}, {"DEFAULT_CHARACTER_SET_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"DEFAULT_COLLATION_NAME", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}, {"SQL_PATH", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, SKIP_OPEN_TABLE}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }
  • 8. Roland Bouman http://rpbouman.blogspot.com/ 8 Information Schema Plug-ins: Fill Function (1/4) ● fill_table( THD *thd, TABLE_LIST *tables, COND *cond ) ● THD: thread descriptor (sql/sql_class.h) ● TABLE_LIST: (sql/sql_table.h) – List of struct st_table (a.k.a. TABLE) ● COND: Condition.
  • 9. Roland Bouman http://rpbouman.blogspot.com/ 9 Information Schema Plug-ins: Fill Function (2/4) ● Grab first table from the list: TABLE *table= (TABLE *)tables->table; ● Store data in fields: table->field[i]->store(...); ● Store row in table schema_table_store_record(thd, table);
  • 10. Roland Bouman http://rpbouman.blogspot.com/ 10 Information Schema Plug-ins: Fill Function (3/4) ● schema_table_store_record( THD *thd , TABLE *table ) ● Forward declaration in mysql_priv.h ● Defined in sql/sql_show.cc
  • 11. Roland Bouman http://rpbouman.blogspot.com/ 11 Information Schema Plug-ins: Fill Function (4/4) int myplugin_fill_table( THD *thd, TABLE_LIST *tables, COND *cond ){ int status; CHARSET_INFO *scs= system_charset_info; TABLE *table= (TABLE *)tables->table; for ( ... ) { // table->field[0]->store( ... ); ... table->field[X]->store( ... ); status= schema_table_store_record( thd, table ); } return status; }
  • 12. Roland Bouman http://rpbouman.blogspot.com/ 12 Information Schema Plug-ins: Hookup Column Layout and Filler ● plugin_init static int myplugin_init(void *p) { ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p; schema->fields_info= myplugin_field_info; schema->fill_table= myplugin_fill_table; return 0; }
  • 13. Roland Bouman http://rpbouman.blogspot.com/ 13 Information Schema Plug-ins: ST_SCHEMA_TABLE ● ST_SCHEMA_TABLE a.k.a st_schema_table typedef struct st_schema_table { const char* table_name; ST_FIELD_INFO *fields_info; TABLE *(*create_table)(THD *thd, TABLE_LIST *table_list); int (*fill_table) ( THD *thd, TABLE_LIST *tables, COND *cond); int (*old_format) ( THD *thd, struct st_schema_table *schema_table); int (*process_table) ( THD *thd, TABLE_LIST *tables,TABLE *table, bool res, LEX_STRING *db_name, LEX_STRING *table_name); int idx_field1, idx_field2; bool hidden; uint i_s_requested_object; } ST_SCHEMA_TABLE;
  • 14. Roland Bouman http://rpbouman.blogspot.com/ 14 Information Schema Plug-ins: Hookup Column Layout and Filler ● plugin_init static int myplugin_init(void *p) { ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p; schema->fields_info= myplugin_field_info; schema->fill_table= myplugin_fill_table; return 0; }
  • 15. Roland Bouman http://rpbouman.blogspot.com/ 15 Information Schema Plug-ins: Hookup Column Layout and Filler ● plugin_init static int myplugin_init(void *p) { ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p; schema->fields_info= myplugin_field_info; schema->fill_table= myplugin_fill_table; return 0; }
  • 16. Roland Bouman http://rpbouman.blogspot.com/ 16 Information Schema Plug-ins: Hookup Column Layout and Filler ● plugin_init static int myplugin_init(void *p) { ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p; schema->fields_info= myplugin_field_info; schema->fill_table= myplugin_fill_table; return 0; }