Kim Alvefur
037c70246d
util.sql: Don't send SQLCipher key to Postgres or MySQL (thanks gllmhyt)
...
This was copied from util.sqlite3 which only deals with SQLite3, but
here Postgres or MySQL are also possibilities, which wouldn't support
this.
2025-02-16 11:52:07 +01:00
Kim Alvefur
654edd37bb
util.sql: SQLCipher support
...
This enables use of encrypted databases if LuaDBI or LuaSQLite3 has been
linked against SQLCipher. Using `LD_PRELOAD` may work as well.
Requires SQLCipher >= 4.0.0 due to the use of UPSERT
2025-01-23 16:38:56 +01:00
Kim Alvefur
6aa08d7c58
util.sql: Remove unused String() and Integer() functions
...
According to MattJ, leftovers from an earlier vision for util.sql
2023-07-22 14:55:27 +02:00
Kim Alvefur
43531740f9
util: Prefix module imports with prosody namespace
2023-03-17 16:23:16 +01:00
Kim Alvefur
0147b972e0
mod_storage_sql: Record connection to database as module status
...
Allows retrieving this in e.g. a health reporting module
Thanks pfak
2023-01-30 00:38:26 +01:00
Kim Alvefur
b0361006e1
util.sql: Handle failure to detect connection encoding
...
Silences a luacheck warning about an unused variable
2019-12-23 21:13:27 +01:00
Kim Alvefur
272944f4df
util.sql: Preserve 3rd and 4th return values from transaction ( fixes #1434 ) (thanks mrdoctorwho)
2019-09-28 18:24:28 +02:00
Kim Alvefur
358ade2979
util.sql: Remove tostring call from logging
...
Taken care of by loggingmanager now
2019-07-30 02:23:44 +02:00
Kim Alvefur
c2576aea62
util.sql: Ignore if tables and indices already exist on creation ( fixes #1064 )
...
Tested with SQLite3 3.16.2 and 3.27.2 and Postgres 11.
MySQL does not support IF NOT EXISTS for indices so not handled here.
2019-05-30 23:50:28 +02:00
Kim Alvefur
1086a1325d
util.sql: Switch from hacky multi-arg xpcall implementation to util.xpcall
2018-11-11 02:26:40 +01:00
Kim Alvefur
43b814a83b
vairious: Add annotation when an empty environment is set [luacheck]
2018-02-28 20:06:26 +01:00
Kim Alvefur
c904d1e28d
util: Ignore some Lua 5.1 vs 5.2 compat things [luacheck]
2017-11-10 17:47:11 +01:00
Kim Alvefur
1438a38845
util: Various minor changes to please [luacheck]
2017-11-10 05:42:32 +01:00
Kim Alvefur
bd1b01460c
util.sql: Discard useless substitution count from string.gsub in SQL debug logs
2017-11-08 10:45:58 +01:00
Kim Alvefur
eb07e55b14
util.sql: Return an error message when a SQL commit fails (LuaDBI doesn't) (Thanks Ge0rG)
2017-11-07 09:26:48 +01:00
Matthew Wild
1e9b966c59
util.sql: Don't log at error level if a transaction failed and was retried ok
2017-10-04 10:16:42 +01:00
Matthew Wild
c5af3aee3e
util.sql: Greedily read all rows so we can close queries early ( fixes #391 )
2017-08-04 18:52:15 +01:00
Kim Alvefur
656c5d45a1
util.sql: Produce more SQL-standard-like debug messages
2017-04-13 22:37:35 +02:00
Kim Alvefur
b3cd19063f
util.sql: Strip indentation from queries for debug logging
2017-04-12 18:57:40 +02:00
Kim Alvefur
f2c30c688f
util.sql: Apply quote transform in engine:execute so it is applied to eg encoding checks in mod_storage_sql (thanks Martin)
2017-04-12 17:26:44 +02:00
Kim Alvefur
91baabfede
SQL: Use standard quotes for columns and other identifiers, rewrite to grave accents for MySQL only ( fixes #885 )
2017-04-10 23:13:39 +02:00
Anton Shestakov
8e2e80c3f3
util.sql: remove unused one-letter loop variables [luacheck]
2016-07-23 18:22:05 +08:00
Kim Alvefur
8d720b7bfb
util.sql: Import type too (fix global access)
2016-05-22 14:37:52 +02:00
Matthew Wild
8a32b7f2c3
util.sql: Import pcall ( fixes #677 )
2016-05-22 02:16:11 +01:00
Kim Alvefur
c24be27b2f
util.sql: Log errors in transaction to error level with traceback but return only error message ( fixes #464 )
2016-03-25 16:09:34 +01:00
Matthew Wild
c50a32df40
util.sql: Charset should be innocent until proven guilty (initialize charset_ok to true), fixes bug introduced in 187ba2e9c012
2016-03-23 12:17:28 +00:00
Kim Alvefur
c00adb21f4
util.sql: Catch errors from LuaDBI connect ( Fixes #568 )
2016-03-21 09:50:52 +01:00
Kim Alvefur
f46a677512
util.sql: Remove unused arguments [luacheck]
2016-03-13 18:35:00 +01:00
Kim Alvefur
2b1ff306c3
util.sql: Don't break out of result retreival loops
2016-03-13 18:31:53 +01:00
Kim Alvefur
b65ec4aebe
util.sql: Move per-driver (currenly only PostgreSQL) query transform into its own method
2016-03-13 17:38:49 +01:00
Kim Alvefur
58a6a4b140
util.sql: Localize unpack() in Lua 5.2 compatible way
2016-02-22 17:30:12 +01:00
Kim Alvefur
a729f9553c
util.sql: Raw query debug logging (needs to be explicitly enabled by a plugin)
2016-02-21 19:25:01 +01:00
Kim Alvefur
28202ed1c9
util.sql: Export db2uri (mod_storage_sql2 command uses it) (thanks mike)
2015-09-02 14:14:22 +02:00
Kim Alvefur
90f5cf4cc1
util.sql: Log when transactions begin
2015-08-30 13:45:36 +02:00
Kim Alvefur
eaa823a597
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
2015-02-21 10:36:37 +01:00
Kim Alvefur
97ed1aed6c
util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
2015-07-17 12:43:04 +02:00
Matthew Wild
376dd43396
util.sql: Add safety check to ensure our chosen connection charset is actually being used (MySQL)
2015-07-08 15:25:42 +01:00
Matthew Wild
c23293f382
util.sql: Fix log level of debug message
2015-07-08 15:16:17 +01:00
Matthew Wild
5a90847cd7
util.sql: Log debug message when connecting to database
2015-07-08 15:15:32 +01:00
Matthew Wild
eed81c2f94
util.sql: Make set_encoding() return failure of SET NAMES
2015-07-08 15:14:24 +01:00
Matthew Wild
9f5bd334c5
util.sql: Return failure if set_encoding() fails
2015-07-08 15:10:25 +01:00
Matthew Wild
eeb1c1be54
util.sql: Use appropriate collation for the chosen character set - fixes MySQL silently ignoring our SET NAMES command when we use utf8mb4
2015-07-08 15:06:20 +01:00
Matthew Wild
7a4ec3c57c
util.sql: Create table with same charset as the charset we selected for our connection, also use corresponding _bin collation
2015-07-08 15:04:23 +01:00
Matthew Wild
137f763966
util.sql: Allow onconnect callback to fail connection to the DB by returning false, err
2015-07-07 17:43:14 +01:00
Kim Alvefur
3dd49f5620
util.sql: Call onconnect, provide noop dummy if not set
2015-07-02 22:32:44 +02:00
Matthew Wild
3edc813e77
util.sql: Remove built-in engine caching. This is the wrong layer to do this, and unintentionally sharing connections could cause problems (e.g. when interleaving multiple queries and result fetching)
2015-06-03 15:57:46 +01:00
Matthew Wild
41996240ed
util.sql: Expose db2uri helper function
2015-06-03 15:55:43 +01:00
Matthew Wild
15e84d4ec5
util.sql: Rename some variable to match conventions
2015-06-03 15:54:52 +01:00
Matthew Wild
bfba36b194
util.sql: Remove unused functions and unused commented code
2015-05-30 22:23:19 +01:00
Kim Alvefur
655e1cde09
mod_storage_sql2, util.sql: Set character encoding on every connect
2014-12-11 09:18:39 +01:00