@@ -2113,4 +2113,213 @@ var FunctionQueryTests = []QueryTest{
21132113 Query : "select date(0)" ,
21142114 Expected : []sql.Row {{"0000-00-00" }},
21152115 },
2116+ {
2117+ Query : "select extract(day from 0)" ,
2118+ Expected : []sql.Row {{0 }},
2119+ },
2120+ {
2121+ Query : "select extract(day from false)" ,
2122+ Expected : []sql.Row {{0 }},
2123+ },
2124+ {
2125+ Query : "select extract(day from true)" ,
2126+ Expected : []sql.Row {{nil }},
2127+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
2128+ ExpectedWarningsCount : 1 ,
2129+ },
2130+ {
2131+ Query : "select extract(month from 0)" ,
2132+ Expected : []sql.Row {{0 }},
2133+ },
2134+ {
2135+ Query : "select extract(month from false)" ,
2136+ Expected : []sql.Row {{0 }},
2137+ },
2138+ {
2139+ Query : "select extract(month from true)" ,
2140+ Expected : []sql.Row {{nil }},
2141+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
2142+ ExpectedWarningsCount : 1 ,
2143+ },
2144+ {
2145+ Query : "select extract(quarter from 0)" ,
2146+ Expected : []sql.Row {{0 }},
2147+ },
2148+ {
2149+ Query : "select extract(quarter from false)" ,
2150+ Expected : []sql.Row {{0 }},
2151+ },
2152+ {
2153+ Query : "select extract(quarter from true)" ,
2154+ Expected : []sql.Row {{nil }},
2155+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
2156+ ExpectedWarningsCount : 1 ,
2157+ },
2158+ {
2159+ Query : "select extract(year from 0)" ,
2160+ Expected : []sql.Row {{0 }},
2161+ },
2162+ {
2163+ Query : "select extract(year from false)" ,
2164+ Expected : []sql.Row {{0 }},
2165+ },
2166+ {
2167+ Query : "select extract(year from true)" ,
2168+ Expected : []sql.Row {{nil }},
2169+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
2170+ ExpectedWarningsCount : 1 ,
2171+ },
2172+ {
2173+ Query : "select extract(year_month from 0)" ,
2174+ Expected : []sql.Row {{0 }},
2175+ },
2176+ {
2177+ Query : "select extract(year_month from false)" ,
2178+ Expected : []sql.Row {{0 }},
2179+ },
2180+ {
2181+ Query : "select extract(year_month from true)" ,
2182+ Expected : []sql.Row {{nil }},
2183+ ExpectedWarning : mysql .ERTruncatedWrongValue ,
2184+ ExpectedWarningsCount : 1 ,
2185+ },
2186+ {
2187+ Query : "select extract(day_microsecond from 0)" ,
2188+ Expected : []sql.Row {{0 }},
2189+ },
2190+ {
2191+ Query : "select extract(day_microsecond from false)" ,
2192+ Expected : []sql.Row {{0 }},
2193+ },
2194+ {
2195+ Skip : true ,
2196+ Query : "select extract(day_microsecond from true)" ,
2197+ Expected : []sql.Row {{1000000 }},
2198+ },
2199+ {
2200+ Query : "select extract(day_second from 0)" ,
2201+ Expected : []sql.Row {{0 }},
2202+ },
2203+ {
2204+ Query : "select extract(day_second from false)" ,
2205+ Expected : []sql.Row {{0 }},
2206+ },
2207+ {
2208+ // https://github.com/dolthub/dolt/issues/10087
2209+ Skip : true ,
2210+ Query : "select extract(day_second from true)" ,
2211+ Expected : []sql.Row {{1 }},
2212+ },
2213+ {
2214+ Query : "select extract(day_minute from 0)" ,
2215+ Expected : []sql.Row {{0 }},
2216+ },
2217+ {
2218+ Query : "select extract(day_minute from false)" ,
2219+ Expected : []sql.Row {{0 }},
2220+ },
2221+ {
2222+ // https://github.com/dolthub/dolt/issues/10087
2223+ Skip : true ,
2224+ Query : "select extract(day_minute from true)" ,
2225+ Expected : []sql.Row {{0 }},
2226+ },
2227+ {
2228+ Query : "select extract(day_hour from 0)" ,
2229+ Expected : []sql.Row {{0 }},
2230+ },
2231+ {
2232+ Query : "select extract(day_hour from false)" ,
2233+ Expected : []sql.Row {{0 }},
2234+ },
2235+ {
2236+ // https://github.com/dolthub/dolt/issues/10087
2237+ Skip : true ,
2238+ Query : "select extract(day_hour from true)" ,
2239+ Expected : []sql.Row {{0 }},
2240+ },
2241+ {
2242+ Query : "select extract(second_microsecond from 0)" ,
2243+ Expected : []sql.Row {{0 }},
2244+ },
2245+ {
2246+ Query : "select extract(second_microsecond from false)" ,
2247+ Expected : []sql.Row {{0 }},
2248+ },
2249+ {
2250+ // https://github.com/dolthub/dolt/issues/10087
2251+ Skip : true ,
2252+ Query : "select extract(second_microsecond from true)" ,
2253+ Expected : []sql.Row {{1000000 }},
2254+ },
2255+ {
2256+ Query : "select extract(minute_microsecond from 0)" ,
2257+ Expected : []sql.Row {{0 }},
2258+ },
2259+ {
2260+ Query : "select extract(minute_microsecond from false)" ,
2261+ Expected : []sql.Row {{0 }},
2262+ },
2263+ {
2264+ // https://github.com/dolthub/dolt/issues/10087
2265+ Skip : true ,
2266+ Query : "select extract(minute_microsecond from true)" ,
2267+ Expected : []sql.Row {{1000000 }},
2268+ },
2269+ {
2270+ Query : "select extract(minute_second from 0)" ,
2271+ Expected : []sql.Row {{0 }},
2272+ },
2273+ {
2274+ Query : "select extract(minute_second from false)" ,
2275+ Expected : []sql.Row {{0 }},
2276+ },
2277+ {
2278+ // https://github.com/dolthub/dolt/issues/10087
2279+ Skip : true ,
2280+ Query : "select extract(minute_second from true)" ,
2281+ Expected : []sql.Row {{1 }},
2282+ },
2283+ {
2284+ Query : "select extract(hour_microsecond from 0)" ,
2285+ Expected : []sql.Row {{0 }},
2286+ },
2287+ {
2288+ Query : "select extract(hour_microsecond from false)" ,
2289+ Expected : []sql.Row {{0 }},
2290+ },
2291+ {
2292+ // https://github.com/dolthub/dolt/issues/10087
2293+ Skip : true ,
2294+ Query : "select extract(hour_microsecond from true)" ,
2295+ Expected : []sql.Row {{1000000 }},
2296+ },
2297+ {
2298+ Query : "select extract(hour_second from 0)" ,
2299+ Expected : []sql.Row {{0 }},
2300+ },
2301+ {
2302+ Query : "select extract(hour_second from false)" ,
2303+ Expected : []sql.Row {{0 }},
2304+ },
2305+ {
2306+ // https://github.com/dolthub/dolt/issues/10087
2307+ Skip : true ,
2308+ Query : "select extract(hour_second from true)" ,
2309+ Expected : []sql.Row {{1 }},
2310+ },
2311+ {
2312+ Query : "select extract(hour_minute from 0)" ,
2313+ Expected : []sql.Row {{0 }},
2314+ },
2315+ {
2316+ Query : "select extract(hour_minute from false)" ,
2317+ Expected : []sql.Row {{0 }},
2318+ },
2319+ {
2320+ // https://github.com/dolthub/dolt/issues/10087
2321+ Skip : true ,
2322+ Query : "select extract(hour_minute from true)" ,
2323+ Expected : []sql.Row {{0 }},
2324+ },
21162325}
0 commit comments