1
0
mirror of https://github.com/luapower/mysql.git synced 2024-11-05 10:00:32 +01:00

unimportant

This commit is contained in:
Cosmin Apreutesei 2021-12-07 14:47:52 +02:00
parent fb5336213d
commit 1a27dad1a6
3 changed files with 18 additions and 32 deletions

View File

@ -999,8 +999,6 @@ local function get_err_packet(buf)
return message, errno, sqlstate
end
local get_collation --fw. decl.
function mysql.log(severity, ...)
local logging = mysql.logging
if not logging then return end
@ -1030,20 +1028,19 @@ function mysql.connect(opt)
self.max_packet_size = opt.max_packet_size or 16 * 1024 * 1024 --16 MB
local ok, err
local collation = 0 --default
if opt.collation ~= 'server' then
if opt.collation then
collation = assert(collation_codes[opt.collation], 'invalid collation')
self.collation = opt.collation
self.charset = self.collation:match'^[^_]+'
elseif opt.charset then
local collation_name = assert(default_collations[opt.charset], 'invalid charset')
collation = assert(collation_codes[collation_name])
self.charset = opt.charset
self.collation = collation_name
end
assert(self.collation, 'charset and/or collation required')
local collation
if opt.collation then
collation = assert(collation_codes[opt.collation], 'invalid collation')
self.collation = opt.collation
self.charset = self.collation:match'^[^_]+'
assert(not opt.charset or opt.charset == self.charset, 'supplied charset does not match collation')
elseif opt.charset then
local collation_name = assert(default_collations[opt.charset], 'invalid charset')
collation = assert(collation_codes[collation_name])
self.charset = opt.charset
self.collation = collation_name
end
assert(self.collation, 'charset or collation required')
check_io(self, tcp:connect(host, port))
@ -1097,10 +1094,6 @@ function mysql.connect(opt)
self.to_lua = mysql.to_lua
self.state = 'ready'
if opt.collation == 'server' then
self.collation, self.charset = get_collation(self)
end
self.charset_is_ascii_superset = self.charset and not mb_charsets[self.charset]
self.db = opt.db
self.user = opt.user
@ -1279,12 +1272,6 @@ local function query(self, sql, opt)
end
conn.query = protect(query)
--[[local]] function get_collation(self)
local t = query(self, 'select @@collation_connection cl, @@character_set_connection cs')[1]
return t.cl, t.cs
end
conn.get_collation = protect(get_collation)
do
local function pass(self, db, ret, ...)
if not ret then return nil, ... end

View File

@ -51,10 +51,10 @@ The `options` argument is a Lua table holding the following keys:
* `user`: user name.
* `password`: password (optional).
* `db`: the database to set as current database (optional).
* `collation`: the collation used for the connection (`charset` is implied by this).
* use `'server'` to get the server's collation and charset for the connection.
* `charset`: the character set used for the connection.
* if `collation` not set, the default collation for the charset is selected.
* `charset`: the character set used for the connection (required, see below).
* `collation`: the collation used for the connection (required, see below).
* if only `charset` is given, the default collation for the charset is set automatically.
* if `collation` is given, `charset` is set automatically and must not be supplied.
* `max_packet_size`: the upper limit for the reply packets sent from the server (defaults to 16 MB).
* `ssl`: if `true`, then uses SSL to connect to MySQL (defaults to `false`).
If the server does not have SSL support (or just disabled), the error string
@ -150,8 +150,7 @@ for which the charset is ASCII or an ASCII superset (ascii, utf8).
### `cn:esc(s) -> s`
Escape string to be used inside SQL string literals. This only works
if the current collation is known (see `collation` arg on `connect()`).
Escape string to be used inside SQL string literals.
### Multiple result set support

View File

@ -12,7 +12,7 @@ sock.run(function()
user = 'root',
password = 'root',
db = 'sp',
collation = 'server',
charset = 'utf8mb4',
})
assert(conn:query[[