Skip to content

Instantly share code, notes, and snippets.

#include "postgres.h"
#include "fmgr.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
void _PG_init(void);
select * from yourtable t
where encode(convert_to(t::text,'SQL_ASCII'),'hex')
!~ '(?x)
^(?:(?:[0-7][0-9a-f])
|(?:(?:c[2-9a-f]|d[0-9a-f])
|e0[ab][0-9a-f]
|ed[89][0-9a-f]
|(?:(?:e[1-9abcef])
|f0[9ab][0-9a-f]
|f[1-3][89ab][0-9a-f]
mcp: @ @mcp
.fnstart
@ BB#0:
.save {r4, r5, r6, lr}
push {r4, r5, r6, lr}
mov r2, r1
ldrb r12, [r2, #4]!
ldrb lr, [r1]
ldrb r6, [r2, #2]
ldrb r2, [r2, #3]
create table mydata_real (id serial, date date, value text);
create table mydata_real_y2015 (check (date >= '2015-01-01' and date < '2016-01-01')) inherits (mydata_real);
create table mydata_real_y2016 (check (date >= '2016-01-01' and date < '2017-01-01')) inherits (mydata_real);
create function mydata_nope() returns trigger language plpgsql
as $f$ begin raise exception 'insert on wrong table'; return NULL; end; $f$;
create trigger mydata_nope before insert on mydata_real execute procedure mydata_nope();
create view mydata as select * from mydata_real;
postgres=# \h select
Command: SELECT
Description: retrieve rows from a table or view
Syntax:
[ WITH [ RECURSIVE ] with_query [, ...] ]
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
* | expression [ [ AS ] output_name ] [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition ]
[ GROUP BY expression [, ...] ]
@RhodiumToad
RhodiumToad / gist:5901567
Created July 1, 2013 14:56
suggested fix for boolean selectivity
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index da66f34..4e8f3f2 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -1549,11 +1549,17 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg,
selec = 1.0 - freq_null;
break;
case IS_TRUE:
- case IS_NOT_TRUE:
case IS_FALSE: