Skip to content

Instantly share code, notes, and snippets.

Craig Ringer ringerc

Block or report user

Report or block ringerc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c8d8e31a1dcb55e19f56269954eabdf0
BEGIN;
SET LOCAL bdr.skip_ddl_locking=on;
SET LOCAL bdr.skip_ddl_replication=on;
CREATE OR REPLACE FUNCTION public.simple_log_row()
RETURNS trigger LANGUAGE plpgsql
SET search_path = 'pg_catalog'
AS $$
BEGIN
@ringerc
ringerc / gist:d4a8fe97f5fd332d8b883d596d61e257
Created Aug 11, 2017
Failover slots with streaming rep proto
View gist:d4a8fe97f5fd332d8b883d596d61e257
Phys rep Phys rep
using phys using
slot "B" phys slot "C"
+-------+ +--------+ +-------+
T | A <^--------+ B <---------+ C |
I | | | | | |
M +-------+ +--------+ +-------+
E | | |
| | | |CREATEs
| | | |logical slot X
View spk-build-fixes.patch
From a7a69e8dc87504163222ba2570bda6920114a5c3 Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@redacted>
Date: Sun, 26 Jun 2016 19:58:48 +0800
Subject: [PATCH] SPK utils build fixes
---
.gitignore | 4 ++++
src/SPK/File_IO.cpp | 2 ++
src/SPK/Makefile | 9 +++++----
src/SPK/String.h | 3 +++
View pg_elephant.c
#include "postgres.h"
#include "fmgr.h"
PG_MODULE_MAGIC;
PGDLLEXPORT Datum pg_elephant(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(pg_elephant);
static const char * const elephant =
"............MMMMMMMMMMM8..........MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ...........\n"
@ringerc
ringerc / schema.sql
Created Feb 8, 2016
Demo Python script for replicating to Solr
View schema.sql
CREATE TABLE book_lines
(
id serial primary key,
book_line text not null
);
View jpegify.py
#!python
# coding=utf-8
#
# usage: python jpegify.py *.pdf
#
# Written for Python 2 or python 3
from __future__ import print_function
import os
@ringerc
ringerc / disconnect.py
Created Oct 3, 2015
Compare disconnect/reconnect and pooled times
View disconnect.py
#!/usr/bin/env python
#
# Disconnect/reconnect each query
#
# Takes 0.45s to run here
#
import time
import psycopg2
start_t = time.time()
View pg_restore_views.diff
From 0319a7ecbab5c1e85e300d93f674087786be144a Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Wed, 1 Apr 2015 10:46:29 +0800
Subject: [PATCH] pg_restore -t should select views, matviews, and foreign
tables
Currently pg_restore's '-t' option selects only tables, not other
relations. It should be able to match anything that behaves like
a relation in the relation namespace, anything that's interchangable
with a table, including:
@ringerc
ringerc / simple_spi_boilerplate.c
Last active Aug 29, 2015
SPI bgworker boilerplate
View simple_spi_boilerplate.c
/* Simpler version that assumes there is no active tx or snapshot and SPI isn't connected yet */
const char * some_sql = "SELECT 1;";
/* setup */
Assert(!IsTransactionState());
StartTransactionCommand();
SetCurrentStatementStartTimestamp();
SPI_connect();
PushActiveSnapshot(GetTransactionSnapshot());
View testcase.sql
CREATE SCHEMA myschema;
CREATE TABLE myschema.zzafter(id integer);
CREATE OR REPLACE FUNCTION myschema.aabefore()
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
somefield myschema.zzafter.id%TYPE;
You can’t perform that action at this time.