Commit 2135d44d authored by Andrew McDonnell's avatar Andrew McDonnell

Merge on bzr pull

parents 227bb5e0 699e3924
DROP TABLE IF EXISTS graph_base;
Warnings:
Note 1051 Unknown table 'graph_base'
DROP TABLE IF EXISTS graph;
Warnings:
Note 1051 Unknown table 'graph'
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
......@@ -62,5 +58,4 @@ latch origid destid weight seq linkid
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph;
DROP TABLE graph_base;
DROP TABLE graph, graph_base;
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
DROP TABLE IF EXISTS graph2;
--enable_warnings
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
......@@ -93,5 +95,4 @@ DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph;
DROP TABLE graph_base;
DROP TABLE graph, graph_base;
--disable_warnings
DROP TABLE IF EXISTS not_backing;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE `not_backing` (
id int(10) unsigned NOT NULL DEFAULT '0',
......@@ -19,6 +22,7 @@ CREATE TABLE backing (
KEY name (info)
) DEFAULT CHARSET=latin1;
# oqgraph v2 create table should fail (missing attributes)
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH;
--error 1296
......@@ -26,102 +30,136 @@ DESCRIBE oqtable;
# attributes test
# empty table reference
DROP TABLE IF EXISTS `oqtable`;
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='';
--error 1296
DESCRIBE oqtable;
# non-existent table reference
DROP TABLE IF EXISTS `oqtable`;
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='bogus';
--error 1296
DESCRIBE oqtable;
# invalid table reference
DROP TABLE IF EXISTS `oqtable`;
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='not_backing';
--error 1296
DESCRIBE oqtable;
# empty origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='';
--error 1296
DESCRIBE oqtable;
# invalid origid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type origid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='not_id_type';
--error 1296
DESCRIBE oqtable;
# missing destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id';
--error 1296
DESCRIBE oqtable;
# empty destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='';
--error 1296
DESCRIBE oqtable;
# invalid destid reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='not_id_type';
--error 1296
DESCRIBE oqtable;
# invalid origid with valid destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='bogus',DESTID='id';
--error 1296
DESCRIBE oqtable;
# wrong type origid with valid destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='not_id_type',DESTID='id';
--error 1296
DESCRIBE oqtable;
# same origid and destid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id';
# this should fail when we put a check in for ORIGID != DESTID
# --error 1296
DESCRIBE oqtable;
# invalid weight reference
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='bogus';
--error 1296
DESCRIBE oqtable;
# wrong type weight
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='not_weight_type';
--error 1296
DESCRIBE oqtable;
# all valid
--disable_warnings
DROP TABLE IF EXISTS oqtable;
--enable_warnings
CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL, destid BIGINT UNSIGNED NULL, weight DOUBLE NULL, seq BIGINT UNSIGNED NULL, linkid BIGINT UNSIGNED NULL, KEY (latch, origid, destid) USING HASH, KEY (latch, destid, origid) USING HASH ) ENGINE=OQGRAPH, DATA_TABLE='backing',ORIGID='id',DESTID='id',WEIGHT='weight';
DESCRIBE oqtable;
# cleanup
--disable_warnings
DROP TABLE IF EXISTS oqtable;
DROP TABLE IF EXISTS backing;
DROP TABLE IF EXISTS not_backing;
--enable_warnings
# SQL implementation of randsocial.c for OQGRAPH
# Copyright (C) by Arjen Lentz <arjen@openquery.com> for Open Query
# GPL v2+ licensed with the rest of OQGRAPH
# for use in mysql-test
# 2013-03-01 first implementation based on randsocial.c in old oqgraph v2 tree
delimiter |;
--disable_warnings
DROP PROCEDURE IF EXISTS randnotx|
--enable_warnings
CREATE PROCEDURE randnotx (INOUT rseed INT, IN items INT, IN x INT, OUT rval INT)
BEGIN
REPEAT
# Simple LCG (BSD)
SET rseed = (rseed * 1103515245 + 12345) & 2147483647;
SET rval = ((rseed >> 16) & 32767) MOD items;
UNTIL rval <> x
END REPEAT;
END|
--disable_warnings
DROP PROCEDURE IF EXISTS randgraphproc|
--enable_warnings
# this procedure is deterministic with its private seeded random generator
CREATE PROCEDURE randgraphproc (IN items INT, IN friends INT, IN fanof INT, IN maxweight INT)
BEGIN
DECLARE i,j,weight,rseed,rval INT;
# we need repeatability even in multi-threading
SET rseed = items;
SET i = 0;
WHILE i < items DO
SET j = 0;
WHILE j < (friends + fanof) DO
CALL randnotx(rseed,items,i,rval);
IF (maxweight > 0) THEN
# Use -1 as we don't need to exclude anything
CALL randnotx(rseed,items,-1,weight);
SET weight = weight MOD maxweight;
ELSE
SET weight = 0;
END IF;
# SELECT CONCAT('INSERT IGNORE rsb VALUES (',i,',',rval,',',weight,');');
INSERT IGNORE rsb VALUES (i,rval,weight);
# only create backlinks for friends, not fans
IF (j < friends) THEN
# SELECT CONCAT('INSERT IGNORE rsb VALUES (',rval,',',i,',',weight,');');
INSERT IGNORE rsb VALUES (rval,i,weight);
END IF;
SET j = j + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END|
DELIMITER ;;
--disable_warnings
DROP TABLE IF EXISTS rsb, rsb_graph;
--enable_warnings
CREATE TABLE rsb (
f INT UNSIGNED NOT NULL,
t INT UNSIGNED NOT NULL,
......@@ -17,9 +21,70 @@ CREATE TABLE rsb_graph (
KEY (latch,destid,origid) USING HASH
) ENGINE=OQGRAPH data_table='rsb' origid='f' destid='t' weight='weight';
# this graph generator is designed to be deterministic
# (so we don't need to ship a large test dataset)
--source suite/oqgraph/randgraphproc.inc
# --source suite/oqgraph/randgraphproc.inc
# SQL implementation of randsocial.c for OQGRAPH
# Copyright (C) 2013 by Arjen Lentz <arjen@openquery.com> for Open Query
# GPL v2+ licensed with the rest of OQGRAPH
# for use in mysql-test
# 2013-03-01 first implementation based on randsocial.c in old oqgraph v2 tree
delimiter |;
--disable_warnings
DROP PROCEDURE IF EXISTS randnotx|
--enable_warnings
CREATE PROCEDURE randnotx (INOUT rseed INT, IN items INT, IN x INT, OUT rval INT) DETERMINISTIC
BEGIN
REPEAT
# Simple LCG (BSD)
SET rseed = (rseed * 1103515245 + 12345) & 2147483647;
SET rval = ((rseed >> 16) & 32767) MOD items;
UNTIL rval <> x
END REPEAT;
END;|
# this procedure is deterministic with its private seeded random generator
--disable_warnings
DROP PROCEDURE IF EXISTS randgraphproc|
--enable_warnings
CREATE PROCEDURE randgraphproc (IN items INT, IN friends INT, IN fanof INT, IN maxweight INT) DETERMINISTIC
BEGIN
DECLARE i,j,weight,rseed,rval INT;
SET rseed = items;
SET i = 0;
WHILE i < items DO
SET j = 0;
WHILE j < (friends + fanof) DO
CALL randnotx(rseed,items,i,rval);
IF (maxweight > 0) THEN
CALL randnotx(rseed,items,-1,weight);
SET weight = weight MOD maxweight;
ELSE
SET weight = 0;
END IF;
INSERT IGNORE rsb VALUES (i,rval,weight);
IF (j < friends) THEN
INSERT IGNORE rsb VALUES (rval,i,weight);
END IF;
SET j = j + 1;
END WHILE;
SET i = i + 1;
END WHILE;
END;|
DELIMITER ;|
# generate social graph of 10000 people having 5 friends (two-way) and being fan of 2 others (one-way)), max weight 3
CALL randgraphproc(10000,5,2,3);
......@@ -45,7 +110,7 @@ SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND origid=976;
SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND origid=74;
# how many possible sources to here
# this doesn't appear to work right now in v3 ? comes up empty but the dataset is not
# this doesn't appear to work right now in v3 ? #if 0 in code. check with Antony
SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND destid=1;
SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND destid=9999;
SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND destid=52;
......@@ -56,8 +121,7 @@ SELECT COUNT(*) FROM rsb_graph WHERE latch=1 AND destid=6483;
# joins
# cleaning up our tables
DROP TABLE IF EXISTS rsb_graph;
DROP TABLE IF EXISTS rsb;
DROP TABLE rsb_graph, rsb;
# cleaning up procs from randgraphproc.inc
DROP PROCEDURE randgraphproc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment