From: Matteo Nastasi (mop) Date: Mon, 30 Nov 2015 06:11:47 +0000 (+0100) Subject: sql.d filename semantic changed X-Git-Tag: v5.3.0~38 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=db0ecb0547a5279447768ab01056151e8edbb2f6;p=brisk.git sql.d filename semantic changed --- diff --git a/sql/builder.sh b/sql/builder.sh index b71624d..2bb9917 100755 --- a/sql/builder.sh +++ b/sql/builder.sh @@ -55,12 +55,12 @@ one_or_all() { if [ "$1" ]; then echo "$1" elif [ "$TYPE_FILES" = "a" ]; then - echo sql.d/[0-9]* + find sql.d/ -name '[0-9]*' -type f | tr '\n' ' ' elif [ "$TYPE_FILES" = "d" ]; then - echo sql.d/[0-9]*.{sql,devel} + find sql.d/ -name '[0-9]*' | egrep '.*_devel.sql$|^[^_]+.sql$' | tr '\n' ' ' else - echo sql.d/[0-9]*.sql - fi); do + find sql.d/ -name '[0-9]*' | egrep '^[^_]+.sql$' | tr '\n' ' ' + fi); do echo "-- FILE BEG: $fil" cat "$fil" echo "-- FILE END: $fil" diff --git a/sql/sql.d/066-insert-unnorm-games.sql.test b/sql/sql.d/066-insert-unnorm-games.sql.test deleted file mode 100644 index 930815e..0000000 --- a/sql/sql.d/066-insert-unnorm-games.sql.test +++ /dev/null @@ -1,37 +0,0 @@ -DELETE FROM #PFX#bin5_matches WHERE code = 100 OR code = 101; - -INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (100, 'normalize_points', 2, 1, 1) RETURNING *; -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10101, 0); -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10102, 1); -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10103, 2); -INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) - VALUES (200, 100, to_timestamp(#NOW# - 1000), 2, 60, 0, -1, -1, 0, 0) RETURNING *; -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10101, 0); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10102, 0); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10103, 0); -UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100; -INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) - VALUES (201, 100, to_timestamp(#NOW# - 900), 0, 61, 37, 2, 1, 1, 1) RETURNING *; -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10101, 2); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10102, -2); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10103, -4); - - -INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (101, 'normalize_points2', 2, 1, 0) RETURNING *; -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10101, 0); -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10102, 1); -INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10103, 2); -INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) - VALUES (202, 101, to_timestamp(#NOW# - 800), 2, 60, 0, -1, -1, 0, 0) RETURNING *; -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10101, 0); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10102, 0); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10103, 0); -UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100; -INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) - VALUES (203, 101, to_timestamp(#NOW# - 700), 0, 81, 37, 2, 1, 1, 1) RETURNING *; -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10101, 6); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10102, -6); -INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10103, -12); - - - diff --git a/sql/sql.d/066-insert-unnorm-games_test.sql b/sql/sql.d/066-insert-unnorm-games_test.sql new file mode 100644 index 0000000..930815e --- /dev/null +++ b/sql/sql.d/066-insert-unnorm-games_test.sql @@ -0,0 +1,37 @@ +DELETE FROM #PFX#bin5_matches WHERE code = 100 OR code = 101; + +INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (100, 'normalize_points', 2, 1, 1) RETURNING *; +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10101, 0); +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10102, 1); +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (100, 10103, 2); +INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) + VALUES (200, 100, to_timestamp(#NOW# - 1000), 2, 60, 0, -1, -1, 0, 0) RETURNING *; +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10101, 0); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10102, 0); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (200, 10103, 0); +UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100; +INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) + VALUES (201, 100, to_timestamp(#NOW# - 900), 0, 61, 37, 2, 1, 1, 1) RETURNING *; +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10101, 2); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10102, -2); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (201, 10103, -4); + + +INSERT INTO #PFX#bin5_matches (code, ttok, tidx, mazzo_next, mult_next) VALUES (101, 'normalize_points2', 2, 1, 0) RETURNING *; +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10101, 0); +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10102, 1); +INSERT INTO #PFX#bin5_table_orders (mcode, ucode, pos) VALUES (101, 10103, 2); +INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) + VALUES (202, 101, to_timestamp(#NOW# - 800), 2, 60, 0, -1, -1, 0, 0) RETURNING *; +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10101, 0); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10102, 0); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (202, 10103, 0); +UPDATE #PFX#bin5_matches SET (mazzo_next, mult_next) = (2, 0) WHERE code = 100; +INSERT INTO #PFX#bin5_games (code, mcode, tstamp, act, asta_pnt, pnt, asta_win, friend, mazzo, mult) + VALUES (203, 101, to_timestamp(#NOW# - 700), 0, 81, 37, 2, 1, 1, 1) RETURNING *; +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10101, 6); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10102, -6); +INSERT INTO #PFX#bin5_points (gcode, ucode, pts) VALUES (203, 10103, -12); + + + diff --git a/sql/sql.d/900-anagr.sql.devel b/sql/sql.d/900-anagr.sql.devel deleted file mode 100644 index 1d42603..0000000 --- a/sql/sql.d/900-anagr.sql.devel +++ /dev/null @@ -1,33 +0,0 @@ --- --- Populate users db. --- - --- macro for user_flag bit-field --- define('USER_FLAG_TY_ALL', 0xff0000); // done --- define('USER_FLAG_TY_NORM', 0x010000); // done --- define('USER_FLAG_TY_SUPER', 0x020000); // done --- define('USER_FLAG_TY_CERT', 0x040000); // done --- define('USER_FLAG_TY_APPR', 0x080000); // done --- define('USER_FLAG_TY_FIRONLY', 0x200000); // done --- define('USER_FLAG_TY_ADMIN', 0x400000); // done --- define('USER_FLAG_TY_DISABLE', 0x800000); // done - - -DELETE FROM #PFX#users WHERE code = 10101; -DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101); -DELETE FROM #PFX#users WHERE code = 10102; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101); -DELETE FROM #PFX#users WHERE code = 10103; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00030000' as integer), 10102); -DELETE FROM #PFX#users WHERE code = 10104; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102); -DELETE FROM #PFX#users WHERE code = 10105; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103); -DELETE FROM #PFX#users WHERE code = 10106; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103); -DELETE FROM #PFX#users WHERE code = 10107; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10107, E'"/\\''|', md5('sev'), 'sev@pluto.com', CAST (X'00210000' as integer), 10103); -DELETE FROM #PFX#users WHERE code = 10108; -INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10108, E'appr', md5('appr'), 'appr@pluto.com', CAST (X'00080000' as integer), 10103); -ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10109; diff --git a/sql/sql.d/900-anagr_devel.sql b/sql/sql.d/900-anagr_devel.sql new file mode 100644 index 0000000..1d42603 --- /dev/null +++ b/sql/sql.d/900-anagr_devel.sql @@ -0,0 +1,33 @@ +-- +-- Populate users db. +-- + +-- macro for user_flag bit-field +-- define('USER_FLAG_TY_ALL', 0xff0000); // done +-- define('USER_FLAG_TY_NORM', 0x010000); // done +-- define('USER_FLAG_TY_SUPER', 0x020000); // done +-- define('USER_FLAG_TY_CERT', 0x040000); // done +-- define('USER_FLAG_TY_APPR', 0x080000); // done +-- define('USER_FLAG_TY_FIRONLY', 0x200000); // done +-- define('USER_FLAG_TY_ADMIN', 0x400000); // done +-- define('USER_FLAG_TY_DISABLE', 0x800000); // done + + +DELETE FROM #PFX#users WHERE code = 10101; +DELETE FROM #PFX#users WHERE guar_code = 10101 AND code != 10101; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10101, 'uno', md5('one'), 'uno@pluto.com', CAST (X'00450000' as integer), 10101); +DELETE FROM #PFX#users WHERE code = 10102; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10102, 'due', md5('two'), 'due@pluto.com', CAST (X'00010000' as integer), 10101); +DELETE FROM #PFX#users WHERE code = 10103; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10103, 'tre', md5('thr'), 'tre@pluto.com', CAST (X'00030000' as integer), 10102); +DELETE FROM #PFX#users WHERE code = 10104; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10104, 'qua', md5('for'), 'qua@pluto.com', CAST (X'00010000' as integer), 10102); +DELETE FROM #PFX#users WHERE code = 10105; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10105, 'cin', md5('fiv'), 'cin@pluto.com', CAST (X'00010000' as integer), 10103); +DELETE FROM #PFX#users WHERE code = 10106; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10106, 'sei', md5('six'), 'sei@pluto.com', CAST (X'00210000' as integer), 10103); +DELETE FROM #PFX#users WHERE code = 10107; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10107, E'"/\\''|', md5('sev'), 'sev@pluto.com', CAST (X'00210000' as integer), 10103); +DELETE FROM #PFX#users WHERE code = 10108; +INSERT INTO #PFX#users (code, login, pass, email, type, guar_code) VALUES (10108, E'appr', md5('appr'), 'appr@pluto.com', CAST (X'00080000' as integer), 10103); +ALTER SEQUENCE #PFX#users_code_seq RESTART WITH 10109; diff --git a/sql/sql.d/910-usernet-sql.devel b/sql/sql.d/910-usernet-sql.devel deleted file mode 100644 index 2138d71..0000000 --- a/sql/sql.d/910-usernet-sql.devel +++ /dev/null @@ -1,25 +0,0 @@ --- primary owner 10101 -DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10102; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10102, 4, 2, 5); -DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10103; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10103, 5, 2, 3); --- primary owner: discarded target -DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10104; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10104, 1, 2, 5); - --- secondary owners for 10101 -DELETE FROM #PFX#usersnet WHERE owner = 10102 AND inher = 10102 AND target = 10105; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10102, 10102, 10105, 4, 2, 3); -DELETE FROM #PFX#usersnet WHERE owner = 10103 AND inher = 10103 AND target = 10105; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10103, 10103, 10105, 4, 3, 4); -DELETE FROM #PFX#usersnet WHERE owner = 10104 AND inher = 10104 AND target = 10105; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10104, 10104, 10105, 4, 5, 4); - -DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10107; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10107, 3, 3, 4); -DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher is NULL AND target = 10107; -INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, NULL, 10107, 3, 3, 4); - -SELECT * FROM bsk_usersnet_wideskill; -SELECT * FROM bsk_usersnet_narrowskill; - diff --git a/sql/sql.d/910-usernet_devel.sql b/sql/sql.d/910-usernet_devel.sql new file mode 100644 index 0000000..2138d71 --- /dev/null +++ b/sql/sql.d/910-usernet_devel.sql @@ -0,0 +1,25 @@ +-- primary owner 10101 +DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10102; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10102, 4, 2, 5); +DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10103; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10103, 5, 2, 3); +-- primary owner: discarded target +DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10104; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10104, 1, 2, 5); + +-- secondary owners for 10101 +DELETE FROM #PFX#usersnet WHERE owner = 10102 AND inher = 10102 AND target = 10105; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10102, 10102, 10105, 4, 2, 3); +DELETE FROM #PFX#usersnet WHERE owner = 10103 AND inher = 10103 AND target = 10105; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10103, 10103, 10105, 4, 3, 4); +DELETE FROM #PFX#usersnet WHERE owner = 10104 AND inher = 10104 AND target = 10105; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10104, 10104, 10105, 4, 5, 4); + +DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher = 10101 AND target = 10107; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, 10101, 10107, 3, 3, 4); +DELETE FROM #PFX#usersnet WHERE owner = 10101 AND inher is NULL AND target = 10107; +INSERT INTO #PFX#usersnet (owner, inher, target, friend, skill, trust) VALUES (10101, NULL, 10107, 3, 3, 4); + +SELECT * FROM bsk_usersnet_wideskill; +SELECT * FROM bsk_usersnet_narrowskill; +