psi.h 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011
  1. /* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  18. #ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
  19. #define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
  20. #ifdef EMBEDDED_LIBRARY
  21. #define DISABLE_ALL_PSI
  22. #endif /* EMBEDDED_LIBRARY */
  23. #ifndef MY_GLOBAL_INCLUDED
  24. /*
  25. Make sure a .c or .cc file contains an include to my_global.h first.
  26. When this include is missing, all the #ifdef HAVE_XXX have no effect,
  27. and the resulting binary won't build, or won't link,
  28. or will crash at runtime
  29. since various structures will have different binary definitions.
  30. */
  31. #error "You must include my_global.h in the code for the build to be correct."
  32. #endif
  33. #include "psi_base.h"
  34. #include "psi_memory.h"
  35. /*
  36. MAINTAINER:
  37. The following pattern:
  38. typedef struct XYZ XYZ;
  39. is not needed in C++, but required for C.
  40. */
  41. C_MODE_START
  42. /** @sa MDL_key. */
  43. struct MDL_key;
  44. typedef struct MDL_key MDL_key;
  45. /** @sa enum_mdl_type. */
  46. typedef int opaque_mdl_type;
  47. /** @sa enum_mdl_duration. */
  48. typedef int opaque_mdl_duration;
  49. /** @sa MDL_wait::enum_wait_status. */
  50. typedef int opaque_mdl_status;
  51. /** @sa enum_vio_type. */
  52. typedef int opaque_vio_type;
  53. struct TABLE_SHARE;
  54. struct sql_digest_storage;
  55. #ifdef __cplusplus
  56. class THD;
  57. #else
  58. /*
  59. Phony declaration when compiling C code.
  60. This is ok, because the C code will never have a THD anyway.
  61. */
  62. struct opaque_THD
  63. {
  64. int dummy;
  65. };
  66. typedef struct opaque_THD THD;
  67. #endif
  68. /**
  69. @file mysql/psi/psi.h
  70. Performance schema instrumentation interface.
  71. @defgroup Instrumentation_interface Instrumentation Interface
  72. @ingroup Performance_schema
  73. @{
  74. */
  75. /**
  76. Interface for an instrumented mutex.
  77. This is an opaque structure.
  78. */
  79. struct PSI_mutex;
  80. typedef struct PSI_mutex PSI_mutex;
  81. /**
  82. Interface for an instrumented rwlock.
  83. This is an opaque structure.
  84. */
  85. struct PSI_rwlock;
  86. typedef struct PSI_rwlock PSI_rwlock;
  87. /**
  88. Interface for an instrumented condition.
  89. This is an opaque structure.
  90. */
  91. struct PSI_cond;
  92. typedef struct PSI_cond PSI_cond;
  93. /**
  94. Interface for an instrumented table share.
  95. This is an opaque structure.
  96. */
  97. struct PSI_table_share;
  98. typedef struct PSI_table_share PSI_table_share;
  99. /**
  100. Interface for an instrumented table handle.
  101. This is an opaque structure.
  102. */
  103. struct PSI_table;
  104. typedef struct PSI_table PSI_table;
  105. /**
  106. Interface for an instrumented thread.
  107. This is an opaque structure.
  108. */
  109. struct PSI_thread;
  110. typedef struct PSI_thread PSI_thread;
  111. /**
  112. Interface for an instrumented file handle.
  113. This is an opaque structure.
  114. */
  115. struct PSI_file;
  116. typedef struct PSI_file PSI_file;
  117. /**
  118. Interface for an instrumented socket descriptor.
  119. This is an opaque structure.
  120. */
  121. struct PSI_socket;
  122. typedef struct PSI_socket PSI_socket;
  123. /**
  124. Interface for an instrumented prepared statement.
  125. This is an opaque structure.
  126. */
  127. struct PSI_prepared_stmt;
  128. typedef struct PSI_prepared_stmt PSI_prepared_stmt;
  129. /**
  130. Interface for an instrumented table operation.
  131. This is an opaque structure.
  132. */
  133. struct PSI_table_locker;
  134. typedef struct PSI_table_locker PSI_table_locker;
  135. /**
  136. Interface for an instrumented statement.
  137. This is an opaque structure.
  138. */
  139. struct PSI_statement_locker;
  140. typedef struct PSI_statement_locker PSI_statement_locker;
  141. /**
  142. Interface for an instrumented transaction.
  143. This is an opaque structure.
  144. */
  145. struct PSI_transaction_locker;
  146. typedef struct PSI_transaction_locker PSI_transaction_locker;
  147. /**
  148. Interface for an instrumented idle operation.
  149. This is an opaque structure.
  150. */
  151. struct PSI_idle_locker;
  152. typedef struct PSI_idle_locker PSI_idle_locker;
  153. /**
  154. Interface for an instrumented statement digest operation.
  155. This is an opaque structure.
  156. */
  157. struct PSI_digest_locker;
  158. typedef struct PSI_digest_locker PSI_digest_locker;
  159. /**
  160. Interface for an instrumented stored procedure share.
  161. This is an opaque structure.
  162. */
  163. struct PSI_sp_share;
  164. typedef struct PSI_sp_share PSI_sp_share;
  165. /**
  166. Interface for an instrumented stored program.
  167. This is an opaque structure.
  168. */
  169. struct PSI_sp_locker;
  170. typedef struct PSI_sp_locker PSI_sp_locker;
  171. /**
  172. Interface for an instrumented metadata lock.
  173. This is an opaque structure.
  174. */
  175. struct PSI_metadata_lock;
  176. typedef struct PSI_metadata_lock PSI_metadata_lock;
  177. /**
  178. Interface for an instrumented stage progress.
  179. This is a public structure, for efficiency.
  180. */
  181. struct PSI_stage_progress
  182. {
  183. ulonglong m_work_completed;
  184. ulonglong m_work_estimated;
  185. };
  186. typedef struct PSI_stage_progress PSI_stage_progress;
  187. /** IO operation performed on an instrumented table. */
  188. enum PSI_table_io_operation
  189. {
  190. /** Row fetch. */
  191. PSI_TABLE_FETCH_ROW= 0,
  192. /** Row write. */
  193. PSI_TABLE_WRITE_ROW= 1,
  194. /** Row update. */
  195. PSI_TABLE_UPDATE_ROW= 2,
  196. /** Row delete. */
  197. PSI_TABLE_DELETE_ROW= 3
  198. };
  199. typedef enum PSI_table_io_operation PSI_table_io_operation;
  200. /**
  201. State data storage for @c start_table_io_wait_v1_t,
  202. @c start_table_lock_wait_v1_t.
  203. This structure provide temporary storage to a table locker.
  204. The content of this structure is considered opaque,
  205. the fields are only hints of what an implementation
  206. of the psi interface can use.
  207. This memory is provided by the instrumented code for performance reasons.
  208. @sa start_table_io_wait_v1_t
  209. @sa start_table_lock_wait_v1_t
  210. */
  211. struct PSI_table_locker_state
  212. {
  213. /** Internal state. */
  214. uint m_flags;
  215. /** Current io operation. */
  216. enum PSI_table_io_operation m_io_operation;
  217. /** Current table handle. */
  218. struct PSI_table *m_table;
  219. /** Current table share. */
  220. struct PSI_table_share *m_table_share;
  221. /** Current thread. */
  222. struct PSI_thread *m_thread;
  223. /** Timer start. */
  224. ulonglong m_timer_start;
  225. /** Timer function. */
  226. ulonglong (*m_timer)(void);
  227. /** Internal data. */
  228. void *m_wait;
  229. /**
  230. Implementation specific.
  231. For table io, the table io index.
  232. For table lock, the lock type.
  233. */
  234. uint m_index;
  235. };
  236. typedef struct PSI_table_locker_state PSI_table_locker_state;
  237. /** Entry point for the performance schema interface. */
  238. struct PSI_bootstrap
  239. {
  240. /**
  241. ABI interface finder.
  242. Calling this method with an interface version number returns either
  243. an instance of the ABI for this version, or NULL.
  244. @param version the interface version number to find
  245. @return a versioned interface (PSI_v1, PSI_v2 or PSI)
  246. @sa PSI_VERSION_1
  247. @sa PSI_v1
  248. @sa PSI_VERSION_2
  249. @sa PSI_v2
  250. @sa PSI_CURRENT_VERSION
  251. @sa PSI
  252. */
  253. void* (*get_interface)(int version);
  254. };
  255. typedef struct PSI_bootstrap PSI_bootstrap;
  256. #ifdef HAVE_PSI_INTERFACE
  257. #ifdef DISABLE_ALL_PSI
  258. #ifndef DISABLE_PSI_THREAD
  259. #define DISABLE_PSI_THREAD
  260. #endif
  261. #ifndef DISABLE_PSI_MUTEX
  262. #define DISABLE_PSI_MUTEX
  263. #endif
  264. #ifndef DISABLE_PSI_RWLOCK
  265. #define DISABLE_PSI_RWLOCK
  266. #endif
  267. #ifndef DISABLE_PSI_COND
  268. #define DISABLE_PSI_COND
  269. #endif
  270. #ifndef DISABLE_PSI_FILE
  271. #define DISABLE_PSI_FILE
  272. #endif
  273. #ifndef DISABLE_PSI_TABLE
  274. #define DISABLE_PSI_TABLE
  275. #endif
  276. #ifndef DISABLE_PSI_SOCKET
  277. #define DISABLE_PSI_SOCKET
  278. #endif
  279. #ifndef DISABLE_PSI_STAGE
  280. #define DISABLE_PSI_STAGE
  281. #endif
  282. #ifndef DISABLE_PSI_STATEMENT
  283. #define DISABLE_PSI_STATEMENT
  284. #endif
  285. #ifndef DISABLE_PSI_SP
  286. #define DISABLE_PSI_SP
  287. #endif
  288. #ifndef DISABLE_PSI_IDLE
  289. #define DISABLE_PSI_IDLE
  290. #endif
  291. #ifndef DISABLE_PSI_STATEMENT_DIGEST
  292. #define DISABLE_PSI_STATEMENT_DIGEST
  293. #endif
  294. #ifndef DISABLE_PSI_METADATA
  295. #define DISABLE_PSI_METADATA
  296. #endif
  297. #ifndef DISABLE_PSI_MEMORY
  298. #define DISABLE_PSI_MEMORY
  299. #endif
  300. #ifndef DISABLE_PSI_TRANSACTION
  301. #define DISABLE_PSI_TRANSACTION
  302. #endif
  303. #ifndef DISABLE_PSI_SP
  304. #define DISABLE_PSI_SP
  305. #endif
  306. #ifndef DISABLE_PSI_PS
  307. #define DISABLE_PSI_PS
  308. #endif
  309. #endif
  310. /**
  311. @def DISABLE_PSI_MUTEX
  312. Compiling option to disable the mutex instrumentation.
  313. This option is mostly intended to be used during development,
  314. when doing special builds with only a subset of the performance schema instrumentation,
  315. for code analysis / profiling / performance tuning of a specific instrumentation alone.
  316. @sa DISABLE_PSI_RWLOCK
  317. @sa DISABLE_PSI_COND
  318. @sa DISABLE_PSI_FILE
  319. @sa DISABLE_PSI_THREAD
  320. @sa DISABLE_PSI_TABLE
  321. @sa DISABLE_PSI_STAGE
  322. @sa DISABLE_PSI_STATEMENT
  323. @sa DISABLE_PSI_SP
  324. @sa DISABLE_PSI_STATEMENT_DIGEST
  325. @sa DISABLE_PSI_SOCKET
  326. @sa DISABLE_PSI_MEMORY
  327. @sa DISABLE_PSI_IDLE
  328. @sa DISABLE_PSI_METADATA
  329. @sa DISABLE PSI_TRANSACTION
  330. */
  331. #ifndef DISABLE_PSI_MUTEX
  332. #define HAVE_PSI_MUTEX_INTERFACE
  333. #endif
  334. /**
  335. @def DISABLE_PSI_RWLOCK
  336. Compiling option to disable the rwlock instrumentation.
  337. @sa DISABLE_PSI_MUTEX
  338. */
  339. #ifndef DISABLE_PSI_RWLOCK
  340. #define HAVE_PSI_RWLOCK_INTERFACE
  341. #endif
  342. /**
  343. @def DISABLE_PSI_COND
  344. Compiling option to disable the cond instrumentation.
  345. @sa DISABLE_PSI_MUTEX
  346. */
  347. #ifndef DISABLE_PSI_COND
  348. #define HAVE_PSI_COND_INTERFACE
  349. #endif
  350. /**
  351. @def DISABLE_PSI_FILE
  352. Compiling option to disable the file instrumentation.
  353. @sa DISABLE_PSI_MUTEX
  354. */
  355. #ifndef DISABLE_PSI_FILE
  356. #define HAVE_PSI_FILE_INTERFACE
  357. #endif
  358. /**
  359. @def DISABLE_PSI_THREAD
  360. Compiling option to disable the thread instrumentation.
  361. @sa DISABLE_PSI_MUTEX
  362. */
  363. #ifndef DISABLE_PSI_THREAD
  364. #define HAVE_PSI_THREAD_INTERFACE
  365. #endif
  366. /**
  367. @def DISABLE_PSI_TABLE
  368. Compiling option to disable the table instrumentation.
  369. @sa DISABLE_PSI_MUTEX
  370. */
  371. #ifndef DISABLE_PSI_TABLE
  372. #define HAVE_PSI_TABLE_INTERFACE
  373. #endif
  374. /**
  375. @def DISABLE_PSI_STAGE
  376. Compiling option to disable the stage instrumentation.
  377. @sa DISABLE_PSI_MUTEX
  378. */
  379. #ifndef DISABLE_PSI_STAGE
  380. #define HAVE_PSI_STAGE_INTERFACE
  381. #endif
  382. /**
  383. @def DISABLE_PSI_STATEMENT
  384. Compiling option to disable the statement instrumentation.
  385. @sa DISABLE_PSI_MUTEX
  386. */
  387. #ifndef DISABLE_PSI_STATEMENT
  388. #define HAVE_PSI_STATEMENT_INTERFACE
  389. #endif
  390. /**
  391. @def DISABLE_PSI_SP
  392. Compiling option to disable the stored program instrumentation.
  393. @sa DISABLE_PSI_MUTEX
  394. */
  395. #ifndef DISABLE_PSI_SP
  396. #define HAVE_PSI_SP_INTERFACE
  397. #endif
  398. /**
  399. @def DISABLE_PSI_PS
  400. Compiling option to disable the prepared statement instrumentation.
  401. @sa DISABLE_PSI_MUTEX
  402. */
  403. #ifndef DISABLE_PSI_STATEMENT
  404. #ifndef DISABLE_PSI_PS
  405. #define HAVE_PSI_PS_INTERFACE
  406. #endif
  407. #endif
  408. /**
  409. @def DISABLE_PSI_STATEMENT_DIGEST
  410. Compiling option to disable the statement digest instrumentation.
  411. */
  412. #ifndef DISABLE_PSI_STATEMENT
  413. #ifndef DISABLE_PSI_STATEMENT_DIGEST
  414. #define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
  415. #endif
  416. #endif
  417. /**
  418. @def DISABLE_PSI_TRANSACTION
  419. Compiling option to disable the transaction instrumentation.
  420. @sa DISABLE_PSI_MUTEX
  421. */
  422. #ifndef DISABLE_PSI_TRANSACTION
  423. #define HAVE_PSI_TRANSACTION_INTERFACE
  424. #endif
  425. /**
  426. @def DISABLE_PSI_SOCKET
  427. Compiling option to disable the statement instrumentation.
  428. @sa DISABLE_PSI_MUTEX
  429. */
  430. #ifndef DISABLE_PSI_SOCKET
  431. #define HAVE_PSI_SOCKET_INTERFACE
  432. #endif
  433. /**
  434. @def DISABLE_PSI_MEMORY
  435. Compiling option to disable the memory instrumentation.
  436. @sa DISABLE_PSI_MUTEX
  437. */
  438. #ifndef DISABLE_PSI_MEMORY
  439. #define HAVE_PSI_MEMORY_INTERFACE
  440. #endif
  441. /**
  442. @def DISABLE_PSI_IDLE
  443. Compiling option to disable the idle instrumentation.
  444. @sa DISABLE_PSI_MUTEX
  445. */
  446. #ifndef DISABLE_PSI_IDLE
  447. #define HAVE_PSI_IDLE_INTERFACE
  448. #endif
  449. /**
  450. @def DISABLE_PSI_METADATA
  451. Compiling option to disable the metadata instrumentation.
  452. @sa DISABLE_PSI_MUTEX
  453. */
  454. #ifndef DISABLE_PSI_METADATA
  455. #define HAVE_PSI_METADATA_INTERFACE
  456. #endif
  457. /**
  458. @def PSI_VERSION_1
  459. Performance Schema Interface number for version 1.
  460. This version is supported.
  461. */
  462. #define PSI_VERSION_1 1
  463. /**
  464. @def PSI_VERSION_2
  465. Performance Schema Interface number for version 2.
  466. This version is not implemented, it's a placeholder.
  467. */
  468. #define PSI_VERSION_2 2
  469. /**
  470. @def PSI_CURRENT_VERSION
  471. Performance Schema Interface number for the most recent version.
  472. The most current version is @c PSI_VERSION_1
  473. */
  474. #define PSI_CURRENT_VERSION 1
  475. #ifndef USE_PSI_2
  476. #ifndef USE_PSI_1
  477. #define USE_PSI_1
  478. #endif
  479. #endif
  480. /**
  481. Interface for an instrumented mutex operation.
  482. This is an opaque structure.
  483. */
  484. struct PSI_mutex_locker;
  485. typedef struct PSI_mutex_locker PSI_mutex_locker;
  486. /**
  487. Interface for an instrumented rwlock operation.
  488. This is an opaque structure.
  489. */
  490. struct PSI_rwlock_locker;
  491. typedef struct PSI_rwlock_locker PSI_rwlock_locker;
  492. /**
  493. Interface for an instrumented condition operation.
  494. This is an opaque structure.
  495. */
  496. struct PSI_cond_locker;
  497. typedef struct PSI_cond_locker PSI_cond_locker;
  498. /**
  499. Interface for an instrumented file operation.
  500. This is an opaque structure.
  501. */
  502. struct PSI_file_locker;
  503. typedef struct PSI_file_locker PSI_file_locker;
  504. /**
  505. Interface for an instrumented socket operation.
  506. This is an opaque structure.
  507. */
  508. struct PSI_socket_locker;
  509. typedef struct PSI_socket_locker PSI_socket_locker;
  510. /**
  511. Interface for an instrumented MDL operation.
  512. This is an opaque structure.
  513. */
  514. struct PSI_metadata_locker;
  515. typedef struct PSI_metadata_locker PSI_metadata_locker;
  516. /** Operation performed on an instrumented mutex. */
  517. enum PSI_mutex_operation
  518. {
  519. /** Lock. */
  520. PSI_MUTEX_LOCK= 0,
  521. /** Lock attempt. */
  522. PSI_MUTEX_TRYLOCK= 1
  523. };
  524. typedef enum PSI_mutex_operation PSI_mutex_operation;
  525. /**
  526. Operation performed on an instrumented rwlock.
  527. For basic READ / WRITE lock,
  528. operations are "READ" or "WRITE".
  529. For SX-locks, operations are "SHARED", "SHARED-EXCLUSIVE" or "EXCLUSIVE".
  530. */
  531. enum PSI_rwlock_operation
  532. {
  533. /** Read lock. */
  534. PSI_RWLOCK_READLOCK= 0,
  535. /** Write lock. */
  536. PSI_RWLOCK_WRITELOCK= 1,
  537. /** Read lock attempt. */
  538. PSI_RWLOCK_TRYREADLOCK= 2,
  539. /** Write lock attempt. */
  540. PSI_RWLOCK_TRYWRITELOCK= 3,
  541. /** Shared lock. */
  542. PSI_RWLOCK_SHAREDLOCK= 4,
  543. /** Shared Exclusive lock. */
  544. PSI_RWLOCK_SHAREDEXCLUSIVELOCK= 5,
  545. /** Exclusive lock. */
  546. PSI_RWLOCK_EXCLUSIVELOCK= 6,
  547. /** Shared lock attempt. */
  548. PSI_RWLOCK_TRYSHAREDLOCK= 7,
  549. /** Shared Exclusive lock attempt. */
  550. PSI_RWLOCK_TRYSHAREDEXCLUSIVELOCK= 8,
  551. /** Exclusive lock attempt. */
  552. PSI_RWLOCK_TRYEXCLUSIVELOCK= 9
  553. };
  554. typedef enum PSI_rwlock_operation PSI_rwlock_operation;
  555. /** Operation performed on an instrumented condition. */
  556. enum PSI_cond_operation
  557. {
  558. /** Wait. */
  559. PSI_COND_WAIT= 0,
  560. /** Wait, with timeout. */
  561. PSI_COND_TIMEDWAIT= 1
  562. };
  563. typedef enum PSI_cond_operation PSI_cond_operation;
  564. /** Operation performed on an instrumented file. */
  565. enum PSI_file_operation
  566. {
  567. /** File creation, as in @c create(). */
  568. PSI_FILE_CREATE= 0,
  569. /** Temporary file creation, as in @c create_temp_file(). */
  570. PSI_FILE_CREATE_TMP= 1,
  571. /** File open, as in @c open(). */
  572. PSI_FILE_OPEN= 2,
  573. /** File open, as in @c fopen(). */
  574. PSI_FILE_STREAM_OPEN= 3,
  575. /** File close, as in @c close(). */
  576. PSI_FILE_CLOSE= 4,
  577. /** File close, as in @c fclose(). */
  578. PSI_FILE_STREAM_CLOSE= 5,
  579. /**
  580. Generic file read, such as @c fgets(), @c fgetc(), @c fread(), @c read(),
  581. @c pread().
  582. */
  583. PSI_FILE_READ= 6,
  584. /**
  585. Generic file write, such as @c fputs(), @c fputc(), @c fprintf(),
  586. @c vfprintf(), @c fwrite(), @c write(), @c pwrite().
  587. */
  588. PSI_FILE_WRITE= 7,
  589. /** Generic file seek, such as @c fseek() or @c seek(). */
  590. PSI_FILE_SEEK= 8,
  591. /** Generic file tell, such as @c ftell() or @c tell(). */
  592. PSI_FILE_TELL= 9,
  593. /** File flush, as in @c fflush(). */
  594. PSI_FILE_FLUSH= 10,
  595. /** File stat, as in @c stat(). */
  596. PSI_FILE_STAT= 11,
  597. /** File stat, as in @c fstat(). */
  598. PSI_FILE_FSTAT= 12,
  599. /** File chsize, as in @c my_chsize(). */
  600. PSI_FILE_CHSIZE= 13,
  601. /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */
  602. PSI_FILE_DELETE= 14,
  603. /** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */
  604. PSI_FILE_RENAME= 15,
  605. /** File sync, as in @c fsync() or @c my_sync(). */
  606. PSI_FILE_SYNC= 16
  607. };
  608. typedef enum PSI_file_operation PSI_file_operation;
  609. /** Lock operation performed on an instrumented table. */
  610. enum PSI_table_lock_operation
  611. {
  612. /** Table lock, in the server layer. */
  613. PSI_TABLE_LOCK= 0,
  614. /** Table lock, in the storage engine layer. */
  615. PSI_TABLE_EXTERNAL_LOCK= 1
  616. };
  617. typedef enum PSI_table_lock_operation PSI_table_lock_operation;
  618. /** State of an instrumented socket. */
  619. enum PSI_socket_state
  620. {
  621. /** Idle, waiting for the next command. */
  622. PSI_SOCKET_STATE_IDLE= 1,
  623. /** Active, executing a command. */
  624. PSI_SOCKET_STATE_ACTIVE= 2
  625. };
  626. typedef enum PSI_socket_state PSI_socket_state;
  627. /** Operation performed on an instrumented socket. */
  628. enum PSI_socket_operation
  629. {
  630. /** Socket creation, as in @c socket() or @c socketpair(). */
  631. PSI_SOCKET_CREATE= 0,
  632. /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
  633. PSI_SOCKET_CONNECT= 1,
  634. /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
  635. PSI_SOCKET_BIND= 2,
  636. /** Socket close, as in @c shutdown(). */
  637. PSI_SOCKET_CLOSE= 3,
  638. /** Socket send, @c send(). */
  639. PSI_SOCKET_SEND= 4,
  640. /** Socket receive, @c recv(). */
  641. PSI_SOCKET_RECV= 5,
  642. /** Socket send, @c sendto(). */
  643. PSI_SOCKET_SENDTO= 6,
  644. /** Socket receive, @c recvfrom). */
  645. PSI_SOCKET_RECVFROM= 7,
  646. /** Socket send, @c sendmsg(). */
  647. PSI_SOCKET_SENDMSG= 8,
  648. /** Socket receive, @c recvmsg(). */
  649. PSI_SOCKET_RECVMSG= 9,
  650. /** Socket seek, such as @c fseek() or @c seek(). */
  651. PSI_SOCKET_SEEK= 10,
  652. /** Socket options, as in @c getsockopt() and @c setsockopt(). */
  653. PSI_SOCKET_OPT= 11,
  654. /** Socket status, as in @c sockatmark() and @c isfdtype(). */
  655. PSI_SOCKET_STAT= 12,
  656. /** Socket shutdown, as in @c shutdown(). */
  657. PSI_SOCKET_SHUTDOWN= 13,
  658. /** Socket select, as in @c select() and @c poll(). */
  659. PSI_SOCKET_SELECT= 14
  660. };
  661. typedef enum PSI_socket_operation PSI_socket_operation;
  662. /**
  663. Instrumented mutex key.
  664. To instrument a mutex, a mutex key must be obtained using @c register_mutex.
  665. Using a zero key always disable the instrumentation.
  666. */
  667. typedef unsigned int PSI_mutex_key;
  668. /**
  669. Instrumented rwlock key.
  670. To instrument a rwlock, a rwlock key must be obtained
  671. using @c register_rwlock.
  672. Using a zero key always disable the instrumentation.
  673. */
  674. typedef unsigned int PSI_rwlock_key;
  675. /**
  676. Instrumented cond key.
  677. To instrument a condition, a condition key must be obtained
  678. using @c register_cond.
  679. Using a zero key always disable the instrumentation.
  680. */
  681. typedef unsigned int PSI_cond_key;
  682. /**
  683. Instrumented thread key.
  684. To instrument a thread, a thread key must be obtained
  685. using @c register_thread.
  686. Using a zero key always disable the instrumentation.
  687. */
  688. typedef unsigned int PSI_thread_key;
  689. /**
  690. Instrumented file key.
  691. To instrument a file, a file key must be obtained using @c register_file.
  692. Using a zero key always disable the instrumentation.
  693. */
  694. #ifndef PSI_FILE_KEY_DEFINED
  695. typedef unsigned int PSI_file_key;
  696. #define PSI_FILE_KEY_DEFINED
  697. #endif
  698. /**
  699. Instrumented stage key.
  700. To instrument a stage, a stage key must be obtained using @c register_stage.
  701. Using a zero key always disable the instrumentation.
  702. */
  703. typedef unsigned int PSI_stage_key;
  704. /**
  705. Instrumented statement key.
  706. To instrument a statement, a statement key must be obtained using @c register_statement.
  707. Using a zero key always disable the instrumentation.
  708. */
  709. typedef unsigned int PSI_statement_key;
  710. /**
  711. Instrumented socket key.
  712. To instrument a socket, a socket key must be obtained using @c register_socket.
  713. Using a zero key always disable the instrumentation.
  714. */
  715. typedef unsigned int PSI_socket_key;
  716. #ifdef HAVE_PSI_1
  717. /**
  718. @defgroup Group_PSI_v1 Application Binary Interface, version 1
  719. @ingroup Instrumentation_interface
  720. @{
  721. */
  722. /**
  723. Mutex information.
  724. @since PSI_VERSION_1
  725. This structure is used to register an instrumented mutex.
  726. */
  727. struct PSI_mutex_info_v1
  728. {
  729. /**
  730. Pointer to the key assigned to the registered mutex.
  731. */
  732. PSI_mutex_key *m_key;
  733. /**
  734. The name of the mutex to register.
  735. */
  736. const char *m_name;
  737. /**
  738. The flags of the mutex to register.
  739. @sa PSI_FLAG_GLOBAL
  740. */
  741. int m_flags;
  742. };
  743. typedef struct PSI_mutex_info_v1 PSI_mutex_info_v1;
  744. /**
  745. Rwlock information.
  746. @since PSI_VERSION_1
  747. This structure is used to register an instrumented rwlock.
  748. */
  749. struct PSI_rwlock_info_v1
  750. {
  751. /**
  752. Pointer to the key assigned to the registered rwlock.
  753. */
  754. PSI_rwlock_key *m_key;
  755. /**
  756. The name of the rwlock to register.
  757. */
  758. const char *m_name;
  759. /**
  760. The flags of the rwlock to register.
  761. @sa PSI_FLAG_GLOBAL
  762. */
  763. int m_flags;
  764. };
  765. typedef struct PSI_rwlock_info_v1 PSI_rwlock_info_v1;
  766. /**
  767. Condition information.
  768. @since PSI_VERSION_1
  769. This structure is used to register an instrumented cond.
  770. */
  771. struct PSI_cond_info_v1
  772. {
  773. /**
  774. Pointer to the key assigned to the registered cond.
  775. */
  776. PSI_cond_key *m_key;
  777. /**
  778. The name of the cond to register.
  779. */
  780. const char *m_name;
  781. /**
  782. The flags of the cond to register.
  783. @sa PSI_FLAG_GLOBAL
  784. */
  785. int m_flags;
  786. };
  787. typedef struct PSI_cond_info_v1 PSI_cond_info_v1;
  788. /**
  789. Thread instrument information.
  790. @since PSI_VERSION_1
  791. This structure is used to register an instrumented thread.
  792. */
  793. struct PSI_thread_info_v1
  794. {
  795. /**
  796. Pointer to the key assigned to the registered thread.
  797. */
  798. PSI_thread_key *m_key;
  799. /**
  800. The name of the thread instrument to register.
  801. */
  802. const char *m_name;
  803. /**
  804. The flags of the thread to register.
  805. @sa PSI_FLAG_GLOBAL
  806. */
  807. int m_flags;
  808. };
  809. typedef struct PSI_thread_info_v1 PSI_thread_info_v1;
  810. /**
  811. File instrument information.
  812. @since PSI_VERSION_1
  813. This structure is used to register an instrumented file.
  814. */
  815. struct PSI_file_info_v1
  816. {
  817. /**
  818. Pointer to the key assigned to the registered file.
  819. */
  820. PSI_file_key *m_key;
  821. /**
  822. The name of the file instrument to register.
  823. */
  824. const char *m_name;
  825. /**
  826. The flags of the file instrument to register.
  827. @sa PSI_FLAG_GLOBAL
  828. */
  829. int m_flags;
  830. };
  831. typedef struct PSI_file_info_v1 PSI_file_info_v1;
  832. /**
  833. Stage instrument information.
  834. @since PSI_VERSION_1
  835. This structure is used to register an instrumented stage.
  836. */
  837. struct PSI_stage_info_v1
  838. {
  839. /** The registered stage key. */
  840. PSI_stage_key m_key;
  841. /** The name of the stage instrument to register. */
  842. const char *m_name;
  843. /** The flags of the stage instrument to register. */
  844. int m_flags;
  845. };
  846. typedef struct PSI_stage_info_v1 PSI_stage_info_v1;
  847. /**
  848. Statement instrument information.
  849. @since PSI_VERSION_1
  850. This structure is used to register an instrumented statement.
  851. */
  852. struct PSI_statement_info_v1
  853. {
  854. /** The registered statement key. */
  855. PSI_statement_key m_key;
  856. /** The name of the statement instrument to register. */
  857. const char *m_name;
  858. /** The flags of the statement instrument to register. */
  859. int m_flags;
  860. };
  861. typedef struct PSI_statement_info_v1 PSI_statement_info_v1;
  862. /**
  863. Socket instrument information.
  864. @since PSI_VERSION_1
  865. This structure is used to register an instrumented socket.
  866. */
  867. struct PSI_socket_info_v1
  868. {
  869. /**
  870. Pointer to the key assigned to the registered socket.
  871. */
  872. PSI_socket_key *m_key;
  873. /**
  874. The name of the socket instrument to register.
  875. */
  876. const char *m_name;
  877. /**
  878. The flags of the socket instrument to register.
  879. @sa PSI_FLAG_GLOBAL
  880. */
  881. int m_flags;
  882. };
  883. typedef struct PSI_socket_info_v1 PSI_socket_info_v1;
  884. /**
  885. State data storage for @c start_idle_wait_v1_t.
  886. This structure provide temporary storage to an idle locker.
  887. The content of this structure is considered opaque,
  888. the fields are only hints of what an implementation
  889. of the psi interface can use.
  890. This memory is provided by the instrumented code for performance reasons.
  891. @sa start_idle_wait_v1_t.
  892. */
  893. struct PSI_idle_locker_state_v1
  894. {
  895. /** Internal state. */
  896. uint m_flags;
  897. /** Current thread. */
  898. struct PSI_thread *m_thread;
  899. /** Timer start. */
  900. ulonglong m_timer_start;
  901. /** Timer function. */
  902. ulonglong (*m_timer)(void);
  903. /** Internal data. */
  904. void *m_wait;
  905. };
  906. typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
  907. /**
  908. State data storage for @c start_mutex_wait_v1_t.
  909. This structure provide temporary storage to a mutex locker.
  910. The content of this structure is considered opaque,
  911. the fields are only hints of what an implementation
  912. of the psi interface can use.
  913. This memory is provided by the instrumented code for performance reasons.
  914. @sa start_mutex_wait_v1_t
  915. */
  916. struct PSI_mutex_locker_state_v1
  917. {
  918. /** Internal state. */
  919. uint m_flags;
  920. /** Current operation. */
  921. enum PSI_mutex_operation m_operation;
  922. /** Current mutex. */
  923. struct PSI_mutex *m_mutex;
  924. /** Current thread. */
  925. struct PSI_thread *m_thread;
  926. /** Timer start. */
  927. ulonglong m_timer_start;
  928. /** Timer function. */
  929. ulonglong (*m_timer)(void);
  930. /** Internal data. */
  931. void *m_wait;
  932. };
  933. typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state_v1;
  934. /**
  935. State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
  936. This structure provide temporary storage to a rwlock locker.
  937. The content of this structure is considered opaque,
  938. the fields are only hints of what an implementation
  939. of the psi interface can use.
  940. This memory is provided by the instrumented code for performance reasons.
  941. @sa start_rwlock_rdwait_v1_t
  942. @sa start_rwlock_wrwait_v1_t
  943. */
  944. struct PSI_rwlock_locker_state_v1
  945. {
  946. /** Internal state. */
  947. uint m_flags;
  948. /** Current operation. */
  949. enum PSI_rwlock_operation m_operation;
  950. /** Current rwlock. */
  951. struct PSI_rwlock *m_rwlock;
  952. /** Current thread. */
  953. struct PSI_thread *m_thread;
  954. /** Timer start. */
  955. ulonglong m_timer_start;
  956. /** Timer function. */
  957. ulonglong (*m_timer)(void);
  958. /** Internal data. */
  959. void *m_wait;
  960. };
  961. typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state_v1;
  962. /**
  963. State data storage for @c start_cond_wait_v1_t.
  964. This structure provide temporary storage to a condition locker.
  965. The content of this structure is considered opaque,
  966. the fields are only hints of what an implementation
  967. of the psi interface can use.
  968. This memory is provided by the instrumented code for performance reasons.
  969. @sa start_cond_wait_v1_t
  970. */
  971. struct PSI_cond_locker_state_v1
  972. {
  973. /** Internal state. */
  974. uint m_flags;
  975. /** Current operation. */
  976. enum PSI_cond_operation m_operation;
  977. /** Current condition. */
  978. struct PSI_cond *m_cond;
  979. /** Current mutex. */
  980. struct PSI_mutex *m_mutex;
  981. /** Current thread. */
  982. struct PSI_thread *m_thread;
  983. /** Timer start. */
  984. ulonglong m_timer_start;
  985. /** Timer function. */
  986. ulonglong (*m_timer)(void);
  987. /** Internal data. */
  988. void *m_wait;
  989. };
  990. typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state_v1;
  991. /**
  992. State data storage for @c get_thread_file_name_locker_v1_t.
  993. This structure provide temporary storage to a file locker.
  994. The content of this structure is considered opaque,
  995. the fields are only hints of what an implementation
  996. of the psi interface can use.
  997. This memory is provided by the instrumented code for performance reasons.
  998. @sa get_thread_file_name_locker_v1_t
  999. @sa get_thread_file_stream_locker_v1_t
  1000. @sa get_thread_file_descriptor_locker_v1_t
  1001. */
  1002. struct PSI_file_locker_state_v1
  1003. {
  1004. /** Internal state. */
  1005. uint m_flags;
  1006. /** Current operation. */
  1007. enum PSI_file_operation m_operation;
  1008. /** Current file. */
  1009. struct PSI_file *m_file;
  1010. /** Current file name. */
  1011. const char *m_name;
  1012. /** Current file class. */
  1013. void *m_class;
  1014. /** Current thread. */
  1015. struct PSI_thread *m_thread;
  1016. /** Operation number of bytes. */
  1017. size_t m_number_of_bytes;
  1018. /** Timer start. */
  1019. ulonglong m_timer_start;
  1020. /** Timer function. */
  1021. ulonglong (*m_timer)(void);
  1022. /** Internal data. */
  1023. void *m_wait;
  1024. };
  1025. typedef struct PSI_file_locker_state_v1 PSI_file_locker_state_v1;
  1026. /**
  1027. State data storage for @c start_metadata_wait_v1_t.
  1028. This structure provide temporary storage to a metadata locker.
  1029. The content of this structure is considered opaque,
  1030. the fields are only hints of what an implementation
  1031. of the psi interface can use.
  1032. This memory is provided by the instrumented code for performance reasons.
  1033. @sa start_metadata_wait_v1_t
  1034. */
  1035. struct PSI_metadata_locker_state_v1
  1036. {
  1037. /** Internal state. */
  1038. uint m_flags;
  1039. /** Current metadata lock. */
  1040. struct PSI_metadata_lock *m_metadata_lock;
  1041. /** Current thread. */
  1042. struct PSI_thread *m_thread;
  1043. /** Timer start. */
  1044. ulonglong m_timer_start;
  1045. /** Timer function. */
  1046. ulonglong (*m_timer)(void);
  1047. /** Internal data. */
  1048. void *m_wait;
  1049. };
  1050. typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state_v1;
  1051. /* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
  1052. #define PSI_SCHEMA_NAME_LEN (64 * 3)
  1053. /**
  1054. State data storage for @c get_thread_statement_locker_v1_t,
  1055. @c get_thread_statement_locker_v1_t.
  1056. This structure provide temporary storage to a statement locker.
  1057. The content of this structure is considered opaque,
  1058. the fields are only hints of what an implementation
  1059. of the psi interface can use.
  1060. This memory is provided by the instrumented code for performance reasons.
  1061. @sa get_thread_statement_locker_v1_t
  1062. */
  1063. struct PSI_statement_locker_state_v1
  1064. {
  1065. /** Discarded flag. */
  1066. my_bool m_discarded;
  1067. /** In prepare flag. */
  1068. my_bool m_in_prepare;
  1069. /** Metric, no index used flag. */
  1070. uchar m_no_index_used;
  1071. /** Metric, no good index used flag. */
  1072. uchar m_no_good_index_used;
  1073. /** Internal state. */
  1074. uint m_flags;
  1075. /** Instrumentation class. */
  1076. void *m_class;
  1077. /** Current thread. */
  1078. struct PSI_thread *m_thread;
  1079. /** Timer start. */
  1080. ulonglong m_timer_start;
  1081. /** Timer function. */
  1082. ulonglong (*m_timer)(void);
  1083. /** Internal data. */
  1084. void *m_statement;
  1085. /** Locked time. */
  1086. ulonglong m_lock_time;
  1087. /** Rows sent. */
  1088. ulonglong m_rows_sent;
  1089. /** Rows examined. */
  1090. ulonglong m_rows_examined;
  1091. /** Metric, temporary tables created on disk. */
  1092. ulong m_created_tmp_disk_tables;
  1093. /** Metric, temporary tables created. */
  1094. ulong m_created_tmp_tables;
  1095. /** Metric, number of select full join. */
  1096. ulong m_select_full_join;
  1097. /** Metric, number of select full range join. */
  1098. ulong m_select_full_range_join;
  1099. /** Metric, number of select range. */
  1100. ulong m_select_range;
  1101. /** Metric, number of select range check. */
  1102. ulong m_select_range_check;
  1103. /** Metric, number of select scan. */
  1104. ulong m_select_scan;
  1105. /** Metric, number of sort merge passes. */
  1106. ulong m_sort_merge_passes;
  1107. /** Metric, number of sort merge. */
  1108. ulong m_sort_range;
  1109. /** Metric, number of sort rows. */
  1110. ulong m_sort_rows;
  1111. /** Metric, number of sort scans. */
  1112. ulong m_sort_scan;
  1113. /** Statement digest. */
  1114. const struct sql_digest_storage *m_digest;
  1115. /** Current schema name. */
  1116. char m_schema_name[PSI_SCHEMA_NAME_LEN];
  1117. /** Length in bytes of @c m_schema_name. */
  1118. uint m_schema_name_length;
  1119. /** Statement character set number. */
  1120. uint m_cs_number;
  1121. PSI_sp_share *m_parent_sp_share;
  1122. PSI_prepared_stmt *m_parent_prepared_stmt;
  1123. };
  1124. typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state_v1;
  1125. /**
  1126. State data storage for @c get_thread_transaction_locker_v1_t,
  1127. @c get_thread_transaction_locker_v1_t.
  1128. This structure provide temporary storage to a transaction locker.
  1129. The content of this structure is considered opaque,
  1130. the fields are only hints of what an implementation
  1131. of the psi interface can use.
  1132. This memory is provided by the instrumented code for performance reasons.
  1133. @sa get_thread_transaction_locker_v1_t
  1134. */
  1135. struct PSI_transaction_locker_state_v1
  1136. {
  1137. /** Internal state. */
  1138. uint m_flags;
  1139. /** Instrumentation class. */
  1140. void *m_class;
  1141. /** Current thread. */
  1142. struct PSI_thread *m_thread;
  1143. /** Timer start. */
  1144. ulonglong m_timer_start;
  1145. /** Timer function. */
  1146. ulonglong (*m_timer)(void);
  1147. /** Internal data. */
  1148. void *m_transaction;
  1149. /** True if read-only transaction, false if read-write. */
  1150. my_bool m_read_only;
  1151. /** True if transaction is autocommit. */
  1152. my_bool m_autocommit;
  1153. /** Number of statements. */
  1154. ulong m_statement_count;
  1155. /** Total number of savepoints. */
  1156. ulong m_savepoint_count;
  1157. /** Number of rollback_to_savepoint. */
  1158. ulong m_rollback_to_savepoint_count;
  1159. /** Number of release_savepoint. */
  1160. ulong m_release_savepoint_count;
  1161. };
  1162. typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state_v1;
  1163. /**
  1164. State data storage for @c start_socket_wait_v1_t.
  1165. This structure provide temporary storage to a socket locker.
  1166. The content of this structure is considered opaque,
  1167. the fields are only hints of what an implementation
  1168. of the psi interface can use.
  1169. This memory is provided by the instrumented code for performance reasons.
  1170. @sa start_socket_wait_v1_t
  1171. */
  1172. struct PSI_socket_locker_state_v1
  1173. {
  1174. /** Internal state. */
  1175. uint m_flags;
  1176. /** Current socket. */
  1177. struct PSI_socket *m_socket;
  1178. /** Current thread. */
  1179. struct PSI_thread *m_thread;
  1180. /** Operation number of bytes. */
  1181. size_t m_number_of_bytes;
  1182. /** Timer start. */
  1183. ulonglong m_timer_start;
  1184. /** Timer function. */
  1185. ulonglong (*m_timer)(void);
  1186. /** Current operation. */
  1187. enum PSI_socket_operation m_operation;
  1188. /** Source file. */
  1189. const char* m_src_file;
  1190. /** Source line number. */
  1191. int m_src_line;
  1192. /** Internal data. */
  1193. void *m_wait;
  1194. };
  1195. typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state_v1;
  1196. struct PSI_sp_locker_state_v1
  1197. {
  1198. /** Internal state. */
  1199. uint m_flags;
  1200. /** Current thread. */
  1201. struct PSI_thread *m_thread;
  1202. /** Timer start. */
  1203. ulonglong m_timer_start;
  1204. /** Timer function. */
  1205. ulonglong (*m_timer)(void);
  1206. /** Stored Procedure share. */
  1207. PSI_sp_share* m_sp_share;
  1208. };
  1209. typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state_v1;
  1210. /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
  1211. /**
  1212. Mutex registration API.
  1213. @param category a category name (typically a plugin name)
  1214. @param info an array of mutex info to register
  1215. @param count the size of the info array
  1216. */
  1217. typedef void (*register_mutex_v1_t)
  1218. (const char *category, struct PSI_mutex_info_v1 *info, int count);
  1219. /**
  1220. Rwlock registration API.
  1221. @param category a category name (typically a plugin name)
  1222. @param info an array of rwlock info to register
  1223. @param count the size of the info array
  1224. */
  1225. typedef void (*register_rwlock_v1_t)
  1226. (const char *category, struct PSI_rwlock_info_v1 *info, int count);
  1227. /**
  1228. Cond registration API.
  1229. @param category a category name (typically a plugin name)
  1230. @param info an array of cond info to register
  1231. @param count the size of the info array
  1232. */
  1233. typedef void (*register_cond_v1_t)
  1234. (const char *category, struct PSI_cond_info_v1 *info, int count);
  1235. /**
  1236. Thread registration API.
  1237. @param category a category name (typically a plugin name)
  1238. @param info an array of thread info to register
  1239. @param count the size of the info array
  1240. */
  1241. typedef void (*register_thread_v1_t)
  1242. (const char *category, struct PSI_thread_info_v1 *info, int count);
  1243. /**
  1244. File registration API.
  1245. @param category a category name (typically a plugin name)
  1246. @param info an array of file info to register
  1247. @param count the size of the info array
  1248. */
  1249. typedef void (*register_file_v1_t)
  1250. (const char *category, struct PSI_file_info_v1 *info, int count);
  1251. /**
  1252. Stage registration API.
  1253. @param category a category name
  1254. @param info an array of stage info to register
  1255. @param count the size of the info array
  1256. */
  1257. typedef void (*register_stage_v1_t)
  1258. (const char *category, struct PSI_stage_info_v1 **info, int count);
  1259. /**
  1260. Statement registration API.
  1261. @param category a category name
  1262. @param info an array of stage info to register
  1263. @param count the size of the info array
  1264. */
  1265. typedef void (*register_statement_v1_t)
  1266. (const char *category, struct PSI_statement_info_v1 *info, int count);
  1267. /**
  1268. Socket registration API.
  1269. @param category a category name (typically a plugin name)
  1270. @param info an array of socket info to register
  1271. @param count the size of the info array
  1272. */
  1273. typedef void (*register_socket_v1_t)
  1274. (const char *category, struct PSI_socket_info_v1 *info, int count);
  1275. /**
  1276. Mutex instrumentation initialisation API.
  1277. @param key the registered mutex key
  1278. @param identity the address of the mutex itself
  1279. @return an instrumented mutex
  1280. */
  1281. typedef struct PSI_mutex* (*init_mutex_v1_t)
  1282. (PSI_mutex_key key, const void *identity);
  1283. /**
  1284. Mutex instrumentation destruction API.
  1285. @param mutex the mutex to destroy
  1286. */
  1287. typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex);
  1288. /**
  1289. Rwlock instrumentation initialisation API.
  1290. @param key the registered rwlock key
  1291. @param identity the address of the rwlock itself
  1292. @return an instrumented rwlock
  1293. */
  1294. typedef struct PSI_rwlock* (*init_rwlock_v1_t)
  1295. (PSI_rwlock_key key, const void *identity);
  1296. /**
  1297. Rwlock instrumentation destruction API.
  1298. @param rwlock the rwlock to destroy
  1299. */
  1300. typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
  1301. /**
  1302. Cond instrumentation initialisation API.
  1303. @param key the registered key
  1304. @param identity the address of the rwlock itself
  1305. @return an instrumented cond
  1306. */
  1307. typedef struct PSI_cond* (*init_cond_v1_t)
  1308. (PSI_cond_key key, const void *identity);
  1309. /**
  1310. Cond instrumentation destruction API.
  1311. @param cond the rcond to destroy
  1312. */
  1313. typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
  1314. /**
  1315. Socket instrumentation initialisation API.
  1316. @param key the registered mutex key
  1317. @param socket descriptor
  1318. @param addr the socket ip address
  1319. @param addr_len length of socket ip address
  1320. @return an instrumented socket
  1321. */
  1322. typedef struct PSI_socket* (*init_socket_v1_t)
  1323. (PSI_socket_key key, const my_socket *fd,
  1324. const struct sockaddr *addr, socklen_t addr_len);
  1325. /**
  1326. socket instrumentation destruction API.
  1327. @param socket the socket to destroy
  1328. */
  1329. typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
  1330. /**
  1331. Acquire a table share instrumentation.
  1332. @param temporary True for temporary tables
  1333. @param share The SQL layer table share
  1334. @return a table share instrumentation, or NULL
  1335. */
  1336. typedef struct PSI_table_share* (*get_table_share_v1_t)
  1337. (my_bool temporary, struct TABLE_SHARE *share);
  1338. /**
  1339. Release a table share.
  1340. @param info the table share to release
  1341. */
  1342. typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
  1343. /**
  1344. Drop a table share.
  1345. @param temporary True for temporary tables
  1346. @param schema_name the table schema name
  1347. @param schema_name_length the table schema name length
  1348. @param table_name the table name
  1349. @param table_name_length the table name length
  1350. */
  1351. typedef void (*drop_table_share_v1_t)
  1352. (my_bool temporary, const char *schema_name, int schema_name_length,
  1353. const char *table_name, int table_name_length);
  1354. /**
  1355. Open an instrumentation table handle.
  1356. @param share the table to open
  1357. @param identity table handle identity
  1358. @return a table handle, or NULL
  1359. */
  1360. typedef struct PSI_table* (*open_table_v1_t)
  1361. (struct PSI_table_share *share, const void *identity);
  1362. /**
  1363. Unbind a table handle from the current thread.
  1364. This operation happens when an opened table is added to the open table cache.
  1365. @param table the table to unbind
  1366. */
  1367. typedef void (*unbind_table_v1_t)
  1368. (struct PSI_table *table);
  1369. /**
  1370. Rebind a table handle to the current thread.
  1371. This operation happens when a table from the open table cache
  1372. is reused for a thread.
  1373. @param table the table to unbind
  1374. */
  1375. typedef PSI_table* (*rebind_table_v1_t)
  1376. (PSI_table_share *share, const void *identity, PSI_table *table);
  1377. /**
  1378. Close an instrumentation table handle.
  1379. Note that the table handle is invalid after this call.
  1380. @param table the table handle to close
  1381. */
  1382. typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
  1383. struct PSI_table *table);
  1384. /**
  1385. Create a file instrumentation for a created file.
  1386. This method does not create the file itself, but is used to notify the
  1387. instrumentation interface that a file was just created.
  1388. @param key the file instrumentation key for this file
  1389. @param name the file name
  1390. @param file the file handle
  1391. */
  1392. typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
  1393. File file);
  1394. /**
  1395. Spawn a thread.
  1396. This method creates a new thread, with instrumentation.
  1397. @param key the instrumentation key for this thread
  1398. @param thread the resulting thread
  1399. @param attr the thread attributes
  1400. @param start_routine the thread start routine
  1401. @param arg the thread start routine argument
  1402. */
  1403. typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
  1404. my_thread_handle *thread,
  1405. const my_thread_attr_t *attr,
  1406. void *(*start_routine)(void*), void *arg);
  1407. /**
  1408. Create instrumentation for a thread.
  1409. @param key the registered key
  1410. @param identity an address typical of the thread
  1411. @return an instrumented thread
  1412. */
  1413. typedef struct PSI_thread* (*new_thread_v1_t)
  1414. (PSI_thread_key key, const void *identity, ulonglong thread_id);
  1415. /**
  1416. Assign a THD to an instrumented thread.
  1417. @param thread the instrumented thread
  1418. @param THD the sql layer THD to assign
  1419. */
  1420. typedef void (*set_thread_THD_v1_t)(struct PSI_thread *thread,
  1421. THD *thd);
  1422. /**
  1423. Assign an id to an instrumented thread.
  1424. @param thread the instrumented thread
  1425. @param id the id to assign
  1426. */
  1427. typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
  1428. ulonglong id);
  1429. /**
  1430. Assign the current operating system thread id to an instrumented thread.
  1431. The operating system task id is obtained from @c gettid()
  1432. @param thread the instrumented thread
  1433. */
  1434. typedef void (*set_thread_os_id_v1_t)(struct PSI_thread *thread);
  1435. /**
  1436. Get the instrumentation for the running thread.
  1437. For this function to return a result,
  1438. the thread instrumentation must have been attached to the
  1439. running thread using @c set_thread()
  1440. @return the instrumentation for the running thread
  1441. */
  1442. typedef struct PSI_thread* (*get_thread_v1_t)(void);
  1443. /**
  1444. Assign a user name to the instrumented thread.
  1445. @param user the user name
  1446. @param user_len the user name length
  1447. */
  1448. typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
  1449. /**
  1450. Assign a user name and host name to the instrumented thread.
  1451. @param user the user name
  1452. @param user_len the user name length
  1453. @param host the host name
  1454. @param host_len the host name length
  1455. */
  1456. typedef void (*set_thread_account_v1_t)(const char *user, int user_len,
  1457. const char *host, int host_len);
  1458. /**
  1459. Assign a current database to the instrumented thread.
  1460. @param db the database name
  1461. @param db_len the database name length
  1462. */
  1463. typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
  1464. /**
  1465. Assign a current command to the instrumented thread.
  1466. @param command the current command
  1467. */
  1468. typedef void (*set_thread_command_v1_t)(int command);
  1469. /**
  1470. Assign a connection type to the instrumented thread.
  1471. @param conn_type the connection type
  1472. */
  1473. typedef void (*set_connection_type_v1_t)(opaque_vio_type conn_type);
  1474. /**
  1475. Assign a start time to the instrumented thread.
  1476. @param start_time the thread start time
  1477. */
  1478. typedef void (*set_thread_start_time_v1_t)(time_t start_time);
  1479. /**
  1480. Assign a state to the instrumented thread.
  1481. @param state the thread state
  1482. */
  1483. typedef void (*set_thread_state_v1_t)(const char* state);
  1484. /**
  1485. Assign a process info to the instrumented thread.
  1486. @param info the process into string
  1487. @param info_len the process into string length
  1488. */
  1489. typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
  1490. /**
  1491. Attach a thread instrumentation to the running thread.
  1492. In case of thread pools, this method should be called when
  1493. a worker thread picks a work item and runs it.
  1494. Also, this method should be called if the instrumented code does not
  1495. keep the pointer returned by @c new_thread() and relies on @c get_thread()
  1496. instead.
  1497. @param thread the thread instrumentation
  1498. */
  1499. typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
  1500. /** Delete the current thread instrumentation. */
  1501. typedef void (*delete_current_thread_v1_t)(void);
  1502. /** Delete a thread instrumentation. */
  1503. typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
  1504. /**
  1505. Get a file instrumentation locker, for opening or creating a file.
  1506. @param state data storage for the locker
  1507. @param key the file instrumentation key
  1508. @param op the operation to perform
  1509. @param name the file name
  1510. @param identity a pointer representative of this file.
  1511. @return a file locker, or NULL
  1512. */
  1513. typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
  1514. (struct PSI_file_locker_state_v1 *state,
  1515. PSI_file_key key, enum PSI_file_operation op, const char *name,
  1516. const void *identity);
  1517. /**
  1518. Get a file stream instrumentation locker.
  1519. @param state data storage for the locker
  1520. @param file the file stream to access
  1521. @param op the operation to perform
  1522. @return a file locker, or NULL
  1523. */
  1524. typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t)
  1525. (struct PSI_file_locker_state_v1 *state,
  1526. struct PSI_file *file, enum PSI_file_operation op);
  1527. /**
  1528. Get a file instrumentation locker.
  1529. @param state data storage for the locker
  1530. @param file the file descriptor to access
  1531. @param op the operation to perform
  1532. @return a file locker, or NULL
  1533. */
  1534. typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t)
  1535. (struct PSI_file_locker_state_v1 *state,
  1536. File file, enum PSI_file_operation op);
  1537. /**
  1538. Record a mutex instrumentation unlock event.
  1539. @param mutex the mutex instrumentation
  1540. */
  1541. typedef void (*unlock_mutex_v1_t)
  1542. (struct PSI_mutex *mutex);
  1543. /**
  1544. Record a rwlock instrumentation unlock event.
  1545. @param rwlock the rwlock instrumentation
  1546. */
  1547. typedef void (*unlock_rwlock_v1_t)
  1548. (struct PSI_rwlock *rwlock);
  1549. /**
  1550. Record a condition instrumentation signal event.
  1551. @param cond the cond instrumentation
  1552. */
  1553. typedef void (*signal_cond_v1_t)
  1554. (struct PSI_cond *cond);
  1555. /**
  1556. Record a condition instrumentation broadcast event.
  1557. @param cond the cond instrumentation
  1558. */
  1559. typedef void (*broadcast_cond_v1_t)
  1560. (struct PSI_cond *cond);
  1561. /**
  1562. Record an idle instrumentation wait start event.
  1563. @param state data storage for the locker
  1564. @param file the source file name
  1565. @param line the source line number
  1566. @return an idle locker, or NULL
  1567. */
  1568. typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
  1569. (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
  1570. /**
  1571. Record an idle instrumentation wait end event.
  1572. @param locker a thread locker for the running thread
  1573. */
  1574. typedef void (*end_idle_wait_v1_t)
  1575. (struct PSI_idle_locker *locker);
  1576. /**
  1577. Record a mutex instrumentation wait start event.
  1578. @param state data storage for the locker
  1579. @param mutex the instrumented mutex to lock
  1580. @param op the operation to perform
  1581. @param file the source file name
  1582. @param line the source line number
  1583. @return a mutex locker, or NULL
  1584. */
  1585. typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
  1586. (struct PSI_mutex_locker_state_v1 *state,
  1587. struct PSI_mutex *mutex,
  1588. enum PSI_mutex_operation op,
  1589. const char *src_file, uint src_line);
  1590. /**
  1591. Record a mutex instrumentation wait end event.
  1592. @param locker a thread locker for the running thread
  1593. @param rc the wait operation return code
  1594. */
  1595. typedef void (*end_mutex_wait_v1_t)
  1596. (struct PSI_mutex_locker *locker, int rc);
  1597. /**
  1598. Record a rwlock instrumentation read wait start event.
  1599. @param locker a thread locker for the running thread
  1600. @param must must block: 1 for lock, 0 for trylock
  1601. */
  1602. typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
  1603. (struct PSI_rwlock_locker_state_v1 *state,
  1604. struct PSI_rwlock *rwlock,
  1605. enum PSI_rwlock_operation op,
  1606. const char *src_file, uint src_line);
  1607. /**
  1608. Record a rwlock instrumentation read wait end event.
  1609. @param locker a thread locker for the running thread
  1610. @param rc the wait operation return code
  1611. */
  1612. typedef void (*end_rwlock_rdwait_v1_t)
  1613. (struct PSI_rwlock_locker *locker, int rc);
  1614. /**
  1615. Record a rwlock instrumentation write wait start event.
  1616. @param locker a thread locker for the running thread
  1617. @param must must block: 1 for lock, 0 for trylock
  1618. */
  1619. typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
  1620. (struct PSI_rwlock_locker_state_v1 *state,
  1621. struct PSI_rwlock *rwlock,
  1622. enum PSI_rwlock_operation op,
  1623. const char *src_file, uint src_line);
  1624. /**
  1625. Record a rwlock instrumentation write wait end event.
  1626. @param locker a thread locker for the running thread
  1627. @param rc the wait operation return code
  1628. */
  1629. typedef void (*end_rwlock_wrwait_v1_t)
  1630. (struct PSI_rwlock_locker *locker, int rc);
  1631. /**
  1632. Record a condition instrumentation wait start event.
  1633. @param locker a thread locker for the running thread
  1634. @param must must block: 1 for wait, 0 for timedwait
  1635. */
  1636. typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
  1637. (struct PSI_cond_locker_state_v1 *state,
  1638. struct PSI_cond *cond,
  1639. struct PSI_mutex *mutex,
  1640. enum PSI_cond_operation op,
  1641. const char *src_file, uint src_line);
  1642. /**
  1643. Record a condition instrumentation wait end event.
  1644. @param locker a thread locker for the running thread
  1645. @param rc the wait operation return code
  1646. */
  1647. typedef void (*end_cond_wait_v1_t)
  1648. (struct PSI_cond_locker *locker, int rc);
  1649. /**
  1650. Record a table instrumentation io wait start event.
  1651. @param locker a table locker for the running thread
  1652. @param file the source file name
  1653. @param line the source line number
  1654. */
  1655. typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
  1656. (struct PSI_table_locker_state *state,
  1657. struct PSI_table *table,
  1658. enum PSI_table_io_operation op,
  1659. uint index,
  1660. const char *src_file, uint src_line);
  1661. /**
  1662. Record a table instrumentation io wait end event.
  1663. @param locker a table locker for the running thread
  1664. @param numrows the number of rows involved in io
  1665. */
  1666. typedef void (*end_table_io_wait_v1_t)
  1667. (struct PSI_table_locker *locker,
  1668. ulonglong numrows);
  1669. /**
  1670. Record a table instrumentation lock wait start event.
  1671. @param locker a table locker for the running thread
  1672. @param file the source file name
  1673. @param line the source line number
  1674. */
  1675. typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
  1676. (struct PSI_table_locker_state *state,
  1677. struct PSI_table *table,
  1678. enum PSI_table_lock_operation op,
  1679. ulong flags,
  1680. const char *src_file, uint src_line);
  1681. /**
  1682. Record a table instrumentation lock wait end event.
  1683. @param locker a table locker for the running thread
  1684. */
  1685. typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
  1686. typedef void (*unlock_table_v1_t)(struct PSI_table *table);
  1687. /**
  1688. Start a file instrumentation open operation.
  1689. @param locker the file locker
  1690. @param op the operation to perform
  1691. @param src_file the source file name
  1692. @param src_line the source line number
  1693. */
  1694. typedef void (*start_file_open_wait_v1_t)
  1695. (struct PSI_file_locker *locker, const char *src_file, uint src_line);
  1696. /**
  1697. End a file instrumentation open operation, for file streams.
  1698. @param locker the file locker.
  1699. @param result the opened file (NULL indicates failure, non NULL success).
  1700. @return an instrumented file handle
  1701. */
  1702. typedef struct PSI_file* (*end_file_open_wait_v1_t)
  1703. (struct PSI_file_locker *locker, void *result);
  1704. /**
  1705. End a file instrumentation open operation, for non stream files.
  1706. @param locker the file locker.
  1707. @param file the file number assigned by open() or create() for this file.
  1708. */
  1709. typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
  1710. (struct PSI_file_locker *locker, File file);
  1711. /**
  1712. End a file instrumentation open operation, for non stream temporary files.
  1713. @param locker the file locker.
  1714. @param file the file number assigned by open() or create() for this file.
  1715. @param filename the file name generated during temporary file creation.
  1716. */
  1717. typedef void (*end_temp_file_open_wait_and_bind_to_descriptor_v1_t)
  1718. (struct PSI_file_locker *locker, File file, const char *filename);
  1719. /**
  1720. Record a file instrumentation start event.
  1721. @param locker a file locker for the running thread
  1722. @param op file operation to be performed
  1723. @param count the number of bytes requested, or 0 if not applicable
  1724. @param src_file the source file name
  1725. @param src_line the source line number
  1726. */
  1727. typedef void (*start_file_wait_v1_t)
  1728. (struct PSI_file_locker *locker, size_t count,
  1729. const char *src_file, uint src_line);
  1730. /**
  1731. Record a file instrumentation end event.
  1732. Note that for file close operations, the instrumented file handle
  1733. associated with the file (which was provided to obtain a locker)
  1734. is invalid after this call.
  1735. @param locker a file locker for the running thread
  1736. @param count the number of bytes actually used in the operation,
  1737. or 0 if not applicable, or -1 if the operation failed
  1738. @sa get_thread_file_name_locker
  1739. @sa get_thread_file_stream_locker
  1740. @sa get_thread_file_descriptor_locker
  1741. */
  1742. typedef void (*end_file_wait_v1_t)
  1743. (struct PSI_file_locker *locker, size_t count);
  1744. /**
  1745. Start a file instrumentation close operation.
  1746. @param locker the file locker
  1747. @param op the operation to perform
  1748. @param src_file the source file name
  1749. @param src_line the source line number
  1750. */
  1751. typedef void (*start_file_close_wait_v1_t)
  1752. (struct PSI_file_locker *locker, const char *src_file, uint src_line);
  1753. /**
  1754. End a file instrumentation close operation.
  1755. @param locker the file locker.
  1756. @param rc the close operation return code (0 for success).
  1757. @return an instrumented file handle
  1758. */
  1759. typedef void (*end_file_close_wait_v1_t)
  1760. (struct PSI_file_locker *locker, int rc);
  1761. /**
  1762. Rename a file instrumentation close operation.
  1763. @param locker the file locker.
  1764. @param old_name name of the file to be renamed.
  1765. @param new_name name of the file after rename.
  1766. @param rc the rename operation return code (0 for success).
  1767. */
  1768. typedef void (*end_file_rename_wait_v1_t)
  1769. (struct PSI_file_locker *locker, const char *old_name,
  1770. const char *new_name, int rc);
  1771. /**
  1772. Start a new stage, and implicitly end the previous stage.
  1773. @param key the key of the new stage
  1774. @param src_file the source file name
  1775. @param src_line the source line number
  1776. @return the new stage progress
  1777. */
  1778. typedef PSI_stage_progress* (*start_stage_v1_t)
  1779. (PSI_stage_key key, const char *src_file, int src_line);
  1780. typedef PSI_stage_progress* (*get_current_stage_progress_v1_t)(void);
  1781. /** End the current stage. */
  1782. typedef void (*end_stage_v1_t) (void);
  1783. /**
  1784. Get a statement instrumentation locker.
  1785. @param state data storage for the locker
  1786. @param key the statement instrumentation key
  1787. @param charset client character set
  1788. @return a statement locker, or NULL
  1789. */
  1790. typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
  1791. (struct PSI_statement_locker_state_v1 *state,
  1792. PSI_statement_key key, const void *charset, PSI_sp_share *sp_share);
  1793. /**
  1794. Refine a statement locker to a more specific key.
  1795. Note that only events declared mutable can be refined.
  1796. @param the statement locker for the current event
  1797. @param key the new key for the event
  1798. @sa PSI_FLAG_MUTABLE
  1799. */
  1800. typedef struct PSI_statement_locker* (*refine_statement_v1_t)
  1801. (struct PSI_statement_locker *locker,
  1802. PSI_statement_key key);
  1803. /**
  1804. Start a new statement event.
  1805. @param locker the statement locker for this event
  1806. @param db the active database name for this statement
  1807. @param db_length the active database name length for this statement
  1808. @param src_file source file name
  1809. @param src_line source line number
  1810. */
  1811. typedef void (*start_statement_v1_t)
  1812. (struct PSI_statement_locker *locker,
  1813. const char *db, uint db_length,
  1814. const char *src_file, uint src_line);
  1815. /**
  1816. Set the statement text for a statement event.
  1817. @param locker the current statement locker
  1818. @param text the statement text
  1819. @param text_len the statement text length
  1820. */
  1821. typedef void (*set_statement_text_v1_t)
  1822. (struct PSI_statement_locker *locker,
  1823. const char *text, uint text_len);
  1824. /**
  1825. Set a statement event lock time.
  1826. @param locker the statement locker
  1827. @param lock_time the locked time, in microseconds
  1828. */
  1829. typedef void (*set_statement_lock_time_t)
  1830. (struct PSI_statement_locker *locker, ulonglong lock_time);
  1831. /**
  1832. Set a statement event rows sent metric.
  1833. @param locker the statement locker
  1834. @param count the number of rows sent
  1835. */
  1836. typedef void (*set_statement_rows_sent_t)
  1837. (struct PSI_statement_locker *locker, ulonglong count);
  1838. /**
  1839. Set a statement event rows examined metric.
  1840. @param locker the statement locker
  1841. @param count the number of rows examined
  1842. */
  1843. typedef void (*set_statement_rows_examined_t)
  1844. (struct PSI_statement_locker *locker, ulonglong count);
  1845. /**
  1846. Increment a statement event "created tmp disk tables" metric.
  1847. @param locker the statement locker
  1848. @param count the metric increment value
  1849. */
  1850. typedef void (*inc_statement_created_tmp_disk_tables_t)
  1851. (struct PSI_statement_locker *locker, ulong count);
  1852. /**
  1853. Increment a statement event "created tmp tables" metric.
  1854. @param locker the statement locker
  1855. @param count the metric increment value
  1856. */
  1857. typedef void (*inc_statement_created_tmp_tables_t)
  1858. (struct PSI_statement_locker *locker, ulong count);
  1859. /**
  1860. Increment a statement event "select full join" metric.
  1861. @param locker the statement locker
  1862. @param count the metric increment value
  1863. */
  1864. typedef void (*inc_statement_select_full_join_t)
  1865. (struct PSI_statement_locker *locker, ulong count);
  1866. /**
  1867. Increment a statement event "select full range join" metric.
  1868. @param locker the statement locker
  1869. @param count the metric increment value
  1870. */
  1871. typedef void (*inc_statement_select_full_range_join_t)
  1872. (struct PSI_statement_locker *locker, ulong count);
  1873. /**
  1874. Increment a statement event "select range join" metric.
  1875. @param locker the statement locker
  1876. @param count the metric increment value
  1877. */
  1878. typedef void (*inc_statement_select_range_t)
  1879. (struct PSI_statement_locker *locker, ulong count);
  1880. /**
  1881. Increment a statement event "select range check" metric.
  1882. @param locker the statement locker
  1883. @param count the metric increment value
  1884. */
  1885. typedef void (*inc_statement_select_range_check_t)
  1886. (struct PSI_statement_locker *locker, ulong count);
  1887. /**
  1888. Increment a statement event "select scan" metric.
  1889. @param locker the statement locker
  1890. @param count the metric increment value
  1891. */
  1892. typedef void (*inc_statement_select_scan_t)
  1893. (struct PSI_statement_locker *locker, ulong count);
  1894. /**
  1895. Increment a statement event "sort merge passes" metric.
  1896. @param locker the statement locker
  1897. @param count the metric increment value
  1898. */
  1899. typedef void (*inc_statement_sort_merge_passes_t)
  1900. (struct PSI_statement_locker *locker, ulong count);
  1901. /**
  1902. Increment a statement event "sort range" metric.
  1903. @param locker the statement locker
  1904. @param count the metric increment value
  1905. */
  1906. typedef void (*inc_statement_sort_range_t)
  1907. (struct PSI_statement_locker *locker, ulong count);
  1908. /**
  1909. Increment a statement event "sort rows" metric.
  1910. @param locker the statement locker
  1911. @param count the metric increment value
  1912. */
  1913. typedef void (*inc_statement_sort_rows_t)
  1914. (struct PSI_statement_locker *locker, ulong count);
  1915. /**
  1916. Increment a statement event "sort scan" metric.
  1917. @param locker the statement locker
  1918. @param count the metric increment value
  1919. */
  1920. typedef void (*inc_statement_sort_scan_t)
  1921. (struct PSI_statement_locker *locker, ulong count);
  1922. /**
  1923. Set a statement event "no index used" metric.
  1924. @param locker the statement locker
  1925. @param count the metric value
  1926. */
  1927. typedef void (*set_statement_no_index_used_t)
  1928. (struct PSI_statement_locker *locker);
  1929. /**
  1930. Set a statement event "no good index used" metric.
  1931. @param locker the statement locker
  1932. @param count the metric value
  1933. */
  1934. typedef void (*set_statement_no_good_index_used_t)
  1935. (struct PSI_statement_locker *locker);
  1936. /**
  1937. End a statement event.
  1938. @param locker the statement locker
  1939. @param stmt_da the statement diagnostics area.
  1940. @sa Diagnostics_area
  1941. */
  1942. typedef void (*end_statement_v1_t)
  1943. (struct PSI_statement_locker *locker, void *stmt_da);
  1944. /**
  1945. Get a transaction instrumentation locker.
  1946. @param state data storage for the locker
  1947. @param xid the xid for this transaction
  1948. @param trxid the InnoDB transaction id
  1949. @param iso_level isolation level for this transaction
  1950. @param read_only true if transaction access mode is read-only
  1951. @param autocommit true if transaction is autocommit
  1952. @return a transaction locker, or NULL
  1953. */
  1954. typedef struct PSI_transaction_locker* (*get_thread_transaction_locker_v1_t)
  1955. (struct PSI_transaction_locker_state_v1 *state, const void *xid,
  1956. const ulonglong *trxid, int isolation_level, my_bool read_only,
  1957. my_bool autocommit);
  1958. /**
  1959. Start a new transaction event.
  1960. @param locker the transaction locker for this event
  1961. @param src_file source file name
  1962. @param src_line source line number
  1963. */
  1964. typedef void (*start_transaction_v1_t)
  1965. (struct PSI_transaction_locker *locker,
  1966. const char *src_file, uint src_line);
  1967. /**
  1968. Set the transaction xid.
  1969. @param locker the transaction locker for this event
  1970. @param xid the id of the XA transaction
  1971. #param xa_state is the state of the XA transaction
  1972. */
  1973. typedef void (*set_transaction_xid_v1_t)
  1974. (struct PSI_transaction_locker *locker,
  1975. const void *xid, int xa_state);
  1976. /**
  1977. Set the state of the XA transaction.
  1978. @param locker the transaction locker for this event
  1979. @param xa_state the new state of the xa transaction
  1980. */
  1981. typedef void (*set_transaction_xa_state_v1_t)
  1982. (struct PSI_transaction_locker *locker,
  1983. int xa_state);
  1984. /**
  1985. Set the transaction gtid.
  1986. @param locker the transaction locker for this event
  1987. @param sid the source id for the transaction, mapped from sidno
  1988. @param gtid_spec the gtid specifier for the transaction
  1989. */
  1990. typedef void (*set_transaction_gtid_v1_t)
  1991. (struct PSI_transaction_locker *locker,
  1992. const void *sid, const void *gtid_spec);
  1993. /**
  1994. Set the transaction trx_id.
  1995. @param locker the transaction locker for this event
  1996. @param trxid the storage engine transaction ID
  1997. */
  1998. typedef void (*set_transaction_trxid_v1_t)
  1999. (struct PSI_transaction_locker *locker,
  2000. const ulonglong *trxid);
  2001. /**
  2002. Increment a transaction event savepoint count.
  2003. @param locker the transaction locker
  2004. @param count the increment value
  2005. */
  2006. typedef void (*inc_transaction_savepoints_v1_t)
  2007. (struct PSI_transaction_locker *locker, ulong count);
  2008. /**
  2009. Increment a transaction event rollback to savepoint count.
  2010. @param locker the transaction locker
  2011. @param count the increment value
  2012. */
  2013. typedef void (*inc_transaction_rollback_to_savepoint_v1_t)
  2014. (struct PSI_transaction_locker *locker, ulong count);
  2015. /**
  2016. Increment a transaction event release savepoint count.
  2017. @param locker the transaction locker
  2018. @param count the increment value
  2019. */
  2020. typedef void (*inc_transaction_release_savepoint_v1_t)
  2021. (struct PSI_transaction_locker *locker, ulong count);
  2022. /**
  2023. Commit or rollback the transaction.
  2024. @param locker the transaction locker for this event
  2025. @param commit true if transaction was committed, false if rolled back
  2026. */
  2027. typedef void (*end_transaction_v1_t)
  2028. (struct PSI_transaction_locker *locker,
  2029. my_bool commit);
  2030. /**
  2031. Record a socket instrumentation start event.
  2032. @param locker a socket locker for the running thread
  2033. @param op socket operation to be performed
  2034. @param count the number of bytes requested, or 0 if not applicable
  2035. @param src_file the source file name
  2036. @param src_line the source line number
  2037. */
  2038. typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
  2039. (struct PSI_socket_locker_state_v1 *state,
  2040. struct PSI_socket *socket,
  2041. enum PSI_socket_operation op,
  2042. size_t count,
  2043. const char *src_file, uint src_line);
  2044. /**
  2045. Record a socket instrumentation end event.
  2046. Note that for socket close operations, the instrumented socket handle
  2047. associated with the socket (which was provided to obtain a locker)
  2048. is invalid after this call.
  2049. @param locker a socket locker for the running thread
  2050. @param count the number of bytes actually used in the operation,
  2051. or 0 if not applicable, or -1 if the operation failed
  2052. @sa get_thread_socket_locker
  2053. */
  2054. typedef void (*end_socket_wait_v1_t)
  2055. (struct PSI_socket_locker *locker, size_t count);
  2056. /**
  2057. Set the socket state for an instrumented socket.
  2058. @param socket the instrumented socket
  2059. @param state socket state
  2060. */
  2061. typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
  2062. enum PSI_socket_state state);
  2063. /**
  2064. Set the socket info for an instrumented socket.
  2065. @param socket the instrumented socket
  2066. @param fd the socket descriptor
  2067. @param addr the socket ip address
  2068. @param addr_len length of socket ip address
  2069. @param thread_id associated thread id
  2070. */
  2071. typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
  2072. const my_socket *fd,
  2073. const struct sockaddr *addr,
  2074. socklen_t addr_len);
  2075. /**
  2076. Bind a socket to the thread that owns it.
  2077. @param socket instrumented socket
  2078. */
  2079. typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
  2080. /**
  2081. Get a prepare statement.
  2082. @param locker a statement locker for the running thread.
  2083. */
  2084. typedef PSI_prepared_stmt* (*create_prepared_stmt_v1_t)
  2085. (void *identity, uint stmt_id, PSI_statement_locker *locker,
  2086. const char *stmt_name, size_t stmt_name_length,
  2087. const char *name, size_t length);
  2088. /**
  2089. destroy a prepare statement.
  2090. @param prepared_stmt prepared statement.
  2091. */
  2092. typedef void (*destroy_prepared_stmt_v1_t)
  2093. (PSI_prepared_stmt *prepared_stmt);
  2094. /**
  2095. repreare a prepare statement.
  2096. @param prepared_stmt prepared statement.
  2097. */
  2098. typedef void (*reprepare_prepared_stmt_v1_t)
  2099. (PSI_prepared_stmt *prepared_stmt);
  2100. /**
  2101. Record a prepare statement instrumentation execute event.
  2102. @param locker a statement locker for the running thread.
  2103. @param prepared_stmt prepared statement.
  2104. */
  2105. typedef void (*execute_prepared_stmt_v1_t)
  2106. (PSI_statement_locker *locker, PSI_prepared_stmt* prepared_stmt);
  2107. /**
  2108. Set the statement text for a prepared statment event.
  2109. @param prepared_stmt prepared statement.
  2110. @param text the prepared statement text
  2111. @param text_len the prepared statement text length
  2112. */
  2113. typedef void (*set_prepared_stmt_text_v1_t)(PSI_prepared_stmt *prepared_stmt,
  2114. const char *text,
  2115. uint text_len);
  2116. /**
  2117. Get a digest locker for the current statement.
  2118. @param locker a statement locker for the running thread
  2119. */
  2120. typedef struct PSI_digest_locker * (*digest_start_v1_t)
  2121. (struct PSI_statement_locker *locker);
  2122. /**
  2123. Add a token to the current digest instrumentation.
  2124. @param locker a digest locker for the current statement
  2125. @param token the lexical token to add
  2126. @param yylval the lexical token attributes
  2127. */
  2128. typedef void (*digest_end_v1_t)
  2129. (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
  2130. typedef PSI_sp_locker* (*start_sp_v1_t)
  2131. (struct PSI_sp_locker_state_v1 *state, struct PSI_sp_share* sp_share);
  2132. typedef void (*end_sp_v1_t)
  2133. (struct PSI_sp_locker *locker);
  2134. typedef void (*drop_sp_v1_t)
  2135. (uint object_type,
  2136. const char *schema_name, uint schema_name_length,
  2137. const char *object_name, uint object_name_length);
  2138. /**
  2139. Acquire a sp share instrumentation.
  2140. @param type of stored program
  2141. @param schema name of stored program
  2142. @param name of stored program
  2143. @return a stored program share instrumentation, or NULL
  2144. */
  2145. typedef struct PSI_sp_share* (*get_sp_share_v1_t)
  2146. (uint object_type,
  2147. const char *schema_name, uint schema_name_length,
  2148. const char *object_name, uint object_name_length);
  2149. /**
  2150. Release a stored program share.
  2151. @param info the stored program share to release
  2152. */
  2153. typedef void (*release_sp_share_v1_t)(struct PSI_sp_share *share);
  2154. typedef PSI_metadata_lock* (*create_metadata_lock_v1_t)
  2155. (void *identity,
  2156. const MDL_key *key,
  2157. opaque_mdl_type mdl_type,
  2158. opaque_mdl_duration mdl_duration,
  2159. opaque_mdl_status mdl_status,
  2160. const char *src_file,
  2161. uint src_line);
  2162. typedef void (*set_metadata_lock_status_v1_t)(PSI_metadata_lock *lock,
  2163. opaque_mdl_status mdl_status);
  2164. typedef void (*destroy_metadata_lock_v1_t)(PSI_metadata_lock *lock);
  2165. typedef struct PSI_metadata_locker* (*start_metadata_wait_v1_t)
  2166. (struct PSI_metadata_locker_state_v1 *state,
  2167. struct PSI_metadata_lock *mdl,
  2168. const char *src_file, uint src_line);
  2169. typedef void (*end_metadata_wait_v1_t)
  2170. (struct PSI_metadata_locker *locker, int rc);
  2171. /**
  2172. Stores an array of connection attributes
  2173. @param buffer char array of length encoded connection attributes
  2174. in network format
  2175. @param length length of the data in buffer
  2176. @param from_cs charset in which @c buffer is encoded
  2177. @return state
  2178. @retval non_0 attributes truncated
  2179. @retval 0 stored the attribute
  2180. */
  2181. typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
  2182. const void *from_cs);
  2183. /**
  2184. Performance Schema Interface, version 1.
  2185. @since PSI_VERSION_1
  2186. */
  2187. struct PSI_v1
  2188. {
  2189. /** @sa register_mutex_v1_t. */
  2190. register_mutex_v1_t register_mutex;
  2191. /** @sa register_rwlock_v1_t. */
  2192. register_rwlock_v1_t register_rwlock;
  2193. /** @sa register_cond_v1_t. */
  2194. register_cond_v1_t register_cond;
  2195. /** @sa register_thread_v1_t. */
  2196. register_thread_v1_t register_thread;
  2197. /** @sa register_file_v1_t. */
  2198. register_file_v1_t register_file;
  2199. /** @sa register_stage_v1_t. */
  2200. register_stage_v1_t register_stage;
  2201. /** @sa register_statement_v1_t. */
  2202. register_statement_v1_t register_statement;
  2203. /** @sa register_socket_v1_t. */
  2204. register_socket_v1_t register_socket;
  2205. /** @sa init_mutex_v1_t. */
  2206. init_mutex_v1_t init_mutex;
  2207. /** @sa destroy_mutex_v1_t. */
  2208. destroy_mutex_v1_t destroy_mutex;
  2209. /** @sa init_rwlock_v1_t. */
  2210. init_rwlock_v1_t init_rwlock;
  2211. /** @sa destroy_rwlock_v1_t. */
  2212. destroy_rwlock_v1_t destroy_rwlock;
  2213. /** @sa init_cond_v1_t. */
  2214. init_cond_v1_t init_cond;
  2215. /** @sa destroy_cond_v1_t. */
  2216. destroy_cond_v1_t destroy_cond;
  2217. /** @sa init_socket_v1_t. */
  2218. init_socket_v1_t init_socket;
  2219. /** @sa destroy_socket_v1_t. */
  2220. destroy_socket_v1_t destroy_socket;
  2221. /** @sa get_table_share_v1_t. */
  2222. get_table_share_v1_t get_table_share;
  2223. /** @sa release_table_share_v1_t. */
  2224. release_table_share_v1_t release_table_share;
  2225. /** @sa drop_table_share_v1_t. */
  2226. drop_table_share_v1_t drop_table_share;
  2227. /** @sa open_table_v1_t. */
  2228. open_table_v1_t open_table;
  2229. /** @sa unbind_table_v1_t. */
  2230. unbind_table_v1_t unbind_table;
  2231. /** @sa rebind_table_v1_t. */
  2232. rebind_table_v1_t rebind_table;
  2233. /** @sa close_table_v1_t. */
  2234. close_table_v1_t close_table;
  2235. /** @sa create_file_v1_t. */
  2236. create_file_v1_t create_file;
  2237. /** @sa spawn_thread_v1_t. */
  2238. spawn_thread_v1_t spawn_thread;
  2239. /** @sa new_thread_v1_t. */
  2240. new_thread_v1_t new_thread;
  2241. /** @sa set_thread_id_v1_t. */
  2242. set_thread_id_v1_t set_thread_id;
  2243. /** @sa set_thread_THD_v1_t. */
  2244. set_thread_THD_v1_t set_thread_THD;
  2245. /** @sa set_thread_os_id_v1_t. */
  2246. set_thread_os_id_v1_t set_thread_os_id;
  2247. /** @sa get_thread_v1_t. */
  2248. get_thread_v1_t get_thread;
  2249. /** @sa set_thread_user_v1_t. */
  2250. set_thread_user_v1_t set_thread_user;
  2251. /** @sa set_thread_account_v1_t. */
  2252. set_thread_account_v1_t set_thread_account;
  2253. /** @sa set_thread_db_v1_t. */
  2254. set_thread_db_v1_t set_thread_db;
  2255. /** @sa set_thread_command_v1_t. */
  2256. set_thread_command_v1_t set_thread_command;
  2257. /** @sa set_connection_type_v1_t. */
  2258. set_connection_type_v1_t set_connection_type;
  2259. /** @sa set_thread_start_time_v1_t. */
  2260. set_thread_start_time_v1_t set_thread_start_time;
  2261. /** @sa set_thread_state_v1_t. */
  2262. set_thread_state_v1_t set_thread_state;
  2263. /** @sa set_thread_info_v1_t. */
  2264. set_thread_info_v1_t set_thread_info;
  2265. /** @sa set_thread_v1_t. */
  2266. set_thread_v1_t set_thread;
  2267. /** @sa delete_current_thread_v1_t. */
  2268. delete_current_thread_v1_t delete_current_thread;
  2269. /** @sa delete_thread_v1_t. */
  2270. delete_thread_v1_t delete_thread;
  2271. /** @sa get_thread_file_name_locker_v1_t. */
  2272. get_thread_file_name_locker_v1_t get_thread_file_name_locker;
  2273. /** @sa get_thread_file_stream_locker_v1_t. */
  2274. get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
  2275. /** @sa get_thread_file_descriptor_locker_v1_t. */
  2276. get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
  2277. /** @sa unlock_mutex_v1_t. */
  2278. unlock_mutex_v1_t unlock_mutex;
  2279. /** @sa unlock_rwlock_v1_t. */
  2280. unlock_rwlock_v1_t unlock_rwlock;
  2281. /** @sa signal_cond_v1_t. */
  2282. signal_cond_v1_t signal_cond;
  2283. /** @sa broadcast_cond_v1_t. */
  2284. broadcast_cond_v1_t broadcast_cond;
  2285. /** @sa start_idle_wait_v1_t. */
  2286. start_idle_wait_v1_t start_idle_wait;
  2287. /** @sa end_idle_wait_v1_t. */
  2288. end_idle_wait_v1_t end_idle_wait;
  2289. /** @sa start_mutex_wait_v1_t. */
  2290. start_mutex_wait_v1_t start_mutex_wait;
  2291. /** @sa end_mutex_wait_v1_t. */
  2292. end_mutex_wait_v1_t end_mutex_wait;
  2293. /** @sa start_rwlock_rdwait_v1_t. */
  2294. start_rwlock_rdwait_v1_t start_rwlock_rdwait;
  2295. /** @sa end_rwlock_rdwait_v1_t. */
  2296. end_rwlock_rdwait_v1_t end_rwlock_rdwait;
  2297. /** @sa start_rwlock_wrwait_v1_t. */
  2298. start_rwlock_wrwait_v1_t start_rwlock_wrwait;
  2299. /** @sa end_rwlock_wrwait_v1_t. */
  2300. end_rwlock_wrwait_v1_t end_rwlock_wrwait;
  2301. /** @sa start_cond_wait_v1_t. */
  2302. start_cond_wait_v1_t start_cond_wait;
  2303. /** @sa end_cond_wait_v1_t. */
  2304. end_cond_wait_v1_t end_cond_wait;
  2305. /** @sa start_table_io_wait_v1_t. */
  2306. start_table_io_wait_v1_t start_table_io_wait;
  2307. /** @sa end_table_io_wait_v1_t. */
  2308. end_table_io_wait_v1_t end_table_io_wait;
  2309. /** @sa start_table_lock_wait_v1_t. */
  2310. start_table_lock_wait_v1_t start_table_lock_wait;
  2311. /** @sa end_table_lock_wait_v1_t. */
  2312. end_table_lock_wait_v1_t end_table_lock_wait;
  2313. /** @sa start_file_open_wait_v1_t. */
  2314. start_file_open_wait_v1_t start_file_open_wait;
  2315. /** @sa end_file_open_wait_v1_t. */
  2316. end_file_open_wait_v1_t end_file_open_wait;
  2317. /** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */
  2318. end_file_open_wait_and_bind_to_descriptor_v1_t
  2319. end_file_open_wait_and_bind_to_descriptor;
  2320. /** @sa end_temp_file_open_wait_and_bind_to_descriptor_v1_t. */
  2321. end_temp_file_open_wait_and_bind_to_descriptor_v1_t
  2322. end_temp_file_open_wait_and_bind_to_descriptor;
  2323. /** @sa start_file_wait_v1_t. */
  2324. start_file_wait_v1_t start_file_wait;
  2325. /** @sa end_file_wait_v1_t. */
  2326. end_file_wait_v1_t end_file_wait;
  2327. /** @sa start_file_close_wait_v1_t. */
  2328. start_file_close_wait_v1_t start_file_close_wait;
  2329. /** @sa end_file_close_wait_v1_t. */
  2330. end_file_close_wait_v1_t end_file_close_wait;
  2331. /** @sa rename_file_close_wait_v1_t. */
  2332. end_file_rename_wait_v1_t end_file_rename_wait;
  2333. /** @sa start_stage_v1_t. */
  2334. start_stage_v1_t start_stage;
  2335. /** @sa get_current_stage_progress_v1_t. */
  2336. get_current_stage_progress_v1_t get_current_stage_progress;
  2337. /** @sa end_stage_v1_t. */
  2338. end_stage_v1_t end_stage;
  2339. /** @sa get_thread_statement_locker_v1_t. */
  2340. get_thread_statement_locker_v1_t get_thread_statement_locker;
  2341. /** @sa refine_statement_v1_t. */
  2342. refine_statement_v1_t refine_statement;
  2343. /** @sa start_statement_v1_t. */
  2344. start_statement_v1_t start_statement;
  2345. /** @sa set_statement_text_v1_t. */
  2346. set_statement_text_v1_t set_statement_text;
  2347. /** @sa set_statement_lock_time_t. */
  2348. set_statement_lock_time_t set_statement_lock_time;
  2349. /** @sa set_statement_rows_sent_t. */
  2350. set_statement_rows_sent_t set_statement_rows_sent;
  2351. /** @sa set_statement_rows_examined_t. */
  2352. set_statement_rows_examined_t set_statement_rows_examined;
  2353. /** @sa inc_statement_created_tmp_disk_tables. */
  2354. inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
  2355. /** @sa inc_statement_created_tmp_tables. */
  2356. inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
  2357. /** @sa inc_statement_select_full_join. */
  2358. inc_statement_select_full_join_t inc_statement_select_full_join;
  2359. /** @sa inc_statement_select_full_range_join. */
  2360. inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
  2361. /** @sa inc_statement_select_range. */
  2362. inc_statement_select_range_t inc_statement_select_range;
  2363. /** @sa inc_statement_select_range_check. */
  2364. inc_statement_select_range_check_t inc_statement_select_range_check;
  2365. /** @sa inc_statement_select_scan. */
  2366. inc_statement_select_scan_t inc_statement_select_scan;
  2367. /** @sa inc_statement_sort_merge_passes. */
  2368. inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
  2369. /** @sa inc_statement_sort_range. */
  2370. inc_statement_sort_range_t inc_statement_sort_range;
  2371. /** @sa inc_statement_sort_rows. */
  2372. inc_statement_sort_rows_t inc_statement_sort_rows;
  2373. /** @sa inc_statement_sort_scan. */
  2374. inc_statement_sort_scan_t inc_statement_sort_scan;
  2375. /** @sa set_statement_no_index_used. */
  2376. set_statement_no_index_used_t set_statement_no_index_used;
  2377. /** @sa set_statement_no_good_index_used. */
  2378. set_statement_no_good_index_used_t set_statement_no_good_index_used;
  2379. /** @sa end_statement_v1_t. */
  2380. end_statement_v1_t end_statement;
  2381. /** @sa get_thread_transaction_locker_v1_t. */
  2382. get_thread_transaction_locker_v1_t get_thread_transaction_locker;
  2383. /** @sa start_transaction_v1_t. */
  2384. start_transaction_v1_t start_transaction;
  2385. /** @sa set_transaction_xid_v1_t. */
  2386. set_transaction_xid_v1_t set_transaction_xid;
  2387. /** @sa set_transaction_xa_state_v1_t. */
  2388. set_transaction_xa_state_v1_t set_transaction_xa_state;
  2389. /** @sa set_transaction_gtid_v1_t. */
  2390. set_transaction_gtid_v1_t set_transaction_gtid;
  2391. /** @sa set_transaction_trxid_v1_t. */
  2392. set_transaction_trxid_v1_t set_transaction_trxid;
  2393. /** @sa inc_transaction_savepoints_v1_t. */
  2394. inc_transaction_savepoints_v1_t inc_transaction_savepoints;
  2395. /** @sa inc_transaction_rollback_to_savepoint_v1_t. */
  2396. inc_transaction_rollback_to_savepoint_v1_t inc_transaction_rollback_to_savepoint;
  2397. /** @sa inc_transaction_release_savepoint_v1_t. */
  2398. inc_transaction_release_savepoint_v1_t inc_transaction_release_savepoint;
  2399. /** @sa end_transaction_v1_t. */
  2400. end_transaction_v1_t end_transaction;
  2401. /** @sa start_socket_wait_v1_t. */
  2402. start_socket_wait_v1_t start_socket_wait;
  2403. /** @sa end_socket_wait_v1_t. */
  2404. end_socket_wait_v1_t end_socket_wait;
  2405. /** @sa set_socket_state_v1_t. */
  2406. set_socket_state_v1_t set_socket_state;
  2407. /** @sa set_socket_info_v1_t. */
  2408. set_socket_info_v1_t set_socket_info;
  2409. /** @sa set_socket_thread_owner_v1_t. */
  2410. set_socket_thread_owner_v1_t set_socket_thread_owner;
  2411. /** @sa create_prepared_stmt_v1_t. */
  2412. create_prepared_stmt_v1_t create_prepared_stmt;
  2413. /** @sa destroy_prepared_stmt_v1_t. */
  2414. destroy_prepared_stmt_v1_t destroy_prepared_stmt;
  2415. /** @sa reprepare_prepared_stmt_v1_t. */
  2416. reprepare_prepared_stmt_v1_t reprepare_prepared_stmt;
  2417. /** @sa execute_prepared_stmt_v1_t. */
  2418. execute_prepared_stmt_v1_t execute_prepared_stmt;
  2419. /** @sa set_prepared_stmt_text_v1_t. */
  2420. set_prepared_stmt_text_v1_t set_prepared_stmt_text;
  2421. /** @sa digest_start_v1_t. */
  2422. digest_start_v1_t digest_start;
  2423. /** @sa digest_end_v1_t. */
  2424. digest_end_v1_t digest_end;
  2425. /** @sa set_thread_connect_attrs_v1_t. */
  2426. set_thread_connect_attrs_v1_t set_thread_connect_attrs;
  2427. /** @sa start_sp_v1_t. */
  2428. start_sp_v1_t start_sp;
  2429. /** @sa start_sp_v1_t. */
  2430. end_sp_v1_t end_sp;
  2431. /** @sa drop_sp_v1_t. */
  2432. drop_sp_v1_t drop_sp;
  2433. /** @sa get_sp_share_v1_t. */
  2434. get_sp_share_v1_t get_sp_share;
  2435. /** @sa release_sp_share_v1_t. */
  2436. release_sp_share_v1_t release_sp_share;
  2437. /** @sa register_memory_v1_t. */
  2438. register_memory_v1_t register_memory;
  2439. /** @sa memory_alloc_v1_t. */
  2440. memory_alloc_v1_t memory_alloc;
  2441. /** @sa memory_realloc_v1_t. */
  2442. memory_realloc_v1_t memory_realloc;
  2443. /** @sa memory_claim_v1_t. */
  2444. memory_claim_v1_t memory_claim;
  2445. /** @sa memory_free_v1_t. */
  2446. memory_free_v1_t memory_free;
  2447. unlock_table_v1_t unlock_table;
  2448. create_metadata_lock_v1_t create_metadata_lock;
  2449. set_metadata_lock_status_v1_t set_metadata_lock_status;
  2450. destroy_metadata_lock_v1_t destroy_metadata_lock;
  2451. start_metadata_wait_v1_t start_metadata_wait;
  2452. end_metadata_wait_v1_t end_metadata_wait;
  2453. };
  2454. /** @} (end of group Group_PSI_v1) */
  2455. #endif /* HAVE_PSI_1 */
  2456. #ifdef USE_PSI_2
  2457. #define HAVE_PSI_2
  2458. #endif
  2459. #ifdef HAVE_PSI_2
  2460. /**
  2461. @defgroup Group_PSI_v2 Application Binary Interface, version 2
  2462. @ingroup Instrumentation_interface
  2463. @{
  2464. */
  2465. /**
  2466. Performance Schema Interface, version 2.
  2467. This is a placeholder, this interface is not defined yet.
  2468. @since PSI_VERSION_2
  2469. */
  2470. struct PSI_v2
  2471. {
  2472. /** Placeholder */
  2473. int placeholder;
  2474. /* ... extended interface ... */
  2475. };
  2476. /** Placeholder */
  2477. struct PSI_mutex_info_v2
  2478. {
  2479. /** Placeholder */
  2480. int placeholder;
  2481. };
  2482. /** Placeholder */
  2483. struct PSI_rwlock_info_v2
  2484. {
  2485. /** Placeholder */
  2486. int placeholder;
  2487. };
  2488. /** Placeholder */
  2489. struct PSI_cond_info_v2
  2490. {
  2491. /** Placeholder */
  2492. int placeholder;
  2493. };
  2494. /** Placeholder */
  2495. struct PSI_thread_info_v2
  2496. {
  2497. /** Placeholder */
  2498. int placeholder;
  2499. };
  2500. /** Placeholder */
  2501. struct PSI_file_info_v2
  2502. {
  2503. /** Placeholder */
  2504. int placeholder;
  2505. };
  2506. /** Placeholder */
  2507. struct PSI_stage_info_v2
  2508. {
  2509. /** Placeholder */
  2510. int placeholder;
  2511. };
  2512. /** Placeholder */
  2513. struct PSI_statement_info_v2
  2514. {
  2515. /** Placeholder */
  2516. int placeholder;
  2517. };
  2518. /** Placeholder */
  2519. struct PSI_transaction_info_v2
  2520. {
  2521. /** Placeholder */
  2522. int placeholder;
  2523. };
  2524. /** Placeholder */
  2525. struct PSI_idle_locker_state_v2
  2526. {
  2527. /** Placeholder */
  2528. int placeholder;
  2529. };
  2530. /** Placeholder */
  2531. struct PSI_mutex_locker_state_v2
  2532. {
  2533. /** Placeholder */
  2534. int placeholder;
  2535. };
  2536. /** Placeholder */
  2537. struct PSI_rwlock_locker_state_v2
  2538. {
  2539. /** Placeholder */
  2540. int placeholder;
  2541. };
  2542. /** Placeholder */
  2543. struct PSI_cond_locker_state_v2
  2544. {
  2545. /** Placeholder */
  2546. int placeholder;
  2547. };
  2548. /** Placeholder */
  2549. struct PSI_file_locker_state_v2
  2550. {
  2551. /** Placeholder */
  2552. int placeholder;
  2553. };
  2554. /** Placeholder */
  2555. struct PSI_statement_locker_state_v2
  2556. {
  2557. /** Placeholder */
  2558. int placeholder;
  2559. };
  2560. /** Placeholder */
  2561. struct PSI_transaction_locker_state_v2
  2562. {
  2563. /** Placeholder */
  2564. int placeholder;
  2565. };
  2566. /** Placeholder */
  2567. struct PSI_socket_locker_state_v2
  2568. {
  2569. /** Placeholder */
  2570. int placeholder;
  2571. };
  2572. struct PSI_metadata_locker_state_v2
  2573. {
  2574. int placeholder;
  2575. };
  2576. /** @} (end of group Group_PSI_v2) */
  2577. #endif /* HAVE_PSI_2 */
  2578. /**
  2579. @typedef PSI
  2580. The instrumentation interface for the current version.
  2581. @sa PSI_CURRENT_VERSION
  2582. */
  2583. /**
  2584. @typedef PSI_mutex_info
  2585. The mutex information structure for the current version.
  2586. */
  2587. /**
  2588. @typedef PSI_rwlock_info
  2589. The rwlock information structure for the current version.
  2590. */
  2591. /**
  2592. @typedef PSI_cond_info
  2593. The cond information structure for the current version.
  2594. */
  2595. /**
  2596. @typedef PSI_thread_info
  2597. The thread information structure for the current version.
  2598. */
  2599. /**
  2600. @typedef PSI_file_info
  2601. The file information structure for the current version.
  2602. */
  2603. /* Export the required version */
  2604. #ifdef USE_PSI_1
  2605. typedef struct PSI_v1 PSI;
  2606. typedef struct PSI_mutex_info_v1 PSI_mutex_info;
  2607. typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
  2608. typedef struct PSI_cond_info_v1 PSI_cond_info;
  2609. typedef struct PSI_thread_info_v1 PSI_thread_info;
  2610. typedef struct PSI_file_info_v1 PSI_file_info;
  2611. typedef struct PSI_stage_info_v1 PSI_stage_info;
  2612. typedef struct PSI_statement_info_v1 PSI_statement_info;
  2613. typedef struct PSI_transaction_info_v1 PSI_transaction_info;
  2614. typedef struct PSI_socket_info_v1 PSI_socket_info;
  2615. typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
  2616. typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
  2617. typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
  2618. typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
  2619. typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
  2620. typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
  2621. typedef struct PSI_transaction_locker_state_v1 PSI_transaction_locker_state;
  2622. typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
  2623. typedef struct PSI_sp_locker_state_v1 PSI_sp_locker_state;
  2624. typedef struct PSI_metadata_locker_state_v1 PSI_metadata_locker_state;
  2625. #endif
  2626. #ifdef USE_PSI_2
  2627. typedef struct PSI_v2 PSI;
  2628. typedef struct PSI_mutex_info_v2 PSI_mutex_info;
  2629. typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
  2630. typedef struct PSI_cond_info_v2 PSI_cond_info;
  2631. typedef struct PSI_thread_info_v2 PSI_thread_info;
  2632. typedef struct PSI_file_info_v2 PSI_file_info;
  2633. typedef struct PSI_stage_info_v2 PSI_stage_info;
  2634. typedef struct PSI_statement_info_v2 PSI_statement_info;
  2635. typedef struct PSI_transaction_info_v2 PSI_transaction_info;
  2636. typedef struct PSI_socket_info_v2 PSI_socket_info;
  2637. typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
  2638. typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
  2639. typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
  2640. typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
  2641. typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
  2642. typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
  2643. typedef struct PSI_transaction_locker_state_v2 PSI_transaction_locker_state;
  2644. typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
  2645. typedef struct PSI_sp_locker_state_v2 PSI_sp_locker_state;
  2646. typedef struct PSI_metadata_locker_state_v2 PSI_metadata_locker_state;
  2647. #endif
  2648. #else /* HAVE_PSI_INTERFACE */
  2649. /**
  2650. Dummy structure, used to declare PSI_server when no instrumentation
  2651. is available.
  2652. The content does not matter, since PSI_server will be NULL.
  2653. */
  2654. struct PSI_none
  2655. {
  2656. int opaque;
  2657. };
  2658. typedef struct PSI_none PSI;
  2659. /**
  2660. Stage instrument information.
  2661. @since PSI_VERSION_1
  2662. This structure is used to register an instrumented stage.
  2663. */
  2664. struct PSI_stage_info_none
  2665. {
  2666. /** Unused stage key. */
  2667. unsigned int m_key;
  2668. /** The name of the stage instrument. */
  2669. const char *m_name;
  2670. /** Unused stage flags. */
  2671. int m_flags;
  2672. };
  2673. /**
  2674. The stage instrumentation has to co exist with the legacy
  2675. THD::set_proc_info instrumentation.
  2676. To avoid duplication of the instrumentation in the server,
  2677. the common PSI_stage_info structure is used,
  2678. so we export it here, even when not building
  2679. with HAVE_PSI_INTERFACE.
  2680. */
  2681. typedef struct PSI_stage_info_none PSI_stage_info;
  2682. #endif /* HAVE_PSI_INTERFACE */
  2683. extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
  2684. /*
  2685. Allow to override PSI_XXX_CALL at compile time
  2686. with more efficient implementations, if available.
  2687. If nothing better is available,
  2688. make a dynamic call using the PSI_server function pointer.
  2689. */
  2690. #define PSI_DYNAMIC_CALL(M) PSI_server->M
  2691. /** @} */
  2692. C_MODE_END
  2693. #endif /* MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H */