postgresql

postgreSQL Fibonacci Sequence - Query has no destination for result data

蹲街弑〆低调 提交于 2021-02-08 06:23:07
问题 So I wrote a Fibonacci sequence function like this: CREATE OR REPLACE FUNCTION fibonacci (lastN INTEGER) RETURNS int AS $$ BEGIN WITH RECURSIVE t(a, b) AS ( VALUES(0,1) UNION ALL SELECT GREATEST(a, b), a + b AS a from t WHERE b < $1 ) SELECT a FROM t; END; $$ LANGUAGE plpgsql; But when I called: SELECT * FROM fibonacci(20); the console shows: ERROR: query has no destination for result data HINT: If you want to discard the results of a SELECT, use PERFORM instead. CONTEXT: PL/pgSQL function

Unknown auth message code 1397113172 when connect to Heroku postgres

六眼飞鱼酱① 提交于 2021-02-08 06:17:35
问题 Thanks reading my issue. Currently, I am using postgres (hobby-dev) on Heroku and facing this issue every time that I connect to the database. error: Uncaught (in promise) Error: Unknown auth message code 1397113172 throw new Error(`Unknown auth message code ${code}`); ^ at Connection.handleAuth (connection.ts:197:15) at Connection.startup (connection.ts:155:16) at async Pool._createConnection (pool.ts:32:5) at async pool.ts:61:7 at async Promise.all (index 0) at async Pool._startup (pool.ts

Is there a safe way to modify the table pg_constraint so as no more checking be done ( temporarily )?

旧巷老猫 提交于 2021-02-08 06:11:56
问题 So as to restore a database from a dump, I want to temporarily disable all the constraints in all the tables of my database, which content I have emptied ( postregsql 8.3). Is there a safe way to modify a field in the pg_constraint table that easily allows to bypass the constraint ? I don't think so when I look at the documentation pg_constraint. Is it possible to drop the pg_constraint table content, then refill it again ? If not, how people do restore/copy databases with tables that are

Is there a safe way to modify the table pg_constraint so as no more checking be done ( temporarily )?

橙三吉。 提交于 2021-02-08 06:11:44
问题 So as to restore a database from a dump, I want to temporarily disable all the constraints in all the tables of my database, which content I have emptied ( postregsql 8.3). Is there a safe way to modify a field in the pg_constraint table that easily allows to bypass the constraint ? I don't think so when I look at the documentation pg_constraint. Is it possible to drop the pg_constraint table content, then refill it again ? If not, how people do restore/copy databases with tables that are

How to prevent SQL Injection in PostgreSQL JSON/JSONB field?

白昼怎懂夜的黑 提交于 2021-02-08 05:49:13
问题 How can I prevent SQL injection attacks in Go while using "database/sql"? This solves the single value field problem because you can remove the quotes, but I can't do that filtering a JSON/JSONB field, like in the following because the $1 is considered a string: `SELECT * FROM foo WHERE bar @> '{"baz": "$1"}'` The following works but it's prone to SQL Injection: `SELECT * FROM foo WHERE bar @> '{"baz": "` + "qux" + `"}'` How do I solve this? EDITED after @mkopriva's comment: How would I build

multi thread python psycopg2

僤鯓⒐⒋嵵緔 提交于 2021-02-08 05:46:40
问题 I'm using multi thread inside my program in python. I've got 3 queues. In one of them I'm inserting data to postgres database. But before, I need to check if in the database already exists row with specific domain name. So I've got: class AnotherThread(threading.Thread): def __init__(self, another_queue): threading.Thread.__init__(self) self.another_queue = another_queue def run(self): while True: chunk = self.another_queue.get() if chunk is not '': dane = chunk[0].split(',',2) cur.execute(

Convert Oracle stored procedure using REF_CURSOR and package global variable to Postgresql or MySQL

我是研究僧i 提交于 2021-02-08 05:46:15
问题 This package uses two unique features of Oracle, REF_CURSOR and a package global variable. I would like to port the functionality from Oracle to Postgresql or MySQL. PACKAGE tox IS /*=======================*/ g_spool_key spool.key%TYPE := NULL; TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; /*=======================*/ PROCEDURE begin_spool; /*=======================*/ PROCEDURE into_spool ( in_txt IN spool.txt%TYPE ); /*=======================*/ PROCEDURE reset_spool; /*====================

Simplest way to split human name in postgres?

六眼飞鱼酱① 提交于 2021-02-08 05:42:27
问题 Consider a table with full human names: create table names (full_name varchar not null); insert into names (full_name) values ('Jane Marie Doe'), ('John Doe'); In postgres, what is the simplest (most readable) way to split the names into first and last? first_name | last_name ------------+----------- Jane Marie | Doe John | Doe (2 rows) This is what I came up with, but it seems really complicated. Surely there's a simpler way? select array_to_string(ary[1:len - 1], ' ') as first_name, ary[len

Simplest way to split human name in postgres?

谁说胖子不能爱 提交于 2021-02-08 05:42:10
问题 Consider a table with full human names: create table names (full_name varchar not null); insert into names (full_name) values ('Jane Marie Doe'), ('John Doe'); In postgres, what is the simplest (most readable) way to split the names into first and last? first_name | last_name ------------+----------- Jane Marie | Doe John | Doe (2 rows) This is what I came up with, but it seems really complicated. Surely there's a simpler way? select array_to_string(ary[1:len - 1], ' ') as first_name, ary[len

IntelliJ IDEA 安装、注册码激活

我怕爱的太早我们不能终老 提交于 2021-02-08 05:29:06
IntelliJ IDEA 安装、注册码激活 一、安装 1、下载IDEA 2、双击.exe文件,显示如图,点击next 3、选择安装位置,点击next 4、勾选相应操作系统位数、安装插件,点击next 5、接下来就是选择我们的菜单,然后点击install安装就会进入安装过程 6、安装完成后,会出现下图finish结束按钮,上面的选项是问我们是否现在打开IDEA 注: JDK安装步骤参考如下网址: https://www.cnblogs.com/Michelle20180227/p/10564215.html 二、激活 方法一:使用激活服务器激活方法 步骤 1、打开注册/激活窗口; 2、选择 License server; 3、填入上述其中一个网址(如:http://idea .java .sx ); 4、点击Activate即可完美激活! 方法二:注册码激活方法(建议用这种) 1、进入hosts文件中:C:\Windows\System32\drivers\etc\hosts 2、将“0.0.0.0 account.jetbrains.com”添加到hosts文件中 注意:添加只有重新打开hosts文件进行确认之后在进行下一步操作。 修改成功后如图所示: 注:将这条数据加入之后会提示保存,然后确认之后,重新打开hosts文件确认是否添加成功,有时候会提示确认两次。 4