psi.h 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408
  1. /* Copyright (c) 2008, 2015, 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 as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software Foundation,
  11. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  12. #ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
  13. #define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
  14. #ifdef EMBEDDED_LIBRARY
  15. #define DISABLE_PSI_MUTEX
  16. #define DISABLE_PSI_RWLOCK
  17. #define DISABLE_PSI_COND
  18. #define DISABLE_PSI_FILE
  19. #define DISABLE_PSI_TABLE
  20. #define DISABLE_PSI_SOCKET
  21. #define DISABLE_PSI_STAGE
  22. #define DISABLE_PSI_STATEMENT
  23. #define DISABLE_PSI_IDLE
  24. #define DISABLE_PSI_STATEMENT_DIGEST
  25. #endif /* EMBEDDED_LIBRARY */
  26. #ifndef MY_GLOBAL_INCLUDED
  27. /*
  28. Make sure a .c or .cc file contains an include to my_global.h first.
  29. When this include is missing, all the #ifdef HAVE_XXX have no effect,
  30. and the resulting binary won't build, or won't link,
  31. or will crash at runtime
  32. since various structures will have different binary definitions.
  33. */
  34. #error "You must include my_global.h in the code for the build to be correct."
  35. #endif
  36. C_MODE_START
  37. struct TABLE_SHARE;
  38. struct sql_digest_storage;
  39. /**
  40. @file mysql/psi/psi.h
  41. Performance schema instrumentation interface.
  42. @defgroup Instrumentation_interface Instrumentation Interface
  43. @ingroup Performance_schema
  44. @{
  45. */
  46. /**
  47. Interface for an instrumented mutex.
  48. This is an opaque structure.
  49. */
  50. struct PSI_mutex;
  51. typedef struct PSI_mutex PSI_mutex;
  52. /**
  53. Interface for an instrumented rwlock.
  54. This is an opaque structure.
  55. */
  56. struct PSI_rwlock;
  57. typedef struct PSI_rwlock PSI_rwlock;
  58. /**
  59. Interface for an instrumented condition.
  60. This is an opaque structure.
  61. */
  62. struct PSI_cond;
  63. typedef struct PSI_cond PSI_cond;
  64. /**
  65. Interface for an instrumented table share.
  66. This is an opaque structure.
  67. */
  68. struct PSI_table_share;
  69. typedef struct PSI_table_share PSI_table_share;
  70. /**
  71. Interface for an instrumented table handle.
  72. This is an opaque structure.
  73. */
  74. struct PSI_table;
  75. typedef struct PSI_table PSI_table;
  76. /**
  77. Interface for an instrumented thread.
  78. This is an opaque structure.
  79. */
  80. struct PSI_thread;
  81. typedef struct PSI_thread PSI_thread;
  82. /**
  83. Interface for an instrumented file handle.
  84. This is an opaque structure.
  85. */
  86. struct PSI_file;
  87. typedef struct PSI_file PSI_file;
  88. /**
  89. Interface for an instrumented socket descriptor.
  90. This is an opaque structure.
  91. */
  92. struct PSI_socket;
  93. typedef struct PSI_socket PSI_socket;
  94. /**
  95. Interface for an instrumented table operation.
  96. This is an opaque structure.
  97. */
  98. struct PSI_table_locker;
  99. typedef struct PSI_table_locker PSI_table_locker;
  100. /**
  101. Interface for an instrumented statement.
  102. This is an opaque structure.
  103. */
  104. struct PSI_statement_locker;
  105. typedef struct PSI_statement_locker PSI_statement_locker;
  106. /**
  107. Interface for an instrumented idle operation.
  108. This is an opaque structure.
  109. */
  110. struct PSI_idle_locker;
  111. typedef struct PSI_idle_locker PSI_idle_locker;
  112. /**
  113. Interface for an instrumented statement digest operation.
  114. This is an opaque structure.
  115. */
  116. struct PSI_digest_locker;
  117. typedef struct PSI_digest_locker PSI_digest_locker;
  118. /** Entry point for the performance schema interface. */
  119. struct PSI_bootstrap
  120. {
  121. /**
  122. ABI interface finder.
  123. Calling this method with an interface version number returns either
  124. an instance of the ABI for this version, or NULL.
  125. @param version the interface version number to find
  126. @return a versioned interface (PSI_v1, PSI_v2 or PSI)
  127. @sa PSI_VERSION_1
  128. @sa PSI_v1
  129. @sa PSI_VERSION_2
  130. @sa PSI_v2
  131. @sa PSI_CURRENT_VERSION
  132. @sa PSI
  133. */
  134. void* (*get_interface)(int version);
  135. };
  136. typedef struct PSI_bootstrap PSI_bootstrap;
  137. #ifdef HAVE_PSI_INTERFACE
  138. /**
  139. @def DISABLE_PSI_MUTEX
  140. Compiling option to disable the mutex instrumentation.
  141. This option is mostly intended to be used during development,
  142. when doing special builds with only a subset of the performance schema instrumentation,
  143. for code analysis / profiling / performance tuning of a specific instrumentation alone.
  144. For this reason, DISABLE_PSI_MUTEX is not advertised in the cmake general options.
  145. To disable mutexes, add -DDISABLE_PSI_MUTEX to CFLAGS.
  146. @sa DISABLE_PSI_RWLOCK
  147. @sa DISABLE_PSI_COND
  148. @sa DISABLE_PSI_FILE
  149. @sa DISABLE_PSI_THREAD
  150. @sa DISABLE_PSI_TABLE
  151. @sa DISABLE_PSI_STAGE
  152. @sa DISABLE_PSI_STATEMENT
  153. @sa DISABLE_PSI_SOCKET
  154. @sa DISABLE_PSI_IDLE
  155. */
  156. #ifndef DISABLE_PSI_MUTEX
  157. #define HAVE_PSI_MUTEX_INTERFACE
  158. #endif
  159. /**
  160. @def DISABLE_PSI_RWLOCK
  161. Compiling option to disable the rwlock instrumentation.
  162. @sa DISABLE_PSI_MUTEX
  163. */
  164. #ifndef DISABLE_PSI_RWLOCK
  165. #define HAVE_PSI_RWLOCK_INTERFACE
  166. #endif
  167. /**
  168. @def DISABLE_PSI_COND
  169. Compiling option to disable the cond instrumentation.
  170. @sa DISABLE_PSI_MUTEX
  171. */
  172. #ifndef DISABLE_PSI_COND
  173. #define HAVE_PSI_COND_INTERFACE
  174. #endif
  175. /**
  176. @def DISABLE_PSI_FILE
  177. Compiling option to disable the file instrumentation.
  178. @sa DISABLE_PSI_MUTEX
  179. */
  180. #ifndef DISABLE_PSI_FILE
  181. #define HAVE_PSI_FILE_INTERFACE
  182. #endif
  183. /**
  184. @def DISABLE_PSI_THREAD
  185. Compiling option to disable the thread instrumentation.
  186. @sa DISABLE_PSI_MUTEX
  187. */
  188. #ifndef DISABLE_PSI_THREAD
  189. #define HAVE_PSI_THREAD_INTERFACE
  190. #endif
  191. /**
  192. @def DISABLE_PSI_TABLE
  193. Compiling option to disable the table instrumentation.
  194. @sa DISABLE_PSI_MUTEX
  195. */
  196. #ifndef DISABLE_PSI_TABLE
  197. #define HAVE_PSI_TABLE_INTERFACE
  198. #endif
  199. /**
  200. @def DISABLE_PSI_STAGE
  201. Compiling option to disable the stage instrumentation.
  202. @sa DISABLE_PSI_MUTEX
  203. */
  204. #ifndef DISABLE_PSI_STAGE
  205. #define HAVE_PSI_STAGE_INTERFACE
  206. #endif
  207. /**
  208. @def DISABLE_PSI_STATEMENT
  209. Compiling option to disable the statement instrumentation.
  210. @sa DISABLE_PSI_MUTEX
  211. */
  212. #ifndef DISABLE_PSI_STATEMENT
  213. #define HAVE_PSI_STATEMENT_INTERFACE
  214. #endif
  215. /**
  216. @def DISABLE_PSI_STATEMENT_DIGEST
  217. Compiling option to disable the statement digest instrumentation.
  218. */
  219. #ifndef DISABLE_PSI_STATEMENT
  220. #ifndef DISABLE_PSI_STATEMENT_DIGEST
  221. #define HAVE_PSI_STATEMENT_DIGEST_INTERFACE
  222. #endif
  223. #endif
  224. /**
  225. @def DISABLE_PSI_SOCKET
  226. Compiling option to disable the statement instrumentation.
  227. @sa DISABLE_PSI_MUTEX
  228. */
  229. #ifndef DISABLE_PSI_SOCKET
  230. #define HAVE_PSI_SOCKET_INTERFACE
  231. #endif
  232. /**
  233. @def DISABLE_PSI_IDLE
  234. Compiling option to disable the idle instrumentation.
  235. @sa DISABLE_PSI_MUTEX
  236. */
  237. #ifndef DISABLE_PSI_IDLE
  238. #define HAVE_PSI_IDLE_INTERFACE
  239. #endif
  240. /**
  241. @def PSI_VERSION_1
  242. Performance Schema Interface number for version 1.
  243. This version is supported.
  244. */
  245. #define PSI_VERSION_1 1
  246. /**
  247. @def PSI_VERSION_2
  248. Performance Schema Interface number for version 2.
  249. This version is not implemented, it's a placeholder.
  250. */
  251. #define PSI_VERSION_2 2
  252. /**
  253. @def PSI_CURRENT_VERSION
  254. Performance Schema Interface number for the most recent version.
  255. The most current version is @c PSI_VERSION_1
  256. */
  257. #define PSI_CURRENT_VERSION 1
  258. #ifndef USE_PSI_2
  259. #ifndef USE_PSI_1
  260. #define USE_PSI_1
  261. #endif
  262. #endif
  263. /**
  264. Interface for an instrumented mutex operation.
  265. This is an opaque structure.
  266. */
  267. struct PSI_mutex_locker;
  268. typedef struct PSI_mutex_locker PSI_mutex_locker;
  269. /**
  270. Interface for an instrumented rwlock operation.
  271. This is an opaque structure.
  272. */
  273. struct PSI_rwlock_locker;
  274. typedef struct PSI_rwlock_locker PSI_rwlock_locker;
  275. /**
  276. Interface for an instrumented condition operation.
  277. This is an opaque structure.
  278. */
  279. struct PSI_cond_locker;
  280. typedef struct PSI_cond_locker PSI_cond_locker;
  281. /**
  282. Interface for an instrumented file operation.
  283. This is an opaque structure.
  284. */
  285. struct PSI_file_locker;
  286. typedef struct PSI_file_locker PSI_file_locker;
  287. /**
  288. Interface for an instrumented socket operation.
  289. This is an opaque structure.
  290. */
  291. struct PSI_socket_locker;
  292. typedef struct PSI_socket_locker PSI_socket_locker;
  293. /** Operation performed on an instrumented mutex. */
  294. enum PSI_mutex_operation
  295. {
  296. /** Lock. */
  297. PSI_MUTEX_LOCK= 0,
  298. /** Lock attempt. */
  299. PSI_MUTEX_TRYLOCK= 1
  300. };
  301. typedef enum PSI_mutex_operation PSI_mutex_operation;
  302. /** Operation performed on an instrumented rwlock. */
  303. enum PSI_rwlock_operation
  304. {
  305. /** Read lock. */
  306. PSI_RWLOCK_READLOCK= 0,
  307. /** Write lock. */
  308. PSI_RWLOCK_WRITELOCK= 1,
  309. /** Read lock attempt. */
  310. PSI_RWLOCK_TRYREADLOCK= 2,
  311. /** Write lock attempt. */
  312. PSI_RWLOCK_TRYWRITELOCK= 3
  313. };
  314. typedef enum PSI_rwlock_operation PSI_rwlock_operation;
  315. /** Operation performed on an instrumented condition. */
  316. enum PSI_cond_operation
  317. {
  318. /** Wait. */
  319. PSI_COND_WAIT= 0,
  320. /** Wait, with timeout. */
  321. PSI_COND_TIMEDWAIT= 1
  322. };
  323. typedef enum PSI_cond_operation PSI_cond_operation;
  324. /** Operation performed on an instrumented file. */
  325. enum PSI_file_operation
  326. {
  327. /** File creation, as in @c create(). */
  328. PSI_FILE_CREATE= 0,
  329. /** Temporary file creation, as in @c create_temp_file(). */
  330. PSI_FILE_CREATE_TMP= 1,
  331. /** File open, as in @c open(). */
  332. PSI_FILE_OPEN= 2,
  333. /** File open, as in @c fopen(). */
  334. PSI_FILE_STREAM_OPEN= 3,
  335. /** File close, as in @c close(). */
  336. PSI_FILE_CLOSE= 4,
  337. /** File close, as in @c fclose(). */
  338. PSI_FILE_STREAM_CLOSE= 5,
  339. /**
  340. Generic file read, such as @c fgets(), @c fgetc(), @c fread(), @c read(),
  341. @c pread().
  342. */
  343. PSI_FILE_READ= 6,
  344. /**
  345. Generic file write, such as @c fputs(), @c fputc(), @c fprintf(),
  346. @c vfprintf(), @c fwrite(), @c write(), @c pwrite().
  347. */
  348. PSI_FILE_WRITE= 7,
  349. /** Generic file seek, such as @c fseek() or @c seek(). */
  350. PSI_FILE_SEEK= 8,
  351. /** Generic file tell, such as @c ftell() or @c tell(). */
  352. PSI_FILE_TELL= 9,
  353. /** File flush, as in @c fflush(). */
  354. PSI_FILE_FLUSH= 10,
  355. /** File stat, as in @c stat(). */
  356. PSI_FILE_STAT= 11,
  357. /** File stat, as in @c fstat(). */
  358. PSI_FILE_FSTAT= 12,
  359. /** File chsize, as in @c my_chsize(). */
  360. PSI_FILE_CHSIZE= 13,
  361. /** File delete, such as @c my_delete() or @c my_delete_with_symlink(). */
  362. PSI_FILE_DELETE= 14,
  363. /** File rename, such as @c my_rename() or @c my_rename_with_symlink(). */
  364. PSI_FILE_RENAME= 15,
  365. /** File sync, as in @c fsync() or @c my_sync(). */
  366. PSI_FILE_SYNC= 16
  367. };
  368. typedef enum PSI_file_operation PSI_file_operation;
  369. /** IO operation performed on an instrumented table. */
  370. enum PSI_table_io_operation
  371. {
  372. /** Row fetch. */
  373. PSI_TABLE_FETCH_ROW= 0,
  374. /** Row write. */
  375. PSI_TABLE_WRITE_ROW= 1,
  376. /** Row update. */
  377. PSI_TABLE_UPDATE_ROW= 2,
  378. /** Row delete. */
  379. PSI_TABLE_DELETE_ROW= 3
  380. };
  381. typedef enum PSI_table_io_operation PSI_table_io_operation;
  382. /** Lock operation performed on an instrumented table. */
  383. enum PSI_table_lock_operation
  384. {
  385. /** Table lock, in the server layer. */
  386. PSI_TABLE_LOCK= 0,
  387. /** Table lock, in the storage engine layer. */
  388. PSI_TABLE_EXTERNAL_LOCK= 1
  389. };
  390. typedef enum PSI_table_lock_operation PSI_table_lock_operation;
  391. /** State of an instrumented socket. */
  392. enum PSI_socket_state
  393. {
  394. /** Idle, waiting for the next command. */
  395. PSI_SOCKET_STATE_IDLE= 1,
  396. /** Active, executing a command. */
  397. PSI_SOCKET_STATE_ACTIVE= 2
  398. };
  399. typedef enum PSI_socket_state PSI_socket_state;
  400. /** Operation performed on an instrumented socket. */
  401. enum PSI_socket_operation
  402. {
  403. /** Socket creation, as in @c socket() or @c socketpair(). */
  404. PSI_SOCKET_CREATE= 0,
  405. /** Socket connection, as in @c connect(), @c listen() and @c accept(). */
  406. PSI_SOCKET_CONNECT= 1,
  407. /** Socket bind, as in @c bind(), @c getsockname() and @c getpeername(). */
  408. PSI_SOCKET_BIND= 2,
  409. /** Socket close, as in @c shutdown(). */
  410. PSI_SOCKET_CLOSE= 3,
  411. /** Socket send, @c send(). */
  412. PSI_SOCKET_SEND= 4,
  413. /** Socket receive, @c recv(). */
  414. PSI_SOCKET_RECV= 5,
  415. /** Socket send, @c sendto(). */
  416. PSI_SOCKET_SENDTO= 6,
  417. /** Socket receive, @c recvfrom). */
  418. PSI_SOCKET_RECVFROM= 7,
  419. /** Socket send, @c sendmsg(). */
  420. PSI_SOCKET_SENDMSG= 8,
  421. /** Socket receive, @c recvmsg(). */
  422. PSI_SOCKET_RECVMSG= 9,
  423. /** Socket seek, such as @c fseek() or @c seek(). */
  424. PSI_SOCKET_SEEK= 10,
  425. /** Socket options, as in @c getsockopt() and @c setsockopt(). */
  426. PSI_SOCKET_OPT= 11,
  427. /** Socket status, as in @c sockatmark() and @c isfdtype(). */
  428. PSI_SOCKET_STAT= 12,
  429. /** Socket shutdown, as in @c shutdown(). */
  430. PSI_SOCKET_SHUTDOWN= 13,
  431. /** Socket select, as in @c select() and @c poll(). */
  432. PSI_SOCKET_SELECT= 14
  433. };
  434. typedef enum PSI_socket_operation PSI_socket_operation;
  435. /**
  436. Instrumented mutex key.
  437. To instrument a mutex, a mutex key must be obtained using @c register_mutex.
  438. Using a zero key always disable the instrumentation.
  439. */
  440. typedef unsigned int PSI_mutex_key;
  441. /**
  442. Instrumented rwlock key.
  443. To instrument a rwlock, a rwlock key must be obtained
  444. using @c register_rwlock.
  445. Using a zero key always disable the instrumentation.
  446. */
  447. typedef unsigned int PSI_rwlock_key;
  448. /**
  449. Instrumented cond key.
  450. To instrument a condition, a condition key must be obtained
  451. using @c register_cond.
  452. Using a zero key always disable the instrumentation.
  453. */
  454. typedef unsigned int PSI_cond_key;
  455. /**
  456. Instrumented thread key.
  457. To instrument a thread, a thread key must be obtained
  458. using @c register_thread.
  459. Using a zero key always disable the instrumentation.
  460. */
  461. typedef unsigned int PSI_thread_key;
  462. /**
  463. Instrumented file key.
  464. To instrument a file, a file key must be obtained using @c register_file.
  465. Using a zero key always disable the instrumentation.
  466. */
  467. typedef unsigned int PSI_file_key;
  468. /**
  469. Instrumented stage key.
  470. To instrument a stage, a stage key must be obtained using @c register_stage.
  471. Using a zero key always disable the instrumentation.
  472. */
  473. typedef unsigned int PSI_stage_key;
  474. /**
  475. Instrumented statement key.
  476. To instrument a statement, a statement key must be obtained using @c register_statement.
  477. Using a zero key always disable the instrumentation.
  478. */
  479. typedef unsigned int PSI_statement_key;
  480. /**
  481. Instrumented socket key.
  482. To instrument a socket, a socket key must be obtained using @c register_socket.
  483. Using a zero key always disable the instrumentation.
  484. */
  485. typedef unsigned int PSI_socket_key;
  486. /**
  487. @def USE_PSI_1
  488. Define USE_PSI_1 to use the interface version 1.
  489. */
  490. /**
  491. @def USE_PSI_2
  492. Define USE_PSI_2 to use the interface version 2.
  493. */
  494. /**
  495. @def HAVE_PSI_1
  496. Define HAVE_PSI_1 if the interface version 1 needs to be compiled in.
  497. */
  498. /**
  499. @def HAVE_PSI_2
  500. Define HAVE_PSI_2 if the interface version 2 needs to be compiled in.
  501. */
  502. /**
  503. Global flag.
  504. This flag indicate that an instrumentation point is a global variable,
  505. or a singleton.
  506. */
  507. #define PSI_FLAG_GLOBAL (1 << 0)
  508. /**
  509. Global flag.
  510. This flag indicate that an instrumentation point is a general placeholder,
  511. that can mutate into a more specific instrumentation point.
  512. */
  513. #define PSI_FLAG_MUTABLE (1 << 1)
  514. #ifdef USE_PSI_1
  515. #define HAVE_PSI_1
  516. #endif
  517. #ifdef HAVE_PSI_1
  518. /**
  519. @defgroup Group_PSI_v1 Application Binary Interface, version 1
  520. @ingroup Instrumentation_interface
  521. @{
  522. */
  523. /**
  524. Mutex information.
  525. @since PSI_VERSION_1
  526. This structure is used to register an instrumented mutex.
  527. */
  528. struct PSI_mutex_info_v1
  529. {
  530. /**
  531. Pointer to the key assigned to the registered mutex.
  532. */
  533. PSI_mutex_key *m_key;
  534. /**
  535. The name of the mutex to register.
  536. */
  537. const char *m_name;
  538. /**
  539. The flags of the mutex to register.
  540. @sa PSI_FLAG_GLOBAL
  541. */
  542. int m_flags;
  543. };
  544. /**
  545. Rwlock information.
  546. @since PSI_VERSION_1
  547. This structure is used to register an instrumented rwlock.
  548. */
  549. struct PSI_rwlock_info_v1
  550. {
  551. /**
  552. Pointer to the key assigned to the registered rwlock.
  553. */
  554. PSI_rwlock_key *m_key;
  555. /**
  556. The name of the rwlock to register.
  557. */
  558. const char *m_name;
  559. /**
  560. The flags of the rwlock to register.
  561. @sa PSI_FLAG_GLOBAL
  562. */
  563. int m_flags;
  564. };
  565. /**
  566. Condition information.
  567. @since PSI_VERSION_1
  568. This structure is used to register an instrumented cond.
  569. */
  570. struct PSI_cond_info_v1
  571. {
  572. /**
  573. Pointer to the key assigned to the registered cond.
  574. */
  575. PSI_cond_key *m_key;
  576. /**
  577. The name of the cond to register.
  578. */
  579. const char *m_name;
  580. /**
  581. The flags of the cond to register.
  582. @sa PSI_FLAG_GLOBAL
  583. */
  584. int m_flags;
  585. };
  586. /**
  587. Thread instrument information.
  588. @since PSI_VERSION_1
  589. This structure is used to register an instrumented thread.
  590. */
  591. struct PSI_thread_info_v1
  592. {
  593. /**
  594. Pointer to the key assigned to the registered thread.
  595. */
  596. PSI_thread_key *m_key;
  597. /**
  598. The name of the thread instrument to register.
  599. */
  600. const char *m_name;
  601. /**
  602. The flags of the thread to register.
  603. @sa PSI_FLAG_GLOBAL
  604. */
  605. int m_flags;
  606. };
  607. /**
  608. File instrument information.
  609. @since PSI_VERSION_1
  610. This structure is used to register an instrumented file.
  611. */
  612. struct PSI_file_info_v1
  613. {
  614. /**
  615. Pointer to the key assigned to the registered file.
  616. */
  617. PSI_file_key *m_key;
  618. /**
  619. The name of the file instrument to register.
  620. */
  621. const char *m_name;
  622. /**
  623. The flags of the file instrument to register.
  624. @sa PSI_FLAG_GLOBAL
  625. */
  626. int m_flags;
  627. };
  628. /**
  629. Stage instrument information.
  630. @since PSI_VERSION_1
  631. This structure is used to register an instrumented stage.
  632. */
  633. struct PSI_stage_info_v1
  634. {
  635. /** The registered stage key. */
  636. PSI_stage_key m_key;
  637. /** The name of the stage instrument to register. */
  638. const char *m_name;
  639. /** The flags of the stage instrument to register. */
  640. int m_flags;
  641. };
  642. /**
  643. Statement instrument information.
  644. @since PSI_VERSION_1
  645. This structure is used to register an instrumented statement.
  646. */
  647. struct PSI_statement_info_v1
  648. {
  649. /** The registered statement key. */
  650. PSI_statement_key m_key;
  651. /** The name of the statement instrument to register. */
  652. const char *m_name;
  653. /** The flags of the statement instrument to register. */
  654. int m_flags;
  655. };
  656. /**
  657. Socket instrument information.
  658. @since PSI_VERSION_1
  659. This structure is used to register an instrumented socket.
  660. */
  661. struct PSI_socket_info_v1
  662. {
  663. /**
  664. Pointer to the key assigned to the registered socket.
  665. */
  666. PSI_socket_key *m_key;
  667. /**
  668. The name of the socket instrument to register.
  669. */
  670. const char *m_name;
  671. /**
  672. The flags of the socket instrument to register.
  673. @sa PSI_FLAG_GLOBAL
  674. */
  675. int m_flags;
  676. };
  677. /**
  678. State data storage for @c start_idle_wait_v1_t.
  679. This structure provide temporary storage to an idle locker.
  680. The content of this structure is considered opaque,
  681. the fields are only hints of what an implementation
  682. of the psi interface can use.
  683. This memory is provided by the instrumented code for performance reasons.
  684. @sa start_idle_wait_v1_t.
  685. */
  686. struct PSI_idle_locker_state_v1
  687. {
  688. /** Internal state. */
  689. uint m_flags;
  690. /** Current thread. */
  691. struct PSI_thread *m_thread;
  692. /** Timer start. */
  693. ulonglong m_timer_start;
  694. /** Timer function. */
  695. ulonglong (*m_timer)(void);
  696. /** Internal data. */
  697. void *m_wait;
  698. };
  699. /**
  700. State data storage for @c start_mutex_wait_v1_t.
  701. This structure provide temporary storage to a mutex locker.
  702. The content of this structure is considered opaque,
  703. the fields are only hints of what an implementation
  704. of the psi interface can use.
  705. This memory is provided by the instrumented code for performance reasons.
  706. @sa start_mutex_wait_v1_t
  707. */
  708. struct PSI_mutex_locker_state_v1
  709. {
  710. /** Internal state. */
  711. uint m_flags;
  712. /** Current operation. */
  713. enum PSI_mutex_operation m_operation;
  714. /** Current mutex. */
  715. struct PSI_mutex *m_mutex;
  716. /** Current thread. */
  717. struct PSI_thread *m_thread;
  718. /** Timer start. */
  719. ulonglong m_timer_start;
  720. /** Timer function. */
  721. ulonglong (*m_timer)(void);
  722. /** Internal data. */
  723. void *m_wait;
  724. };
  725. /**
  726. State data storage for @c start_rwlock_rdwait_v1_t, @c start_rwlock_wrwait_v1_t.
  727. This structure provide temporary storage to a rwlock locker.
  728. The content of this structure is considered opaque,
  729. the fields are only hints of what an implementation
  730. of the psi interface can use.
  731. This memory is provided by the instrumented code for performance reasons.
  732. @sa start_rwlock_rdwait_v1_t
  733. @sa start_rwlock_wrwait_v1_t
  734. */
  735. struct PSI_rwlock_locker_state_v1
  736. {
  737. /** Internal state. */
  738. uint m_flags;
  739. /** Current operation. */
  740. enum PSI_rwlock_operation m_operation;
  741. /** Current rwlock. */
  742. struct PSI_rwlock *m_rwlock;
  743. /** Current thread. */
  744. struct PSI_thread *m_thread;
  745. /** Timer start. */
  746. ulonglong m_timer_start;
  747. /** Timer function. */
  748. ulonglong (*m_timer)(void);
  749. /** Internal data. */
  750. void *m_wait;
  751. };
  752. /**
  753. State data storage for @c start_cond_wait_v1_t.
  754. This structure provide temporary storage to a condition locker.
  755. The content of this structure is considered opaque,
  756. the fields are only hints of what an implementation
  757. of the psi interface can use.
  758. This memory is provided by the instrumented code for performance reasons.
  759. @sa start_cond_wait_v1_t
  760. */
  761. struct PSI_cond_locker_state_v1
  762. {
  763. /** Internal state. */
  764. uint m_flags;
  765. /** Current operation. */
  766. enum PSI_cond_operation m_operation;
  767. /** Current condition. */
  768. struct PSI_cond *m_cond;
  769. /** Current mutex. */
  770. struct PSI_mutex *m_mutex;
  771. /** Current thread. */
  772. struct PSI_thread *m_thread;
  773. /** Timer start. */
  774. ulonglong m_timer_start;
  775. /** Timer function. */
  776. ulonglong (*m_timer)(void);
  777. /** Internal data. */
  778. void *m_wait;
  779. };
  780. /**
  781. State data storage for @c get_thread_file_name_locker_v1_t.
  782. This structure provide temporary storage to a file locker.
  783. The content of this structure is considered opaque,
  784. the fields are only hints of what an implementation
  785. of the psi interface can use.
  786. This memory is provided by the instrumented code for performance reasons.
  787. @sa get_thread_file_name_locker_v1_t
  788. @sa get_thread_file_stream_locker_v1_t
  789. @sa get_thread_file_descriptor_locker_v1_t
  790. */
  791. struct PSI_file_locker_state_v1
  792. {
  793. /** Internal state. */
  794. uint m_flags;
  795. /** Current operation. */
  796. enum PSI_file_operation m_operation;
  797. /** Current file. */
  798. struct PSI_file *m_file;
  799. /** Current file name. */
  800. const char *m_name;
  801. /** Current file class. */
  802. void *m_class;
  803. /** Current thread. */
  804. struct PSI_thread *m_thread;
  805. /** Operation number of bytes. */
  806. size_t m_number_of_bytes;
  807. /** Timer start. */
  808. ulonglong m_timer_start;
  809. /** Timer function. */
  810. ulonglong (*m_timer)(void);
  811. /** Internal data. */
  812. void *m_wait;
  813. };
  814. /**
  815. State data storage for @c start_table_io_wait_v1_t,
  816. @c start_table_lock_wait_v1_t.
  817. This structure provide temporary storage to a table locker.
  818. The content of this structure is considered opaque,
  819. the fields are only hints of what an implementation
  820. of the psi interface can use.
  821. This memory is provided by the instrumented code for performance reasons.
  822. @sa start_table_io_wait_v1_t
  823. @sa start_table_lock_wait_v1_t
  824. */
  825. struct PSI_table_locker_state_v1
  826. {
  827. /** Internal state. */
  828. uint m_flags;
  829. /** Current io operation. */
  830. enum PSI_table_io_operation m_io_operation;
  831. /** Current table handle. */
  832. struct PSI_table *m_table;
  833. /** Current table share. */
  834. struct PSI_table_share *m_table_share;
  835. /** Current thread. */
  836. struct PSI_thread *m_thread;
  837. /** Timer start. */
  838. ulonglong m_timer_start;
  839. /** Timer function. */
  840. ulonglong (*m_timer)(void);
  841. /** Internal data. */
  842. void *m_wait;
  843. /**
  844. Implementation specific.
  845. For table io, the table io index.
  846. For table lock, the lock type.
  847. */
  848. uint m_index;
  849. };
  850. /* Duplicate of NAME_LEN, to avoid dependency on mysql_com.h */
  851. #define PSI_SCHEMA_NAME_LEN (64 * 3)
  852. /**
  853. State data storage for @c get_thread_statement_locker_v1_t,
  854. @c get_thread_statement_locker_v1_t.
  855. This structure provide temporary storage to a statement locker.
  856. The content of this structure is considered opaque,
  857. the fields are only hints of what an implementation
  858. of the psi interface can use.
  859. This memory is provided by the instrumented code for performance reasons.
  860. @sa get_thread_statement_locker_v1_t
  861. */
  862. struct PSI_statement_locker_state_v1
  863. {
  864. /** Discarded flag. */
  865. my_bool m_discarded;
  866. /** Metric, no index used flag. */
  867. uchar m_no_index_used;
  868. /** Metric, no good index used flag. */
  869. uchar m_no_good_index_used;
  870. /** Internal state. */
  871. uint m_flags;
  872. /** Instrumentation class. */
  873. void *m_class;
  874. /** Current thread. */
  875. struct PSI_thread *m_thread;
  876. /** Timer start. */
  877. ulonglong m_timer_start;
  878. /** Timer function. */
  879. ulonglong (*m_timer)(void);
  880. /** Internal data. */
  881. void *m_statement;
  882. /** Locked time. */
  883. ulonglong m_lock_time;
  884. /** Rows sent. */
  885. ulonglong m_rows_sent;
  886. /** Rows examined. */
  887. ulonglong m_rows_examined;
  888. /** Metric, temporary tables created on disk. */
  889. ulong m_created_tmp_disk_tables;
  890. /** Metric, temporary tables created. */
  891. ulong m_created_tmp_tables;
  892. /** Metric, number of select full join. */
  893. ulong m_select_full_join;
  894. /** Metric, number of select full range join. */
  895. ulong m_select_full_range_join;
  896. /** Metric, number of select range. */
  897. ulong m_select_range;
  898. /** Metric, number of select range check. */
  899. ulong m_select_range_check;
  900. /** Metric, number of select scan. */
  901. ulong m_select_scan;
  902. /** Metric, number of sort merge passes. */
  903. ulong m_sort_merge_passes;
  904. /** Metric, number of sort merge. */
  905. ulong m_sort_range;
  906. /** Metric, number of sort rows. */
  907. ulong m_sort_rows;
  908. /** Metric, number of sort scans. */
  909. ulong m_sort_scan;
  910. /** Statement digest. */
  911. const struct sql_digest_storage *m_digest;
  912. /** Current schema name. */
  913. char m_schema_name[PSI_SCHEMA_NAME_LEN];
  914. /** Length in bytes of @c m_schema_name. */
  915. uint m_schema_name_length;
  916. /** Statement character set number. */
  917. uint m_cs_number;
  918. };
  919. /**
  920. State data storage for @c start_socket_wait_v1_t.
  921. This structure provide temporary storage to a socket locker.
  922. The content of this structure is considered opaque,
  923. the fields are only hints of what an implementation
  924. of the psi interface can use.
  925. This memory is provided by the instrumented code for performance reasons.
  926. @sa start_socket_wait_v1_t
  927. */
  928. struct PSI_socket_locker_state_v1
  929. {
  930. /** Internal state. */
  931. uint m_flags;
  932. /** Current socket. */
  933. struct PSI_socket *m_socket;
  934. /** Current thread. */
  935. struct PSI_thread *m_thread;
  936. /** Operation number of bytes. */
  937. size_t m_number_of_bytes;
  938. /** Timer start. */
  939. ulonglong m_timer_start;
  940. /** Timer function. */
  941. ulonglong (*m_timer)(void);
  942. /** Current operation. */
  943. enum PSI_socket_operation m_operation;
  944. /** Source file. */
  945. const char* m_src_file;
  946. /** Source line number. */
  947. int m_src_line;
  948. /** Internal data. */
  949. void *m_wait;
  950. };
  951. /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
  952. /**
  953. Mutex registration API.
  954. @param category a category name (typically a plugin name)
  955. @param info an array of mutex info to register
  956. @param count the size of the info array
  957. */
  958. typedef void (*register_mutex_v1_t)
  959. (const char *category, struct PSI_mutex_info_v1 *info, int count);
  960. /**
  961. Rwlock registration API.
  962. @param category a category name (typically a plugin name)
  963. @param info an array of rwlock info to register
  964. @param count the size of the info array
  965. */
  966. typedef void (*register_rwlock_v1_t)
  967. (const char *category, struct PSI_rwlock_info_v1 *info, int count);
  968. /**
  969. Cond registration API.
  970. @param category a category name (typically a plugin name)
  971. @param info an array of cond info to register
  972. @param count the size of the info array
  973. */
  974. typedef void (*register_cond_v1_t)
  975. (const char *category, struct PSI_cond_info_v1 *info, int count);
  976. /**
  977. Thread registration API.
  978. @param category a category name (typically a plugin name)
  979. @param info an array of thread info to register
  980. @param count the size of the info array
  981. */
  982. typedef void (*register_thread_v1_t)
  983. (const char *category, struct PSI_thread_info_v1 *info, int count);
  984. /**
  985. File registration API.
  986. @param category a category name (typically a plugin name)
  987. @param info an array of file info to register
  988. @param count the size of the info array
  989. */
  990. typedef void (*register_file_v1_t)
  991. (const char *category, struct PSI_file_info_v1 *info, int count);
  992. /**
  993. Stage registration API.
  994. @param category a category name
  995. @param info an array of stage info to register
  996. @param count the size of the info array
  997. */
  998. typedef void (*register_stage_v1_t)
  999. (const char *category, struct PSI_stage_info_v1 **info, int count);
  1000. /**
  1001. Statement registration API.
  1002. @param category a category name
  1003. @param info an array of stage info to register
  1004. @param count the size of the info array
  1005. */
  1006. typedef void (*register_statement_v1_t)
  1007. (const char *category, struct PSI_statement_info_v1 *info, int count);
  1008. /**
  1009. Socket registration API.
  1010. @param category a category name (typically a plugin name)
  1011. @param info an array of socket info to register
  1012. @param count the size of the info array
  1013. */
  1014. typedef void (*register_socket_v1_t)
  1015. (const char *category, struct PSI_socket_info_v1 *info, int count);
  1016. /**
  1017. Mutex instrumentation initialisation API.
  1018. @param key the registered mutex key
  1019. @param identity the address of the mutex itself
  1020. @return an instrumented mutex
  1021. */
  1022. typedef struct PSI_mutex* (*init_mutex_v1_t)
  1023. (PSI_mutex_key key, const void *identity);
  1024. /**
  1025. Mutex instrumentation destruction API.
  1026. @param mutex the mutex to destroy
  1027. */
  1028. typedef void (*destroy_mutex_v1_t)(struct PSI_mutex *mutex);
  1029. /**
  1030. Rwlock instrumentation initialisation API.
  1031. @param key the registered rwlock key
  1032. @param identity the address of the rwlock itself
  1033. @return an instrumented rwlock
  1034. */
  1035. typedef struct PSI_rwlock* (*init_rwlock_v1_t)
  1036. (PSI_rwlock_key key, const void *identity);
  1037. /**
  1038. Rwlock instrumentation destruction API.
  1039. @param rwlock the rwlock to destroy
  1040. */
  1041. typedef void (*destroy_rwlock_v1_t)(struct PSI_rwlock *rwlock);
  1042. /**
  1043. Cond instrumentation initialisation API.
  1044. @param key the registered key
  1045. @param identity the address of the rwlock itself
  1046. @return an instrumented cond
  1047. */
  1048. typedef struct PSI_cond* (*init_cond_v1_t)
  1049. (PSI_cond_key key, const void *identity);
  1050. /**
  1051. Cond instrumentation destruction API.
  1052. @param cond the rcond to destroy
  1053. */
  1054. typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
  1055. /**
  1056. Socket instrumentation initialisation API.
  1057. @param key the registered mutex key
  1058. @param socket descriptor
  1059. @param addr the socket ip address
  1060. @param addr_len length of socket ip address
  1061. @return an instrumented socket
  1062. */
  1063. typedef struct PSI_socket* (*init_socket_v1_t)
  1064. (PSI_socket_key key, const my_socket *fd,
  1065. const struct sockaddr *addr, socklen_t addr_len);
  1066. /**
  1067. socket instrumentation destruction API.
  1068. @param socket the socket to destroy
  1069. */
  1070. typedef void (*destroy_socket_v1_t)(struct PSI_socket *socket);
  1071. /**
  1072. Acquire a table share instrumentation.
  1073. @param temporary True for temporary tables
  1074. @param share The SQL layer table share
  1075. @return a table share instrumentation, or NULL
  1076. */
  1077. typedef struct PSI_table_share* (*get_table_share_v1_t)
  1078. (my_bool temporary, struct TABLE_SHARE *share);
  1079. /**
  1080. Release a table share.
  1081. @param info the table share to release
  1082. */
  1083. typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
  1084. /**
  1085. Drop a table share.
  1086. @param temporary True for temporary tables
  1087. @param schema_name the table schema name
  1088. @param schema_name_length the table schema name length
  1089. @param table_name the table name
  1090. @param table_name_length the table name length
  1091. */
  1092. typedef void (*drop_table_share_v1_t)
  1093. (my_bool temporary, const char *schema_name, int schema_name_length,
  1094. const char *table_name, int table_name_length);
  1095. /**
  1096. Open an instrumentation table handle.
  1097. @param share the table to open
  1098. @param identity table handle identity
  1099. @return a table handle, or NULL
  1100. */
  1101. typedef struct PSI_table* (*open_table_v1_t)
  1102. (struct PSI_table_share *share, const void *identity);
  1103. /**
  1104. Unbind a table handle from the current thread.
  1105. This operation happens when an opened table is added to the open table cache.
  1106. @param table the table to unbind
  1107. */
  1108. typedef void (*unbind_table_v1_t)
  1109. (struct PSI_table *table);
  1110. /**
  1111. Rebind a table handle to the current thread.
  1112. This operation happens when a table from the open table cache
  1113. is reused for a thread.
  1114. @param table the table to unbind
  1115. */
  1116. typedef PSI_table* (*rebind_table_v1_t)
  1117. (PSI_table_share *share, const void *identity, PSI_table *table);
  1118. /**
  1119. Close an instrumentation table handle.
  1120. Note that the table handle is invalid after this call.
  1121. @param table the table handle to close
  1122. */
  1123. typedef void (*close_table_v1_t)(struct PSI_table *table);
  1124. /**
  1125. Create a file instrumentation for a created file.
  1126. This method does not create the file itself, but is used to notify the
  1127. instrumentation interface that a file was just created.
  1128. @param key the file instrumentation key for this file
  1129. @param name the file name
  1130. @param file the file handle
  1131. */
  1132. typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
  1133. File file);
  1134. /**
  1135. Spawn a thread.
  1136. This method creates a new thread, with instrumentation.
  1137. @param key the instrumentation key for this thread
  1138. @param thread the resulting thread
  1139. @param attr the thread attributes
  1140. @param start_routine the thread start routine
  1141. @param arg the thread start routine argument
  1142. */
  1143. typedef int (*spawn_thread_v1_t)(PSI_thread_key key,
  1144. pthread_t *thread,
  1145. const pthread_attr_t *attr,
  1146. void *(*start_routine)(void*), void *arg);
  1147. /**
  1148. Create instrumentation for a thread.
  1149. @param key the registered key
  1150. @param identity an address typical of the thread
  1151. @return an instrumented thread
  1152. */
  1153. typedef struct PSI_thread* (*new_thread_v1_t)
  1154. (PSI_thread_key key, const void *identity, ulonglong thread_id);
  1155. /**
  1156. Assign an id to an instrumented thread.
  1157. @param thread the instrumented thread
  1158. @param id the id to assign
  1159. */
  1160. typedef void (*set_thread_id_v1_t)(struct PSI_thread *thread,
  1161. ulonglong id);
  1162. /**
  1163. Get the instrumentation for the running thread.
  1164. For this function to return a result,
  1165. the thread instrumentation must have been attached to the
  1166. running thread using @c set_thread()
  1167. @return the instrumentation for the running thread
  1168. */
  1169. typedef struct PSI_thread* (*get_thread_v1_t)(void);
  1170. /**
  1171. Assign a user name to the instrumented thread.
  1172. @param user the user name
  1173. @param user_len the user name length
  1174. */
  1175. typedef void (*set_thread_user_v1_t)(const char *user, int user_len);
  1176. /**
  1177. Assign a user name and host name to the instrumented thread.
  1178. @param user the user name
  1179. @param user_len the user name length
  1180. @param host the host name
  1181. @param host_len the host name length
  1182. */
  1183. typedef void (*set_thread_user_host_v1_t)(const char *user, int user_len,
  1184. const char *host, int host_len);
  1185. /**
  1186. Assign a current database to the instrumented thread.
  1187. @param db the database name
  1188. @param db_len the database name length
  1189. */
  1190. typedef void (*set_thread_db_v1_t)(const char* db, int db_len);
  1191. /**
  1192. Assign a current command to the instrumented thread.
  1193. @param command the current command
  1194. */
  1195. typedef void (*set_thread_command_v1_t)(int command);
  1196. /**
  1197. Assign a start time to the instrumented thread.
  1198. @param start_time the thread start time
  1199. */
  1200. typedef void (*set_thread_start_time_v1_t)(time_t start_time);
  1201. /**
  1202. Assign a state to the instrumented thread.
  1203. @param state the thread state
  1204. */
  1205. typedef void (*set_thread_state_v1_t)(const char* state);
  1206. /**
  1207. Assign a process info to the instrumented thread.
  1208. @param info the process into string
  1209. @param info_len the process into string length
  1210. */
  1211. typedef void (*set_thread_info_v1_t)(const char* info, uint info_len);
  1212. /**
  1213. Attach a thread instrumentation to the running thread.
  1214. In case of thread pools, this method should be called when
  1215. a worker thread picks a work item and runs it.
  1216. Also, this method should be called if the instrumented code does not
  1217. keep the pointer returned by @c new_thread() and relies on @c get_thread()
  1218. instead.
  1219. @param thread the thread instrumentation
  1220. */
  1221. typedef void (*set_thread_v1_t)(struct PSI_thread *thread);
  1222. /** Delete the current thread instrumentation. */
  1223. typedef void (*delete_current_thread_v1_t)(void);
  1224. /** Delete a thread instrumentation. */
  1225. typedef void (*delete_thread_v1_t)(struct PSI_thread *thread);
  1226. /**
  1227. Get a file instrumentation locker, for opening or creating a file.
  1228. @param state data storage for the locker
  1229. @param key the file instrumentation key
  1230. @param op the operation to perform
  1231. @param name the file name
  1232. @param identity a pointer representative of this file.
  1233. @return a file locker, or NULL
  1234. */
  1235. typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t)
  1236. (struct PSI_file_locker_state_v1 *state,
  1237. PSI_file_key key, enum PSI_file_operation op, const char *name,
  1238. const void *identity);
  1239. /**
  1240. Get a file stream instrumentation locker.
  1241. @param state data storage for the locker
  1242. @param file the file stream to access
  1243. @param op the operation to perform
  1244. @return a file locker, or NULL
  1245. */
  1246. typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t)
  1247. (struct PSI_file_locker_state_v1 *state,
  1248. struct PSI_file *file, enum PSI_file_operation op);
  1249. /**
  1250. Get a file instrumentation locker.
  1251. @param state data storage for the locker
  1252. @param file the file descriptor to access
  1253. @param op the operation to perform
  1254. @return a file locker, or NULL
  1255. */
  1256. typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t)
  1257. (struct PSI_file_locker_state_v1 *state,
  1258. File file, enum PSI_file_operation op);
  1259. /**
  1260. Record a mutex instrumentation unlock event.
  1261. @param mutex the mutex instrumentation
  1262. */
  1263. typedef void (*unlock_mutex_v1_t)
  1264. (struct PSI_mutex *mutex);
  1265. /**
  1266. Record a rwlock instrumentation unlock event.
  1267. @param rwlock the rwlock instrumentation
  1268. */
  1269. typedef void (*unlock_rwlock_v1_t)
  1270. (struct PSI_rwlock *rwlock);
  1271. /**
  1272. Record a condition instrumentation signal event.
  1273. @param cond the cond instrumentation
  1274. */
  1275. typedef void (*signal_cond_v1_t)
  1276. (struct PSI_cond *cond);
  1277. /**
  1278. Record a condition instrumentation broadcast event.
  1279. @param cond the cond instrumentation
  1280. */
  1281. typedef void (*broadcast_cond_v1_t)
  1282. (struct PSI_cond *cond);
  1283. typedef struct PSI_idle_locker* (*start_idle_wait_v1_t)
  1284. (struct PSI_idle_locker_state_v1 *state, const char *src_file, uint src_line);
  1285. typedef void (*end_idle_wait_v1_t)
  1286. (struct PSI_idle_locker *locker);
  1287. /**
  1288. Record a mutex instrumentation wait start event.
  1289. @param state data storage for the locker
  1290. @param mutex the instrumented mutex to lock
  1291. @param op the operation to perform
  1292. @param file the source file name
  1293. @param line the source line number
  1294. @return a mutex locker, or NULL
  1295. */
  1296. typedef struct PSI_mutex_locker* (*start_mutex_wait_v1_t)
  1297. (struct PSI_mutex_locker_state_v1 *state,
  1298. struct PSI_mutex *mutex,
  1299. enum PSI_mutex_operation op,
  1300. const char *src_file, uint src_line);
  1301. /**
  1302. Record a mutex instrumentation wait end event.
  1303. @param locker a thread locker for the running thread
  1304. @param rc the wait operation return code
  1305. */
  1306. typedef void (*end_mutex_wait_v1_t)
  1307. (struct PSI_mutex_locker *locker, int rc);
  1308. /**
  1309. Record a rwlock instrumentation read wait start event.
  1310. @param locker a thread locker for the running thread
  1311. @param must must block: 1 for lock, 0 for trylock
  1312. */
  1313. typedef struct PSI_rwlock_locker* (*start_rwlock_rdwait_v1_t)
  1314. (struct PSI_rwlock_locker_state_v1 *state,
  1315. struct PSI_rwlock *rwlock,
  1316. enum PSI_rwlock_operation op,
  1317. const char *src_file, uint src_line);
  1318. /**
  1319. Record a rwlock instrumentation read wait end event.
  1320. @param locker a thread locker for the running thread
  1321. @param rc the wait operation return code
  1322. */
  1323. typedef void (*end_rwlock_rdwait_v1_t)
  1324. (struct PSI_rwlock_locker *locker, int rc);
  1325. /**
  1326. Record a rwlock instrumentation write wait start event.
  1327. @param locker a thread locker for the running thread
  1328. @param must must block: 1 for lock, 0 for trylock
  1329. */
  1330. typedef struct PSI_rwlock_locker* (*start_rwlock_wrwait_v1_t)
  1331. (struct PSI_rwlock_locker_state_v1 *state,
  1332. struct PSI_rwlock *rwlock,
  1333. enum PSI_rwlock_operation op,
  1334. const char *src_file, uint src_line);
  1335. /**
  1336. Record a rwlock instrumentation write wait end event.
  1337. @param locker a thread locker for the running thread
  1338. @param rc the wait operation return code
  1339. */
  1340. typedef void (*end_rwlock_wrwait_v1_t)
  1341. (struct PSI_rwlock_locker *locker, int rc);
  1342. /**
  1343. Record a condition instrumentation wait start event.
  1344. @param locker a thread locker for the running thread
  1345. @param must must block: 1 for wait, 0 for timedwait
  1346. */
  1347. typedef struct PSI_cond_locker* (*start_cond_wait_v1_t)
  1348. (struct PSI_cond_locker_state_v1 *state,
  1349. struct PSI_cond *cond,
  1350. struct PSI_mutex *mutex,
  1351. enum PSI_cond_operation op,
  1352. const char *src_file, uint src_line);
  1353. /**
  1354. Record a condition instrumentation wait end event.
  1355. @param locker a thread locker for the running thread
  1356. @param rc the wait operation return code
  1357. */
  1358. typedef void (*end_cond_wait_v1_t)
  1359. (struct PSI_cond_locker *locker, int rc);
  1360. /**
  1361. Record a table instrumentation io wait start event.
  1362. @param locker a table locker for the running thread
  1363. @param file the source file name
  1364. @param line the source line number
  1365. */
  1366. typedef struct PSI_table_locker* (*start_table_io_wait_v1_t)
  1367. (struct PSI_table_locker_state_v1 *state,
  1368. struct PSI_table *table,
  1369. enum PSI_table_io_operation op,
  1370. uint index,
  1371. const char *src_file, uint src_line);
  1372. /**
  1373. Record a table instrumentation io wait end event.
  1374. @param locker a table locker for the running thread
  1375. */
  1376. typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker);
  1377. /**
  1378. Record a table instrumentation lock wait start event.
  1379. @param locker a table locker for the running thread
  1380. @param file the source file name
  1381. @param line the source line number
  1382. */
  1383. typedef struct PSI_table_locker* (*start_table_lock_wait_v1_t)
  1384. (struct PSI_table_locker_state_v1 *state,
  1385. struct PSI_table *table,
  1386. enum PSI_table_lock_operation op,
  1387. ulong flags,
  1388. const char *src_file, uint src_line);
  1389. /**
  1390. Record a table instrumentation lock wait end event.
  1391. @param locker a table locker for the running thread
  1392. */
  1393. typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
  1394. /**
  1395. Start a file instrumentation open operation.
  1396. @param locker the file locker
  1397. @param op the operation to perform
  1398. @param src_file the source file name
  1399. @param src_line the source line number
  1400. */
  1401. typedef void (*start_file_open_wait_v1_t)
  1402. (struct PSI_file_locker *locker, const char *src_file, uint src_line);
  1403. /**
  1404. End a file instrumentation open operation, for file streams.
  1405. @param locker the file locker.
  1406. @param result the opened file (NULL indicates failure, non NULL success).
  1407. @return an instrumented file handle
  1408. */
  1409. typedef struct PSI_file* (*end_file_open_wait_v1_t)
  1410. (struct PSI_file_locker *locker, void *result);
  1411. /**
  1412. End a file instrumentation open operation, for non stream files.
  1413. @param locker the file locker.
  1414. @param file the file number assigned by open() or create() for this file.
  1415. */
  1416. typedef void (*end_file_open_wait_and_bind_to_descriptor_v1_t)
  1417. (struct PSI_file_locker *locker, File file);
  1418. /**
  1419. Record a file instrumentation start event.
  1420. @param locker a file locker for the running thread
  1421. @param op file operation to be performed
  1422. @param count the number of bytes requested, or 0 if not applicable
  1423. @param src_file the source file name
  1424. @param src_line the source line number
  1425. */
  1426. typedef void (*start_file_wait_v1_t)
  1427. (struct PSI_file_locker *locker, size_t count,
  1428. const char *src_file, uint src_line);
  1429. /**
  1430. Record a file instrumentation end event.
  1431. Note that for file close operations, the instrumented file handle
  1432. associated with the file (which was provided to obtain a locker)
  1433. is invalid after this call.
  1434. @param locker a file locker for the running thread
  1435. @param count the number of bytes actually used in the operation,
  1436. or 0 if not applicable, or -1 if the operation failed
  1437. @sa get_thread_file_name_locker
  1438. @sa get_thread_file_stream_locker
  1439. @sa get_thread_file_descriptor_locker
  1440. */
  1441. typedef void (*end_file_wait_v1_t)
  1442. (struct PSI_file_locker *locker, size_t count);
  1443. /**
  1444. Start a file instrumentation close operation.
  1445. @param locker the file locker
  1446. @param op the operation to perform
  1447. @param src_file the source file name
  1448. @param src_line the source line number
  1449. */
  1450. typedef void (*start_file_close_wait_v1_t)
  1451. (struct PSI_file_locker *locker, const char *src_file, uint src_line);
  1452. /**
  1453. End a file instrumentation close operation.
  1454. @param locker the file locker.
  1455. @param rc the close operation return code (0 for success).
  1456. @return an instrumented file handle
  1457. */
  1458. typedef void (*end_file_close_wait_v1_t)
  1459. (struct PSI_file_locker *locker, int rc);
  1460. /**
  1461. Start a new stage, and implicitly end the previous stage.
  1462. @param key the key of the new stage
  1463. @param src_file the source file name
  1464. @param src_line the source line number
  1465. */
  1466. typedef void (*start_stage_v1_t)
  1467. (PSI_stage_key key, const char *src_file, int src_line);
  1468. /** End the current stage. */
  1469. typedef void (*end_stage_v1_t) (void);
  1470. /**
  1471. Get a statement instrumentation locker.
  1472. @param state data storage for the locker
  1473. @param key the statement instrumentation key
  1474. @param charset client character set
  1475. @return a statement locker, or NULL
  1476. */
  1477. typedef struct PSI_statement_locker* (*get_thread_statement_locker_v1_t)
  1478. (struct PSI_statement_locker_state_v1 *state,
  1479. PSI_statement_key key, const void *charset);
  1480. /**
  1481. Refine a statement locker to a more specific key.
  1482. Note that only events declared mutable can be refined.
  1483. @param the statement locker for the current event
  1484. @param key the new key for the event
  1485. @sa PSI_FLAG_MUTABLE
  1486. */
  1487. typedef struct PSI_statement_locker* (*refine_statement_v1_t)
  1488. (struct PSI_statement_locker *locker,
  1489. PSI_statement_key key);
  1490. /**
  1491. Start a new statement event.
  1492. @param locker the statement locker for this event
  1493. @param db the active database name for this statement
  1494. @param db_length the active database name length for this statement
  1495. @param src_file source file name
  1496. @param src_line source line number
  1497. */
  1498. typedef void (*start_statement_v1_t)
  1499. (struct PSI_statement_locker *locker,
  1500. const char *db, uint db_length,
  1501. const char *src_file, uint src_line);
  1502. /**
  1503. Set the statement text for a statement event.
  1504. @param locker the current statement locker
  1505. @param text the statement text
  1506. @param text_len the statement text length
  1507. */
  1508. typedef void (*set_statement_text_v1_t)
  1509. (struct PSI_statement_locker *locker,
  1510. const char *text, uint text_len);
  1511. /**
  1512. Set a statement event lock time.
  1513. @param locker the statement locker
  1514. @param lock_time the locked time, in microseconds
  1515. */
  1516. typedef void (*set_statement_lock_time_t)
  1517. (struct PSI_statement_locker *locker, ulonglong lock_time);
  1518. /**
  1519. Set a statement event rows sent metric.
  1520. @param locker the statement locker
  1521. @param count the number of rows sent
  1522. */
  1523. typedef void (*set_statement_rows_sent_t)
  1524. (struct PSI_statement_locker *locker, ulonglong count);
  1525. /**
  1526. Set a statement event rows examined metric.
  1527. @param locker the statement locker
  1528. @param count the number of rows examined
  1529. */
  1530. typedef void (*set_statement_rows_examined_t)
  1531. (struct PSI_statement_locker *locker, ulonglong count);
  1532. /**
  1533. Increment a statement event "created tmp disk tables" metric.
  1534. @param locker the statement locker
  1535. @param count the metric increment value
  1536. */
  1537. typedef void (*inc_statement_created_tmp_disk_tables_t)
  1538. (struct PSI_statement_locker *locker, ulong count);
  1539. /**
  1540. Increment a statement event "created tmp tables" metric.
  1541. @param locker the statement locker
  1542. @param count the metric increment value
  1543. */
  1544. typedef void (*inc_statement_created_tmp_tables_t)
  1545. (struct PSI_statement_locker *locker, ulong count);
  1546. /**
  1547. Increment a statement event "select full join" metric.
  1548. @param locker the statement locker
  1549. @param count the metric increment value
  1550. */
  1551. typedef void (*inc_statement_select_full_join_t)
  1552. (struct PSI_statement_locker *locker, ulong count);
  1553. /**
  1554. Increment a statement event "select full range join" metric.
  1555. @param locker the statement locker
  1556. @param count the metric increment value
  1557. */
  1558. typedef void (*inc_statement_select_full_range_join_t)
  1559. (struct PSI_statement_locker *locker, ulong count);
  1560. /**
  1561. Increment a statement event "select range join" metric.
  1562. @param locker the statement locker
  1563. @param count the metric increment value
  1564. */
  1565. typedef void (*inc_statement_select_range_t)
  1566. (struct PSI_statement_locker *locker, ulong count);
  1567. /**
  1568. Increment a statement event "select range check" metric.
  1569. @param locker the statement locker
  1570. @param count the metric increment value
  1571. */
  1572. typedef void (*inc_statement_select_range_check_t)
  1573. (struct PSI_statement_locker *locker, ulong count);
  1574. /**
  1575. Increment a statement event "select scan" metric.
  1576. @param locker the statement locker
  1577. @param count the metric increment value
  1578. */
  1579. typedef void (*inc_statement_select_scan_t)
  1580. (struct PSI_statement_locker *locker, ulong count);
  1581. /**
  1582. Increment a statement event "sort merge passes" metric.
  1583. @param locker the statement locker
  1584. @param count the metric increment value
  1585. */
  1586. typedef void (*inc_statement_sort_merge_passes_t)
  1587. (struct PSI_statement_locker *locker, ulong count);
  1588. /**
  1589. Increment a statement event "sort range" metric.
  1590. @param locker the statement locker
  1591. @param count the metric increment value
  1592. */
  1593. typedef void (*inc_statement_sort_range_t)
  1594. (struct PSI_statement_locker *locker, ulong count);
  1595. /**
  1596. Increment a statement event "sort rows" metric.
  1597. @param locker the statement locker
  1598. @param count the metric increment value
  1599. */
  1600. typedef void (*inc_statement_sort_rows_t)
  1601. (struct PSI_statement_locker *locker, ulong count);
  1602. /**
  1603. Increment a statement event "sort scan" metric.
  1604. @param locker the statement locker
  1605. @param count the metric increment value
  1606. */
  1607. typedef void (*inc_statement_sort_scan_t)
  1608. (struct PSI_statement_locker *locker, ulong count);
  1609. /**
  1610. Set a statement event "no index used" metric.
  1611. @param locker the statement locker
  1612. @param count the metric value
  1613. */
  1614. typedef void (*set_statement_no_index_used_t)
  1615. (struct PSI_statement_locker *locker);
  1616. /**
  1617. Set a statement event "no good index used" metric.
  1618. @param locker the statement locker
  1619. @param count the metric value
  1620. */
  1621. typedef void (*set_statement_no_good_index_used_t)
  1622. (struct PSI_statement_locker *locker);
  1623. /**
  1624. End a statement event.
  1625. @param locker the statement locker
  1626. @param stmt_da the statement diagnostics area.
  1627. @sa Diagnostics_area
  1628. */
  1629. typedef void (*end_statement_v1_t)
  1630. (struct PSI_statement_locker *locker, void *stmt_da);
  1631. /**
  1632. Record a socket instrumentation start event.
  1633. @param locker a socket locker for the running thread
  1634. @param op socket operation to be performed
  1635. @param count the number of bytes requested, or 0 if not applicable
  1636. @param src_file the source file name
  1637. @param src_line the source line number
  1638. */
  1639. typedef struct PSI_socket_locker* (*start_socket_wait_v1_t)
  1640. (struct PSI_socket_locker_state_v1 *state,
  1641. struct PSI_socket *socket,
  1642. enum PSI_socket_operation op,
  1643. size_t count,
  1644. const char *src_file, uint src_line);
  1645. /**
  1646. Record a socket instrumentation end event.
  1647. Note that for socket close operations, the instrumented socket handle
  1648. associated with the socket (which was provided to obtain a locker)
  1649. is invalid after this call.
  1650. @param locker a socket locker for the running thread
  1651. @param count the number of bytes actually used in the operation,
  1652. or 0 if not applicable, or -1 if the operation failed
  1653. @sa get_thread_socket_locker
  1654. */
  1655. typedef void (*end_socket_wait_v1_t)
  1656. (struct PSI_socket_locker *locker, size_t count);
  1657. /**
  1658. Set the socket state for an instrumented socket.
  1659. @param socket the instrumented socket
  1660. @param state socket state
  1661. */
  1662. typedef void (*set_socket_state_v1_t)(struct PSI_socket *socket,
  1663. enum PSI_socket_state state);
  1664. /**
  1665. Set the socket info for an instrumented socket.
  1666. @param socket the instrumented socket
  1667. @param fd the socket descriptor
  1668. @param addr the socket ip address
  1669. @param addr_len length of socket ip address
  1670. @param thread_id associated thread id
  1671. */
  1672. typedef void (*set_socket_info_v1_t)(struct PSI_socket *socket,
  1673. const my_socket *fd,
  1674. const struct sockaddr *addr,
  1675. socklen_t addr_len);
  1676. /**
  1677. Bind a socket to the thread that owns it.
  1678. @param socket instrumented socket
  1679. */
  1680. typedef void (*set_socket_thread_owner_v1_t)(struct PSI_socket *socket);
  1681. /**
  1682. Get a digest locker for the current statement.
  1683. @param locker a statement locker for the running thread
  1684. */
  1685. typedef struct PSI_digest_locker * (*digest_start_v1_t)
  1686. (struct PSI_statement_locker *locker);
  1687. typedef void (*digest_end_v1_t)
  1688. (struct PSI_digest_locker *locker, const struct sql_digest_storage *digest);
  1689. /**
  1690. Stores an array of connection attributes
  1691. @param buffer char array of length encoded connection attributes
  1692. in network format
  1693. @param length legnth of the data in buffer
  1694. @param from_cs charset in which @buffer is encodded
  1695. @return state
  1696. @retval non-0 attributes truncated
  1697. @retval 0 stored the attribute
  1698. */
  1699. typedef int (*set_thread_connect_attrs_v1_t)(const char *buffer, uint length,
  1700. const void *from_cs);
  1701. /**
  1702. Performance Schema Interface, version 1.
  1703. @since PSI_VERSION_1
  1704. */
  1705. struct PSI_v1
  1706. {
  1707. /** @sa register_mutex_v1_t. */
  1708. register_mutex_v1_t register_mutex;
  1709. /** @sa register_rwlock_v1_t. */
  1710. register_rwlock_v1_t register_rwlock;
  1711. /** @sa register_cond_v1_t. */
  1712. register_cond_v1_t register_cond;
  1713. /** @sa register_thread_v1_t. */
  1714. register_thread_v1_t register_thread;
  1715. /** @sa register_file_v1_t. */
  1716. register_file_v1_t register_file;
  1717. /** @sa register_stage_v1_t. */
  1718. register_stage_v1_t register_stage;
  1719. /** @sa register_statement_v1_t. */
  1720. register_statement_v1_t register_statement;
  1721. /** @sa register_socket_v1_t. */
  1722. register_socket_v1_t register_socket;
  1723. /** @sa init_mutex_v1_t. */
  1724. init_mutex_v1_t init_mutex;
  1725. /** @sa destroy_mutex_v1_t. */
  1726. destroy_mutex_v1_t destroy_mutex;
  1727. /** @sa init_rwlock_v1_t. */
  1728. init_rwlock_v1_t init_rwlock;
  1729. /** @sa destroy_rwlock_v1_t. */
  1730. destroy_rwlock_v1_t destroy_rwlock;
  1731. /** @sa init_cond_v1_t. */
  1732. init_cond_v1_t init_cond;
  1733. /** @sa destroy_cond_v1_t. */
  1734. destroy_cond_v1_t destroy_cond;
  1735. /** @sa init_socket_v1_t. */
  1736. init_socket_v1_t init_socket;
  1737. /** @sa destroy_socket_v1_t. */
  1738. destroy_socket_v1_t destroy_socket;
  1739. /** @sa get_table_share_v1_t. */
  1740. get_table_share_v1_t get_table_share;
  1741. /** @sa release_table_share_v1_t. */
  1742. release_table_share_v1_t release_table_share;
  1743. /** @sa drop_table_share_v1_t. */
  1744. drop_table_share_v1_t drop_table_share;
  1745. /** @sa open_table_v1_t. */
  1746. open_table_v1_t open_table;
  1747. /** @sa unbind_table_v1_t. */
  1748. unbind_table_v1_t unbind_table;
  1749. /** @sa rebind_table_v1_t. */
  1750. rebind_table_v1_t rebind_table;
  1751. /** @sa close_table_v1_t. */
  1752. close_table_v1_t close_table;
  1753. /** @sa create_file_v1_t. */
  1754. create_file_v1_t create_file;
  1755. /** @sa spawn_thread_v1_t. */
  1756. spawn_thread_v1_t spawn_thread;
  1757. /** @sa new_thread_v1_t. */
  1758. new_thread_v1_t new_thread;
  1759. /** @sa set_thread_id_v1_t. */
  1760. set_thread_id_v1_t set_thread_id;
  1761. /** @sa get_thread_v1_t. */
  1762. get_thread_v1_t get_thread;
  1763. /** @sa set_thread_user_v1_t. */
  1764. set_thread_user_v1_t set_thread_user;
  1765. /** @sa set_thread_user_host_v1_t. */
  1766. set_thread_user_host_v1_t set_thread_user_host;
  1767. /** @sa set_thread_db_v1_t. */
  1768. set_thread_db_v1_t set_thread_db;
  1769. /** @sa set_thread_command_v1_t. */
  1770. set_thread_command_v1_t set_thread_command;
  1771. /** @sa set_thread_start_time_v1_t. */
  1772. set_thread_start_time_v1_t set_thread_start_time;
  1773. /** @sa set_thread_state_v1_t. */
  1774. set_thread_state_v1_t set_thread_state;
  1775. /** @sa set_thread_info_v1_t. */
  1776. set_thread_info_v1_t set_thread_info;
  1777. /** @sa set_thread_v1_t. */
  1778. set_thread_v1_t set_thread;
  1779. /** @sa delete_current_thread_v1_t. */
  1780. delete_current_thread_v1_t delete_current_thread;
  1781. /** @sa delete_thread_v1_t. */
  1782. delete_thread_v1_t delete_thread;
  1783. /** @sa get_thread_file_name_locker_v1_t. */
  1784. get_thread_file_name_locker_v1_t get_thread_file_name_locker;
  1785. /** @sa get_thread_file_stream_locker_v1_t. */
  1786. get_thread_file_stream_locker_v1_t get_thread_file_stream_locker;
  1787. /** @sa get_thread_file_descriptor_locker_v1_t. */
  1788. get_thread_file_descriptor_locker_v1_t get_thread_file_descriptor_locker;
  1789. /** @sa unlock_mutex_v1_t. */
  1790. unlock_mutex_v1_t unlock_mutex;
  1791. /** @sa unlock_rwlock_v1_t. */
  1792. unlock_rwlock_v1_t unlock_rwlock;
  1793. /** @sa signal_cond_v1_t. */
  1794. signal_cond_v1_t signal_cond;
  1795. /** @sa broadcast_cond_v1_t. */
  1796. broadcast_cond_v1_t broadcast_cond;
  1797. /** @sa start_idle_wait_v1_t. */
  1798. start_idle_wait_v1_t start_idle_wait;
  1799. /** @sa end_idle_wait_v1_t. */
  1800. end_idle_wait_v1_t end_idle_wait;
  1801. /** @sa start_mutex_wait_v1_t. */
  1802. start_mutex_wait_v1_t start_mutex_wait;
  1803. /** @sa end_mutex_wait_v1_t. */
  1804. end_mutex_wait_v1_t end_mutex_wait;
  1805. /** @sa start_rwlock_rdwait_v1_t. */
  1806. start_rwlock_rdwait_v1_t start_rwlock_rdwait;
  1807. /** @sa end_rwlock_rdwait_v1_t. */
  1808. end_rwlock_rdwait_v1_t end_rwlock_rdwait;
  1809. /** @sa start_rwlock_wrwait_v1_t. */
  1810. start_rwlock_wrwait_v1_t start_rwlock_wrwait;
  1811. /** @sa end_rwlock_wrwait_v1_t. */
  1812. end_rwlock_wrwait_v1_t end_rwlock_wrwait;
  1813. /** @sa start_cond_wait_v1_t. */
  1814. start_cond_wait_v1_t start_cond_wait;
  1815. /** @sa end_cond_wait_v1_t. */
  1816. end_cond_wait_v1_t end_cond_wait;
  1817. /** @sa start_table_io_wait_v1_t. */
  1818. start_table_io_wait_v1_t start_table_io_wait;
  1819. /** @sa end_table_io_wait_v1_t. */
  1820. end_table_io_wait_v1_t end_table_io_wait;
  1821. /** @sa start_table_lock_wait_v1_t. */
  1822. start_table_lock_wait_v1_t start_table_lock_wait;
  1823. /** @sa end_table_lock_wait_v1_t. */
  1824. end_table_lock_wait_v1_t end_table_lock_wait;
  1825. /** @sa start_file_open_wait_v1_t. */
  1826. start_file_open_wait_v1_t start_file_open_wait;
  1827. /** @sa end_file_open_wait_v1_t. */
  1828. end_file_open_wait_v1_t end_file_open_wait;
  1829. /** @sa end_file_open_wait_and_bind_to_descriptor_v1_t. */
  1830. end_file_open_wait_and_bind_to_descriptor_v1_t
  1831. end_file_open_wait_and_bind_to_descriptor;
  1832. /** @sa start_file_wait_v1_t. */
  1833. start_file_wait_v1_t start_file_wait;
  1834. /** @sa end_file_wait_v1_t. */
  1835. end_file_wait_v1_t end_file_wait;
  1836. /** @sa start_file_close_wait_v1_t. */
  1837. start_file_close_wait_v1_t start_file_close_wait;
  1838. /** @sa end_file_close_wait_v1_t. */
  1839. end_file_close_wait_v1_t end_file_close_wait;
  1840. /** @sa start_stage_v1_t. */
  1841. start_stage_v1_t start_stage;
  1842. /** @sa end_stage_v1_t. */
  1843. end_stage_v1_t end_stage;
  1844. /** @sa get_thread_statement_locker_v1_t. */
  1845. get_thread_statement_locker_v1_t get_thread_statement_locker;
  1846. /** @sa refine_statement_v1_t. */
  1847. refine_statement_v1_t refine_statement;
  1848. /** @sa start_statement_v1_t. */
  1849. start_statement_v1_t start_statement;
  1850. /** @sa set_statement_text_v1_t. */
  1851. set_statement_text_v1_t set_statement_text;
  1852. /** @sa set_statement_lock_time_t. */
  1853. set_statement_lock_time_t set_statement_lock_time;
  1854. /** @sa set_statement_rows_sent_t. */
  1855. set_statement_rows_sent_t set_statement_rows_sent;
  1856. /** @sa set_statement_rows_examined_t. */
  1857. set_statement_rows_examined_t set_statement_rows_examined;
  1858. /** @sa inc_statement_created_tmp_disk_tables. */
  1859. inc_statement_created_tmp_disk_tables_t inc_statement_created_tmp_disk_tables;
  1860. /** @sa inc_statement_created_tmp_tables. */
  1861. inc_statement_created_tmp_tables_t inc_statement_created_tmp_tables;
  1862. /** @sa inc_statement_select_full_join. */
  1863. inc_statement_select_full_join_t inc_statement_select_full_join;
  1864. /** @sa inc_statement_select_full_range_join. */
  1865. inc_statement_select_full_range_join_t inc_statement_select_full_range_join;
  1866. /** @sa inc_statement_select_range. */
  1867. inc_statement_select_range_t inc_statement_select_range;
  1868. /** @sa inc_statement_select_range_check. */
  1869. inc_statement_select_range_check_t inc_statement_select_range_check;
  1870. /** @sa inc_statement_select_scan. */
  1871. inc_statement_select_scan_t inc_statement_select_scan;
  1872. /** @sa inc_statement_sort_merge_passes. */
  1873. inc_statement_sort_merge_passes_t inc_statement_sort_merge_passes;
  1874. /** @sa inc_statement_sort_range. */
  1875. inc_statement_sort_range_t inc_statement_sort_range;
  1876. /** @sa inc_statement_sort_rows. */
  1877. inc_statement_sort_rows_t inc_statement_sort_rows;
  1878. /** @sa inc_statement_sort_scan. */
  1879. inc_statement_sort_scan_t inc_statement_sort_scan;
  1880. /** @sa set_statement_no_index_used. */
  1881. set_statement_no_index_used_t set_statement_no_index_used;
  1882. /** @sa set_statement_no_good_index_used. */
  1883. set_statement_no_good_index_used_t set_statement_no_good_index_used;
  1884. /** @sa end_statement_v1_t. */
  1885. end_statement_v1_t end_statement;
  1886. /** @sa start_socket_wait_v1_t. */
  1887. start_socket_wait_v1_t start_socket_wait;
  1888. /** @sa end_socket_wait_v1_t. */
  1889. end_socket_wait_v1_t end_socket_wait;
  1890. /** @sa set_socket_state_v1_t. */
  1891. set_socket_state_v1_t set_socket_state;
  1892. /** @sa set_socket_info_v1_t. */
  1893. set_socket_info_v1_t set_socket_info;
  1894. /** @sa set_socket_thread_owner_v1_t. */
  1895. set_socket_thread_owner_v1_t set_socket_thread_owner;
  1896. /** @sa digest_start_v1_t. */
  1897. digest_start_v1_t digest_start;
  1898. /** @sa digest_end_v1_t. */
  1899. digest_end_v1_t digest_end;
  1900. /** @sa set_thread_connect_attrs_v1_t. */
  1901. set_thread_connect_attrs_v1_t set_thread_connect_attrs;
  1902. };
  1903. /** @} (end of group Group_PSI_v1) */
  1904. #endif /* HAVE_PSI_1 */
  1905. #ifdef USE_PSI_2
  1906. #define HAVE_PSI_2
  1907. #endif
  1908. #ifdef HAVE_PSI_2
  1909. /**
  1910. @defgroup Group_PSI_v2 Application Binary Interface, version 2
  1911. @ingroup Instrumentation_interface
  1912. @{
  1913. */
  1914. /**
  1915. Performance Schema Interface, version 2.
  1916. This is a placeholder, this interface is not defined yet.
  1917. @since PSI_VERSION_2
  1918. */
  1919. struct PSI_v2
  1920. {
  1921. /** Placeholder */
  1922. int placeholder;
  1923. /* ... extended interface ... */
  1924. };
  1925. /** Placeholder */
  1926. struct PSI_mutex_info_v2
  1927. {
  1928. /** Placeholder */
  1929. int placeholder;
  1930. };
  1931. /** Placeholder */
  1932. struct PSI_rwlock_info_v2
  1933. {
  1934. /** Placeholder */
  1935. int placeholder;
  1936. };
  1937. /** Placeholder */
  1938. struct PSI_cond_info_v2
  1939. {
  1940. /** Placeholder */
  1941. int placeholder;
  1942. };
  1943. /** Placeholder */
  1944. struct PSI_thread_info_v2
  1945. {
  1946. /** Placeholder */
  1947. int placeholder;
  1948. };
  1949. /** Placeholder */
  1950. struct PSI_file_info_v2
  1951. {
  1952. /** Placeholder */
  1953. int placeholder;
  1954. };
  1955. /** Placeholder */
  1956. struct PSI_stage_info_v2
  1957. {
  1958. /** Placeholder */
  1959. int placeholder;
  1960. };
  1961. /** Placeholder */
  1962. struct PSI_statement_info_v2
  1963. {
  1964. /** Placeholder */
  1965. int placeholder;
  1966. };
  1967. /** Placeholder */
  1968. struct PSI_idle_locker_state_v2
  1969. {
  1970. /** Placeholder */
  1971. int placeholder;
  1972. };
  1973. /** Placeholder */
  1974. struct PSI_mutex_locker_state_v2
  1975. {
  1976. /** Placeholder */
  1977. int placeholder;
  1978. };
  1979. /** Placeholder */
  1980. struct PSI_rwlock_locker_state_v2
  1981. {
  1982. /** Placeholder */
  1983. int placeholder;
  1984. };
  1985. /** Placeholder */
  1986. struct PSI_cond_locker_state_v2
  1987. {
  1988. /** Placeholder */
  1989. int placeholder;
  1990. };
  1991. /** Placeholder */
  1992. struct PSI_file_locker_state_v2
  1993. {
  1994. /** Placeholder */
  1995. int placeholder;
  1996. };
  1997. /** Placeholder */
  1998. struct PSI_table_locker_state_v2
  1999. {
  2000. /** Placeholder */
  2001. int placeholder;
  2002. };
  2003. /** Placeholder */
  2004. struct PSI_statement_locker_state_v2
  2005. {
  2006. /** Placeholder */
  2007. int placeholder;
  2008. };
  2009. /** Placeholder */
  2010. struct PSI_socket_locker_state_v2
  2011. {
  2012. /** Placeholder */
  2013. int placeholder;
  2014. };
  2015. /** @} (end of group Group_PSI_v2) */
  2016. #endif /* HAVE_PSI_2 */
  2017. /**
  2018. @typedef PSI
  2019. The instrumentation interface for the current version.
  2020. @sa PSI_CURRENT_VERSION
  2021. */
  2022. /**
  2023. @typedef PSI_mutex_info
  2024. The mutex information structure for the current version.
  2025. */
  2026. /**
  2027. @typedef PSI_rwlock_info
  2028. The rwlock information structure for the current version.
  2029. */
  2030. /**
  2031. @typedef PSI_cond_info
  2032. The cond information structure for the current version.
  2033. */
  2034. /**
  2035. @typedef PSI_thread_info
  2036. The thread information structure for the current version.
  2037. */
  2038. /**
  2039. @typedef PSI_file_info
  2040. The file information structure for the current version.
  2041. */
  2042. /* Export the required version */
  2043. #ifdef USE_PSI_1
  2044. typedef struct PSI_v1 PSI;
  2045. typedef struct PSI_mutex_info_v1 PSI_mutex_info;
  2046. typedef struct PSI_rwlock_info_v1 PSI_rwlock_info;
  2047. typedef struct PSI_cond_info_v1 PSI_cond_info;
  2048. typedef struct PSI_thread_info_v1 PSI_thread_info;
  2049. typedef struct PSI_file_info_v1 PSI_file_info;
  2050. typedef struct PSI_stage_info_v1 PSI_stage_info;
  2051. typedef struct PSI_statement_info_v1 PSI_statement_info;
  2052. typedef struct PSI_socket_info_v1 PSI_socket_info;
  2053. typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
  2054. typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state;
  2055. typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state;
  2056. typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state;
  2057. typedef struct PSI_file_locker_state_v1 PSI_file_locker_state;
  2058. typedef struct PSI_table_locker_state_v1 PSI_table_locker_state;
  2059. typedef struct PSI_statement_locker_state_v1 PSI_statement_locker_state;
  2060. typedef struct PSI_socket_locker_state_v1 PSI_socket_locker_state;
  2061. #endif
  2062. #ifdef USE_PSI_2
  2063. typedef struct PSI_v2 PSI;
  2064. typedef struct PSI_mutex_info_v2 PSI_mutex_info;
  2065. typedef struct PSI_rwlock_info_v2 PSI_rwlock_info;
  2066. typedef struct PSI_cond_info_v2 PSI_cond_info;
  2067. typedef struct PSI_thread_info_v2 PSI_thread_info;
  2068. typedef struct PSI_file_info_v2 PSI_file_info;
  2069. typedef struct PSI_stage_info_v2 PSI_stage_info;
  2070. typedef struct PSI_statement_info_v2 PSI_statement_info;
  2071. typedef struct PSI_socket_info_v2 PSI_socket_info;
  2072. typedef struct PSI_idle_locker_state_v2 PSI_idle_locker_state;
  2073. typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state;
  2074. typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state;
  2075. typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state;
  2076. typedef struct PSI_file_locker_state_v2 PSI_file_locker_state;
  2077. typedef struct PSI_table_locker_state_v2 PSI_table_locker_state;
  2078. typedef struct PSI_statement_locker_state_v2 PSI_statement_locker_state;
  2079. typedef struct PSI_socket_locker_state_v2 PSI_socket_locker_state;
  2080. #endif
  2081. #else /* HAVE_PSI_INTERFACE */
  2082. /**
  2083. Dummy structure, used to declare PSI_server when no instrumentation
  2084. is available.
  2085. The content does not matter, since PSI_server will be NULL.
  2086. */
  2087. struct PSI_none
  2088. {
  2089. int opaque;
  2090. };
  2091. typedef struct PSI_none PSI;
  2092. /**
  2093. Stage instrument information.
  2094. @since PSI_VERSION_1
  2095. This structure is used to register an instrumented stage.
  2096. */
  2097. struct PSI_stage_info_none
  2098. {
  2099. /** Unused stage key. */
  2100. unsigned int m_key;
  2101. /** The name of the stage instrument. */
  2102. const char *m_name;
  2103. /** Unused stage flags. */
  2104. int m_flags;
  2105. };
  2106. /**
  2107. The stage instrumentation has to co exist with the legacy
  2108. THD::set_proc_info instrumentation.
  2109. To avoid duplication of the instrumentation in the server,
  2110. the common PSI_stage_info structure is used,
  2111. so we export it here, even when not building
  2112. with HAVE_PSI_INTERFACE.
  2113. */
  2114. typedef struct PSI_stage_info_none PSI_stage_info;
  2115. #endif /* HAVE_PSI_INTERFACE */
  2116. extern MYSQL_PLUGIN_IMPORT PSI *PSI_server;
  2117. /*
  2118. Allow to override PSI_XXX_CALL at compile time
  2119. with more efficient implementations, if available.
  2120. If nothing better is available,
  2121. make a dynamic call using the PSI_server function pointer.
  2122. */
  2123. #ifndef PSI_MUTEX_CALL
  2124. #define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
  2125. #endif
  2126. #ifndef PSI_RWLOCK_CALL
  2127. #define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
  2128. #endif
  2129. #ifndef PSI_COND_CALL
  2130. #define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
  2131. #endif
  2132. #ifndef PSI_THREAD_CALL
  2133. #define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
  2134. #endif
  2135. #ifndef PSI_FILE_CALL
  2136. #define PSI_FILE_CALL(M) PSI_DYNAMIC_CALL(M)
  2137. #endif
  2138. #ifndef PSI_SOCKET_CALL
  2139. #define PSI_SOCKET_CALL(M) PSI_DYNAMIC_CALL(M)
  2140. #endif
  2141. #ifndef PSI_STAGE_CALL
  2142. #define PSI_STAGE_CALL(M) PSI_DYNAMIC_CALL(M)
  2143. #endif
  2144. #ifndef PSI_STATEMENT_CALL
  2145. #define PSI_STATEMENT_CALL(M) PSI_DYNAMIC_CALL(M)
  2146. #endif
  2147. #ifndef PSI_DIGEST_CALL
  2148. #define PSI_DIGEST_CALL(M) PSI_DYNAMIC_CALL(M)
  2149. #endif
  2150. #ifndef PSI_TABLE_CALL
  2151. #define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
  2152. #endif
  2153. #ifndef PSI_IDLE_CALL
  2154. #define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
  2155. #endif
  2156. #define PSI_DYNAMIC_CALL(M) PSI_server->M
  2157. /** @} */
  2158. C_MODE_END
  2159. #endif /* MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H */