pgconf asia-201612203-pg reversi
TRANSCRIPT
PGConf.ASIA Lightning Talk(2016-12-03)
pg_reversiぬこ@横浜 (@nuko_yokohama)
2
Self-Introduction
Search with the word "PostgreSQL Ramen".
I'm "nuko_yokohama".I am aiming at PostgreSQL entertainer.
3
The theme about today.
4
Sorry, Useless knowledge
5
Solutions for "Solitaire
employees"
6
pg_reversi
7
Reversi by PostgreSQL
8
pg_reversi SQL Functions.
black(x, y)white(x,y)
black_pass()white_pass()
get_turn_boad_status()
9
Implemented by Implemented by SQL/plpgsql.SQL/plpgsql.
Because, I do not want to Because, I do not want to implemented by implemented by
C language!C language!絶対に C言語で書きたくないでござる!
10
Viewer is implemented psql
script file.(Used PostgreSQL 9.6
feature “\crosstabview”)
11
Viewer script file.SELECT get_turn_boad_status() AS status;\o /dev/nullSELECT x AS " ", y, CASE WHEN status = 1 THEN '●' WHEN status = -1 THEN '○' ELSE ' ' END AS statusFROM boad ORDER BY x;\o\crosstabview " " y status y
Point. SELECT result output to /dev/null
12
pg_reversi image
13
pg_reversiDemonstration
14
Able to play Reversi with psql!
15
Up to this point is the explanation of the "Standard edition".
16
pg_reversiEnterprise Edition
17
FeaturesBy emit_log_hook, to conceal the SQL
log from pg_reversi application.static voidpg_reversi_emit_log_hook(ErrorData *data) { const char* appname = application_name;
if (appname == NULL || *appname == '\0') { /* applicatoin_name is no set */ return ; }
if (!strcmp(appname, "pg_reversi")) { /* When application_name is pg_reversi, output to the server log is suppressed. */ data->output_to_server = false; } return ;}
18
Setting the pg_reversi to PostgreSQL setting "preload_shared_libraries'.
preload_shared_libraries = 'pg_reversi'
In psql not, use the "pg_reversi" utility (psql copy).
$ pg_reversi -U postgres pg_reversi
19
Show “application_name”$ psql -U postgres pg_reversi -c "SHOW application_name" application_name ------------------ psql(1 row)
$ pg_reversi -U postgres pg_reversi -c "SHOW application_name" application_name ------------------ pg_reversi(1 row)
20
Enterprise EditionDemonstration
21
Standard Edition
Since SQL is output to the Since SQL is output to the server log, the DBA will server log, the DBA will
check it!check it!↓↓
My boss gets angry!My boss gets angry!
22
Enterprise EditionSQL is not logged.SQL is not logged.
↓↓DBA and Boss also does DBA and Boss also does
not notice. not notice. Everyone is happy.Everyone is happy.
Win-Win!Win-Win!
23
Exactly, feature for Exactly, feature for "Lazy employee in "Lazy employee in
Enterprise company".Enterprise company".
24
Conclusion
25
Reversi can also be played.
(It can not be used with pgAdmin4!)
26
Only on the Only on the PostgreSQL….PostgreSQL….
27
End.