xref: /openbmc/linux/tools/perf/Documentation/db-export.txt (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1*1159faceSAdrian HunterDatabase Export
2*1159faceSAdrian Hunter===============
3*1159faceSAdrian Hunter
4*1159faceSAdrian Hunterperf tool's python scripting engine:
5*1159faceSAdrian Hunter
6*1159faceSAdrian Hunter	tools/perf/util/scripting-engines/trace-event-python.c
7*1159faceSAdrian Hunter
8*1159faceSAdrian Huntersupports scripts:
9*1159faceSAdrian Hunter
10*1159faceSAdrian Hunter	tools/perf/scripts/python/export-to-sqlite.py
11*1159faceSAdrian Hunter	tools/perf/scripts/python/export-to-postgresql.py
12*1159faceSAdrian Hunter
13*1159faceSAdrian Hunterwhich export data to a SQLite3 or PostgreSQL database.
14*1159faceSAdrian Hunter
15*1159faceSAdrian HunterThe export process provides records with unique sequential ids which allows the
16*1159faceSAdrian Hunterdata to be imported directly to a database and provides the relationships
17*1159faceSAdrian Hunterbetween tables.
18*1159faceSAdrian Hunter
19*1159faceSAdrian HunterOver time it is possible to continue to expand the export while maintaining
20*1159faceSAdrian Hunterbackward and forward compatibility, by following some simple rules:
21*1159faceSAdrian Hunter
22*1159faceSAdrian Hunter1. Because of the nature of SQL, existing tables and columns can continue to be
23*1159faceSAdrian Hunterused so long as the names and meanings (and to some extent data types) remain
24*1159faceSAdrian Hunterthe same.
25*1159faceSAdrian Hunter
26*1159faceSAdrian Hunter2. New tables and columns can be added, without affecting existing SQL queries,
27*1159faceSAdrian Hunterso long as the new names are unique.
28*1159faceSAdrian Hunter
29*1159faceSAdrian Hunter3. Scripts that use a database (e.g. exported-sql-viewer.py) can maintain
30*1159faceSAdrian Hunterbackward compatibility by testing for the presence of new tables and columns
31*1159faceSAdrian Hunterbefore using them. e.g. function IsSelectable() in exported-sql-viewer.py
32*1159faceSAdrian Hunter
33*1159faceSAdrian Hunter4. The export scripts themselves maintain forward compatibility (i.e. an existing
34*1159faceSAdrian Hunterscript will continue to work with new versions of perf) by accepting a variable
35*1159faceSAdrian Hunternumber of arguments (e.g. def call_return_table(*x)) i.e. perf can pass more
36*1159faceSAdrian Hunterarguments which old scripts will ignore.
37*1159faceSAdrian Hunter
38*1159faceSAdrian Hunter5. The scripting engine tests for the existence of script handler functions
39*1159faceSAdrian Hunterbefore calling them.  The scripting engine can also test for the support of new
40*1159faceSAdrian Hunteror optional features by checking for the existence and value of script global
41*1159faceSAdrian Huntervariables.
42