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
11 months ago
Kim Alvefur
022159d0f0
util.sqlite3: Clean up unused variables
...
Many leftovers from the earlier version of util.sql this was based on
and cleanup applied there since then.
2 years ago
Kim Alvefur
dd37d17425
util.sqlite3: Don't cache prepared statements for one-off queries
...
The :execute method is mainly used for one-off queries such as creating
tables and indices. There is no need to cache this prepared statement,
as those queries are only done on startup.
Further, prepared statements can't be reused without being reset, so
this was likely broken anyway.
3 years ago
Kim Alvefur
95687d9ddd
util.sqlite3: Deduplicate query methods
...
There were 3 very similar methods:
- :execute()
- :execute_query()
- :execute_update()
The first one returns the prepared statement and is mainly used
internally in the library for CREATE statements.
The later two only really differ in how the results are returned.
Those two are one main method and one small one that only picks out the
iterator.
3 years ago
Kim Alvefur
eaf8765ee9
util.sqlite3: Fix indentation
3 years ago
Kim Alvefur
43531740f9
util: Prefix module imports with prosody namespace
3 years ago
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
3 years ago
Kim Alvefur
e3836f22e0
util.sqlite3: Skip prepared statements when no parameters are given
...
Seems CREATE INDEX is unhappy as a prepared statement. Perhaps because
the table has not been COMMIT-ed yet?
3 years ago
Kim Alvefur
320d4032a2
util.sqlite3: Create util.error registry from headers
...
The 'type' fields are a first guess.
4 years ago
Kim Alvefur
2dada39e39
util.sqlite3: SQLite3-only variant of util.sql using LuaSQLite3
...
http://lua.sqlite.org/
3 years ago
Kim Alvefur
b0361006e1
util.sql: Handle failure to detect connection encoding
...
Silences a luacheck warning about an unused variable
6 years ago
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.
7 years ago
Kim Alvefur
272944f4df
util.sql: Preserve 3rd and 4th return values from transaction ( fixes #1434 ) (thanks mrdoctorwho)
6 years ago
Kim Alvefur
1086a1325d
util.sql: Switch from hacky multi-arg xpcall implementation to util.xpcall
7 years ago
Kim Alvefur
358ade2979
util.sql: Remove tostring call from logging
...
Taken care of by loggingmanager now
7 years ago
Kim Alvefur
eb07e55b14
util.sql: Return an error message when a SQL commit fails (LuaDBI doesn't) (Thanks Ge0rG)
8 years ago
Matthew Wild
1e9b966c59
util.sql: Don't log at error level if a transaction failed and was retried ok
8 years ago
Matthew Wild
c5af3aee3e
util.sql: Greedily read all rows so we can close queries early ( fixes #391 )
9 years ago
Kim Alvefur
656c5d45a1
util.sql: Produce more SQL-standard-like debug messages
9 years ago
Kim Alvefur
b3cd19063f
util.sql: Strip indentation from queries for debug logging
9 years ago
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)
9 years ago
Kim Alvefur
91baabfede
SQL: Use standard quotes for columns and other identifiers, rewrite to grave accents for MySQL only ( fixes #885 )
9 years ago
Kim Alvefur
43b814a83b
vairious: Add annotation when an empty environment is set [luacheck]
8 years ago
Kim Alvefur
c904d1e28d
util: Ignore some Lua 5.1 vs 5.2 compat things [luacheck]
8 years ago
Kim Alvefur
1438a38845
util: Various minor changes to please [luacheck]
8 years ago
Kim Alvefur
bd1b01460c
util.sql: Discard useless substitution count from string.gsub in SQL debug logs
8 years ago
Anton Shestakov
8e2e80c3f3
util.sql: remove unused one-letter loop variables [luacheck]
10 years ago
Kim Alvefur
8d720b7bfb
util.sql: Import type too (fix global access)
10 years ago
Matthew Wild
8a32b7f2c3
util.sql: Import pcall ( fixes #677 )
10 years ago
Kim Alvefur
c24be27b2f
util.sql: Log errors in transaction to error level with traceback but return only error message ( fixes #464 )
10 years ago
Matthew Wild
c50a32df40
util.sql: Charset should be innocent until proven guilty (initialize charset_ok to true), fixes bug introduced in 187ba2e9c012
10 years ago
Kim Alvefur
c00adb21f4
util.sql: Catch errors from LuaDBI connect ( Fixes #568 )
10 years ago
Kim Alvefur
f46a677512
util.sql: Remove unused arguments [luacheck]
10 years ago
Kim Alvefur
2b1ff306c3
util.sql: Don't break out of result retreival loops
10 years ago
Kim Alvefur
b65ec4aebe
util.sql: Move per-driver (currenly only PostgreSQL) query transform into its own method
10 years ago
Kim Alvefur
58a6a4b140
util.sql: Localize unpack() in Lua 5.2 compatible way
10 years ago
Kim Alvefur
a729f9553c
util.sql: Raw query debug logging (needs to be explicitly enabled by a plugin)
10 years ago
Kim Alvefur
28202ed1c9
util.sql: Export db2uri (mod_storage_sql2 command uses it) (thanks mike)
10 years ago
Kim Alvefur
90f5cf4cc1
util.sql: Log when transactions begin
10 years ago
Kim Alvefur
97ed1aed6c
util.{interpolation,prosodyctl,sql}: Trim trailing whitespace
11 years ago
Matthew Wild
376dd43396
util.sql: Add safety check to ensure our chosen connection charset is actually being used (MySQL)
11 years ago
Matthew Wild
c23293f382
util.sql: Fix log level of debug message
11 years ago
Matthew Wild
5a90847cd7
util.sql: Log debug message when connecting to database
11 years ago
Matthew Wild
eed81c2f94
util.sql: Make set_encoding() return failure of SET NAMES
11 years ago
Matthew Wild
9f5bd334c5
util.sql: Return failure if set_encoding() fails
11 years ago
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
11 years ago
Matthew Wild
7a4ec3c57c
util.sql: Create table with same charset as the charset we selected for our connection, also use corresponding _bin collation
11 years ago
Matthew Wild
137f763966
util.sql: Allow onconnect callback to fail connection to the DB by returning false, err
11 years ago
Kim Alvefur
3dd49f5620
util.sql: Call onconnect, provide noop dummy if not set
11 years ago
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)
11 years ago