Skip to content

Instantly share code, notes, and snippets.

@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:
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 [, ...] ]
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;
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]
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]
#include "postgres.h"
#include "fmgr.h"
#include "utils/guc.h"
PG_MODULE_MAGIC;
void _PG_init(void);
function dcopy(orig_t)
if type(orig_t) ~= "table" then return orig_t end
--[[
Recurse with memoization; t is always a table, if it's a table
previously seen then return the memoized copy, otherwise make
a new empty table and copy
--]]
local memot = {}
local function dcopy_rec(t)
local nt = memot[t]
--- src/lua.c.orig 2018-07-19 19:12:54 UTC
+++ src/lua.c
@@ -73,6 +73,9 @@ static void print_usage (const char *bad
" -l name require library 'name' into global 'name'\n"
" -v show version information\n"
" -E ignore environment variables\n"
+#if defined(LUA_USE_READLINE_DL)
+ " -N disable command-line editing\n"
+#endif
" -- stop handling options\n"
-- do this stuff as postgres
\c - postgres
-- this role will own all the objects
create role appowner;
create schema app authorization appowner;
-- this is the admin group, which grants the admins the ability to
-- adopt the owner role for admin tasks. The noinherit means that the
-- admins don't get any other permissions from the owner.
-- this role will own all the objects
create role appowner;
create schema app authorization appowner;
-- this is the admin group, which grants the admins the ability to
-- adopt the owner role for admin tasks. The noinherit means that the
-- admins don't get any other permissions from the owner.
create role appadmin noinherit in role appowner;