Skip to content

Instantly share code, notes, and snippets.

View anarazel's full-sized avatar

Andres Freund anarazel

View GitHub Profile
DROP FUNCTION IF EXISTS easydb_count__insert_trigger() CASCADE;
DROP FUNCTION IF EXISTS easydb_count__delete_trigger() CASCADE;
DROP FUNCTION IF EXISTS easydb_count__truncate_trigger() CASCADE;
DROP FUNCTION IF EXISTS easydb_get_count(namxe);
DROP FUNCTION IF EXISTS easydb_create_count_trigger(name);
DROP FUNCTION IF EXISTS easydb_remove_count_trigger(name);
DROP TABLE IF EXISTS eadb_table_stats CASCADE;
EXPLAIN ANALYSE
SELECT COUNT(*)
FROM aps_application_instances ai
JOIN aps_service_instances si ON (ai.app_instance_id = si.app_instance_id AND si.is_basic = 'y' )
LEFT JOIN (
aps_packages_upgrade_relations pur
JOIN aps_packages pu ON (pur.app_id = pu.app_id AND pur.tgt_ver = pu.app_ver AND pu.disabled = 'n' )
) ON (ai.app_id = pur.app_id AND ai.app_ver = pur.src_ver)
LEFT JOIN aps_service_instance_operation_requests sior ON (sior.service_instance_id = si.service_instance_id AND sior.operation = 'u')
JOIN aps_external_application_instances hai ON (ai.app_instance_id = hai.app_instance_id)
postgres=# CREATE TEXT SEARCH CONFIGURATION nofile ( COPY = simple);
CREATE TEXT SEARCH CONFIGURATION
Time: 210.210 ms
postgres=# ALTER TEXT SEARCH CONFIGURATION nofile DROP MAPPING FOR file;
ALTER TEXT SEARCH CONFIGURATION
Time: 2.649 ms
postgres=# SELECT * FROM ts_debug('simple', 'term1/term2');
alias | description | token | dictionaries | dictionary | lexemes
-------+-------------------+-------------+--------------+------------+---------------
file | File or path name | term1/term2 | {simple} | simple | {term1/term2}
SELECT pg_current_xlog_insert_location();
pg_current_xlog_insert_location
---------------------------------
0/18C01E8
CHECKPOINT;
CREATE TABLE replication_example(id SERIAL PRIMARY KEY, somedata int, text varchar(120));
begin;
INSERT INTO replication_example(somedata, text) VALUES (1, 1);
INSERT INTO replication_example(somedata, text) VALUES (1, 2);
Session 1:
DROP TABLE IF EXISTS test_drop_concurrently ;
CREATE TABLE test_drop_concurrently(id serial primary key, data int);
INSERT INTO test_drop_concurrently(data) SELECT * FROM generate_series(1,
100);
CREATE INDEX test_drop_concurrently_data ON test_drop_concurrently(data);
SET enable_seqscan = false;
diff --git a/handler.c b/handler.c
index 13c89ec..3f21e79 100644
--- a/handler.c
+++ b/handler.c
@@ -1236,7 +1236,7 @@ static int autoview_handler (BODY *a, STATE *s)
int rc = 0;
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
- rfc1524_mailcap_lookup (a, type, entry, M_AUTOVIEW);
+ rfc1524_mailcap_lookup (a, type, entry, s->flags & M_REPLYING ? M_COMPOSE : M_AUTOVIEW);
#ifdef HAVE__BUILTIN_BSWAP64
#define BSWAP64(x) __builtin_bswap64(x)
#else
#define BSWAP64(x) ((((x) << 56) & UINT64CONST(0xff00000000000000)) | \
(((x) << 40) & UINT64CONST(0x00ff000000000000)) | \
(((x) << 24) & UINT64CONST(0x0000ff0000000000)) | \
(((x) << 8) & UINT64CONST(0x000000ff00000000)) | \
(((x) >> 8) & UINT64CONST(0x00000000ff000000)) | \
(((x) >> 24) & UINT64CONST(0x0000000000ff0000)) | \
(((x) >> 40) & UINT64CONST(0x000000000000ff00)) | \
@anarazel
anarazel / gist:af10ee63fa508a902b2c22c67c488930
Created September 4, 2018 21:16
__builtin_isinf is busted
andres@alap4:~/src/postgresql$ clang-7 -march=i386 -O2 -m32 ~/tmp/flttst.c -o ~/tmp/flttst && ~/tmp/flttst
r1 = 1, r2 = 0
andres@alap4:~/src/postgresql$ clang-7 -march=nehalem -O2 -m32 ~/tmp/flttst.c -o ~/tmp/flttst && ~/tmp/flttst
r1 = 1, r2 = 1
andres@alap4:~/src/postgresql$ cat ~/tmp/flttst.c
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
movb $0, (%rbx)
movl (%rax,%rcx), %esi
movq %rsi, (%r10)
movb $0, 1(%rbx)
movl 4(%rax,%rcx), %esi
movq %rsi, 8(%r10)
movb $0, 2(%rbx)
movl 8(%rax,%rcx), %esi
movq %rsi, 16(%r10)
movb $0, 3(%rbx)
$ cat /tmp/combine.ll
; ModuleID = '<stdin>'
source_filename = "pg"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
define void @evalexpr_0_0(i8* align 8 noalias, i32* align 8 noalias) {
entry:
%a01 = getelementptr i8, i8* %0, i16 0