Skip to content

Instantly share code, notes, and snippets.

View kshvakov's full-sized avatar
💭
I may be slow to respond.

Kirill Shvakov kshvakov

💭
I may be slow to respond.
View GitHub Profile
@kshvakov
kshvakov / cpp_stm_free_tutorial.md
Created June 25, 2018 18:45 — forked from graninas/cpp_stm_free_tutorial.md
Software Transactional Memory in C++: Pure Functional Approach (tutorial)

Software Transactional Memory in C++: pure functional approach (Tutorial)

In this article I’ll tell you about my pure functional library for Software Transactional Memory (STM) that I’ve built in C++. I adopted some advanced functional programming concepts that make it composable and convenient to use. Its implementation is rather small and robust, which differentiates the library from competitors. Let’s discuss what STM is and how to use it.

Links

create or replace function scheduler.run_tasks() returns void as $$
declare
_function_name varchar;
_sqlstate text;
_message text;
_exception_detail text;
_exception_hint text;
_exception_context text;
_run_tasks_counter bigint;
_start_time timestamp with time zone;
@kshvakov
kshvakov / install.md
Created May 30, 2016 18:59
Установка Postgres-CI

Требования

Для работы необходим PostgreSQL-server 9.5 и, более-менее "свежий", Docker

Настройка сервера баз данных

Т.к. app-server и worker работают в docker-контейнерах, то следует прописать его (докера) сеть в pg_hba.conf

host    all             all  172.17.0.0/24 password
$ time ./try_advisory_lock
Waiting
[5] Done, processed 1274 rows.
[7] Done, processed 1236 rows.
[2] Done, processed 1252 rows.
[4] Done, processed 1237 rows.
[8] Done, processed 1257 rows.
[6] Done, processed 1257 rows.
[3] Done, processed 1244 rows.
[1] Done, processed 1243 rows.
do $$
declare
_rawjson json;
_item record;
_id int;
_param text;
begin
for _rawjson in select * from json_array_elements('[{"id" : 42, "params" : ["bad", "sad"] }]'::json) loop
_item = (select j from json_to_record(_rawjson) AS j (
id int,
@kshvakov
kshvakov / pg_basebackup.patch
Created March 24, 2016 09:45
Backport pg_basebackup --slot option from 9.6 to 9.5
--- src/bin/pg_basebackup/pg_basebackup_origin.c 2016-03-24 12:42:30.312362751 +0300
+++ src/bin/pg_basebackup/pg_basebackup.c 2016-03-24 09:45:40.804376436 +0300
@@ -239,6 +239,7 @@
" (in kB/s, or use suffix \"k\" or \"M\")\n"));
printf(_(" -R, --write-recovery-conf\n"
" write recovery.conf after backup\n"));
+ printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
printf(_(" -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
" relocate tablespace in OLDDIR to NEWDIR\n"));
printf(_(" -x, --xlog include required WAL files in backup (fetch mode)\n"));