postgres to_number(text,text2) //text2 = 999999.99 为保留两位有效数据,不然将不识别小数点,只认识数字类型 select cast(“extension”#>>’{lat}’ as double precision) as lat, cast(“extension”#>>’{lng}’ as numeric) as lng from ads where id=6;
更新同一表中的同一数据 先后开启事务A、B。A更新a,B更新a。后提交的会回滚:could not serialize access due to concurrent update 先后开启事务A、B。A更新a,B更新a。后提交的会回滚:could not serialize access due to concurrent update 先后开启事务A、B。A更新a(0.109 ms),B更新b(0.113 ms)。A和B都会commit成功(但B会等A执行成功且commit之后,B才会执行成功,最后B也提交) 更新同一表中的不同数据 先后开启事务A、B。A更新a(0.197 ms),B更新b(0.202 ms)。A和B都会commit成功 先后开启事务A、B。A更新a(0.233 ms),B更新b(0.274 ms)。后提交的会回滚:
ERROR: could not serialize access due to read/write dependencies among transactions DETAIL: Reason code: Canceled on identification as a pivot, during commit attempt. HINT: The transaction might succeed if retried.
varUser = sequelize.define('user', { firstName: { type: Sequelize.STRING, field: 'first_name'// Will result in an attribute that is firstName when user facing but first_name in the database }, lastName: { type: Sequelize.STRING } }, { freezeTableName: true// Model 对应的表名将与model名相同 });
var cookieParser = require('cookie-parser'); var csrf = require('csurf'); var bodyParser = require('body-parser'); var express = require('express'); // setup route middlewares var csrfProtection = csrf({ cookie: true }); var parseForm = bodyParser.urlencoded({ extended: false }); // create express app var app = express(); // we need this because "cookie" is true in csrfProtection app.use(cookieParser()); app.get('/form', csrfProtection, function(req, res) { // pass the csrfToken to the view res.render('send', { csrfToken: req.csrfToken() }); }); app.post('/process', parseForm, csrfProtection, function(req, res) { res.send('data is being processed'); });