Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch uuid-funcs Excluding Merge-Ins
This is equivalent to a diff from 5c118617cf to 97ba442b8d
2019-10-23
| ||
18:14 | Add uuid_string and uuid_blob functions (Leaf check-in: 97ba442b8d user: numist tags: uuid-funcs) | |
18:09 | When a vector comparison appears in the WHERE clause and the constraint side has a COLLATE clause on the first term of the vector, be sure to honor that COLLATE clause. Ticket [135c9da7513e5a97]. (check-in: 978b2d20cf user: drh tags: trunk) | |
18:01 | Create new branch named "uuid-funcs" (check-in: 815dc0437c user: numist tags: uuid-funcs) | |
2019-10-22
| ||
20:16 | Merge the row-value fix from trunk. (check-in: 1fbd743861 user: drh tags: generated-columns) | |
19:51 | Disqualify row-value comparisons for use by an index if the right-hand side has an affinity that does not match the index. Fix for ticket [6ef984af8972c2eb] (check-in: 5c118617cf user: drh tags: trunk) | |
11:29 | Previous check-in to fix [b47e3627ecaadbde] was incomplete. This check-in completes the fix and adds a test cases. (check-in: c7da1c01f1 user: drh tags: trunk) | |
Changes to src/func.c.
1797 1797 sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT); 1798 1798 } 1799 1799 } 1800 1800 } 1801 1801 #else 1802 1802 # define groupConcatValue 0 1803 1803 #endif /* SQLITE_OMIT_WINDOWFUNC */ 1804 + 1805 +/* 1806 +** The uuid_blob() function. Interpret the argument as a RFC 4122 UUID string. 1807 +** Return a blob representing the parsed UUID. 1808 +*/ 1809 +static void uuidBlob( 1810 + sqlite3_context *context, 1811 + int argc, 1812 + sqlite3_value **argv 1813 +){ 1814 + int h, i, j = 0, rc = SQLITE_ERROR; 1815 + unsigned char parsed[16]; 1816 + const char *zHex; 1817 + assert( argc==1 ); 1818 + UNUSED_PARAMETER(argc); 1819 + zHex = sqlite3_value_text(argv[0]); 1820 + if( sqlite3_value_bytes(argv[0])==36 ){ 1821 + for (i=0, h = zHex[i]; i <= 36; i++, h=zHex[i]) { 1822 + if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) { 1823 + if( h !='-' ){ 1824 + break; 1825 + } 1826 + }else if (i==36 && h==0 ){ 1827 + rc = SQLITE_OK; 1828 + }else{ 1829 + if( (h<'0' || h>'9')&&(h<'a'||h>'f')&&(h<'A'||h>'F') ){ 1830 + break; 1831 + } 1832 + if( j%2 ){ 1833 + parsed[j++ / 2] |= sqlite3HexToInt(h); 1834 + }else{ 1835 + parsed[j++ / 2] = sqlite3HexToInt(h) << 4; 1836 + } 1837 + } 1838 + } 1839 + } 1840 + 1841 + if( rc ){ 1842 + sqlite3_result_error(context, "parameter is not a valid UUID", -1); 1843 + return; 1844 + }else{ 1845 + sqlite3_result_blob(context, parsed, sizeof(parsed), SQLITE_TRANSIENT); 1846 + } 1847 +} 1848 + 1849 +/* 1850 +** The uuid_string() function. Argument must be a 128-bit blob. Return a 1851 +** RFC 4122 string representation of the blob. 1852 +*/ 1853 +static void uuidString( 1854 + sqlite3_context *context, 1855 + int argc, 1856 + sqlite3_value **argv 1857 +){ 1858 + int i, n; 1859 + const unsigned char *pBlob; 1860 + char *zHex, *z; 1861 + assert( argc==1 ); 1862 + UNUSED_PARAMETER(argc); 1863 + pBlob = sqlite3_value_blob(argv[0]); 1864 + n = sqlite3_value_bytes(argv[0]); 1865 + if( n>16 ){ 1866 + sqlite3_result_error_toobig(context); 1867 + return; 1868 + } 1869 + if( n<16 ){ 1870 + sqlite3_result_error(context, "parameter too small to print as UUID", -1); 1871 + return; 1872 + } 1873 + z = zHex = contextMalloc(context, 36); 1874 + if( zHex ){ 1875 + for(i=0; i<16; i++, pBlob++){ 1876 + unsigned char c = *pBlob; 1877 + *(z++) = hexdigits[(c>>4)&0xf]; 1878 + *(z++) = hexdigits[c&0xf]; 1879 + if( i==3||i==5||i==7||i==9 ){ 1880 + *(z++) = '-'; 1881 + } 1882 + } 1883 + sqlite3_result_text(context, zHex, 36, sqlite3_free); 1884 + } 1885 +} 1804 1886 1805 1887 /* 1806 1888 ** This routine does per-connection function registration. Most 1807 1889 ** of the built-in functions above are part of the global function set. 1808 1890 ** This routine only deals with those that are not global. 1809 1891 */ 1810 1892 void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){ ................................................................................ 1903 1985 ** The array cannot be constant since changes are made to the 1904 1986 ** FuncDef.pHash elements at start-time. The elements of this array 1905 1987 ** are read-only after initialization is complete. 1906 1988 ** 1907 1989 ** For peak efficiency, put the most frequently used function last. 1908 1990 */ 1909 1991 static FuncDef aBuiltinFunc[] = { 1992 + FUNCTION(uuid_str, 1, 0, 0, uuidString), 1993 + FUNCTION(uuid_blob, 1, 0, 0, uuidBlob), 1910 1994 #ifdef SQLITE_SOUNDEX 1911 1995 FUNCTION(soundex, 1, 0, 0, soundexFunc ), 1912 1996 #endif 1913 1997 #ifndef SQLITE_OMIT_LOAD_EXTENSION 1914 1998 VFUNCTION(load_extension, 1, 0, 0, loadExt ), 1915 1999 VFUNCTION(load_extension, 2, 0, 0, loadExt ), 1916 2000 #endif