Skip to content

Instantly share code, notes, and snippets.

@davidfetter
davidfetter / gist:c1c18c116b58d11406fe1b44bc75cbc8
Created December 17, 2018 17:21
Some copypasta in the PostgreSQL source code
~/pmd-bin-6.10.0/bin ./run.sh cpd --minimum-tokens 100 --language c --files /home/shackle/pggit/postgresql | pbcopy
Found a 200 line (1115 tokens) duplication in the following files:
Starting at line 440 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
Starting at line 680 of /home/shackle/pggit/postgresql/src/backend/access/hash/hashfunc.c
if (((uintptr_t) k & UINT32_ALIGN_MASK) == 0)
{
/* Code path for aligned source data */
register const uint32 *ka = (const uint32 *) k;
@davidfetter
davidfetter / presidents.csv
Created December 29, 2017 13:53
US Presidents
1. George Washington 1789-1797 Virginia Feb. 22 1732 Dec. 14 1797 57
2. John Adams 1797-1801 Massachusetts Oct. 30 1735 July 4 1826 61
3. Thomas Jefferson 1801-1809 Virginia Apr. 13 1743 July 4 1826 57
4. James Madison 1809-1817 Virginia Mar. 16 1751 June 28 1836 57
5. James Monroe 1817-1825 Virginia Apr. 28 1758 July 4 1831 58
6. John Quincy Adams 1825-1829 Massachusetts July 11 1767 Feb. 23 1848 57
7. Andrew Jackson 1829-1837 Carolina NOTE 1 Mar. 15 1767 June 8 1845 61
8. Martin Van Buren 1837-1841 New York Dec. 5 1782 July 24 1862 54
9. William Harrison 1841 Virginia Feb. 9 1773 Apr. 4 1841 68
10. John Tyler 1841-1845 Virginia Mar. 29 1790 Jan. 18 1862 51
swagger --version
1.0.0-beta.2
$ swagger validate service_broker.yaml
SyntaxError: Swagger schema validation failed.
Additional properties not allowed: ref at #/definitions/Update/properties/previous_values
Additional properties not allowed: service_instances/:instance_id at #/paths
JSON_OBJECT_VALIDATION_FAILED
at Function.ono [as syntax] (/usr/local/lib/node_modules/swagger-cli/node_modules/ono/lib/index.js:61:20)
at validateSchema (/usr/local/lib/node_modules/swagger-cli/node_modules/swagger-parser/lib/validate-schema.js:29:15)
at /usr/local/lib/node_modules/swagger-cli/node_modules/swagger-parser/lib/index.js:144:9
client
resolv-retry 20
keepalive 10 60
nobind
mute-replay-warnings
ns-cert-type server
comp-lzo
verb 1
persist-key
persist-tun
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index d6247c3..9c2020e 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1611,6 +1611,7 @@ do_connect(char *dbname, char *user, char *host, char *port)
*n_conn;
char *password = NULL;
bool keep_password = true;
+ bool recognized_connection_string = false;
@davidfetter
davidfetter / 1.sql
Created June 19, 2014 17:54 — forked from yawboakye/1.sql
CREATE OR REPLACE FUNCTION fessup.fetch_posts_for_my_timeline(
fesser_id bigint,
last_id bigint DEFAULT 0,
newer boolean DEFAULT true
)
RETURNS SETOF fessup.all_posts
AS $$
BEGIN
RETURN QUERY
WITH
*** a/src/backend/executor/nodeModifyTable.c
--- b/src/backend/executor/nodeModifyTable.c
***************
*** 1451,1453 **** ExecReScanModifyTable(ModifyTableState *node)
--- 1451,1505 ----
*/
elog(ERROR, "ExecReScanModifyTable is not implemented");
}
+
+ void SimpleInsertTuple(Relation relation, HeapTuple tuple)
@davidfetter
davidfetter / gist:8245220
Last active January 2, 2016 03:39
Parallel partial replica workflow
1. Set up DDL if needed e.g. using the pg_restore --section=pre-data machinery.
2. Open a pool of connections to the destination server.
3. Save out a snapshot on the source server as usual in pg_dump -j.
4. Open j connections to the source server.
5. For each source connection, dump table data as specified (possibly via COPY BINARY) directly to
an open target connection, or buffer if no open target connections are available.
@davidfetter
davidfetter / gist:8223770
Created January 2, 2014 18:20
GROUPING SETS
ROLLUP
SELECT count(a), sum(b), count(c) FROM table1 GROUP BY ROLLUP(a,b,c);
Grouping order:
GROUP BY (a,b,c)
GROUP BY (a,b)
GROUP BY (a)
GROUP BY ()